[9120] Implement option to use delay in ForcedDespawn for creature

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-01-07 20:18:22 +01:00
parent a2e92cdb4e
commit 9c48e32bb7
3 changed files with 30 additions and 4 deletions

View file

@ -105,6 +105,12 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
return true;
}
bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
m_owner.ForcedDespawn();
return true;
}
Creature::Creature() :
Unit(), i_AI(NULL),
lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0),
@ -1294,9 +1300,19 @@ void Creature::Respawn()
}
}
void Creature::ForcedDespawn()
void Creature::ForcedDespawn(uint32 timeMSToDespawn)
{
setDeathState(JUST_DIED);
if (timeMSToDespawn)
{
ForcedDespawnDelayEvent *pEvent = new ForcedDespawnDelayEvent(*this);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn));
return;
}
if (isAlive())
setDeathState(JUST_DIED);
RemoveCorpse();
SetHealth(0); // just for nice GM-mode view
}