Skip to content

Commit

Permalink
NPCBot: Do not reset master on recall. Try to check bot ownership in …
Browse files Browse the repository at this point in the history
…`.npcbot fix` command

(cherry picked from commit 40a60fbac6931be0e7e8881b855bcb329900c59f)
  • Loading branch information
trickerer committed Nov 18, 2024
1 parent 4e6bcca commit 862376f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ void bot_ai::ResetBotAI(uint8 resetType)
_botAwaitState = BOT_AWAIT_NONE;
_reviveTimer = 0;

master = reinterpret_cast<Player*>(me);
if (resetType & BOTAI_RESET_MASK_RESET_MASTER)
master = reinterpret_cast<Player*>(me);
if (resetType & BOTAI_RESET_MASK_ABANDON_MASTER)
_ownerGuid = 0;
if (resetType == BOTAI_RESET_INIT || resetType == BOTAI_RESET_LOGOUT)
Expand Down Expand Up @@ -3480,6 +3481,15 @@ void bot_ai::ReceiveEmote(Player* player, uint32 emote)
std::ostringstream report;
report << "Problems:";

if (_ownerGuid && !HasBotCommandState(BOT_COMMAND_UNBIND) && (master->ToUnit() == me->ToUnit() || _ownerGuid != master->GetGUID().GetRawValue()))
{
if (Player* real_owner = ObjectAccessor::FindPlayerByLowGUID(_ownerGuid))
{
report << "\n owner is in world by bot isn't owned by it";
if (!SetBotOwner(real_owner))
report << "\n (failed to set owner to '" << real_owner->GetName() << "'!)";
}
}
if ((me->HasUnitFlag(UNIT_FLAG_STUNNED) || me->HasUnitState(UNIT_STATE_STUNNED)) &&
!me->HasAuraType(SPELL_AURA_MOD_STUN))
{
Expand Down
3 changes: 2 additions & 1 deletion src/server/game/AI/NpcBots/botcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ enum BotAIResetType
BOTAI_RESET_LOGOUT = 0x08,
BOTAI_RESET_FORCERECALL = 0x10,

BOTAI_RESET_MASK_ABANDON_MASTER = (BOTAI_RESET_INIT | BOTAI_RESET_DISMISS)
BOTAI_RESET_MASK_ABANDON_MASTER = (BOTAI_RESET_INIT | BOTAI_RESET_DISMISS),
BOTAI_RESET_MASK_RESET_MASTER = (BOTAI_RESET_INIT | BOTAI_RESET_DISMISS | BOTAI_RESET_UNBIND | BOTAI_RESET_LOGOUT)
};

enum BotMovementType
Expand Down

0 comments on commit 862376f

Please sign in to comment.