Entities/Creature: Add arg2 to DespawnOrUnsummon to allow overriding respawn time. This matches changes that will be merged as part of dynamic spawning, allowing scripts to transition early.

This commit is contained in:
treeston
2016-08-25 23:04:21 +02:00
committed by Aokromes
parent ca98eaf408
commit e12a7116f8
3 changed files with 26 additions and 20 deletions

View File

@@ -573,16 +573,7 @@ void BossAI::_DespawnAtEvade(uint32 delayToRespawn, Creature* who)
return;
}
uint32 corpseDelay = who->GetCorpseDelay();
uint32 respawnDelay = who->GetRespawnDelay();
who->SetCorpseDelay(1);
who->SetRespawnDelay(delayToRespawn - 1);
who->DespawnOrUnsummon();
who->SetCorpseDelay(corpseDelay);
who->SetRespawnDelay(respawnDelay);
me->DespawnOrUnsummon(0, Seconds(delayToRespawn));
if (instance && who == me)
instance->SetBossState(_bossId, FAIL);

View File

@@ -173,7 +173,7 @@ CreatureBaseStats const* CreatureBaseStats::GetBaseStats(uint8 level, uint8 unit
bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
m_owner.DespawnOrUnsummon(); // since we are here, we are not TempSummon as object type cannot change during runtime
m_owner.DespawnOrUnsummon(0, m_respawnTimer); // since we are here, we are not TempSummon as object type cannot change during runtime
return true;
}
@@ -1796,28 +1796,42 @@ void Creature::Respawn(bool force)
UpdateObjectVisibility();
}
void Creature::ForcedDespawn(uint32 timeMSToDespawn)
void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds const& forceRespawnTimer)
{
if (timeMSToDespawn)
{
ForcedDespawnDelayEvent* pEvent = new ForcedDespawnDelayEvent(*this);
ForcedDespawnDelayEvent* pEvent = new ForcedDespawnDelayEvent(*this, forceRespawnTimer);
m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn));
return;
}
if (IsAlive())
setDeathState(JUST_DIED);
{
if (forceRespawnTimer > Seconds::zero())
{
uint32 respawnDelay = m_respawnDelay;
uint32 corpseDelay = m_corpseDelay;
m_respawnDelay = forceRespawnTimer.count();
m_corpseDelay = 0;
setDeathState(JUST_DIED);
m_respawnDelay = respawnDelay;
m_corpseDelay = corpseDelay;
}
else
setDeathState(JUST_DIED);
}
RemoveCorpse(false);
}
void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/)
void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds const& forceRespawnTimer /*= 0*/)
{
if (TempSummon* summon = this->ToTempSummon())
summon->UnSummon(msTimeToDespawn);
else
ForcedDespawn(msTimeToDespawn);
ForcedDespawn(msTimeToDespawn, forceRespawnTimer);
}
bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const

View File

@@ -599,8 +599,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
void RemoveCorpse(bool setSpawnTime = true);
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
void DespawnOrUnsummon(Milliseconds const& time) { DespawnOrUnsummon(uint32(time.count())); }
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0, Seconds const& forceRespawnTime = Seconds(0));
void DespawnOrUnsummon(Milliseconds const& time, Seconds const& forceRespawnTime = Seconds(0)) { DespawnOrUnsummon(uint32(time.count()), forceRespawnTime); }
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
@@ -750,7 +750,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool CanAlwaysSee(WorldObject const* obj) const override;
private:
void ForcedDespawn(uint32 timeMSToDespawn = 0);
void ForcedDespawn(uint32 timeMSToDespawn = 0, Seconds const& forceRespawnTimer = Seconds(0));
bool CheckNoGrayAggroConfig(uint32 playerLevel, uint32 creatureLevel) const; // No aggro from gray creatures
//WaypointMovementGenerator vars
@@ -789,11 +789,12 @@ class TC_GAME_API AssistDelayEvent : public BasicEvent
class TC_GAME_API ForcedDespawnDelayEvent : public BasicEvent
{
public:
ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { }
ForcedDespawnDelayEvent(Creature& owner, Seconds const& respawnTimer) : BasicEvent(), m_owner(owner), m_respawnTimer(respawnTimer) { }
bool Execute(uint64 e_time, uint32 p_time) override;
private:
Creature& m_owner;
Seconds const m_respawnTimer;
};
#endif