Skip to content

Commit

Permalink
NPCBots: Fix bots not refreshing their ability to swim unit state
Browse files Browse the repository at this point in the history
(cherry picked from commit a36b6a36e2b97da27e7d9f666f4e2346c038d1b7)

# Conflicts:
#	src/server/game/AI/NpcBots/bot_ai.cpp
#	src/server/game/Entities/Creature/Creature.cpp
#	src/server/game/Entities/Unit/Unit.cpp
  • Loading branch information
trickerer committed Nov 15, 2024
1 parent 9334f8a commit 91b1b42
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ const std::string& bot_ai::LocalizedNpcText(Player const* forPlayer, uint32 text

void bot_ai::InitializeAI()
{
me->RefreshSwimmingFlag();

if (!me->GetSpawnId() && !IsTempBot())
SetWanderer();

Expand Down Expand Up @@ -16092,6 +16090,8 @@ void bot_ai::JustEngagedWith(Unit* u)

ResetChase(u);

me->RefreshSwimmingFlag();

if (IsLastOrder(BOT_ORDER_PULL, 0, u->GetGUID()))
CompleteOrder(_orders.front());

Expand Down Expand Up @@ -19007,6 +19007,9 @@ bool bot_ai::FinishTeleport(bool reset)
me->BotStopMovement();
if (reset)
this->Reset();

me->RefreshSwimmingFlag();

//bot->SetAI(oldAI);
//me->IsAIEnabled = true;
canUpdate = true;
Expand Down
1 change: 1 addition & 0 deletions src/server/game/AI/NpcBots/botmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,7 @@ void BotMgr::_reviveBot(Creature* bot, WorldLocation* dest)
bot->Motion_Initialize();
bot->setDeathState(DeathState::Alive);
//bot->GetBotAI()->Reset();
bot->RefreshSwimmingFlag();
bot->GetBotAI()->SetShouldUpdateStats();

uint8 restore_factor = (bot->IsWandererBot() || (!bot->GetBotAI()->IAmFree() && bot->GetBotOwner()->InBattleground())) ? 1 : 4;
Expand Down
5 changes: 5 additions & 0 deletions src/server/game/Entities/Creature/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3456,6 +3456,11 @@ bool Creature::CanSwim() const
if (Unit::CanSwim() || (!Unit::CanSwim() && !CanFly()))
return true;

//npcbot
if (IsNPCBotOrPet())
return true;
//end npcbot

if (IsPet())
return true;

Expand Down
4 changes: 0 additions & 4 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21453,10 +21453,6 @@ bool Unit::CanSwim() const
return false;
if (HasUnitFlag(UNIT_FLAG_PET_IN_COMBAT))
return true;
//npcbot
if (IsNPCBotOrPet())
return true;
//end npcbot
return HasUnitFlag(UNIT_FLAG_RENAME | UNIT_FLAG_SWIMMING);
}

Expand Down

0 comments on commit 91b1b42

Please sign in to comment.