Jump to content

Playerbot (archive)


Recommended Posts

Hi, I am not sure if this is an issue but when trying to get the bots to tank and heal via combat orders it wouldn't work. I am taking a look through the source to see if anything is wrong and it looks like those two are not being processed, I could be wrong and they might be in here somewhere else. This stuff is pretty new to me. :P

void PlayerbotAI::SetCombatOrderByStr( std::string str, Unit *target ) {
   CombatOrderType co;
   if( str == "tank" ) co = ORDERS_TANK;
   else if( str == "assist" ) co = ORDERS_ASSIST;
   else if( str == "heal" ) co = ORDERS_HEAL;
   else if( str == "protect" ) co = ORDERS_PROTECT;
   else co = ORDERS_RESET;
   SetCombatOrder( co, target );
}

void PlayerbotAI::SetCombatOrder( CombatOrderType co, Unit *target ) {
   if( (co == ORDERS_ASSIST || co == ORDERS_PROTECT) && !target )
       return;
   if( co == ORDERS_RESET ) {
       m_combatOrder = ORDERS_NONE;
       m_targetAssist = 0;
       m_targetProtect = 0;
       return;
   }
   if( co == ORDERS_PROTECT )
       m_targetProtect = target;
   else if( co == ORDERS_ASSIST )
       m_targetAssist = target;
   if( (co&ORDERS_PRIMARY) )
       m_combatOrder = (CombatOrderType)(((uint32)m_combatOrder&(uint32)ORDERS_SECONDARY)|(uint32)co);
   else
       m_combatOrder = (CombatOrderType)(((uint32)m_combatOrder&(uint32)ORDERS_PRIMARY)|(uint32)co);
}

Also, when doing .bot co mybot assist myotherbot or commands with co, I am not getting a response back so I don't know if it's being recognized or not. Or maybe you just have it that way. :P

Hi,

I haven't got much more to add to deviljohn 's answer. I agree from the code you cited, that ORDERS_TANK seems to be overlooked. However I did a simple search of the code

grep -r "ORDERS_TANK" *

and I get this

Player.h: TANK = 0x02,

PlayerbotAI.cpp: else if( m_combatOrder&ORDERS_TANK )

PlayerbotAI.cpp: out << "I TANK";

PlayerbotAI.cpp: m_targetType = (m_combatOrder==ORDERS_TANK ? TARGET_THREATEN : TARGET_NORMAL);

PlayerbotAI.cpp: m_targetType = (m_combatOrder==ORDERS_TANK ? TARGET_THREATEN : TARGET_NORMAL);

PlayerbotAI.cpp: m_targetType = (m_combatOrder==ORDERS_TANK ? TARGET_THREATEN : TARGET_NORMAL);

PlayerbotAI.cpp: if( str == "tank" ) co = ORDERS_TANK;

PlayerbotAI.h: ORDERS_TANK = 0x01, // bind attackers by gaining threat

PlayerbotWarriorAI.cpp: if( (co&PlayerbotAI::ORDERS_TANK) && DEFENSIVE_STANCE>0 && !m_bot->HasAura(DEFENSIVE_STANCE, EFFECT_INDEX_0) && ai->CastSpell(DEFENSIVE_STANCE) )

PlayerbotWarriorAI.cpp: else if( (co&PlayerbotAI::ORDERS_TANK) && TAUNT>0 && m_bot->HasAura(DEFENSIVE_STANCE, EFFECT_INDEX_0) && ai->CastSpell(TAUNT,*pTarget) )

PlayerbotWarriorAI.cpp: if( (co&PlayerbotAI::ORDERS_TANK) && !m_bot->HasAura(DEFENSIVE_STANCE, EFFECT_INDEX_0) && ai->CastSpell(DEFENSIVE_STANCE) )

PlayerbotWarriorAI.cpp: else if( !(co&PlayerbotAI::ORDERS_TANK) && !m_bot->HasAura(BATTLE_STANCE, EFFECT_INDEX_0) && ai->CastSpell(BATTLE_STANCE) )

WaypointMovementGenerator.cpp: //if ((bot->client->ps.eFlags & EF_TANK) && nodes[bot->current_node].links[link].flags & PATH_NOTANKS) //if this path is blocked, skip it

WaypointMovementGenerator.cpp: if (bot->client && (bot->client->ps.eFlags & EF_TANK) && nodes[atNode].links.flags & PATH_NOTANKS)

blu

You will see that this and other combat order flags are used throughtout the code.

With your final question; unfortunately No News Is Good News . The original code only complains if the combat order is not understood. I agree that it would an improvement if the bot(s) responded with something like "SIR!"

Hope this helps

Link to comment
Share on other sites

  • Replies 1.8k
  • Created
  • Last Reply

Top Posters In This Topic

I've applied the prototype patch blueboy provided on this page and it fails on line 2745 i think PlayerbotAI.cpp

Blueboy any idea how could i fix this ?

Thanks,any help would be useful

Hi,

Any details about the fail, so I can trace the source of the error? It works fine on my linux box.

Cheers

Link to comment
Share on other sites

well after i cloned mangos and pulled your repo i applied the patch and i got this :

Welcome to Git (version 1.6.5.1-preview20091022)

Run 'git help git' to display the help index.

Run 'git help <command>' to display help for specific commands.

Administrator@VLADEX /e/New Folder/mangos (master)

$ patch -p1 < detection.patch

patching file `src/game/PlayerbotAI.cpp'

Hunk #2 FAILED at 2745.

1 out of 3 hunks FAILED -- saving rejects to src/game/PlayerbotAI.cpp.rej

patching file `src/game/PlayerbotAI.h'

patch unexpectedly ends in middle of line

Hunk #1 succeeded at 126 with fuzz 2.

Administrator@VLADEX /e/New Folder/mangos (master)

$

Notice that im running my server on Windows xp x64

Link to comment
Share on other sites

well after i cloned mangos and pulled your repo i applied the patch and i got this :

Welcome to Git (version 1.6.5.1-preview20091022)

Run 'git help git' to display the help index.

Run 'git help <command>' to display help for specific commands.

Administrator@VLADEX /e/New Folder/mangos (master)

$ patch -p1 < detection.patch

patching file `src/game/PlayerbotAI.cpp'

Hunk #2 FAILED at 2745.

1 out of 3 hunks FAILED -- saving rejects to src/game/PlayerbotAI.cpp.rej

patching file `src/game/PlayerbotAI.h'

patch unexpectedly ends in middle of line

Hunk #1 succeeded at 126 with fuzz 2.

Administrator@VLADEX /e/New Folder/mangos (master)

$

Notice that im running my server on Windows xp x64

hi

I will copy and paste the patch I posted, as you will have done. I will then attempt to patch a clone of MaNGOS. You did not say which version you were using, so I will try the latest. TIP: ( Use the '--dry-run' option with the patch utility. It will test the patch and save you time having to download the core again). I'll get back to you.

Link to comment
Share on other sites

another wierd thing is that the core frizzes when i do .bot command

Hi,

If you patch did not apply properly to the core, this has probably damaged the parsing process of the .bot command. I will try to find what is going wrong. To save your time in the future, if the patch breaks do not continue.

Cheers

Link to comment
Share on other sites

Forgot to mention that i used the lastest repo of mangos ! always the lastest

Hi,

I have found the problem, and it is an issue with whitespaces. I pasted the 'detection.patch' in this forum and it stripped out text formatting (Tabs etc ..) . Unfortunately the code in PlayerbotAI.cpp still contains this text formatting. So the 3 line pattern in the patch is different to the 3 line pattern in PlayerbotAI.cpp. I suggest you open up both PlayerbotAI.cpp and the detection.patch with you favourite editor. Then replace the pattern in the patch with the pattern from PlayerbotAI.cpp (copy and paste).

3 line pattern @ lines 102-104 in patch

    else if (text == "quests")
   {
              bool hasIncompleteQuests = false;

replace this with the pattern @ lines 2679-2681 in PlayerbotAI.cpp. I know they look the same, but I assure you they are different. This should fix the patch. I will update blueboy presently, but I thought you might want an immediate fix

Hope this helps

Link to comment
Share on other sites

try using --whitespace=fix when using apply

like

git apply playerbotfix.patch --whitespace=fix

Hi,

I did, that's partly why the patch ended up different from the code, but thanks for the info. I wish I had never heard of 'whitespaces':mad: I will create a new patch, and post it without using the '--whitespace=fix' preprocessing.

Cheers

Link to comment
Share on other sites

Hi,

Yes I agree, it works fine with the blueboy repo and it's alot sleeker, great work. :cool:

Less important; I couldn't get it to work with the 'Tasssador' repo, but I can still use the old script for that :rolleyes:

Thanks for your contribution

valhalla in valhalla branch, current mangos commit in master branch:

#!/bin/bash -x
git clone git://github.com/mangos/mangos.git valhalla
cd valhalla
git fetch git://github.com/Tasssadar/Valhalla-Project.git master:valhalla
HASH=`git log valhalla --pretty=oneline | grep -m 1 '\\[9[0-9]\\{3\\}]' | cut -d " " -f 1`
git diff $HASH valhalla > ../valhalla.patch

valhalla in master branch, current mangos commit in mangos branch:

#!/bin/bash -x
git clone git://github.com/Tasssadar/Valhalla-Project.git valhalla
cd valhalla
git fetch git://github.com/mangos/mangos.git master:mangos
HASH=`git log --pretty=oneline | grep -m 1 '\\[9[0-9]\\{3\\}]' | cut -d " " -f 1`
git checkout mangos
git diff $HASH master > ../valhalla.patch

I hope you find my scripts useful! Obviously they will have to be updated once MaNGOS is > [9999].

skinlayers

Link to comment
Share on other sites

Hi,

I have found the problem, and it is an issue with whitespaces. I pasted the 'detection.patch' in this forum and it stripped out text formatting (Tabs etc ..) . Unfortunately the code in PlayerbotAI.cpp still contains this text formatting. So the 3 line pattern in the patch is different to the 3 line pattern in PlayerbotAI.cpp. I suggest you open up both PlayerbotAI.cpp and the detection.patch with you favourite editor. Then replace the pattern in the patch with the pattern from PlayerbotAI.cpp (copy and paste).

3 line pattern @ lines 102-104 in patch

    else if (text == "quests")
   {
              bool hasIncompleteQuests = false;

replace this with the pattern @ lines 2679-2681 in PlayerbotAI.cpp. I know they look the same, but I assure you they are different. This should fix the patch. I will update blueboy presently, but I thought you might want an immediate fix

Hope this helps

thanks,ill test it right now and see if it works

Link to comment
Share on other sites

right,i still got errors , i replaced it in playerAI.cpp and the detection.patch and still got failed thingy in the same lines

Hi,

I think the best thing would be for you to wait until I update blueboy next. I will remove the 'text formatting' myself from PlayerbotAI.cpp, and the original patch I posted should then work.

Cheers

Link to comment
Share on other sites

Hi mrelfire & Bramm,

I've been looking at the HasAura issue, and have something I would like you to test. I have tried it on my linux box and it works with no ill effects. It might just work for you too. I have rewritten the HasAura function in PlayerbotAI.cpp to call on the sister (overloaded) function HasAura in Unit.cpp.

I suggest you comment out the old function and replace it with the new prototype in PlayerbotAI.cpp

/*
bool PlayerbotAI::HasAura(uint32 spellId, const Unit& player) const
{
   for (Unit::AuraMap::const_iterator iter = player.GetAuras().begin(); iter != player.GetAuras().end(); ++iter)
   {
       if (iter->second->GetId() == spellId)
           return true;
   }
   return false;
}
*/

bool PlayerbotAI::HasAura(uint32 spellId, const Unit& player) const
{
   return  player.HasAura(spellId);
}

Please let me know if this works,

Cheers

I have done these modifications.

And tested with latest mangos

crash all the time => priest & magicien run away from me and the server crash

Link to comment
Share on other sites

I have done these modifications.

And tested with latest mangos

crash all the time => priest & magicien run away from me and the server crash

Hi,

I just do not know how to proceed with this. We need someone who runs MaNGOS on a windows server, to troubleshoot this. I haven't got a spare server and I have none of the problems you list on linux. Is there an event that triggers your priests and magicians to run away? Your not running with a dual faction mod, by any chance. I tried that and I found a mixed (horde/alliance) group to be unworkable.

Please let me know

Link to comment
Share on other sites

I just create bots in dalaran where I start, nothing else...

I am using windows server x64 widnwos server 2008 R2 core 7, 32 Megs memory

Of course it is only one faction: alliance

do you want crash dumps ? pdumps ?

Hi,

are the dumps similar to the other dumps posted? If not, could you post an edited version of the crash dump? This useful info was taken from the last dumps posted,

access violation // nature of the crash

HasAura @ line 866 in PlayerbotAI.cpp. //where the crash occurs

Without a machine to directly try ideas out on, it is very difficult to debug. I am pleased your only using one faction.

Does the priest and magician run away as soon as they are summoned in dalaran?

Does this happen with any other classes of bot?

This might take awhile to sort out, please get back to me!

Link to comment
Share on other sites

Hi Guys,

I've updated the code on blueboy to be compatible with the latest MaNGOS[9591] and revised the survey patch to work.

Revised survey patch

diff --git a/src/game/PlayerbotAI.cpp b/src/game/PlayerbotAI.cpp
index 1922828..5409da0 100644
--- a/src/game/PlayerbotAI.cpp
+++ b/src/game/PlayerbotAI.cpp
@@ -2229,6 +2229,75 @@ void PlayerbotAI::extractItemIds(const std::string& text, std::list<uint32>& ite
    }
}

+bool PlayerbotAI::extractGOinfo(const std::string& text, uint32 &guid, uint32 &entry, int &mapid, float &x, float &y, float &z) const
+{
+
+     //    Link format
+     //    |cFFFFFF00|Hfound:" << guid << ':'  << entry << ':' << x << ':' << y << ':' << z  << ':' << mapid << ':' <<  "|h[" << gInfo->name << "]|h|r";
+     //    |cFFFFFF00|Hfound:5093:1731:-9295:-270:81.874:0:|h[Copper Vein]|h|r
+
+    uint8 pos = 0;
+
+        // extract GO guid
+        int i = text.find("Hfound:", pos); // base H = 11
+        if (i == -1) // break if error
+            return false;
+
+        pos = i + 7; //start of window in text 11 + 7 = 18
+        int endPos = text.find(':', pos); // end of window in text 22
+        if (endPos == -1) //break if error
+            return false;
+        std::string guidC = text.substr(pos, endPos - pos); // get string within window i.e guid 22 - 18 =  4
+        guid = atol(guidC.c_str()); // convert ascii to long int
+
+        // extract GO entry
+        pos = endPos + 1;
+        endPos = text.find(':', pos); // end of window in text
+        if (endPos == -1) //break if error
+            return false;
+
+        std::string entryC = text.substr(pos, endPos - pos); // get string within window i.e entry
+        entry = atol(entryC.c_str()); // convert ascii to float
+
+        // extract GO x
+        pos = endPos + 1;
+        endPos = text.find(':', pos); // end of window in text
+        if (endPos == -1) //break if error
+            return false;
+
+        std::string xC = text.substr(pos, endPos - pos); // get string within window i.e x
+        x = atof(xC.c_str()); // convert ascii to float
+
+        // extract GO y
+        pos = endPos + 1;
+        endPos = text.find(':', pos); // end of window in text
+        if (endPos == -1) //break if error
+            return false;
+
+        std::string yC = text.substr(pos, endPos - pos); // get string within window i.e y
+        y = atof(yC.c_str()); // convert ascii to float
+
+        // extract GO z
+        pos = endPos + 1;
+        endPos = text.find(':', pos); // end of window in text
+        if (endPos == -1) //break if error
+            return false;
+
+        std::string zC = text.substr(pos, endPos - pos); // get string within window i.e z
+        z = atof(zC.c_str()); // convert ascii to float
+
+        //extract GO mapid
+        pos = endPos + 1;
+        endPos = text.find(':', pos); // end of window in text
+        if (endPos == -1) //break if error
+            return false;
+
+        std::string mapidC = text.substr(pos, endPos - pos); // get string within window i.e mapid
+        mapid = atoi(mapidC.c_str()); // convert ascii to int
+        pos = endPos; // end
+        return true;
+}
+
// extracts currency in #g#s#c format
uint32 PlayerbotAI::extractMoney(const std::string& text) const
{
@@ -2676,6 +2745,23 @@ void PlayerbotAI::HandleCommand(const std::string& text, Player& fromPlayer)
            EquipItem(**it);
    }

+    // find item in world
+     else if (text.size() > 2 && text.substr(0, 2) == "f " || text.size() > 5 && text.substr(0, 5) == "find ")
+    {
+        uint32 guid;
+        float x,y,z;
+        uint32 entry;
+        int mapid;
+        if(extractGOinfo(text, guid, entry, mapid, x, y, z))
+        {      // sLog.outDebug("find: guid : %u entry : %u x : (%f) y : (%f) z : (%f) mapid : %d",guid, entry, x, y, z, mapid);
+               m_bot->UpdateGroundPositionZ(x,y,z);
+               SetMovementOrder( MOVEMENT_STAY );
+               m_bot->GetMotionMaster()->MovePoint( mapid, x, y, z );
+        }
+        else
+               SendWhisper("I have no info on that object", fromPlayer);
+     }
+
        else if (text == "quests")
        {
               bool hasIncompleteQuests = false;
@@ -2803,6 +2889,45 @@ void PlayerbotAI::HandleCommand(const std::string& text, Player& fromPlayer)
         ch.SendSysMessage(out.str().c_str());
    }

+    // Survey project: 09:50 09/03/10
+    else if (text == "survey")
+    {
+      float distance = 100.0f;
+      uint32 count = 0;
+      std::ostringstream detectout;
+
+      QueryResult *result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, "
+        "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ "
+        "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_",
+         m_bot->GetPositionX(), m_bot->GetPositionY(), m_bot->GetPositionZ(),
+         m_bot->GetMapId(), m_bot->GetPositionX(), m_bot->GetPositionY(), m_bot->GetPositionZ(), distance*distance);
+
+      if (result)
+      {
+         do
+         {
+             Field *fields = result->Fetch();
+             uint32 guid = fields[0].GetUInt32();
+             uint32 entry = fields[1].GetUInt32();
+             float x = fields[2].GetFloat();
+             float y = fields[3].GetFloat();
+             float z = fields[4].GetFloat();
+             int mapid = fields[5].GetUInt16();
+
+             GameObjectInfo const * gInfo = ObjectMgr::GetGameObjectInfo(entry);
+
+             if(!gInfo)
+                 continue;
+
+             if(count < 12) // count, limits number of links
+                  detectout << "|cFFFFFF00|Hfound:" << guid << ":" << entry << ":" << x << ":" << y << ":" << z  << ":" << mapid  << ":" <<  "|h[" << gInfo->name << "]|h|r";
+             ++count;
+         } while (result->NextRow());
+
+         delete result;
+      }
+      SendWhisper(detectout.str().c_str(), fromPlayer);
+    }

    else
    {
diff --git a/src/game/PlayerbotAI.h b/src/game/PlayerbotAI.h
index 377dfaa..fc19482 100644
--- a/src/game/PlayerbotAI.h
+++ b/src/game/PlayerbotAI.h
@@ -129,6 +129,9 @@ class MANGOS_DLL_SPEC PlayerbotAI
        // extracts currency from a string as #g#s#c and returns the total in copper
        uint32 extractMoney(const std::string& text) const;

+        // extracts gameobject info from link
+        bool extractGOinfo(const std::string& text, uint32 &guid,  uint32 &entry, int &mapid, float &x, float &y, float &z) const;
+
        // finds items in bots equipment and adds them to foundItemList, removes found items from itemIdSearchList
        void findItemsInEquip(std::list<uint32>& itemIdSearchList, std::list<Item*>& foundItemList) const;
        // finds items in bots inventory and adds them to foundItemList, removes found items from itemIdSearchList

Hope it works this time :D

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use