Jump to content

Playerbot (archive)


Recommended Posts

  • Replies 1.8k
  • Created
  • Last Reply

Top Posters In This Topic

Hi

Thanks for all the work you put in.

Altough i'll just mention that i get an error message while applying the patch

I'm giving you the info, if i got more question, i'll just open a topic in the help forum...

$ git apply --check mangos-9591-playerbot.patch

error: patch failed: src/game/Chat.cpp:904

error: src/game/Chat.cpp: patch does not apply

Link to comment
Share on other sites

Hi

Thanks for all the work you put in.

Altough i'll just mention that i get an error message while applying the patch

I'm giving you the info, if i got more question, i'll just open a topic in the help forum...

$ git apply --check mangos-9591-playerbot.patch

error: patch failed: src/game/Chat.cpp:904

error: src/game/Chat.cpp: patch does not apply

I think you must be doing something wrong when you create your patch mangos-9591-playerbot.patch

I've just created a new patch from the code on blueboy and applied it the MaNGOS[9599]. It works perfectly.

Your not applying anything, prior to playerbot are you. If you modify the MaNGOS code prior to playerbot, you might well break the patch. Apply playerbot first, then other mods

Try using the script created by skinlayers in post #930, that works great.

Let me know how you get on

Link to comment
Share on other sites

Blueboy, I just noticed something in the PlayerbotAI.cpp that might be mrelfire's problem,

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(const char* spellName) const

{

return HasAura(spellName, *m_bot);

}

bool PlayerbotAI::HasAura(const char* spellName, const Unit& player) const

{

uint32 spellId = getSpellId(spellName);

return (spellId) ? HasAura(spellId, player) : false; <=== on my Win7 x64 in VS Pro I get a signed/unsigned variable error/warning here and it looks like it's tring to force a HasAura at false. I could be wrong but maybe take a look at the flow and see.

Link to comment
Share on other sites

Blueboy, I just noticed something in the PlayerbotAI.cpp that might be mrelfire's problem,

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(const char* spellName) const

{

return HasAura(spellName, *m_bot);

}

bool PlayerbotAI::HasAura(const char* spellName, const Unit& player) const

{

uint32 spellId = getSpellId(spellName);

return (spellId) ? HasAura(spellId, player) : false; <=== on my Win7 x64 in VS Pro I get a signed/unsigned variable error/warning here and it looks like it's tring to force a HasAura at false. I could be wrong but maybe take a look at the flow and see.

Hi,

Thanks for the info, I need all the help I can get with this issue. It also give me an opportunity to ask, whether you are experiening problems. This seems to only effect Windows systems, and it appears that VC 9.0 does not like the way 'std::allocator' is used in HasAura. I found several similar issues on the internet, and Microsoft blame the coding and not the compiler. VC 9.0 adheres strongly to C++ Standards. Apparently, earlier versions of VC were less fussy. They suggest rewritting the code to comply with C++ Standards :rolleyes: You will see that HasAura is an overloaded function that only differs in the parameters passed. I tried redirecting the program flow to the sister HasAura function, defined in Unit.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);
}

I hoped that this would bypass the offending HasAura function in PlayerbotAI.cpp, and solve the issue :rolleyes: No such luck. It continues to crash with code from the core.

I took a look at the HasAura function;

bool PlayerbotAI::HasAura(const char* spellName, const Unit& player) const
{
   uint32 spellId = getSpellId(spellName);
   return (spellId) ? HasAura(spellId, player) : false;
}

This is not forcing a false condition. If spellId has a positive non zero value, it then calls HasAura(spellId, player) else it returns false. The logic is sound. But, thanks for the idea.

Edit: Your getting signed/unsigned variable error/warning because getSpellId returns an unsigned integer value, that is then tested in a boolean expression.

Cheers

Link to comment
Share on other sites

i had to manually apply your survey patch but all seems to be working. I created a repo with playerbot and a few other mods. It seems to run fine though i don't really have an extensive testing bed.

Hi,

I am pleased that the survey patch is working. I'm hoping that it will encourage you guys to have a go developing the AI. I shouldn't worry too much about your test bed, compared to most users, my system is quite modest too :D

Cheers

Link to comment
Share on other sites

Hi,

I am pleased that the survey patch is working. I'm hoping that it will encourage you guys to have a go developing the AI. I shouldn't worry too much about your test bed, compared to most users, my system is quite modest too :D

Cheers

Did you officially put the survey patch inisde your "official" repo ?

Link to comment
Share on other sites

Hi Guys,

No the survey patch is not in the offical repo, because it is a development in progress. I want to keep the main repo clean. The patch works, but not the way I want it to. I would like to filter out event triggered objects, and display only objects that exist.

Cheers

Link to comment
Share on other sites

Hi Guys,

I have now successfully filtered out unwanted objects from the survey command. We can now look at developing commands to allow the bot(s) to interact with the objects.

diff --git a/src/game/PlayerbotAI.cpp b/src/game/PlayerbotAI.cpp
index 1922828..0676a5a 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,65 @@ void PlayerbotAI::HandleCommand(const std::string& text, Player& fromPlayer)
         ch.SendSysMessage(out.str().c_str());
    }

