Jump to content

Playerbot


Recommended Posts

great news :) about the new sell items feature. Could it be possible to have a command to sell all gray items? could be very useful.

one thing i noticed about quests started from items dropped. There are some quests that start from an item but that does not work at the moment. The master starts the quest from the item. The bots say they started the quest but actually they don't even though they have the item in their inventory. Westfall Deed is an example.

Hi steveb,

vladex has correctly answered the first part of your question, about the disposal of 'gray items'. This is an automatic feature, so there is no specific command. To use, approach a vendor with your party, and just select the vendor.

In response to your request for bot(s) to be able to start quests from acquired items, I now have a working solution that I would like you to try, before I push it to portal master.

For this code to work, it is necessary to modify the 'SMSG_TRADE_STATUS' code on portal as I have done on vendor. This will enable users to display (i.e. [iTEM LINK]) quest items in the bot inventory (from client 'TRADE' on the bot avatar).

/t [botname] use [iTEM LINK]

I have added conditional code to UseItem() in PlayerbotAI.cpp. This checks whether the item being used actually starts a quest or not. If it does, then a 'CMSG_QUESTGIVER_ACCEPT_QUEST' packet is created and sent, automatically accepting the bot item quest.

diff --git a/src/game/playerbot/PlayerbotAI.cpp b/src/game/playerbot/PlayerbotAI.cpp
index 4b3f723..bffe9d4 100644
--- a/src/game/playerbot/PlayerbotAI.cpp
+++ b/src/game/playerbot/PlayerbotAI.cpp
@@ -813,7 +813,7 @@ void PlayerbotAI::HandleBotOutgoingPacket(const WorldPacket& packet)
                for (uint8 slot = INVENTORY_SLOT_ITEM_START; slot < INVENTORY_SLOT_ITEM_END; slot++)
                {
                    const Item* const pItem = m_bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
-                    if (pItem && pItem->CanBeTraded())
+                    if (pItem)
                    {
                        const ItemPrototype* const pItemProto = pItem->GetProto();

@@ -845,7 +845,7 @@ void PlayerbotAI::HandleBotOutgoingPacket(const WorldPacket& packet)
                        for (uint8 slot = 0; slot < pBag->GetBagSize(); ++slot)
                        {
                            const Item* const pItem = m_bot->GetItemByPos(bag, slot);
-                            if (pItem && pItem->CanBeTraded())
+                            if (pItem)
                            {
                                const ItemPrototype* const pItemProto = pItem->GetProto();

@@ -3621,6 +3621,17 @@ void PlayerbotAI::UseItem(Item *item, uint32 targetFlag, ObjectGuid targetGUID)
    uint32 glyphIndex = 0;
    uint8 unk_flags = 0;

+    if(uint32 questid = item->GetProto()->StartQuest)
+    {
+        m_bot->GetMotionMaster()->Clear(true);
+        WorldPacket* const packet = new WorldPacket(CMSG_QUESTGIVER_ACCEPT_QUEST, 8+4+4);
+        *packet << item_guid;
+        *packet << questid;
+        *packet << uint32(0);
+        m_bot->GetSession()->QueuePacket(packet); // queue the packet to get around race condition
+        return;
+    }
+
    uint32 spellId = 0;
    for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
    {

I have tested the code in 'Eversong Woods' with item [Tainted Arcane Sliver]. Using this item, starts a quest of the same name. if you could test the above patch with other such items (e.g. Westfall Deed) I would appreciate it.

Hope this helps

Link to comment
Share on other sites

  • Replies 799
  • Created
  • Last Reply

Top Posters In This Topic

Sure i will test now and post results ;) Great work

Later edit: Works great. The bots will accept the quest on Use <item> and is also listed as an active quest and completed also with no problem.

But one little thing: there is no text print out when the bot accepts the quest from the command.

What i mean is that after the command is used: Use <itemlink> you dont get a msg with Got the quest or Started quest from <itemlink> or I can't start that quest. A msg to tell you whether the bot started the quest or he cannot start the quest.

For the rest is all great and fun doing quests with the bots :)

Link to comment
Share on other sites

Sure i will test now and post results ;) Great work

Later edit: Works great. The bots will accept the quest on Use <item> and is also listed as an active quest and completed also with no problem.

But one little thing: there is no text print out when the bot accepts the quest from the command.

What i mean is that after the command is used: Use <itemlink> you dont get a msg with Got the quest or Started quest from <itemlink> or I can't start that quest. A msg to tell you whether the bot started the quest or he cannot start the quest.

For the rest is all great and fun doing quests with the bots :)

Yes, I was thinking the same about the 'quest confirmation text'. When I push it to portal, the text will be there. Thanks for testing the code.

Cheers

Link to comment
Share on other sites

More observations:

-bots disenchant items even without the skill. so they just roll on green items and disenchant without the skill?

-sometimes when entering instances if i have more bots not all will be teleported in the instance. using "follow" does not summon them also. so i have to remove them and then add them back.

-there seems to be a bug also with collecting/looting. I start up my server, go ingame but bots do not loot/collect anything. I have to do : collect none

and then collect combat quest etc and it will work again

More observations later

Link to comment
Share on other sites

an observation to your observation, lol..

-bots disenchant items even without the skill. so they just roll on green items and disenchant without the skill?

that is the actual game engine, when you roll for an item to be disenchanted it automaticly gives you the items resulted from disenching that item. no but i suppose.

Link to comment
Share on other sites

More observations:

-bots disenchant items even without the skill. so they just roll on green items and disenchant without the skill?

-sometimes when entering instances if i have more bots not all will be teleported in the instance. using "follow" does not summon them also. so i have to remove them and then add them back.

-there seems to be a bug also with collecting/looting. I start up my server, go ingame but bots do not loot/collect anything. I have to do : collect none

and then collect combat quest etc and it will work again

More observations later

Hi,

I see that the first of your observations has been answered. Remember that any materials produced by the disenchantment, can be traded with a bot that does have the skill.

With your second, when you say "if I have more bots"; Is this in addition to your group party bots? If this is so, then it's not a bug, but the core preventing non-party members entering the same instance (This is an anti-cheat mechanism). If you wish to enter an instance with a larger group, try converting your standard group to a raid group. That should work, and all member bots should be able to teleport through the portal.

With your last observation, have you enabled all default collection settings in file 'playerbot.conf' ?

PlayerbotAI.Collect.Combat = 1

PlayerbotAI.Collect.Quest = 1

PlayerbotAI.Collect.Profession = 1

PlayerbotAI.Collect.Loot = 1

PlayerbotAI.Collect.Skin = 1

PlayerbotAI.Collect.Objects = 1

The only setting that requires manual adjustment after a server restart is the collection of nearby objects. This feature has to be 'trained'. By default, the collection of nearby objects is empty and requires input e.g.

First do a survey

[botname]whispers: [Milly's Harvest][battered Chest][Milly's Harvest]...

then get

get [battered Chest]

and finally to check the settings, collect

[botname]whispers: I'm collecting all loot, profession, quest items after combat and nearby objects (Battered Chest)

If you have done all the above and it still errs, are you using the latest code on loot-fix-bt. I'm using this and have not experienced the issues you mention.

Hope this helps

Link to comment
Share on other sites

hi Blueboy!

observed some changes not necessary.

https://gist.github.com/957756

Hi thanks for spotting the unecessary whitespaces. I'll apply those changes relevant to playerbot shortly.

In Player.cpp

@@ -1501,7 +1501,7 @@ void Player::Update( uint32 update_diff, uint32 p_time )
    if (IsHasDelayedTeleport())
        TeleportTo(m_teleport_dest, m_teleport_options);

-        // Playerbot mod
+    // Playerbot mod
    if (m_playerbotAI)
        m_playerbotAI->UpdateAI(p_time);
    else if (m_playerbotMgr)

and in WorldSession.cpp,

@@ -523,7 +523,7 @@ void WorldSession::LogoutPlayer(bool Save)
        sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetObjectGuid(), true);
        sSocialMgr.RemovePlayerSocial (_player->GetGUIDLow ());

