diff options
| author | treeston <treeston.mmoc@gmail.com> | 2016-09-09 16:21:27 +0200 |
|---|---|---|
| committer | treeston <treeston.mmoc@gmail.com> | 2016-09-09 16:21:27 +0200 |
| commit | b3d44d6c366c7e4f12a6ce30ee5cf6b9bff68a06 (patch) | |
| tree | 5b0518a14d556de4944ebaa977a17a1ce2f5955a /src/server/game/Entities/Creature | |
| parent | 9180bcd404ff0a89144bbe834a2efe189bd0eb86 (diff) | |
Creature/Scripting: Move CreatureAI::CanRespawn to CreatureScript::CanSpawn. Now also applies to initial spawn. Dynamic spawning prep.
Diffstat (limited to 'src/server/game/Entities/Creature')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 7a40b43f236..86dff1592c2 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -518,9 +518,9 @@ void Creature::Update(uint32 diff) time_t now = time(NULL); if (m_respawnTime <= now) { - bool allowed = IsAIEnabled ? AI()->CanRespawn() : true; // First check if there are any scripts that object to us respawning - if (!allowed) // Will be rechecked on next Update call - break; + // First check if there are any scripts that object to us respawning + if (!sScriptMgr->CanSpawn(GetSpawnId(), GetCreatureTemplate(), GetCreatureData(), GetMap())) + break; // Will be rechecked on next Update call ObjectGuid dbtableHighGuid(HighGuid::Unit, GetEntry(), m_spawnId); time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid); @@ -1388,6 +1388,11 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad m_deathState = ALIVE; m_respawnTime = GetMap()->GetCreatureRespawnTime(m_spawnId); + + // Is the creature script objecting to us spawning? If yes, delay by one second (then re-check in ::Update) + if (!m_respawnTime && !sScriptMgr->CanSpawn(spawnId, GetCreatureTemplate(), GetCreatureData(), map)) + m_respawnTime = time(NULL)+1; + if (m_respawnTime) // respawn on Update { m_deathState = DEAD; |
