aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp11
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp26
-rw-r--r--src/server/game/Entities/Creature/Creature.h9
3 files changed, 26 insertions, 20 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 316a9704cac..9fb8608241c 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -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);
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 05ba2211752..424215168bb 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -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;
}
@@ -1776,28 +1776,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
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 7e8d5e3a9ad..2bcd7b5cd23 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -598,8 +598,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;
@@ -755,7 +755,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
@@ -794,11 +794,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