feat(Core/Creature): Actually despawn creatures on evade with Despawn… (#14786)
This commit is contained in:
parent
b4e3f1310b
commit
f59ee4ef7c
3 changed files with 14 additions and 29 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue