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
  • Loading branch information
trickerer committed Dec 2, 2024
1 parent b89001f commit 0d4562a
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 @@ -361,7 +361,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 @@ -2583,8 +2583,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 @@ -2612,8 +2615,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 @@ -1607,10 +1607,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 @@ -1831,6 +1827,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 @@ -2779,6 +2778,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 @@ -310,6 +310,7 @@ class TC_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 0d4562a

Please sign in to comment.