+    // Survey project: 19:30 17/03/10 rev.2 filter out event triggered objects
+    else if (text == "survey")
+    {
+      uint32 count = 0;
+      std::ostringstream detectout;
+      QueryResult *result;
+      GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr.GetActiveEventList();
+
+
+        std::ostringstream eventFilter;
+        eventFilter << " AND (event IS NULL ";
+        bool initString = true;
+
+        for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
+        {
+            if (initString)
+            {
+                eventFilter  <<  "OR event IN (" <<*itr;
+                initString =false;
+            }
+            else
+                eventFilter << "," << *itr;
+        }
+
+        if (!initString)
+            eventFilter << "))";
+        else
+            eventFilter << ")";
+
+        result = WorldDatabase.PQuery("SELECT gameobject.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 "
+            "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10",
+            m_bot->GetPositionX(), m_bot->GetPositionY(), m_bot->GetPositionZ(), m_bot->GetMapId(),eventFilter.str().c_str());
+
+      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;
+
+             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..94ef634 100644
--- a/src/game/PlayerbotAI.h
+++ b/src/game/PlayerbotAI.h
@@ -3,6 +3,7 @@

#include "Common.h"
#include "QuestDef.h"
+#include "GameEventMgr.h"

class WorldPacket;
class WorldObject;
@@ -129,6 +130,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 you like it.

Warning Possible issue with MaNGOS

There maybe an issue with the latest MaNGOS[9599]. When I shut the server down, it crashes, without info. I would be interested to hear if your getting the same. MaNGOS[9591] does not seem to cause issue so I advise you not to update until they sort it out.

Link to comment
Share on other sites

Thank you blueboy, I'm still trying to comprehind C++ vers. good old ancheint C, or Assymbler, but I'm trying...as to overloaded functions, I've yet to get an explanation on that since we don't have that in C or Assymblyand in the languges I know an overloaded function causes a crash....

Hi,

'Overloaded' is a term for functions that have the same name, but different parameters. On C and other languages, you can not do this. The compiler decides which version of the function to use, based solely on the parameter list, that must be different. I know 'overloaded' sounds like something bad, but it is quite a useful feature of C++.

Oveloaded functions can operate recursively by calling each other, as 'HasAura' does. This inceases the scope of parameters that can be passed to any one function

        bool HasAura(uint32 spellId, const Unit& player) const;
       bool HasAura(const char* spellName, const Unit& player) const;
       bool HasAura(const char* spellName) const;

Cheers

Link to comment
Share on other sites

I am getting the following error when using the latest commit:

../../../../src/bindings/ScriptDev2/base/escort_ai.cpp: In member function ‘virtual void npc_escortAI::MoveInLineOfSight(Unit*)’:
../../../../src/bindings/ScriptDev2/base/escort_ai.cpp:114: error: ‘class Creature’ has no member named ‘CanInitiateAttack’

Link to comment
Share on other sites

I am getting the following error when using the latest commit:

../../../../src/bindings/ScriptDev2/base/escort_ai.cpp: In member function ‘virtual void npc_escortAI::MoveInLineOfSight(Unit*)’:
../../../../src/bindings/ScriptDev2/base/escort_ai.cpp:114: error: ‘class Creature’ has no member named ‘CanInitiateAttack’

Hi, Any chance of some more information. Latest commit of what ? Playerbot, MaNGOS or ScriptDev2.

I am presently using the code from blueboy with MaNGOS[9610] and ScriptDev2[1644], without issue. It is very important that you heed compatibility information given by ScriptDev2, or you will have issues.

http://www.manground.org/sd2Changelog.html

For instance, ScriptDev2[1644] says

Update sources to use CanInitiateAttack in moveInLineOfSight. Requires Mangos 9603+

i.e It will not work with an earlier version of MaNGOS.

Hope this helps

Link to comment
Share on other sites

I am using everything in your repo:

git clone git://github.com/blueboy/mangos.git sourcecode

Then after I do all the stuff listed on the mangos wiki for getting ready to compile I get those errors after issuing the make command. This is on linux btw.

Hi,

You say your cloning the blueboy repo. This is integrated with MaNGOS[9591] (see commit history). You then tell me very little. I need to know which versions of the software, you're trying to build your server with.

MaNGOS[version] ?

ScriptDev2[version]?

I have looked at the guide for building MaNGOS on linux (wiki), and it is a little vague. If you follow their instructions you will always download the lastest version of ScriptDev2. This might not be what you want. ( When I update blueboy, I usually specify which versions of software, work)

Blueboy code tested with

MaNGOS[9591]

ScriptDev2[1641]

To obtain ScriptDev2[1641], use this Bash Script;

#!/bin/bash

unset VERSION
unset DEST

VERSION=$1
DEST="/home/mangos/compile/mangos/src/bindings/ScriptDev2"
if [ -z "${VERSION}" ]; then
echo "No ScriptDev2 VERSION specified, assume latest VERSION";
else
VERSION="-r "${VERSION};
fi

if [ -d "${DEST}" ]; then
rm -R ${DEST};
fi

mkdir ${DEST};
svn co [url]https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2/[/url] ${DEST} ${VERSION}

NOTE You will need to change the path specified in variable DEST, to match your system

at prompt

./scriptdev2.sh 1641

If you compile this with just the code from blueboy, it will work

As I said in my last post, look at the' http link' and read the commit description. Compare your errors, with the description. Are you using MaNGOS[9603], or later?

Update sources to use CanInitiateAttack in moveInLineOfSight. Requires Mangos 9603+

If you want to use the latest ScripDev2, you will need to merge the code from blueboy, with the latest version of MaNGOS.

As I said in my last post, I believe your using the wrong versions of MaNGOS & ScriptDev2, and this is what causing the errors

Hope this helps

Link to comment
Share on other sites

Thanks for the very successful patch to limit the number of bots per account. I have another suggestion for you, blueboy.

How about upgrading the patch to remove the limiting of bots based on the account's security level? This way, ordinary players would still have the limit imposed but, a GM or Moderator could summon the full nine bots for testing purposes.

It may read something like this in the Playerbot section of mangosd.conf:

#
#  PlayerbotAI.GMNumBots
#  Allows accounts at or above the security level specified to bypass the MaxNumBots limit. 
#Default: 3 - GM/Administrator can always summon up to 9 bots.
#

Just a thought. :)

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