Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions data/sql/updates/pending_db_world/rev_1777182648846009000.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--
-- Magtheridon's Lair: notify the instance script when a Hellfire Channeler
-- evades, so the encounter can transition back to NOT_STARTED if the raid
-- wiped during phase 1 (otherwise the room doors would stay locked).
--
DELETE FROM `smart_scripts` WHERE `entryorguid`=17256 AND `source_type`=0 AND `id`=9;
INSERT INTO `smart_scripts`
(`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,
`event_param1`,`event_param2`,`event_param3`,`event_param4`,`event_param5`,
`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,
`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_param4`,
`target_x`,`target_y`,`target_z`,`target_o`,`comment`)
VALUES
(17256, 0, 9, 0, 7, 0, 100, 0, 0, 0, 0, 0, 0, 34, 10, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
'Hellfire Channeler - On Evade - Set Instance Data 10 to 0');
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,55 @@ class instance_magtheridons_lair : public InstanceMapScript
switch (type)
{
case DATA_CHANNELER_COMBAT:
if (GetBossState(DATA_MAGTHERIDON) != IN_PROGRESS)
if (Creature* magtheridon = instance->GetCreature(_magtheridonGUID))
magtheridon->SetInCombatWithZone();
// data == 1: a Channeler entered combat
// data == 0: a Channeler evaded (sent from C++ on JustReachedHome)
if (data == 1)
{
if (GetBossState(DATA_MAGTHERIDON) != IN_PROGRESS)
{
// Force the encounter into IN_PROGRESS as soon as any Channeler
// is engaged. This:
// 1) closes the room doors and notifies boss mods (DBM, etc.)
// 2) prevents dead Channelers from being resurrected later by
// InstanceScript::UpdateMinionState() when Magtheridon's
// own JustEngagedWith would otherwise transition the state
// to IN_PROGRESS after the Channelers are dead.
SetBossState(DATA_MAGTHERIDON, IN_PROGRESS);
if (Creature* magtheridon = instance->GetCreature(_magtheridonGUID))
magtheridon->SetInCombatWithZone();
}
}
else // data == 0: Channeler evaded
{
// If we forced the encounter to IN_PROGRESS during phase 1 and the raid
// wiped (or left the room) before Magtheridon was released, Magtheridon
// himself is still passive and will never trigger _EnterEvadeMode to
// reset the state. We must do it manually when all Channelers have
// returned home, otherwise the room doors stay locked forever.
if (GetBossState(DATA_MAGTHERIDON) == IN_PROGRESS)
{
bool anyChannelerStillFighting = false;
DoForAllMinions(DATA_MAGTHERIDON, [&](Creature* channeler)
{
if (channeler->IsAlive() && channeler->IsInCombat())
anyChannelerStillFighting = true;
});

if (!anyChannelerStillFighting)
{
if (Creature* magtheridon = instance->GetCreature(_magtheridonGUID))
{
// Only reset if Magtheridon is still in his pre-release passive state.
// If he is already engaged (phase 2/3), his own BossAI handles evade.
if (!magtheridon->IsEngaged() && magtheridon->IsImmuneToPC())
{
SetBossState(DATA_MAGTHERIDON, NOT_STARTED);
magtheridon->AI()->Reset();
}
}
}
}
}
break;
case DATA_ACTIVATE_CUBES:
for (ObjectGuid const& guid : _cubesSet)
Expand Down
Loading