Jump to content

Playerbot (archive)


Recommended Posts

  • Replies 1.8k
  • Created
  • Last Reply

Top Posters In This Topic

Of course he is! We are talking about blueboy, after all. :)

Once more your work is appreciated and lauded with much thanks, Great One of The Blueness.

I had an idea concerning the use of playerbot for battlegrounds. Would it not be possible (or even preferable) to instead apply the Playerbot AI scripts to NPCs, using ScriptDev2, and have them populate the BGs?

Link to comment
Share on other sites

just wanted to report i have playerbot working better than ever with ahbot, vehicle, anticheat, and dozens of other modifications compiled under visual studio 2008 and 2010 without making any changes to the playerbot system personally as of rev 10049! excellent work as always blue!

Link to comment
Share on other sites

Hi Guys,

Before you report this..

Relevant to MaNGOS[10050]+

They have made more changes with the core. 'GetItemByTradeSlot' has been dropped altogether now. A new method has been introduced to check what item is contained in the trade slot.

TradeData* GetTradeData() const { return m_trade; }

TradeData* pTrade = m_bot->GetTradeData();

Utilizes the new TradeData class and associated functions to return the item contained in the trade slot.

pTrade->GetTraderData()->GetItem(TradeSlots(slot))

This again tests for equality to a null pointer (PlayerbotAI.cpp, in TradeItem function).

I have also found a more elegant solution to the issue that was causing bot/player trade to hang. The previous fix did not address the issue of 'unprocessed tail data spam' that

recvPacket.read_skip<uint32>(); // 7, amount traded slots ?

in (TradeHandler.cpp, in WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket)), was introduced to stop.

I have now resized the WorldPacket passed, to facilitate the 'read_skip', without throwing a ByteBuffer exception.

I have already checked this out on the development repo portal and will shortly push the changes to blueboy

Hope this helps

Link to comment
Share on other sites

  • 2 weeks later...

Hi Guys,

The code on both repos has been adjusted to compensate for recent core changes.

I have now updated both repos and tested the code with MaNGOS[10094] SD2[1725]. The code compiles and runs without issue under linux and windows.

Remember for SD2 change the following in config.h.in

#define SD2_CONF_VERSION    2009040501

to

#define SD2_CONF_VERSION    2010062001

otherwise the scriptdev2.conf will not load properly

Hope this helps

Link to comment
Share on other sites

it help some of them and i securely wish to thank you for your help...

honestly as soon as 10081 dropped i strated informing my users... mangos dev team doesnt give a rats ass what Our modifications do... vlad anbd tom think they OWN the market... sorry to see just another developer who wasnt chatted with before an update... they change the rules to fit their standards while all of us who work hard to make things work are tramped on without interest

MangoS staff needs to wakt the hell up... or die without progress

Hi,

I know what you mean, the changes can be annoying at times, but where would we be without core development. Doing something else I guess :eek:

Cheers

Link to comment
Share on other sites