-        // Playerbot - remember player GUID for update SQL below
+        // Playerbot - remember player GUID for update SQL below
        uint32 guid = _player->GetGUIDLow();

        ///- Remove the player from the world

You should notify the guys at MaNGOS with the rest.

Cheers

Link to comment
Share on other sites

-sometimes when entering instances if i have more bots not all will be teleported in the instance. using "follow" does not summon them also. so i have to remove them and then add them back.

I have a group with 3 bots and me so no need for raid. Sometimes one of the bots enters the instance while the other 2 are not. Sometimes all 3 are left out. Hope you understand what i mean.

About the loot issue: i am using the loot-fix-bt code and have the config like this:

PlayerbotAI.Collect.Combat = 1
PlayerbotAI.Collect.Quest = 1
PlayerbotAI.Collect.Profession = 1
PlayerbotAI.Collect.Loot = 0
PlayerbotAI.Collect.Skin = 1
PlayerbotAI.Collect.Objects = 1

but i will test a few more times and let you know in detail

Link to comment
Share on other sites

-sometimes when entering instances if i have more bots not all will be teleported in the instance. using "follow" does not summon them also. so i have to remove them and then add them back.

I have a group with 3 bots and me so no need for raid. Sometimes one of the bots enters the instance while the other 2 are not. Sometimes all 3 are left out. Hope you understand what i mean.

About the loot issue: i am using the loot-fix-bt code and have the config like this:

PlayerbotAI.Collect.Combat = 1
PlayerbotAI.Collect.Quest = 1
PlayerbotAI.Collect.Profession = 1
PlayerbotAI.Collect.Loot = 0
PlayerbotAI.Collect.Skin = 1
PlayerbotAI.Collect.Objects = 1

but i will test a few more times and let you know in detail

Hi,

By any chance are you using 'movemaps' ? ( :o I know that is a silliy question, as everyone does). I have noticed recently that the bots frequently get 'stuck'. Ordering the bot to 'follow' or involve them in combat does snap them out of this unresponsive state, but I understand that if would be useless in the case of entering an instance. If you are using 'movemaps' try temporarily disabling this feature in 'mangosd.conf'

# mmap.enabled

# Enable/Disable pathfinding using mmaps

# Default: 1 (enable)

# 0 (disable)

to see if it still occurs. I am at present looking for a solution on my server and would be interested in any feedback you can give.

With your looting issue, I see an obvious difference that might be preventing looting (PlayerbotAI.Collect.Loot = 0). Set this value to 1.

Hope this helps, speak with you soon.

Link to comment
Share on other sites

Hi there again! I am not using movemaps :D. Should I? I use standard vmaps from mangos:

vmap.enableLOS = 1
vmap.enableHeight = 1
vmap.ignoreSpellIds = "7720"
vmap.enableIndoorCheck = 1
DetectPosCollision = 1
TargetPosRecalculateRange = 1.5

Link to comment
Share on other sites

Hi there again! I am not using movemaps :D. Should I? I use standard vmaps from mangos:

vmap.enableLOS = 1
vmap.enableHeight = 1
vmap.ignoreSpellIds = "7720"
vmap.enableIndoorCheck = 1
DetectPosCollision = 1
TargetPosRecalculateRange = 1.5

Arrh!, that throws water on my idea. Oh well, It looks like your issue is not connected to the issue I'm experiencing. Let me know where your issue occurs (i.e which instance) and I'll see if I can reproduce it on my server. Then I can work on a solution.

Yes, 'mmaps' is superb and drastically improves how NPC and bots navigate around fixed objects in the world. A simple example would be,

without 'mmap', if the player jumped from the battlements of a tower, so too would the bots.

with 'mmaps', if the player jumped, the bots would find a more appropriate path ('pathfinding') by running down the stairs. Far nicer visually.

Note that 'vmaps' are still required for height calculations and are not replaced by 'mmaps'. You use both.

The 'stuck' issue.

Theory 'bot' movement is analogous to 'pet' movement. So if bots get 'stuck', so should pets.

Testing

There is a tree by the entrance to Saldean's farmhouse in Westfall. If you run around the tree, eventually the bots get 'stuck'. It doesn't occur with mmaps disabled. I have just tested this with a pet and the same thing occurs. I will need to find other locations where this occurs, before I approach the guys at 'MoveMaps'. So anyone who does use 'MoveMaps' and have experienced this issue, feedback would be appreciated ( location coordinate required).

Hope this helps

Link to comment
Share on other sites

warning fix in vc10

