Skip to content

Commit

Permalink
NPCBots: Fix bots teleportation to invalid coords on leaving a dungeo…
Browse files Browse the repository at this point in the history
…n. Do not display hide/unhide messages if bots are already hidden/unhidden. Druid: Do not use Tranquility out of combat

(cherry picked from commit 0d4562a31eb75ad8cd5a0c53a0f401016bf140d4)
  • Loading branch information
trickerer committed Dec 2, 2024
1 parent dc9d497 commit cde4081
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/server/game/AI/NpcBots/bot_druid_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class druid_bot : public CreatureScript
if (Rand() > 30 + 50 * (me->GetMap()->IsRaid())) return false;
if (!gPlayer->GetGroup()) return false;

bool tranq = IsSpellReady(TRANQUILITY_1, diff, false);
bool tranq = IsSpellReady(TRANQUILITY_1, diff, false) && master->GetBotMgr()->IsPartyInCombat(false);
bool growt = IsSpellReady(WILD_GROWTH_1, diff, false) && !HasRole(BOT_ROLE_DPS);
if (!tranq && !growt)
return false;
Expand Down
14 changes: 10 additions & 4 deletions src/server/game/AI/NpcBots/botcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2609,8 +2609,11 @@ class script_bot_commands : public CommandScript
return false;
}

owner->GetBotMgr()->SetBotsHidden(true);
handler->SendSysMessage("Bots hidden");
if (!owner->GetBotMgr()->GetBotsHidden())
{
owner->GetBotMgr()->SetBotsHidden(true);
handler->SendSysMessage("Bots hidden");
}
return true;
}

Expand Down Expand Up @@ -2638,8 +2641,11 @@ class script_bot_commands : public CommandScript
return false;
}

owner->GetBotMgr()->SetBotsHidden(false);
handler->SendSysMessage("Bots unhidden");
if (owner->GetBotMgr()->GetBotsHidden())
{
owner->GetBotMgr()->SetBotsHidden(false);
handler->SendSysMessage("Bots unhidden");
}
return true;
}

Expand Down
11 changes: 7 additions & 4 deletions src/server/game/AI/NpcBots/botmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,10 +1608,6 @@ void BotMgr::_teleportBot(Creature* bot, Map* newMap, float x, float y, float z,

BotLogger::Log(NPCBOT_LOG_TELEPORT_START, bot, bot->IsInGrid(), bot->IsWandererBot(), botai->CanAppearInWorld(), newMap->GetId(), bool(reset));

if (Map* bmap = bot->FindMap())
if (bmap->GetEntry()->Instanceable() && bot->IsInGrid())
bmap->RemoveFromMap(bot, false);

BotMgr::AddDelayedTeleportCallback([bot, botai, newMap, x, y, z, ori, quick, reset]() {
if (bot->GetVehicle())
bot->ExitVehicle();
Expand Down Expand Up @@ -1832,6 +1828,9 @@ void BotMgr::RemoveBot(ObjectGuid guid, uint8 removetype)
Creature* bot = itr->second;
CleanupsBeforeBotDelete(guid, removetype);

if (_owner->GetSession()->PlayerLogout() && bot->IsInGrid() && bot->FindMap() && bot->FindMap()->GetEntry()->Instanceable())
bot->FindMap()->RemoveFromMap(bot, false);

////remove control bar
//if (GetNpcBotsCount() <= 1 && !_owner->GetPetGUID() && _owner->m_Controlled.empty())
// _owner->SendRemoveControlBar();
Expand Down Expand Up @@ -2780,6 +2779,10 @@ void BotMgr::SetBotAllowCombatPositioning(bool allow)
allow ? _data->RemoveFlag(NPCBOT_MGR_FLAG_DISABLE_COMBAT_POSITIONING) : _data->SetFlag(NPCBOT_MGR_FLAG_DISABLE_COMBAT_POSITIONING);
}

bool BotMgr::GetBotsHidden() const
{
return _data->HasFlag(NPCBOT_MGR_FLAG_HIDE_BOTS);
}
void BotMgr::SetBotsHidden(bool hidden)
{
hidden ? _data->SetFlag(NPCBOT_MGR_FLAG_HIDE_BOTS) : _data->RemoveFlag(NPCBOT_MGR_FLAG_HIDE_BOTS);
Expand Down
1 change: 1 addition & 0 deletions src/server/game/AI/NpcBots/botmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ class AC_GAME_API BotMgr
bool GetBotAllowCombatPositioning() const;
void SetBotAllowCombatPositioning(bool allow);

bool GetBotsHidden() const;
void SetBotsHidden(bool hidden);

uint32 GetEngageDelayDPS() const;
Expand Down

0 comments on commit cde4081

Please sign in to comment.