mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
BattleGround: Fix bot's already cast (ranged) spells to be redirected to bot's ghost on death (#934)
* Update ReleaseSpiritAction.h - add bg_release_time * Update ReleaseSpiritAction.cpp * Update ReleaseSpiritAction.cpp - Move LOG_DEBUG Correct LOG_DEBUG position. * Reliable fix (#67) Reliable fix * Reduced wait time from 8 to 6 min * Update comment
This commit is contained in:
@@ -146,8 +146,33 @@ bool AutoReleaseSpiritAction::isUseful()
|
|||||||
if (bot->InArena())
|
if (bot->InArena())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// if (bot->InBattleground())
|
||||||
|
// return true;
|
||||||
|
|
||||||
|
// When bot dies in BG, wait a couple of seconds before release.
|
||||||
|
// This prevents currently casted (ranged) spells to be re-directed to the bot's ghost.
|
||||||
|
// Use a static map to track release times for each bot.
|
||||||
if (bot->InBattleground())
|
if (bot->InBattleground())
|
||||||
|
{
|
||||||
|
auto botId = bot->GetGUID().GetRawValue();
|
||||||
|
|
||||||
|
// If the bot is not a ghost yet, delay release some.
|
||||||
|
if (!bot->HasPlayerFlag(PLAYER_FLAGS_GHOST))
|
||||||
|
{
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
|
||||||
|
// If this bot has no recorded release time yet, set it to now.
|
||||||
|
if (botReleaseTimes.find(botId) == botReleaseTimes.end())
|
||||||
|
botReleaseTimes[botId] = now;
|
||||||
|
|
||||||
|
// Wait 6 seconds before releasing.
|
||||||
|
if (now - botReleaseTimes[botId] < 6)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Erase the release time for this bot.
|
||||||
|
botReleaseTimes.erase(botId);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (bot->HasPlayerFlag(PLAYER_FLAGS_GHOST))
|
if (bot->HasPlayerFlag(PLAYER_FLAGS_GHOST))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public:
|
|||||||
bool isUseful() override;
|
bool isUseful() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
inline static std::unordered_map<uint32_t, time_t> botReleaseTimes;
|
||||||
uint32_t bg_gossip_time = 0;
|
uint32_t bg_gossip_time = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user