feat(Core/Conditions): Implement CONDITION_TYPE_CREATURE_RESPAWN (#9927)

This commit is contained in:
Skjalf
2022-01-01 20:18:37 -03:00
committed by GitHub
parent 1806792625
commit 8216318f92
3 changed files with 18 additions and 2 deletions

View File

@@ -148,7 +148,8 @@ enum ConditionSourceType
CONDITION_SOURCE_TYPE_PHASE = 26, // don't use on 3.3.5a
CONDITION_SOURCE_TYPE_GRAVEYARD = 27, // don't use on 3.3.5a
CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE = 28,
CONDITION_SOURCE_TYPE_MAX = 29 // placeholder
CONDITION_SOURCE_TYPE_CREATURE_RESPAWN = 29,
CONDITION_SOURCE_TYPE_MAX = 30 // placeholder
};
enum RelationType

View File

@@ -578,7 +578,17 @@ void Creature::Update(uint32 diff)
time_t now = time(nullptr);
if (m_respawnTime <= now)
{
bool allowed = !IsAIEnabled || AI()->CanRespawn(); // First check if there are any scripts that object to us respawning
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_RESPAWN, GetEntry());
if (!sConditionMgr->IsObjectMeetToConditions(this, conditions))
{
// Creature should not respawn, reset respawn timer. Conditions will be checked again the next time it tries to respawn.
m_respawnTime = time(nullptr) + m_respawnDelay;
break;
}
bool allowed = !IsAIEnabled || AI()->CanRespawn(); // First check if there are any scripts that prevent us respawning
if (!allowed) // Will be rechecked on next Update call
break;