diff --git a/win/VC100/game.vcxproj.filters b/win/VC100/game.vcxproj.filters
index daf1591..0f04dea 100644
--- a/win/VC100/game.vcxproj.filters
+++ b/win/VC100/game.vcxproj.filters
@@ -495,6 +495,7 @@
    </ClCompile>
    <ClCompile Include="..\\..\\src\\game\\playerbot\\PlayerbotWarriorAI.cpp">
      <Filter>World/Handlers</Filter>
+    </ClCompile>
    <ClCompile Include="..\\..\\src\\game\\vmap\\BIH.cpp">
      <Filter>vmaps</Filter>
    </ClCompile>
@@ -953,6 +954,7 @@
    </ClInclude>
    <ClInclude Include="..\\..\\src\\game\\playerbot\\PlayerbotWarriorAI.h">
      <Filter>World/Handlers</Filter>
+    </ClInclude>
    <ClInclude Include="..\\..\\src\\game\\vmap\\BIH.h">
      <Filter>vmaps</Filter>
    </ClInclude>

Link to comment
Share on other sites

fix to mangos 11430

but not sure if this the right way!

diff --git a/src/game/playerbot/PlayerbotMgr.cpp b/src/game/playerbot/PlayerbotMgr.cpp
index 404430b..bcf2612 100644
--- a/src/game/playerbot/PlayerbotMgr.cpp
+++ b/src/game/playerbot/PlayerbotMgr.cpp
@@ -9,6 +9,7 @@
#include "../Chat.h"
#include "../Language.h"
#include "../Guild.h"
+#include "../GuildMgr.h"
#include "../WaypointMovementGenerator.h"

class LoginQueryHolder;
@@ -662,7 +663,7 @@ void PlayerbotMgr::HandleMasterIncomingPacket(const WorldPacket& packet)
                    uint32 GuildId = bot->GetGuildId();
                    if (!GuildId)
                        return;
-                    Guild *pGuild = sObjectMgr.GetGuildById(GuildId);
+                    Guild *pGuild = sGuildMgr.GetGuildById(GuildId);
                    if (!pGuild)
                        return;
                    pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, bot->GetGUIDLow(), TotalCost);

Link to comment
Share on other sites

I'm probably showing my ignorance here, but what exactly is this? I've managed to compile mangos, and I've got a server up and running.

I just found this on the forum today (along with an Auction House Bot, which I gather doesn't work right now?), and it sounds awesome! Is this a branch off of the mangos code? Or a patch of some kind? Or something else? My main question is: how can I get this setup? Thanks!

Link to comment
Share on other sites

fix to mangos 11430

but not sure if this the right way!

diff --git a/src/game/playerbot/PlayerbotMgr.cpp b/src/game/playerbot/PlayerbotMgr.cpp
index 404430b..bcf2612 100644
--- a/src/game/playerbot/PlayerbotMgr.cpp
+++ b/src/game/playerbot/PlayerbotMgr.cpp
@@ -9,6 +9,7 @@
#include "../Chat.h"
#include "../Language.h"
#include "../Guild.h"
+#include "../GuildMgr.h"
#include "../WaypointMovementGenerator.h"

class LoginQueryHolder;
@@ -662,7 +663,7 @@ void PlayerbotMgr::HandleMasterIncomingPacket(const WorldPacket& packet)
                    uint32 GuildId = bot->GetGuildId();
                    if (!GuildId)
                        return;
-                    Guild *pGuild = sObjectMgr.GetGuildById(GuildId);
+                    Guild *pGuild = sGuildMgr.GetGuildById(GuildId);
                    if (!pGuild)
                        return;
                    pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, bot->GetGUIDLow(), TotalCost);

Hi kaxias,

Thanks for the patch

@Dark_Oppressor There is a good reason why this does not flag an compile error for most users. They have recently introduced 'GuildMgr' to the core from MaNGOS [11430].

I have now changed the way bots repair their items. The old way captured the opcode 'CMSG_REPAIR_ITEM' (PlayerbotMgr.cpp) only sent when the player selects the 'anvil' at an armour. The patch would be relevant for this code and I will apply it to portal shortly.

The new code from the vendor branch is far more versatile and utilizes the new 'findNearbyCreature mechanism'. Simply, if ordered to repair all or only selected items, the bot(s) will wait until they are in close proximity to an armour. Then they will independently approach the armour and complete the task of repair. The code in PlayerbotMgr.cpp is now redundant and thus does not require the patch.

