From 8216318f922f2c3caf17ff9ff3b574ef599bdd7e Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Sat, 1 Jan 2022 20:18:37 -0300 Subject: [PATCH] feat(Core/Conditions): Implement CONDITION_TYPE_CREATURE_RESPAWN (#9927) --- .../pending_db_world/rev_1640860713284766500.sql | 5 +++++ src/server/game/Conditions/ConditionMgr.h | 3 ++- src/server/game/Entities/Creature/Creature.cpp | 12 +++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1640860713284766500.sql diff --git a/data/sql/updates/pending_db_world/rev_1640860713284766500.sql b/data/sql/updates/pending_db_world/rev_1640860713284766500.sql new file mode 100644 index 000000000..21b10af30 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1640860713284766500.sql @@ -0,0 +1,5 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1640860713284766500'); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 29 AND `SourceEntry` = 12101; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(29, 0, 12101, 0, 0, 13, 0, 2, 3, 3, 1, 0, 0, '', 'Lava Surger only spawn if boss state 3 (Garr) is not DONE.'); diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index d3989dfeb..75b9453e9 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -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 diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 841f42d5a..7f07af7d3 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -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;