There is a bug in Warlock AI. Warlock bot keeps buffing himself Soul Link until he/she runs out of mana limit. The cause is simple, AI checks for wrong aura id before spell cast. To fix it, change:

    // check for buffs with demon
   if(( pet )
       && ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
   {
       //ai->TellMaster( "casting soul link." );
       return;
   }

to

    // check for buffs with demon
   if(( pet )
       && ( SOUL_LINK>0 && !m_bot->HasAura(25228, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
   {
       //ai->TellMaster( "casting soul link." );
       return;
   }

in PlayerbotWarlockAI.cpp

Sorry for no diff provided.

Link to comment
Share on other sites

There is a bug in Warlock AI. Warlock bot keeps buffing himself Soul Link until he/she runs out of mana limit. The cause is simple, AI checks for wrong aura id before spell cast. To fix it, change:
    // check for buffs with demon
   if(( pet )
       && ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
   {
       //ai->TellMaster( "casting soul link." );
       return;
   }

to

    // check for buffs with demon
   if(( pet )
       && ( SOUL_LINK>0 && !m_bot->HasAura(25228, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
   {
       //ai->TellMaster( "casting soul link." );
       return;
   }

in PlayerbotWarlockAI.cpp

Sorry for no diff provided.

Hi,

Thanks very much for your interest in the WarlockAI. I have taken a look at the spell 'soul link' and indeed there are two available, one with a mana cost of 16 (19028) and the other none (25228). Your fix will need tweaking. If you want to utilize the later spell it would be better to assign the id at the head of the PlayerbotWarlockAI.cpp file.

    SOUL_LINK             = ai->getSpellId("soul link");

   SOUL_LINK             = 25228;  // soul link no cost

Then all references to SOUL_LINK will use your id.

if(( pet )

&& ( SOUL_LINK>0 && !m_bot->HasAura(25228, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))

not addressed by your fix.

Also if you wish to use the spell with no cost, then it is not necessary to test whether the caster has (mana >= 16) or not.

I will create a small patch for you to test out, before I make the change to the repos.

portal_soul_link patch

diff --git a/src/game/playerbot/PlayerbotWarlockAI.cpp b/src/game/playerbot/PlayerbotWarlockAI.cpp
index 31d53e7..3ebcd50 100644
--- a/src/game/playerbot/PlayerbotWarlockAI.cpp
+++ b/src/game/playerbot/PlayerbotWarlockAI.cpp
@@ -43,7 +43,7 @@ PlayerbotWarlockAI::PlayerbotWarlockAI(Player* const master, Player* const bot,
    FEL_ARMOR             = ai->getSpellId("fel armor");
    SHADOW_WARD           = ai->getSpellId("shadow ward");
    SOULSHATTER           = ai->getSpellId("soulshatter");
-    SOUL_LINK             = ai->getSpellId("soul link");
+    SOUL_LINK             = 25228; // soul link no cost
    HEALTH_FUNNEL         = ai->getSpellId("health funnel");
    DETECT_INVISIBILITY   = ai->getSpellId("detect invisibility");
    // demon summon
@@ -444,7 +444,7 @@ void PlayerbotWarlockAI::DoNonCombatActions()

    // check for buffs with demon
    if(( pet )
-        && ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
+        && ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK, EFFECT_INDEX_0) && ai->CastSpell(SOUL_LINK,*m_bot) ))
    {
        //ai->TellMaster( "casting soul link." );
        return;

If you use the code on blueboy rather than portal, edit the patch to remove playerbot from the file path.

Note that the bot must have this version of 'soul link' (25228) in its spellbook ( i.e learnt the spell) ,

m_bot->HasAura(25228, EFFECT_INDEX_0)

otherwise it won't work. Can you provide some feedback.

Hope this helps

Link to comment
Share on other sites

I believe you have not a clear view on how Soul Link works. There is a talent in demonology tree called 'Soul Link' that provides the spell of the same name with id 19028. Btw it costs 16% of base mana, does ai->GetManaPercent() return base or final percents?. After warlock casts this spell he/she gets dummy aura (25228). So we need both spell ids here: one for cast, another for check. To avoid hardcoding spell ids, we can add another variable in the head and use it later:

SOUL_LINK_DUMMY_AURA = 25228;

&& ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK_DUMMY_AURA, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))

Link to comment
Share on other sites

I believe you have not a clear view on how Soul Link works. There is a talent in demonology tree called 'Soul Link' that provides the spell of the same name with id 19028. Btw it costs 16% of base mana, does ai->GetManaPercent() return base or final percents?. After warlock casts this spell he/she gets dummy aura (25228). So we need both spell ids here: one for cast, another for check. To avoid hardcoding spell ids, we can add another variable in the head and use it later:

SOUL_LINK_DUMMY_AURA = 25228;

&& ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK_DUMMY_AURA, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))

Hi kyle1,

Thanks for the info. I understand now

cheers ;)

I will update the patch

Revised portal_soul_link patch

diff --git a/src/game/playerbot/PlayerbotWarlockAI.cpp b/src/game/playerbot/PlayerbotWarlockAI.cpp
index 31d53e7..3c89e38 100644
--- a/src/game/playerbot/PlayerbotWarlockAI.cpp
+++ b/src/game/playerbot/PlayerbotWarlockAI.cpp
@@ -44,6 +44,7 @@ PlayerbotWarlockAI::PlayerbotWarlockAI(Player* const master, Player* const bot,
    SHADOW_WARD           = ai->getSpellId("shadow ward");
    SOULSHATTER           = ai->getSpellId("soulshatter");
    SOUL_LINK             = ai->getSpellId("soul link");
+    SOUL_LINK_AURA        = 25228; // dummy aura applied, after spell SOUL_LINK
    HEALTH_FUNNEL         = ai->getSpellId("health funnel");
    DETECT_INVISIBILITY   = ai->getSpellId("detect invisibility");
    // demon summon
@@ -444,7 +445,7 @@ void PlayerbotWarlockAI::DoNonCombatActions()

    // check for buffs with demon
    if(( pet )
-        && ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
+        && ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK_AURA, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
    {
        //ai->TellMaster( "casting soul link." );
        return;
diff --git a/src/game/playerbot/PlayerbotWarlockAI.h b/src/game/playerbot/PlayerbotWarlockAI.h
index 8058c4b..999224c 100644
--- a/src/game/playerbot/PlayerbotWarlockAI.h
+++ b/src/game/playerbot/PlayerbotWarlockAI.h
@@ -41,7 +41,7 @@ class MANGOS_DLL_SPEC PlayerbotWarlockAI : PlayerbotClassAI
        uint32 SHADOW_BOLT, IMMOLATE, INCINERATE, SEARING_PAIN, CONFLAGRATE, SOUL_FIRE, SHADOWFURY, CHAOS_BOLT, SHADOWFLAME, HELLFIRE, RAIN_OF_FIRE, SHADOWBURN;

        // DEMONOLOGY
-        uint32 DEMON_SKIN, DEMON_ARMOR, SHADOW_WARD, FEL_ARMOR, SOULSHATTER, SOUL_LINK, HEALTH_FUNNEL, DETECT_INVISIBILITY;
+        uint32 DEMON_SKIN, DEMON_ARMOR, SHADOW_WARD, FEL_ARMOR, SOULSHATTER, SOUL_LINK, SOUL_LINK_AURA, HEALTH_FUNNEL, DETECT_INVISIBILITY;

        // DEMON SUMMON
        uint32 SUMMON_IMP, SUMMON_VOIDWALKER, SUMMON_SUCCUBUS, SUMMON_FELHUNTER, SUMMON_FELGUARD;

Hope this helps

Link to comment
Share on other sites

Looking into Soul Link issue further I found another bug. Soul Link indeed should check base mana percent, and PlayerBotAI has a method for it:

uint8 PlayerbotAI::GetBaseManaPercent(const Unit& target) const
{
   if (target.GetPower(POWER_MANA) >= target.GetCreateMana())
       return (100);
   else
       return (static_cast<float> (target.GetPower(POWER_MANA)) / target.GetMaxPower(POWER_MANA)) * 100;
}

It looks like it was blindly copypasted from GetManaPercent(). It has to be something like this:

uint8 PlayerbotAI::GetBaseManaPercent(const Unit& target) const
{
   if (target.GetPower(POWER_MANA) >= target.GetCreateMana())
       return (100);
   else
       return (static_cast<float> (target.GetPower(POWER_MANA)) / target.GetCreateMana()) * 100;
}

... and WarlockAI Soul Link string should be:

&& ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK_AURA, EFFECT_INDEX_0) && ai->GetBaseManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))

Link to comment
Share on other sites

Your assessment of GetBaseManaPercent seems reasonable. Obviously, any changes to the AI need testing first. Can you post a patch for others to test out. Usually if there is no response (i.e no news is good news :rolleyes:) to the patch, the changes can be pushed to the repos.

Message to all

The class AIs are screaming out for a massive overhaul. They were first created by various individuals, each with their own style of programming. Information in this thread can be difficult to find, as the thread grows. The playerbot sister site, http://mangos.osh.nu/forums/index.php?app=uportal has been setup to better address this matter. Each class AI has it's own thread, for development purposes. I need a team of interested users to help improve the code. Later, if you like, I can add you to the contributors list for the repos, so you can push your own changes.

Cheers

Link to comment
Share on other sites

Here is a full patch fixing Soul Link issue:

diff --git a/src/game/PlayerbotAI.cpp b/src/game/PlayerbotAI.cpp
index 50c7d8b..4602570 100644
--- a/src/game/PlayerbotAI.cpp
+++ b/src/game/PlayerbotAI.cpp
@@ -820,7 +820,7 @@ uint8 PlayerbotAI::GetBaseManaPercent(const Unit& target) const
    if (target.GetPower(POWER_MANA) >= target.GetCreateMana())
        return (100);
    else
-        return (static_cast<float> (target.GetPower(POWER_MANA)) / target.GetMaxPower(POWER_MANA)) * 100;
+        return (static_cast<float> (target.GetPower(POWER_MANA)) / target.GetCreateMana()) * 100;
}

uint8 PlayerbotAI::GetBaseManaPercent() const
diff --git a/src/game/PlayerbotWarlockAI.cpp b/src/game/PlayerbotWarlockAI.cpp
index 31d53e7..d230735 100644
--- a/src/game/PlayerbotWarlockAI.cpp
+++ b/src/game/PlayerbotWarlockAI.cpp
@@ -44,6 +44,7 @@ PlayerbotWarlockAI::PlayerbotWarlockAI(Player* const master, Player* const bot,
    SHADOW_WARD           = ai->getSpellId("shadow ward");
    SOULSHATTER           = ai->getSpellId("soulshatter");
    SOUL_LINK             = ai->getSpellId("soul link");
+    SOUL_LINK_AURA        = 25228; // dummy aura applied, after spell SOUL_LINK
    HEALTH_FUNNEL         = ai->getSpellId("health funnel");
    DETECT_INVISIBILITY   = ai->getSpellId("detect invisibility");
    // demon summon
@@ -444,7 +445,7 @@ void PlayerbotWarlockAI::DoNonCombatActions()

    // check for buffs with demon
    if(( pet )
-        && ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
+        && ( SOUL_LINK>0 && !m_bot->HasAura(SOUL_LINK_AURA, EFFECT_INDEX_0) && ai->GetBaseManaPercent() >= 16 && ai->CastSpell(SOUL_LINK,*m_bot) ))
    {
        //ai->TellMaster( "casting soul link." );
        return;
diff --git a/src/game/PlayerbotWarlockAI.h b/src/game/PlayerbotWarlockAI.h
index 8058c4b..999224c 100644
--- a/src/game/PlayerbotWarlockAI.h
+++ b/src/game/PlayerbotWarlockAI.h
@@ -41,7 +41,7 @@ class MANGOS_DLL_SPEC PlayerbotWarlockAI : PlayerbotClassAI
        uint32 SHADOW_BOLT, IMMOLATE, INCINERATE, SEARING_PAIN, CONFLAGRATE, SOUL_FIRE, SHADOWFURY, CHAOS_BOLT, SHADOWFLAME, HELLFIRE, RAIN_OF_FIRE, SHADOWBURN;

        // DEMONOLOGY
-        uint32 DEMON_SKIN, DEMON_ARMOR, SHADOW_WARD, FEL_ARMOR, SOULSHATTER, SOUL_LINK, HEALTH_FUNNEL, DETECT_INVISIBILITY;
+        uint32 DEMON_SKIN, DEMON_ARMOR, SHADOW_WARD, FEL_ARMOR, SOULSHATTER, SOUL_LINK, SOUL_LINK_AURA, HEALTH_FUNNEL, DETECT_INVISIBILITY;

        // DEMON SUMMON
        uint32 SUMMON_IMP, SUMMON_VOIDWALKER, SUMMON_SUCCUBUS, SUMMON_FELHUNTER, SUMMON_FELGUARD;

Burned all warlock's mana, loged as another character, summoned warlock, warlock bot casted Soul Link right after he regenerated spell cost. All seems fine.

This is more proof-of-concept than a real solution, because AI needs new functionality to calculate spell cost dynamically. It shouldn't be that hard.

Link to comment
Share on other sites

Hi Guys,

I have got an update, that I hope will improve server stability, when bot(s) interact with instances.

In order for bots to enter an instance they must be invited to a group, with the player as the leader.

I noticed that dispite this restriction, all bot(s) still try to play an active roll in combat.

Snippet of Crash Log

Player Bean is being teleported to map 1
Player Bean is being teleported to map 1
MAP: Removing player 'Bean' from instance '1' of map 'Wailing Caverns' before relocating to other map
Remove player Bean from grid[31,32]
[1 ms] SQL: START TRANSACTION
[0 ms] SQL: DELETE FROM corpse WHERE player = '132' AND corpse_type <> '0'
[1 ms] SQL: INSERT INTO corpse (guid,player,position_x,position_y,position_z,orientation,map,time,corpse_type,instance,phaseMask) VALUES
(13, 132, -70.8849, 

322.705, -106.345, 5.38232, 43, 1277670706, 1, 1, 1)
[35 ms] SQL: COMMIT
Player Pascal (Guid: 31) chase to Creature (Entry: 3640 Guid: 142417)
Sending SMSG_SPELL_START id=75
Player Lutz (Guid: 93) chase to Creature (Entry: 5048 Guid: 142418)
Player Jock (Guid: 131) chase to Creature (Entry: 3640 Guid: 142417)


Warning: Program '/home/mangos/wow/bin/mangos-worldd' crashed.

First, I loaded the player (Bean). I then summoned two bots (Pascal & Cheryl) and invited them to join the player group. Two other bots were then summoned (Lutz & Jock), without an invitation. On passing through the portal to the instance, only the invited bot(s) were allowed to follow and client then repeatedly echoes for those excluded bot(s)

You can summon a player to your instance only if he is in your party with you as leader

.. could not be teleported ..

as expected.

Interestingly though, when the group does attack an example hostile (Entry: 3640 Guid: 142417, Evolving Ectoplasm) inside the instance, notice from the crash log that the excluded bot (Jock) also appears to attack, dispite being outside the instance.

I traced the problem to the function DoNextCombatManeuver() in PlayerbotAI.cpp

Each bot will first obtain the combat target. If the target exists in the world and is not dead, then combat will continue. In the case of Jock, teleporation will be necessary to reach the target and I believe this is what causes the server to crash. All I have done is to include an additional condition that will check that target also exist in the same map as the bot, else the target will be reset.

This appears to resolve this aspect of the instance crash. I would appreciate it if you could draw my attention to any instance issues you experience.

I have updated both repos to MaNGOS[10124] and also applied the fix..

Hope this helps

Link to comment
Share on other sites

blueboy, may you make a diff file or patch file to apply only your modifications.

Or may you make a tut for do'it by myself.

Thnks

Sry for my bad eng

Hi,

If you are referring to the 'instance fix' I've just posted, it is not necessary. I have already made the changes to the code on both repos (http://github.com/blueboy/portal and http://github.com/blueboy/mangos)

If you want to create a playerbot patch from the repos, use the following bash scripts (thanks to skinlayers for his improvements) I have recently updated these to work with MaNGOS[10000]+.

playerbot.sh

#!/bin/bash -x
# create empty .git repository
mkdir playerbot
cd playerbot
git init
# get hash for latest mangos release [XXXX], associated with playerbot release
git pull git://github.com/blueboy/mangos.git master
../gethash.sh
# read hash into 'line' variable 
{
while read line
do
echo $line
done
} < hash.txt
# cleanup & remove unwanted .git repositiory
cd ..
rm -R playerbot
# create empty .git repository
mkdir playerbot
cd playerbot
git init
# pull mangos master branch
git pull git://github.com/mangos/mangos.git master
# change to mangos branch associated with hash
git checkout -b mangos $line
# add remote playerbot branch to compare with local mangos branch
git remote add playerbot git://github.com/blueboy/mangos.git
#merge remote branch with local branch
git pull playerbot master
# difference between merged local branch & mangos hash branch
git diff $line > playerbot.patch

and gethash.sh (must be in same directory) to work with playerbot.sh

#!/bin/bash
[ -f "hash.txt" ] && rm hash.txt
git log --pretty=oneline > commit.txt
{
while read line
do
   echo $line > line.txt
   index=0
   while read -r -n1 char;    do
      MYARRAY[$index]=$char
      let "index++"
       done < line.txt

   ELEMENTS=${#MYARRAY[@]}

   i=0;t=1;n=2
   while [ $n -lt $ELEMENTS ]
   do
       [ "${MYARRAY[$t]}" == "[" ] && [ "${MYARRAY[$n]}" == "1" ] && exit
       echo -n "${MYARRAY[$i]}" >> hash.txt
       let "i++";let "t++";let "n++"
   done
       rm hash.txt
done
} < commit.txt

These scripts will produce a patch from the code on blueboy. You will have to edit them to produce a patch for the code on portal

The patch produced can then be applied as follows,

1. Download ManGOS to your harddrive..

git clone [email][email protected]/mangos/mangos.git[/email]

copy the playerbot.patch to the cloned mangos directory.

2. Select the required version of MaNGOS, with this script

branch.sh <version label > < version HASH> // version HASH can be obtained with the 'git log' command

example;

./branch.sh 10123 b39a1d97ce1b41876a3c6f46a4ce57f7af77f8fd

branch.sh

#!/bin/bash

unset COMMIT
unset BRANCH

COMMIT=$2
BRANCH=$1

[ ! -z "${BRANCH}" ] || { echo No branch name specified ; exit 1 ; }
[ ! -z "${COMMIT}" ] || { echo No commit SHA specified. use git log; exit 1 ; }

git checkout -b ${BRANCH} ${COMMIT}

3.

git apply --check --whitespace=fix playerbot.patch

Hope this helps

Link to comment
Share on other sites

Looking into warlock AI I found that PlayerBot has no ability to cast pet spells. AI expects pet spells to be found in bot's spell list and casted by bot as well. Maybe it was ok before, but it doesn't work now. I created a patch which adds:

1) 'pet spells' command, similar to 'spells';

2) 'petcast' / 'pc' command, similar to 'cast'/'c'

Patch itself: http://pastebin.org/378580

Please test it and leave your comments.

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