mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 02:50:29 +00:00
feat(Core/Creature): Actually despawn creatures on evade with Despawn… (#14786)
This commit is contained in:
@@ -29,21 +29,6 @@
|
||||
#include "Language.h"
|
||||
#include "ZoneScript.h"
|
||||
|
||||
class PhasedRespawn : public BasicEvent
|
||||
{
|
||||
public:
|
||||
PhasedRespawn(Creature& owner) : BasicEvent(), _owner(owner) {}
|
||||
|
||||
bool Execute(uint64 /*eventTime*/, uint32 /*updateTime*/) override
|
||||
{
|
||||
_owner.RespawnOnEvade();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
Creature& _owner;
|
||||
};
|
||||
|
||||
//Disable CreatureAI when charmed
|
||||
void CreatureAI::OnCharmed(bool /*apply*/)
|
||||
{
|
||||
@@ -226,7 +211,6 @@ void CreatureAI::EnterEvadeMode(EvadeReason why)
|
||||
if (cInfo && cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_HARD_RESET))
|
||||
{
|
||||
me->DespawnOnEvade();
|
||||
me->m_Events.AddEvent(new PhasedRespawn(*me), me->m_Events.CalculateTime(20000));
|
||||
}
|
||||
|
||||
sScriptMgr->OnUnitEnterEvadeMode(me, why);
|
||||
|
||||
@@ -2097,22 +2097,24 @@ void Creature::DespawnOrUnsummon(Milliseconds msTimeToDespawn /*= 0*/, Seconds f
|
||||
ForcedDespawn(msTimeToDespawn.count(), forcedRespawnTimer);
|
||||
}
|
||||
|
||||
void Creature::DespawnOnEvade()
|
||||
void Creature::DespawnOnEvade(Seconds respawnDelay)
|
||||
{
|
||||
SetVisible(false);
|
||||
AI()->SummonedCreatureDespawnAll();
|
||||
}
|
||||
|
||||
void Creature::RespawnOnEvade()
|
||||
{
|
||||
SetVisible(true);
|
||||
UpdateMovementFlags();
|
||||
AI()->Reset();
|
||||
AI()->JustReachedHome();
|
||||
if (IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
|
||||
if (respawnDelay < 2s)
|
||||
{
|
||||
GetVehicleKit()->Reset(true);
|
||||
LOG_WARN("entities.unit", "DespawnOnEvade called with delay of {} seconds, defaulting to 2.", respawnDelay.count());
|
||||
respawnDelay = 2s;
|
||||
}
|
||||
|
||||
if (TempSummon* whoSummon = ToTempSummon())
|
||||
{
|
||||
LOG_WARN("entities.unit", "DespawnOnEvade called on a temporary summon.");
|
||||
whoSummon->UnSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
DespawnOrUnsummon(Milliseconds(0), respawnDelay);
|
||||
}
|
||||
|
||||
void Creature::InitializeReactState()
|
||||
|
||||
@@ -272,8 +272,7 @@ public:
|
||||
|
||||
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer);
|
||||
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0) { DespawnOrUnsummon(Milliseconds(msTimeToDespawn), 0s); };
|
||||
void DespawnOnEvade();
|
||||
void RespawnOnEvade();
|
||||
void DespawnOnEvade(Seconds respawnDelay = 20s);
|
||||
|
||||
[[nodiscard]] time_t const& GetRespawnTime() const { return m_respawnTime; }
|
||||
[[nodiscard]] time_t GetRespawnTimeEx() const;
|
||||
|
||||
Reference in New Issue
Block a user