refactor(Scripts/ObsidianSanctum): Modernize script files (#24632)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Andrew
2026-02-07 15:48:05 -03:00
committed by GitHub
parent 008a6199d9
commit 4bda3ca1a9
2 changed files with 709 additions and 908 deletions
@@ -253,19 +253,9 @@ const uint32 dragons[MAX_DRAGONS] = { DATA_TENEBRON, DATA_VESPERON, DATA_SHADRON
// SARTHARION // SARTHARION
///////////////////////////// /////////////////////////////
class boss_sartharion : public CreatureScript struct boss_sartharion : public BossAI
{ {
public: boss_sartharion(Creature* creature) : BossAI(creature, DATA_SARTHARION),
boss_sartharion() : CreatureScript("boss_sartharion") { }
CreatureAI* GetAI(Creature* pCreature) const override
{
return GetObsidianSanctumAI<boss_sartharionAI> (pCreature);
}
struct boss_sartharionAI : public BossAI
{
boss_sartharionAI(Creature* pCreature) : BossAI(pCreature, DATA_SARTHARION),
dragonsCount(0), dragonsCount(0),
lastLavaSide(LAVA_RIGHT_SIDE), lastLavaSide(LAVA_RIGHT_SIDE),
usedBerserk(false), usedBerserk(false),
@@ -289,14 +279,12 @@ public:
void DoAction(int32 param) override void DoAction(int32 param) override
{ {
if (param == ACTION_DRAKE_DIED) if (param == ACTION_DRAKE_DIED)
{
DoCastSelf(SPELL_SARTHARION_TWILIGHT_REVENGE, true); DoCastSelf(SPELL_SARTHARION_TWILIGHT_REVENGE, true);
} }
}
void JustEngagedWith(Unit* pWho) override void JustEngagedWith(Unit* who) override
{ {
if (pWho && !IsTargetInBounds(pWho)) if (who && !IsTargetInBounds(who))
{ {
EnterEvadeMode(); EnterEvadeMode();
return; return;
@@ -322,9 +310,7 @@ public:
{ {
Creature* dragon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(dragons[i])); Creature* dragon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(dragons[i]));
if (!dragon || !dragon->IsAlive() || instance->GetBossState(dragons[i]) == DONE) if (!dragon || !dragon->IsAlive() || instance->GetBossState(dragons[i]) == DONE)
{
continue; continue;
}
dragon->SetImmuneToNPC(true); dragon->SetImmuneToNPC(true);
dragon->SetFullHealth(); dragon->SetFullHealth();
@@ -356,9 +342,7 @@ public:
} }
if (dragonsCount) if (dragonsCount)
{
DoCastSelf(SPELL_WILL_OF_SARTHARION, true); DoCastSelf(SPELL_WILL_OF_SARTHARION, true);
}
me->CallForHelp(500.0f); me->CallForHelp(500.0f);
} }
@@ -375,9 +359,7 @@ public:
if (type == DATA_VOLCANO_BLOWS && data) if (type == DATA_VOLCANO_BLOWS && data)
{ {
if (!volcanoBlows.empty() && std::find(volcanoBlows.begin(), volcanoBlows.end(), data) != volcanoBlows.end()) if (!volcanoBlows.empty() && std::find(volcanoBlows.begin(), volcanoBlows.end(), data) != volcanoBlows.end())
{
return; return;
}
volcanoBlows.push_back(data); volcanoBlows.push_back(data);
} }
@@ -387,26 +369,20 @@ public:
{ {
// it means we want dragons count // it means we want dragons count
if (dataOrGuid == DATA_ACHIEVEMENT_DRAGONS_COUNT) if (dataOrGuid == DATA_ACHIEVEMENT_DRAGONS_COUNT)
{
return dragonsCount; return dragonsCount;
}
// otherwise it is guid to check if player was hit by lava strike :) // otherwise it is guid to check if player was hit by lava strike :)
if (!volcanoBlows.empty() && std::find(volcanoBlows.begin(), volcanoBlows.end(), dataOrGuid) != volcanoBlows.end()) if (!volcanoBlows.empty() && std::find(volcanoBlows.begin(), volcanoBlows.end(), dataOrGuid) != volcanoBlows.end())
{
return 1; return 1;
}
return 0; return 0;
} }
void KilledUnit(Unit* pVictim) override void KilledUnit(Unit* victim) override
{
if (!urand(0, 2) && pVictim->IsPlayer())
{ {
if (!urand(0, 2) && victim->IsPlayer())
Talk(SAY_SARTHARION_SLAY); Talk(SAY_SARTHARION_SLAY);
} }
}
void JustSummoned(Creature* summon) override void JustSummoned(Creature* summon) override
{ {
@@ -453,11 +429,9 @@ public:
{ {
Creature* summon = ObjectAccessor::GetCreature(*me, summonGuid); Creature* summon = ObjectAccessor::GetCreature(*me, summonGuid);
if (summon && summon->GetEntry() == NPC_FIRE_CYCLONE) if (summon && summon->GetEntry() == NPC_FIRE_CYCLONE)
{
summon->CastSpell(summon, SPELL_CYCLONE_AURA_PERIODIC, true); summon->CastSpell(summon, SPELL_CYCLONE_AURA_PERIODIC, true);
} }
} }
}
Talk(SAY_SARTHARION_BERSERK); Talk(SAY_SARTHARION_BERSERK);
below11PctReached = true; below11PctReached = true;
} }
@@ -466,13 +440,11 @@ public:
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
{ {
if (!UpdateVictim()) if (!UpdateVictim())
{
return; return;
}
extraEvents.Update(diff); extraEvents.Update(diff);
// Special events which needs to be fired immidiately // Special events which needs to be fired immediately
while (uint32 const eventId = extraEvents.ExecuteEvent()) while (uint32 const eventId = extraEvents.ExecuteEvent())
{ {
switch (eventId) switch (eventId)
@@ -480,21 +452,15 @@ public:
case EVENT_SARTHARION_BOUNDARY: case EVENT_SARTHARION_BOUNDARY:
{ {
if (!IsTargetInBounds(me->GetVictim())) if (!IsTargetInBounds(me->GetVictim()))
{
EnterEvadeMode(); EnterEvadeMode();
}
else else
{
extraEvents.Repeat(250ms); extraEvents.Repeat(250ms);
}
break; break;
} }
case EVENT_SARTHARION_SUMMON_LAVA: case EVENT_SARTHARION_SUMMON_LAVA:
{ {
if (!urand(0, 3)) if (!urand(0, 3))
{
Talk(SAY_SARTHARION_SPECIAL); Talk(SAY_SARTHARION_SPECIAL);
}
SummonLavaWaves(); SummonLavaWaves();
extraEvents.Repeat(25s); extraEvents.Repeat(25s);
@@ -516,40 +482,32 @@ public:
{ {
Talk(SAY_SARTHARION_CALL_TENEBRON); Talk(SAY_SARTHARION_CALL_TENEBRON);
if (Creature* tenebron = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TENEBRON))) if (Creature* tenebron = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TENEBRON)))
{
tenebron->AI()->DoAction(ACTION_CALL_DRAGON); tenebron->AI()->DoAction(ACTION_CALL_DRAGON);
}
break; break;
} }
case EVENT_SARTHARION_CALL_SHADRON: case EVENT_SARTHARION_CALL_SHADRON:
{ {
Talk(SAY_SARTHARION_CALL_SHADRON); Talk(SAY_SARTHARION_CALL_SHADRON);
if (Creature* shadron = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON))) if (Creature* shadron = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SHADRON)))
{
shadron->AI()->DoAction(ACTION_CALL_DRAGON); shadron->AI()->DoAction(ACTION_CALL_DRAGON);
}
break; break;
} }
case EVENT_SARTHARION_CALL_VESPERON: case EVENT_SARTHARION_CALL_VESPERON:
{ {
Talk(SAY_SARTHARION_CALL_VESPERON); Talk(SAY_SARTHARION_CALL_VESPERON);
if (Creature* vesperon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VESPERON))) if (Creature* vesperon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VESPERON)))
{
vesperon->AI()->DoAction(ACTION_CALL_DRAGON); vesperon->AI()->DoAction(ACTION_CALL_DRAGON);
}
break; break;
} }
} }
} }
// Handle Sartharion combat abbilities // Handle Sartharion combat abilities
events.Update(diff); events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING)) if (me->HasUnitState(UNIT_STATE_CASTING))
{
return; return;
}
while (uint32 const eventId = events.ExecuteEvent()) while (uint32 const eventId = events.ExecuteEvent())
{ {
@@ -576,12 +534,10 @@ public:
case EVENT_SARTHARION_LAVA_STRIKE: case EVENT_SARTHARION_LAVA_STRIKE:
{ {
if (!urand(0, 2)) if (!urand(0, 2))
{
Talk(SAY_SARTHARION_SPECIAL_4); Talk(SAY_SARTHARION_SPECIAL_4);
}
summons.RemoveNotExisting(); summons.RemoveNotExisting();
uint8 rand = urand(0, MAX_CYCLONE_COUNT - 1); // 5 - numer of cyclones uint8 rand = urand(0, MAX_CYCLONE_COUNT - 1); // 5 - number of cyclones
uint8 iter = 0; uint8 iter = 0;
if (!summons.empty()) if (!summons.empty())
{ {
@@ -607,10 +563,8 @@ public:
} }
if (me->HasUnitState(UNIT_STATE_CASTING)) if (me->HasUnitState(UNIT_STATE_CASTING))
{
return; return;
} }
}
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
@@ -693,16 +647,12 @@ public:
for (uint8 i = 0; i < MAX_DRAGONS; ++i) for (uint8 i = 0; i < MAX_DRAGONS; ++i)
{ {
if (instance->GetBossState(dragons[i]) == DONE) if (instance->GetBossState(dragons[i]) == DONE)
{
continue; continue;
}
if (Creature* dragon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(dragons[i]))) if (Creature* dragon = ObjectAccessor::GetCreature(*me, instance->GetGuidData(dragons[i])))
{ {
if (checkCombat && dragon->IsInCombat()) if (checkCombat && dragon->IsInCombat())
{
continue; continue;
}
dragon->DespawnOrUnsummon(); dragon->DespawnOrUnsummon();
dragon->SetRespawnTime(5); dragon->SetRespawnTime(5);
@@ -715,15 +665,11 @@ public:
bool IsTargetInBounds(Unit const* victim) const bool IsTargetInBounds(Unit const* victim) const
{ {
if (!victim || victim->GetPositionX() < SartharionBoundary[0] || victim->GetPositionX() > SartharionBoundary[1] || victim->GetPositionY() > SartharionBoundary[3]) if (!victim || victim->GetPositionX() < SartharionBoundary[0] || victim->GetPositionX() > SartharionBoundary[1] || victim->GetPositionY() > SartharionBoundary[3])
{
return false; return false;
}
// Big island handling // Big island handling
if (victim->GetPositionY() < SartharionBoundary[2]) if (victim->GetPositionY() < SartharionBoundary[2])
{
return victim->GetDistance(bigIslandMiddlePos) <= 6.0f; return victim->GetDistance(bigIslandMiddlePos) <= 6.0f;
}
return true; return true;
} }
@@ -735,11 +681,10 @@ public:
bool usedBerserk; bool usedBerserk;
bool below11PctReached; bool below11PctReached;
}; };
};
struct boss_sartharion_dragonAI : public BossAI struct boss_sartharion_dragonAI : public BossAI
{ {
boss_sartharion_dragonAI(Creature* pCreature, uint32 bossId) : BossAI(pCreature, bossId), isCalledBySartharion(false) boss_sartharion_dragonAI(Creature* creature, uint32 bossId) : BossAI(creature, bossId), isCalledBySartharion(false)
{ {
} }
@@ -778,34 +723,26 @@ struct boss_sartharion_dragonAI : public BossAI
void MovementInform(uint32 type, uint32 pointId) final void MovementInform(uint32 type, uint32 pointId) final
{ {
if (type != WAYPOINT_MOTION_TYPE) if (type != WAYPOINT_MOTION_TYPE)
{
return; return;
}
switch (me->GetEntry()) switch (me->GetEntry())
{ {
case NPC_TENEBRON: case NPC_TENEBRON:
{ {
if (pointId != POINT_FINAL_TENEBRON) if (pointId != POINT_FINAL_TENEBRON)
{
return; return;
}
break; break;
} }
case NPC_SHADRON: case NPC_SHADRON:
{ {
if (pointId != POINT_FINAL_SHADRON) if (pointId != POINT_FINAL_SHADRON)
{
return; return;
}
break; break;
} }
case NPC_VESPERON: case NPC_VESPERON:
{ {
if (pointId != POINT_FINAL_VESPERON) if (pointId != POINT_FINAL_VESPERON)
{
return; return;
}
break; break;
} }
} }
@@ -820,10 +757,8 @@ struct boss_sartharion_dragonAI : public BossAI
if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS) if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS)
{ {
if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION)))
{
sartharion->AI()->JustSummoned(summon); sartharion->AI()->JustSummoned(summon);
} }
}
BossAI::JustSummoned(summon); BossAI::JustSummoned(summon);
} }
@@ -863,18 +798,14 @@ struct boss_sartharion_dragonAI : public BossAI
} }
if (isCalledBySartharion || instance->GetBossState(DATA_SARTHARION) == DONE) if (isCalledBySartharion || instance->GetBossState(DATA_SARTHARION) == DONE)
{
me->SetLootMode(0); me->SetLootMode(0);
}
if (isCalledBySartharion) if (isCalledBySartharion)
{ {
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 0, 500, true, false)) if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 0, 500, true, false))
{
AttackStart(target); AttackStart(target);
} }
} }
}
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
@@ -883,9 +814,7 @@ struct boss_sartharion_dragonAI : public BossAI
// Despawn minions only if not called by Sartharion // Despawn minions only if not called by Sartharion
if (!isCalledBySartharion) if (!isCalledBySartharion)
{
summons.DespawnAll(); summons.DespawnAll();
}
switch (me->GetEntry()) switch (me->GetEntry())
{ {
@@ -893,9 +822,7 @@ struct boss_sartharion_dragonAI : public BossAI
{ {
Talk(SAY_TENEBRON_DEATH); Talk(SAY_TENEBRON_DEATH);
if (!isCalledBySartharion || instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) if (!isCalledBySartharion || instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS)
{
instance->SetBossState(DATA_TENEBRON, DONE); instance->SetBossState(DATA_TENEBRON, DONE);
}
break; break;
} }
case NPC_SHADRON: case NPC_SHADRON:
@@ -904,15 +831,11 @@ struct boss_sartharion_dragonAI : public BossAI
if (isCalledBySartharion) if (isCalledBySartharion)
{ {
if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION)))
{
sartharion->RemoveAura(SPELL_GIFT_OF_TWILIGHT_FIRE); sartharion->RemoveAura(SPELL_GIFT_OF_TWILIGHT_FIRE);
} }
}
if (!isCalledBySartharion || instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) if (!isCalledBySartharion || instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS)
{
instance->SetBossState(DATA_SHADRON, DONE); instance->SetBossState(DATA_SHADRON, DONE);
}
break; break;
} }
case NPC_VESPERON: case NPC_VESPERON:
@@ -920,32 +843,24 @@ struct boss_sartharion_dragonAI : public BossAI
Talk(SAY_VESPERON_DEATH); Talk(SAY_VESPERON_DEATH);
instance->DoAction(ACTION_CLEAR_PORTAL); instance->DoAction(ACTION_CLEAR_PORTAL);
if (!isCalledBySartharion || instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS) if (!isCalledBySartharion || instance->GetBossState(DATA_SARTHARION) != IN_PROGRESS)
{
instance->SetBossState(DATA_VESPERON, DONE); instance->SetBossState(DATA_VESPERON, DONE);
}
break; break;
} }
} }
if (!isCalledBySartharion) if (!isCalledBySartharion)
{
ClearInstance(); ClearInstance();
}
else else
{ {
if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION)))
{
sartharion->AI()->DoAction(ACTION_DRAKE_DIED); sartharion->AI()->DoAction(ACTION_DRAKE_DIED);
} }
} }
}
void KilledUnit(Unit* victim) final void KilledUnit(Unit* victim) final
{ {
if (!victim->IsPlayer() || urand(0, 2)) if (!victim->IsPlayer() || urand(0, 2))
{
return; return;
}
switch (me->GetEntry()) switch (me->GetEntry())
{ {
@@ -976,26 +891,20 @@ struct boss_sartharion_dragonAI : public BossAI
} }
if (!UpdateVictim()) if (!UpdateVictim())
{
return; return;
}
events.Update(diff); events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING)) if (me->HasUnitState(UNIT_STATE_CASTING))
{
return; return;
}
while (uint32 const eventId = events.ExecuteEvent()) while (uint32 const eventId = events.ExecuteEvent())
{ {
ExecuteEvent(eventId); ExecuteEvent(eventId);
if (me->HasUnitState(UNIT_STATE_CASTING)) if (me->HasUnitState(UNIT_STATE_CASTING))
{
return; return;
} }
}
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
} }
@@ -1016,9 +925,7 @@ protected:
if (portalGUID) if (portalGUID)
{ {
if (GameObject* gobj = me->GetMap()->GetGameObject(portalGUID)) if (GameObject* gobj = me->GetMap()->GetGameObject(portalGUID))
{
gobj->Delete(); gobj->Delete();
}
portalGUID.Clear(); portalGUID.Clear();
} }
@@ -1033,19 +940,9 @@ protected:
// TENEBRON // TENEBRON
///////////////////////////// /////////////////////////////
class boss_sartharion_tenebron : public CreatureScript struct boss_sartharion_tenebron : public boss_sartharion_dragonAI
{ {
public: boss_sartharion_tenebron(Creature* creature) : boss_sartharion_dragonAI(creature, DATA_TENEBRON), summons2(creature)
boss_sartharion_tenebron() : CreatureScript("boss_sartharion_tenebron") { }
CreatureAI* GetAI(Creature* pCreature) const override
{
return GetObsidianSanctumAI<boss_sartharion_tenebronAI>(pCreature);
}
struct boss_sartharion_tenebronAI : public boss_sartharion_dragonAI
{
boss_sartharion_tenebronAI(Creature* pCreature) : boss_sartharion_dragonAI(pCreature, DATA_TENEBRON), summons2(pCreature)
{ {
} }
@@ -1053,9 +950,7 @@ public:
{ {
boss_sartharion_dragonAI::Reset(); boss_sartharion_dragonAI::Reset();
if (!isCalledBySartharion) if (!isCalledBySartharion)
{
summons2.DespawnAll(); summons2.DespawnAll();
}
events.ScheduleEvent(EVENT_MINIBOSS_SHADOW_FISSURE, 20s); events.ScheduleEvent(EVENT_MINIBOSS_SHADOW_FISSURE, 20s);
events.ScheduleEvent(EVENT_MINIBOSS_SHADOW_BREATH, 10s); events.ScheduleEvent(EVENT_MINIBOSS_SHADOW_BREATH, 10s);
@@ -1065,18 +960,14 @@ public:
void JustSummoned(Creature* summon) override void JustSummoned(Creature* summon) override
{ {
if (summon->GetEntry() != NPC_TWILIGHT_EGG) if (summon->GetEntry() != NPC_TWILIGHT_EGG)
{
summons.Summon(summon); summons.Summon(summon);
}
// Summons to Sartharion are linked manually // Summons to Sartharion are linked manually
} }
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
{ {
if (!isCalledBySartharion) if (!isCalledBySartharion)
{
summons2.DespawnAll(); summons2.DespawnAll();
}
boss_sartharion_dragonAI::JustDied(killer); boss_sartharion_dragonAI::JustDied(killer);
} }
@@ -1099,9 +990,7 @@ public:
case EVENT_MINIBOSS_SHADOW_BREATH: case EVENT_MINIBOSS_SHADOW_BREATH:
{ {
if (!urand(0, 10)) if (!urand(0, 10))
{
Talk(SAY_TENEBRON_BREATH); Talk(SAY_TENEBRON_BREATH);
}
DoCastVictim(SPELL_SHADOW_BREATH, false); DoCastVictim(SPELL_SHADOW_BREATH, false);
events.Repeat(17500ms); events.Repeat(17500ms);
break; break;
@@ -1109,9 +998,7 @@ public:
case EVENT_MINIBOSS_SHADOW_FISSURE: case EVENT_MINIBOSS_SHADOW_FISSURE:
{ {
if (Unit* target = SelectTarget(SelectTargetMethod::Random)) if (Unit* target = SelectTarget(SelectTargetMethod::Random))
{
DoCast(target, SPELL_SHADOW_FISSURE, false); DoCast(target, SPELL_SHADOW_FISSURE, false);
}
events.Repeat(22500ms); events.Repeat(22500ms);
break; break;
} }
@@ -1123,14 +1010,10 @@ public:
if (!isCalledBySartharion) if (!isCalledBySartharion)
{ {
if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[DATA_TENEBRON].GetPositionX(), portalPos[DATA_TENEBRON].GetPositionY(), portalPos[DATA_TENEBRON].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0)) if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[DATA_TENEBRON].GetPositionX(), portalPos[DATA_TENEBRON].GetPositionY(), portalPos[DATA_TENEBRON].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0))
{
portalGUID = Portal->GetGUID(); portalGUID = Portal->GetGUID();
} }
}
else else
{
instance->DoAction(ACTION_ADD_PORTAL); instance->DoAction(ACTION_ADD_PORTAL);
}
events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2s); events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2s);
events.Repeat(60s); events.Repeat(60s);
@@ -1147,10 +1030,8 @@ public:
if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS) if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS)
{ {
if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION)))
{
sartharion->AI()->JustSummoned(egg); sartharion->AI()->JustSummoned(egg);
} }
}
egg->SetPhaseMask(16, true); egg->SetPhaseMask(16, true);
} }
} }
@@ -1166,9 +1047,7 @@ public:
{ {
Creature const* summon = ObjectAccessor::GetCreature(*me, summonGuid); Creature const* summon = ObjectAccessor::GetCreature(*me, summonGuid);
if (!summon || !summon->IsAlive() || summon->GetEntry() != NPC_TWILIGHT_EGG) if (!summon || !summon->IsAlive() || summon->GetEntry() != NPC_TWILIGHT_EGG)
{
continue; continue;
}
if (Creature* whelp = me->SummonCreature(NPC_TWILIGHT_WHELP, summon->GetPosition(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000)) if (Creature* whelp = me->SummonCreature(NPC_TWILIGHT_WHELP, summon->GetPosition(), TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000))
{ {
@@ -1176,12 +1055,10 @@ public:
if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS) if (isCalledBySartharion && instance->GetBossState(DATA_SARTHARION) == IN_PROGRESS)
{ {
if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION)))
{
sartharion->AI()->JustSummoned(whelp); sartharion->AI()->JustSummoned(whelp);
} }
} }
} }
}
if (!isCalledBySartharion) if (!isCalledBySartharion)
{ {
@@ -1190,9 +1067,7 @@ public:
RemoveTwilightPortal(); RemoveTwilightPortal();
} }
else else
{
instance->DoAction(ACTION_CLEAR_PORTAL); instance->DoAction(ACTION_CLEAR_PORTAL);
}
EntryCheckPredicate pred(NPC_TWILIGHT_EGG); EntryCheckPredicate pred(NPC_TWILIGHT_EGG);
summons.DoAction(ACTION_SWITCH_PHASE, pred); summons.DoAction(ACTION_SWITCH_PHASE, pred);
@@ -1210,25 +1085,14 @@ public:
private: private:
SummonList summons2; SummonList summons2;
}; };
};
///////////////////////////// /////////////////////////////
// SHADRON // SHADRON
///////////////////////////// /////////////////////////////
class boss_sartharion_shadron : public CreatureScript struct boss_sartharion_shadron : public boss_sartharion_dragonAI
{ {
public: boss_sartharion_shadron(Creature* creature) : boss_sartharion_dragonAI(creature, DATA_SHADRON)
boss_sartharion_shadron() : CreatureScript("boss_sartharion_shadron") { }
CreatureAI* GetAI(Creature* pCreature) const override
{
return GetObsidianSanctumAI<boss_sartharion_shadronAI>(pCreature);
}
struct boss_sartharion_shadronAI : public boss_sartharion_dragonAI
{
boss_sartharion_shadronAI(Creature* pCreature) : boss_sartharion_dragonAI(pCreature, DATA_SHADRON)
{ {
} }
@@ -1240,21 +1104,17 @@ public:
events.ScheduleEvent(EVENT_MINIBOSS_OPEN_PORTAL, 15s); events.ScheduleEvent(EVENT_MINIBOSS_OPEN_PORTAL, 15s);
} }
void SummonedCreatureDies(Creature* /*summon*/, Unit* /*summon*/) override void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override
{ {
if (isCalledBySartharion) if (isCalledBySartharion)
{ {
// Acolytes are dead // Acolytes are dead
if (!summons.HasEntry(NPC_ACOLYTE_OF_SHADRON)) if (!summons.HasEntry(NPC_ACOLYTE_OF_SHADRON))
{
instance->DoAction(ACTION_CLEAR_PORTAL); instance->DoAction(ACTION_CLEAR_PORTAL);
}
if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION))) if (Creature* sartharion = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_SARTHARION)))
{
sartharion->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGHT_FIRE); sartharion->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGHT_FIRE);
} }
}
else else
{ {
ClearInstance(); ClearInstance();
@@ -1282,9 +1142,7 @@ public:
case EVENT_MINIBOSS_SHADOW_BREATH: case EVENT_MINIBOSS_SHADOW_BREATH:
{ {
if (!urand(0, 10)) if (!urand(0, 10))
{
Talk(SAY_SHADRON_BREATH); Talk(SAY_SHADRON_BREATH);
}
DoCastVictim(SPELL_SHADOW_BREATH, false); DoCastVictim(SPELL_SHADOW_BREATH, false);
events.Repeat(17500ms); events.Repeat(17500ms);
@@ -1293,9 +1151,7 @@ public:
case EVENT_MINIBOSS_SHADOW_FISSURE: case EVENT_MINIBOSS_SHADOW_FISSURE:
{ {
if (Unit* target = SelectTarget(SelectTargetMethod::Random)) if (Unit* target = SelectTarget(SelectTargetMethod::Random))
{
DoCast(target, SPELL_SHADOW_FISSURE, false); DoCast(target, SPELL_SHADOW_FISSURE, false);
}
events.Repeat(22500ms); events.Repeat(22500ms);
break; break;
} }
@@ -1306,14 +1162,10 @@ public:
if (!isCalledBySartharion) if (!isCalledBySartharion)
{ {
if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[DATA_SHADRON].GetPositionX(), portalPos[DATA_SHADRON].GetPositionY(), portalPos[DATA_SHADRON].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0)) if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[DATA_SHADRON].GetPositionX(), portalPos[DATA_SHADRON].GetPositionY(), portalPos[DATA_SHADRON].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0))
{
portalGUID = Portal->GetGUID(); portalGUID = Portal->GetGUID();
} }
}
else else
{
instance->DoAction(ACTION_ADD_PORTAL); instance->DoAction(ACTION_ADD_PORTAL);
}
events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2s); events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2s);
break; break;
@@ -1325,7 +1177,7 @@ public:
if (Creature* acolyte = me->SummonCreature((isCalledBySartharion ? NPC_ACOLYTE_OF_SHADRON : NPC_DISCIPLE_OF_SHADRON), me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation())) if (Creature* acolyte = me->SummonCreature((isCalledBySartharion ? NPC_ACOLYTE_OF_SHADRON : NPC_DISCIPLE_OF_SHADRON), me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation()))
{ {
/// @todo: inpect JustSummoned /// @todo: inspect JustSummoned
summons.Summon(acolyte); summons.Summon(acolyte);
acolyte->SetPhaseMask(16, true); acolyte->SetPhaseMask(16, true);
} }
@@ -1335,25 +1187,14 @@ public:
} }
} }
}; };
};
///////////////////////////// /////////////////////////////
// VESPERON // VESPERON
///////////////////////////// /////////////////////////////
class boss_sartharion_vesperon : public CreatureScript struct boss_sartharion_vesperon : public boss_sartharion_dragonAI
{ {
public: boss_sartharion_vesperon(Creature* creature) : boss_sartharion_dragonAI(creature, DATA_VESPERON)
boss_sartharion_vesperon() : CreatureScript("boss_sartharion_vesperon") { }
CreatureAI* GetAI(Creature* pCreature) const override
{
return GetObsidianSanctumAI<boss_sartharion_vesperonAI>(pCreature);
}
struct boss_sartharion_vesperonAI : public boss_sartharion_dragonAI
{
boss_sartharion_vesperonAI(Creature* pCreature) : boss_sartharion_dragonAI(pCreature, DATA_VESPERON)
{ {
} }
@@ -1368,9 +1209,7 @@ public:
void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) override
{ {
if (!isCalledBySartharion) if (!isCalledBySartharion)
{
ClearInstance(); ClearInstance();
}
else else
{ {
instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_TORMENT_SARTHARION); instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_TORMENT_SARTHARION);
@@ -1398,9 +1237,7 @@ public:
case EVENT_MINIBOSS_SHADOW_BREATH: case EVENT_MINIBOSS_SHADOW_BREATH:
{ {
if (!urand(0, 10)) if (!urand(0, 10))
{
Talk(SAY_SHADRON_BREATH); Talk(SAY_SHADRON_BREATH);
}
DoCastVictim(SPELL_SHADOW_BREATH, false); DoCastVictim(SPELL_SHADOW_BREATH, false);
events.Repeat(17s + 500ms); events.Repeat(17s + 500ms);
@@ -1409,9 +1246,7 @@ public:
case EVENT_MINIBOSS_SHADOW_FISSURE: case EVENT_MINIBOSS_SHADOW_FISSURE:
{ {
if (Unit* target = SelectTarget(SelectTargetMethod::Random)) if (Unit* target = SelectTarget(SelectTargetMethod::Random))
{
DoCast(target, SPELL_SHADOW_FISSURE, false); DoCast(target, SPELL_SHADOW_FISSURE, false);
}
events.Repeat(22s + 500ms); events.Repeat(22s + 500ms);
break; break;
@@ -1423,14 +1258,10 @@ public:
if (!isCalledBySartharion) if (!isCalledBySartharion)
{ {
if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[DATA_VESPERON].GetPositionX(), portalPos[DATA_VESPERON].GetPositionY(), portalPos[DATA_VESPERON].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0)) if (GameObject* Portal = me->GetVictim()->SummonGameObject(GO_TWILIGHT_PORTAL, portalPos[DATA_VESPERON].GetPositionX(), portalPos[DATA_VESPERON].GetPositionY(), portalPos[DATA_VESPERON].GetPositionZ(), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0))
{
portalGUID = Portal->GetGUID(); portalGUID = Portal->GetGUID();
} }
}
else else
{
instance->DoAction(ACTION_ADD_PORTAL); instance->DoAction(ACTION_ADD_PORTAL);
}
events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2s); events.ScheduleEvent(EVENT_MINIBOSS_SPAWN_HELPERS, 2s);
break; break;
@@ -1460,22 +1291,11 @@ public:
instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_TORMENT_SARTHARION); instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TWILIGHT_TORMENT_SARTHARION);
} }
}; };
};
// other // other
class npc_twilight_summon : public CreatureScript struct npc_twilight_summon : public ScriptedAI
{ {
public: npc_twilight_summon(Creature* creature) : ScriptedAI(creature),
npc_twilight_summon() : CreatureScript("npc_twilight_summon") { }
CreatureAI* GetAI(Creature* pCreature) const override
{
return GetObsidianSanctumAI<npc_twilight_summonAI>(pCreature);
}
struct npc_twilight_summonAI : public ScriptedAI
{
npc_twilight_summonAI(Creature* pCreature) : ScriptedAI(pCreature),
fadeArmorTimer(urand(0, 15000)) fadeArmorTimer(urand(0, 15000))
{ {
} }
@@ -1484,41 +1304,29 @@ public:
{ {
fadeArmorTimer = urand(0, 15000); fadeArmorTimer = urand(0, 15000);
if (me->GetEntry() == NPC_TWILIGHT_EGG) if (me->GetEntry() == NPC_TWILIGHT_EGG)
{
me->SetControlled(true, UNIT_STATE_STUNNED); me->SetControlled(true, UNIT_STATE_STUNNED);
}
else else
{
me->SetInCombatWithZone(); me->SetInCombatWithZone();
} }
}
void DoAction(int32 param) override void DoAction(int32 param) override
{ {
if (param == ACTION_SWITCH_PHASE) if (param == ACTION_SWITCH_PHASE)
{
me->DespawnOrUnsummon(1ms); me->DespawnOrUnsummon(1ms);
} }
}
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
{ {
if (!UpdateVictim() || me->GetEntry() == NPC_TWILIGHT_EGG) if (!UpdateVictim() || me->GetEntry() == NPC_TWILIGHT_EGG)
{
return; return;
}
fadeArmorTimer += diff; fadeArmorTimer += diff;
if (fadeArmorTimer >= 15000) if (fadeArmorTimer >= 15000)
{ {
if (Aura* aur = me->GetVictim()->GetAura(SPELL_FADE_ARMOR)) if (Aura* aur = me->GetVictim()->GetAura(SPELL_FADE_ARMOR))
{
aur->ModStackAmount(1); aur->ModStackAmount(1);
}
else else
{
DoCastVictim(SPELL_FADE_ARMOR, false); DoCastVictim(SPELL_FADE_ARMOR, false);
}
fadeArmorTimer = 0; fadeArmorTimer = 0;
} }
@@ -1529,7 +1337,6 @@ public:
private: private:
uint32 fadeArmorTimer; uint32 fadeArmorTimer;
}; };
};
class spell_sartharion_lava_strike : public SpellScript class spell_sartharion_lava_strike : public SpellScript
{ {
@@ -1549,9 +1356,7 @@ class spell_sartharion_lava_strike : public SpellScript
void HandleDummy(SpellEffIndex /*effIndex*/) void HandleDummy(SpellEffIndex /*effIndex*/)
{ {
if (!GetCaster() || !GetHitUnit()) if (!GetCaster() || !GetHitUnit())
{
return; return;
}
GetCaster()->CastSpell(GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), GetHitUnit()->GetPositionZ(), SPELL_LAVA_STRIKE_DUMMY_TRIGGER, true); GetCaster()->CastSpell(GetHitUnit()->GetPositionX(), GetHitUnit()->GetPositionY(), GetHitUnit()->GetPositionZ(), SPELL_LAVA_STRIKE_DUMMY_TRIGGER, true);
} }
@@ -1559,9 +1364,7 @@ class spell_sartharion_lava_strike : public SpellScript
void HandleSchoolDamage(SpellEffIndex /*effIndex*/) void HandleSchoolDamage(SpellEffIndex /*effIndex*/)
{ {
if (!GetCaster() || !GetHitUnit() || _spawned) if (!GetCaster() || !GetHitUnit() || _spawned)
{
return; return;
}
if (InstanceScript* instance = GetCaster()->GetInstanceScript()) if (InstanceScript* instance = GetCaster()->GetInstanceScript())
{ {
@@ -1577,14 +1380,10 @@ class spell_sartharion_lava_strike : public SpellScript
void Register() override void Register() override
{ {
if (m_scriptSpellId == SPELL_LAVA_STRIKE_DUMMY) if (m_scriptSpellId == SPELL_LAVA_STRIKE_DUMMY)
{
OnEffectHitTarget += SpellEffectFn(spell_sartharion_lava_strike::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); OnEffectHitTarget += SpellEffectFn(spell_sartharion_lava_strike::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
else else
{
OnEffectHitTarget += SpellEffectFn(spell_sartharion_lava_strike::HandleSchoolDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE); OnEffectHitTarget += SpellEffectFn(spell_sartharion_lava_strike::HandleSchoolDamage, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
} }
}
private: private:
bool _spawned; bool _spawned;
@@ -1637,11 +1436,11 @@ class spell_obsidian_sanctum_flame_tsunami_leap : public SpellScript
void AddSC_boss_sartharion() void AddSC_boss_sartharion()
{ {
new boss_sartharion(); RegisterObsidianSanctumCreatureAI(boss_sartharion);
new boss_sartharion_shadron(); RegisterObsidianSanctumCreatureAI(boss_sartharion_shadron);
new boss_sartharion_tenebron(); RegisterObsidianSanctumCreatureAI(boss_sartharion_tenebron);
new boss_sartharion_vesperon(); RegisterObsidianSanctumCreatureAI(boss_sartharion_vesperon);
new npc_twilight_summon(); RegisterObsidianSanctumCreatureAI(npc_twilight_summon);
RegisterSpellScript(spell_sartharion_lava_strike); RegisterSpellScript(spell_sartharion_lava_strike);
RegisterSpellScript(spell_obsidian_sanctum_flame_tsunami); RegisterSpellScript(spell_obsidian_sanctum_flame_tsunami);
RegisterSpellScript(spell_obsidian_sanctum_flame_tsunami_leap); RegisterSpellScript(spell_obsidian_sanctum_flame_tsunami_leap);
@@ -66,4 +66,6 @@ inline AI* GetObsidianSanctumAI(T* obj)
return GetInstanceAI<AI>(obj, ObsidianSanctumScriptName); return GetInstanceAI<AI>(obj, ObsidianSanctumScriptName);
} }
#define RegisterObsidianSanctumCreatureAI(ai_name) RegisterCreatureAIWithFactory(ai_name, GetObsidianSanctumAI)
#endif #endif