This is the playerbot project which is a core modification. You will use MaNGOS as a base for your server code. You are then free to apply various core modifications (playerbot, auctionhousebot, etc) to this. You can do this either by directly merging the mod code into MaNGOS or by applying a pre-prepared (standalone) patch. I prefer the later and use the following bash scripts to create the patches. You can adapt these scripts to create patch from other mods if you wish

First get your code base

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

Creates patch from portal master

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

Create patch from alpha branch (e.g vendor)

#!/bin/bash -x
git clone git://github.com/mangos/mangos.git vendor
cd vendor
git fetch git://github.com/blueboy/portal.git vendor:vendor
git checkout vendor
HASH=`git log --pretty=oneline | grep -m 1 'Merge branch' | cut -d " " -f 1`
git diff $HASH > vendor.patch

To apply the patches, inside the code source directory

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

--check option does a dumby run with the patch, without actually applying it. If no conflicts occur, remove it and run again.

--whitespace=fix option as you might guess, checks for unwanted whitespaces in the patch.

Remember, the more mods that you attempt to merge into your base, the higher the risk of 'merge conflicts'. These need to be resolved before the merge will take. I recommend that you start by merging only one or to mods at first, until you 'git' more confident (sorry for the pun :D).

If all goes well, you can then build your code. If you want a playerbot friendly version of 'auctionhousebot' you can obtain it from https://github.com/blueboy/ahbot. It's not as nice as cyberium's code, but it works.

Hope this helps

Link to comment
Share on other sites

I've updated the loot-fix-bt branch to allow bots to automatically know what game objects to loot in order to get the needed quest item. For example, when your bot is on the quest Milly's Harvest it will automatically add the game object to the collect object list so that you won't even have to tell them survey and get. However, the way I have it implemented right now uses a SQL call for each item in the quest; it may actually cause a bit of overhead that will need to be reduced.

Link to comment
Share on other sites

Hi,

Nice idea, not having to manually 'train' the nearby collection option. I'm sure it will be very popular. If it works via SQL call, will it automatically restore quest items for collection (without user intervention), after a server restart?

Once again, many thanks for your excellent work mate

Link to comment
Share on other sites

It does restore the collection list anytime the SetQuestNeedItems is called (it is called when bots get brought online). That was the reason behind my recent adjustments to the portal/master to make it get called a little less by some of the other code. It might actually be able to be expanded to include game objects that just need to be interacted with (not looted).

Link to comment
Share on other sites

This may sound like a stupid idea but it comes from observations of the Playerbot system in use...

The problems I find are this..

No matter what i do the priest will not stop running in and meleeing the creatures I am fighting.. Even if i use the stay command and the HEAL orders.. They run in and melee and nuke all their mana away,

Ive also noticed that for some reason a level 80 druid 50% of the time does NOTHING during a fight. Stays in normal form and melees.. Casts almost no spells and does not shift forms to fight..

What i propose.. ( Forgive me for the poor explanation code wise please )

is if it would be possible to do something like this..

If (m_Spec_Holy && ORDERS_HEAL && MOVEMENT_STAY)
m_bot->(SOMEHOW CAST ONLY HEAL SPELLS)
else if (m_Spec_SHADOWMAGIC && ORDERS_ASSIST && MOVEMENT_STAY)
m_bot->(SOMEHOW CAST ONLY DAMAGE SPELLS)

I know that is a TERRIBLE explanation of it.. but try to reason it out and let me know if you think it would be possible.

Also for the Druid could possibly do something similar like

If (m_Spec_RESTO && ORDERS_HEAL && MOVEMENT_STAY)
m_bot->(SOMEHOW CAST ONLY HEAL SPELLS)
else if (m_Spec_FERAL && ORDERS_ASSIST && MOVEMENT_STAY)
m_bot->(SOMEHOW FORCE CAT FORM AND DPS)
else if (m_Spec_FERAL && ORDERS_TANK)
m_bot->(SOMEHOW FORCE BEAR FORM AND TANK)

Any idea if something like this is possible?

Link to comment
Share on other sites

Hi Kreegoth,

Thanks for showing interest in playerbot. This is a model request ;) Your suggestions and explanations are great and in particular the 'pseudo code' for your ideas.

In answer to question, yes it should be possible. Leave it with me and I'll put a patch together for you to try out in a few days.

Hope this helps

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