This commit is contained in:
Jelle Meeus
2025-07-13 10:31:07 +02:00
parent de8878f3ea
commit 66a2f1ff73

View File

@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "CreatureScript.h"
#include "Player.h" #include "Player.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "ScriptedCreature.h" #include "ScriptedCreature.h"
@@ -42,8 +43,10 @@ enum Yells
enum Spells enum Spells
{ {
// Kel'Thzuad // Kel'Thzuad
SPELL_FROST_BOLT_SINGLE = 28478, SPELL_FROST_BOLT_SINGLE_10 = 28478,
SPELL_FROST_BOLT_MULTI = 28479, SPELL_FROST_BOLT_SINGLE_25 = 55802,
SPELL_FROST_BOLT_MULTI_10 = 28479,
SPELL_FROST_BOLT_MULTI_25 = 55807,
SPELL_SHADOW_FISURE = 27810, SPELL_SHADOW_FISURE = 27810,
SPELL_VOID_BLAST = 27812, SPELL_VOID_BLAST = 27812,
SPELL_DETONATE_MANA = 27819, SPELL_DETONATE_MANA = 27819,
@@ -61,10 +64,10 @@ enum Spells
enum Misc enum Misc
{ {
NPC_SOLDIER_OF_THE_FROZEN_WASTES = 351073, // NPC_SOLDIER_OF_THE_FROZEN_WASTES = 16427,
NPC_UNSTOPPABLE_ABOMINATION = 351074, // NPC_UNSTOPPABLE_ABOMINATION = 16428,
NPC_SOUL_WEAVER = 351075, // NPC_SOUL_WEAVER = 16429,
NPC_GUARDIAN_OF_ICECROWN = 351076, // NPC_GUARDIAN_OF_ICECROWN = 16441,
ACTION_CALL_HELP_ON = 1, ACTION_CALL_HELP_ON = 1,
ACTION_CALL_HELP_OFF = 2, ACTION_CALL_HELP_OFF = 2,
@@ -142,15 +145,10 @@ public:
struct boss_kelthuzad_40AI : public BossAI struct boss_kelthuzad_40AI : public BossAI
{ {
explicit boss_kelthuzad_40AI(Creature* c) : BossAI(c, BOSS_KELTHUZAD), summons(me) explicit boss_kelthuzad_40AI(Creature* c) : BossAI(c, BOSS_KELTHUZAD), summons(me)
{ {}
pInstance = me->GetInstanceScript();
_justSpawned = true;
}
EventMap events; EventMap events;
SummonList summons; SummonList summons;
InstanceScript* pInstance;
bool _justSpawned;
float NormalizeOrientation(float o) float NormalizeOrientation(float o)
{ {
@@ -221,35 +219,23 @@ public:
summons.DespawnAll(); summons.DespawnAll();
me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE); me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_DISABLE_MOVE);
me->SetReactState(REACT_AGGRESSIVE); me->SetReactState(REACT_AGGRESSIVE);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_FLOOR))) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_FLOOR))
{ {
go->SetPhaseMask(1, true); go->SetPhaseMask(1, true);
go->SetGoState(GO_STATE_READY); go->SetGoState(GO_STATE_READY);
} }
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_GATE)))
{ if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_PORTAL_1))
if(!_justSpawned) // Don't open the door if we just spawned and are still doing the conversation
{
go->SetGoState(GO_STATE_ACTIVE);
}
}
_justSpawned = false;
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_1)))
{
go->SetGoState(GO_STATE_READY); go->SetGoState(GO_STATE_READY);
}
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_2))) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_PORTAL_2))
{
go->SetGoState(GO_STATE_READY); go->SetGoState(GO_STATE_READY);
}
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_3))) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_PORTAL_3))
{
go->SetGoState(GO_STATE_READY); go->SetGoState(GO_STATE_READY);
}
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_4))) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_PORTAL_4))
{
go->SetGoState(GO_STATE_READY); go->SetGoState(GO_STATE_READY);
}
} }
void EnterEvadeMode(EvadeReason why) override void EnterEvadeMode(EvadeReason why) override
@@ -260,14 +246,11 @@ public:
void KilledUnit(Unit* who) override void KilledUnit(Unit* who) override
{ {
if (who->GetTypeId() != TYPEID_PLAYER) if (!who->IsPlayer())
return; return;
Talk(SAY_SLAY); Talk(SAY_SLAY);
if (pInstance) instance->StorePersistentData(PERSISTENT_DATA_IMMORTAL_FAIL, 1);
{
pInstance->SetData(DATA_IMMORTAL_FAIL, 0);
}
} }
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
@@ -279,18 +262,11 @@ public:
guardian->AI()->Talk(EMOTE_GUARDIAN_FLEE); guardian->AI()->Talk(EMOTE_GUARDIAN_FLEE);
} }
Talk(SAY_DEATH); Talk(SAY_DEATH);
if (pInstance)
{
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_GATE)))
{
go->SetGoState(GO_STATE_ACTIVE);
}
}
} }
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if (!me->IsInCombat() && who->GetTypeId() == TYPEID_PLAYER && who->IsAlive() && me->GetDistance(who) <= 50.0f) if (!me->IsInCombat() && who->IsPlayer() && who->IsAlive() && me->GetDistance(who) <= 50.0f)
AttackStart(who); AttackStart(who);
} }
@@ -303,23 +279,17 @@ public:
me->SetTarget(); me->SetTarget();
me->SetReactState(REACT_PASSIVE); me->SetReactState(REACT_PASSIVE);
me->CastSpell(me, SPELL_KELTHUZAD_CHANNEL, false); me->CastSpell(me, SPELL_KELTHUZAD_CHANNEL, false);
events.ScheduleEvent(EVENT_SPAWN_POOL, 5000); events.ScheduleEvent(EVENT_SPAWN_POOL, 5s);
events.ScheduleEvent(EVENT_SUMMON_SOLDIER, 6400); events.ScheduleEvent(EVENT_SUMMON_SOLDIER, 6400ms);
events.ScheduleEvent(EVENT_SUMMON_UNSTOPPABLE_ABOMINATION, 10000); events.ScheduleEvent(EVENT_SUMMON_UNSTOPPABLE_ABOMINATION, 10s);
events.ScheduleEvent(EVENT_SUMMON_SOUL_WEAVER, 12000); events.ScheduleEvent(EVENT_SUMMON_SOUL_WEAVER, 12s);
events.ScheduleEvent(EVENT_PHASE_2, 228000); events.ScheduleEvent(EVENT_PHASE_2, 228s);
events.ScheduleEvent(EVENT_ENRAGE, 900000); events.ScheduleEvent(EVENT_ENRAGE, 15min);
if (pInstance)
if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_FLOOR))
{ {
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_FLOOR))) events.ScheduleEvent(EVENT_FLOOR_CHANGE, 15s);
{ go->SetGoState(GO_STATE_ACTIVE);
events.ScheduleEvent(EVENT_FLOOR_CHANGE, 15000);
go->SetGoState(GO_STATE_ACTIVE);
}
}
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_GATE)))
{
go->SetGoState(GO_STATE_READY);
} }
} }
@@ -351,14 +321,11 @@ public:
switch (events.ExecuteEvent()) switch (events.ExecuteEvent())
{ {
case EVENT_FLOOR_CHANGE: case EVENT_FLOOR_CHANGE:
if (pInstance) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_FLOOR))
{ {
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_FLOOR))) events.ScheduleEvent(EVENT_FLOOR_CHANGE, 15s);
{ go->SetGoState(GO_STATE_READY);
events.ScheduleEvent(EVENT_FLOOR_CHANGE, 15000); go->SetPhaseMask(2, true);
go->SetGoState(GO_STATE_READY);
go->SetPhaseMask(2, true);
}
} }
break; break;
case EVENT_SPAWN_POOL: case EVENT_SPAWN_POOL:
@@ -366,15 +333,15 @@ public:
break; break;
case EVENT_SUMMON_SOLDIER: case EVENT_SUMMON_SOLDIER:
SummonHelper(NPC_SOLDIER_OF_THE_FROZEN_WASTES, 1); SummonHelper(NPC_SOLDIER_OF_THE_FROZEN_WASTES, 1);
events.RepeatEvent(3100); events.Repeat(3100ms);
break; break;
case EVENT_SUMMON_UNSTOPPABLE_ABOMINATION: case EVENT_SUMMON_UNSTOPPABLE_ABOMINATION:
SummonHelper(NPC_UNSTOPPABLE_ABOMINATION, 1); SummonHelper(NPC_UNSTOPPABLE_ABOMINATION, 1);
events.RepeatEvent(18500); events.Repeat(18s + 500ms);
break; break;
case EVENT_SUMMON_SOUL_WEAVER: case EVENT_SUMMON_SOUL_WEAVER:
SummonHelper(NPC_SOUL_WEAVER, 1); SummonHelper(NPC_SOUL_WEAVER, 1);
events.RepeatEvent(30000); events.Repeat(30s);
break; break;
case EVENT_PHASE_2: case EVENT_PHASE_2:
Talk(EMOTE_PHASE_TWO); Talk(EMOTE_PHASE_TWO);
@@ -385,42 +352,42 @@ public:
me->GetMotionMaster()->MoveChase(me->GetVictim()); me->GetMotionMaster()->MoveChase(me->GetVictim());
me->RemoveAura(SPELL_KELTHUZAD_CHANNEL); me->RemoveAura(SPELL_KELTHUZAD_CHANNEL);
me->SetReactState(REACT_AGGRESSIVE); me->SetReactState(REACT_AGGRESSIVE);
events.ScheduleEvent(EVENT_FROST_BOLT_SINGLE, urand(2000, 10000)); events.ScheduleEvent(EVENT_FROST_BOLT_SINGLE, 2s, 10s);
events.ScheduleEvent(EVENT_FROST_BOLT_MULTI, urand(15000, 30000)); events.ScheduleEvent(EVENT_FROST_BOLT_MULTI, 15s, 30s);
events.ScheduleEvent(EVENT_DETONATE_MANA, 30000); events.ScheduleEvent(EVENT_DETONATE_MANA, 30s);
events.ScheduleEvent(EVENT_PHASE_3, 1000); events.ScheduleEvent(EVENT_PHASE_3, 1s);
events.ScheduleEvent(EVENT_SHADOW_FISSURE, 25000); events.ScheduleEvent(EVENT_SHADOW_FISSURE, 25s);
events.ScheduleEvent(EVENT_FROST_BLAST, 45000); events.ScheduleEvent(EVENT_FROST_BLAST, 45s);
if (Is25ManRaid()) if (Is25ManRaid())
{ {
events.ScheduleEvent(EVENT_CHAINS, 90000); events.ScheduleEvent(EVENT_CHAINS, 90s);
} }
break; break;
case EVENT_ENRAGE: case EVENT_ENRAGE:
me->CastSpell(me, SPELL_BERSERK, true); me->CastSpell(me, SPELL_BERSERK, true);
break; break;
case EVENT_FROST_BOLT_SINGLE: case EVENT_FROST_BOLT_SINGLE:
me->CastSpell(me->GetVictim(), SPELL_FROST_BOLT_SINGLE, false); me->CastSpell(me->GetVictim(), RAID_MODE(SPELL_FROST_BOLT_SINGLE_10, SPELL_FROST_BOLT_SINGLE_25, SPELL_FROST_BOLT_SINGLE_10, SPELL_FROST_BOLT_SINGLE_25), false);
events.RepeatEvent(urand(2000, 10000)); events.Repeat(2s, 10s);
break; break;
case EVENT_FROST_BOLT_MULTI: case EVENT_FROST_BOLT_MULTI:
me->CastSpell(me, SPELL_FROST_BOLT_MULTI, false); me->CastSpell(me, RAID_MODE(SPELL_FROST_BOLT_MULTI_10, SPELL_FROST_BOLT_MULTI_25, SPELL_FROST_BOLT_MULTI_10, SPELL_FROST_BOLT_MULTI_25), false);
events.RepeatEvent(urand(15000, 30000)); events.Repeat(15s, 30s);
break; break;
case EVENT_SHADOW_FISSURE: case EVENT_SHADOW_FISSURE:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true)) if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
{ {
me->CastSpell(target, SPELL_SHADOW_FISURE, false); me->CastSpell(target, SPELL_SHADOW_FISURE, false);
} }
events.RepeatEvent(25000); events.Repeat(25s);
break; break;
case EVENT_FROST_BLAST: case EVENT_FROST_BLAST:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0, true)) if (Unit* target = SelectTarget(SelectTargetMethod::Random, RAID_MODE(1, 0, 0, 0), 0, true))
{ {
me->CastSpell(target, SPELL_FROST_BLAST, false); me->CastSpell(target, SPELL_FROST_BLAST, false);
} }
Talk(SAY_FROST_BLAST); Talk(SAY_FROST_BLAST);
events.RepeatEvent(45000); events.Repeat(45s);
break; break;
case EVENT_CHAINS: case EVENT_CHAINS:
for (uint8 i = 0; i < 3; ++i) for (uint8 i = 0; i < 3; ++i)
@@ -431,7 +398,7 @@ public:
} }
} }
Talk(SAY_CHAIN); Talk(SAY_CHAIN);
events.RepeatEvent(90000); events.Repeat(90s);
break; break;
case EVENT_DETONATE_MANA: case EVENT_DETONATE_MANA:
{ {
@@ -439,7 +406,7 @@ public:
ThreatContainer::StorageType const& threatList = me->GetThreatMgr().GetThreatList(); ThreatContainer::StorageType const& threatList = me->GetThreatMgr().GetThreatList();
for (auto itr : threatList) for (auto itr : threatList)
{ {
if (itr->getTarget()->GetTypeId() == TYPEID_PLAYER if (itr->getTarget()->IsPlayer()
&& itr->getTarget()->getPowerType() == POWER_MANA && itr->getTarget()->getPowerType() == POWER_MANA
&& itr->getTarget()->GetPower(POWER_MANA)) && itr->getTarget()->GetPower(POWER_MANA))
{ {
@@ -453,48 +420,41 @@ public:
me->CastSpell(*itr, SPELL_DETONATE_MANA, false); me->CastSpell(*itr, SPELL_DETONATE_MANA, false);
Talk(SAY_SPECIAL); Talk(SAY_SPECIAL);
} }
events.RepeatEvent(30000); events.Repeat(30s);
break; break;
} }
case EVENT_PHASE_3: case EVENT_PHASE_3:
if (me->HealthBelowPct(45)) if (me->HealthBelowPct(45))
{ {
Talk(SAY_REQUEST_AID); Talk(SAY_REQUEST_AID);
events.DelayEvents(5500); events.DelayEvents(5500ms);
events.ScheduleEvent(EVENT_P3_LICH_KING_SAY, 5000); events.ScheduleEvent(EVENT_P3_LICH_KING_SAY, 5s);
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_1))) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_PORTAL_1))
{
go->SetGoState(GO_STATE_ACTIVE); go->SetGoState(GO_STATE_ACTIVE);
}
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_2))) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_PORTAL_2))
{
go->SetGoState(GO_STATE_ACTIVE); go->SetGoState(GO_STATE_ACTIVE);
}
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_3))) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_PORTAL_3))
{
go->SetGoState(GO_STATE_ACTIVE); go->SetGoState(GO_STATE_ACTIVE);
}
if (GameObject* go = me->GetMap()->GetGameObject(pInstance->GetGuidData(DATA_KELTHUZAD_PORTAL_4))) if (GameObject* go = instance->GetGameObject(DATA_KELTHUZAD_PORTAL_4))
{
go->SetGoState(GO_STATE_ACTIVE); go->SetGoState(GO_STATE_ACTIVE);
}
break; break;
} }
events.RepeatEvent(1000); events.Repeat(1s);
break; break;
case EVENT_P3_LICH_KING_SAY: case EVENT_P3_LICH_KING_SAY:
if (pInstance) {
{ if (Creature* cr = instance->GetCreature(DATA_LICH_KING_BOSS))
if (Creature* cr = ObjectAccessor::GetCreature(*me, pInstance->GetGuidData(DATA_LICH_KING_BOSS))) cr->AI()->Talk(SAY_ANSWER_REQUEST);
{
cr->AI()->Talk(SAY_ANSWER_REQUEST); for (uint8 i = 0 ; i < RAID_MODE(2, 4, 4, 4); ++i)
}
}
for (uint8 i = 0 ; i < 5; ++i)
{
events.ScheduleEvent(EVENT_SUMMON_GUARDIAN_OF_ICECROWN, 10000 + (i * 5000)); events.ScheduleEvent(EVENT_SUMMON_GUARDIAN_OF_ICECROWN, 10000 + (i * 5000));
}
break; break;
}
case EVENT_SUMMON_GUARDIAN_OF_ICECROWN: case EVENT_SUMMON_GUARDIAN_OF_ICECROWN:
if (Creature* cr = me->SummonCreature(NPC_GUARDIAN_OF_ICECROWN, SpawnPool[RAND(0, 1, 3, 4)])) if (Creature* cr = me->SummonCreature(NPC_GUARDIAN_OF_ICECROWN, SpawnPool[RAND(0, 1, 3, 4)]))
{ {
@@ -562,7 +522,7 @@ public:
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if (who->GetTypeId() != TYPEID_PLAYER && !who->IsPet()) if (!who->IsPlayer() && !who->IsPet())
return; return;
ScriptedAI::MoveInLineOfSight(who); ScriptedAI::MoveInLineOfSight(who);
@@ -570,10 +530,8 @@ public:
void JustDied(Unit* /*killer*/) override void JustDied(Unit* /*killer*/) override
{ {
if (me->GetEntry() == NPC_UNSTOPPABLE_ABOMINATION && me->GetInstanceScript()) if (me->GetEntry() == NPC_UNSTOPPABLE_ABOMINATION)
{
me->GetInstanceScript()->SetData(DATA_ABOMINATION_KILLED, 0); me->GetInstanceScript()->SetData(DATA_ABOMINATION_KILLED, 0);
}
} }
void AttackStart(Unit* who) override void AttackStart(Unit* who) override
@@ -604,21 +562,19 @@ public:
me->SetInCombatWithZone(); me->SetInCombatWithZone();
if (me->GetEntry() == NPC_UNSTOPPABLE_ABOMINATION) if (me->GetEntry() == NPC_UNSTOPPABLE_ABOMINATION)
{ {
events.ScheduleEvent(EVENT_MINION_FRENZY, 1000); events.ScheduleEvent(EVENT_MINION_FRENZY, 1s);
events.ScheduleEvent(EVENT_MINION_MORTAL_WOUND, 5000); events.ScheduleEvent(EVENT_MINION_MORTAL_WOUND, 5s);
} }
else if (me->GetEntry() == NPC_GUARDIAN_OF_ICECROWN) else if (me->GetEntry() == NPC_GUARDIAN_OF_ICECROWN)
{ {
events.ScheduleEvent(EVENT_MINION_BLOOD_TAP, 15000); events.ScheduleEvent(EVENT_MINION_BLOOD_TAP, 15s);
} }
} }
void KilledUnit(Unit* who) override void KilledUnit(Unit* who) override
{ {
if (who->GetTypeId() == TYPEID_PLAYER && me->GetInstanceScript()) if (who->IsPlayer())
{ me->GetInstanceScript()->StorePersistentData(PERSISTENT_DATA_IMMORTAL_FAIL, 1);
me->GetInstanceScript()->SetData(DATA_IMMORTAL_FAIL, 0);
}
} }
void JustReachedHome() override void JustReachedHome() override
@@ -642,7 +598,7 @@ public:
{ {
case EVENT_MINION_MORTAL_WOUND: case EVENT_MINION_MORTAL_WOUND:
me->CastSpell(me->GetVictim(), SPELL_MORTAL_WOUND, false); me->CastSpell(me->GetVictim(), SPELL_MORTAL_WOUND, false);
events.RepeatEvent(15000); events.Repeat(15s);
break; break;
case EVENT_MINION_FRENZY: case EVENT_MINION_FRENZY:
if (me->HealthBelowPct(35)) if (me->HealthBelowPct(35))
@@ -650,11 +606,11 @@ public:
me->CastSpell(me, SPELL_FRENZY, true); me->CastSpell(me, SPELL_FRENZY, true);
break; break;
} }
events.RepeatEvent(1000); events.Repeat(1s);
break; break;
case EVENT_MINION_BLOOD_TAP: case EVENT_MINION_BLOOD_TAP:
me->CastSpell(me->GetVictim(), SPELL_BLOOD_TAP, false); me->CastSpell(me->GetVictim(), SPELL_BLOOD_TAP, false);
events.RepeatEvent(15000); events.Repeat(15s);
break; break;
} }
DoMeleeAttackIfReady(); DoMeleeAttackIfReady();
@@ -666,6 +622,11 @@ class spell_kelthuzad_frost_blast : public SpellScript
{ {
PrepareSpellScript(spell_kelthuzad_frost_blast); PrepareSpellScript(spell_kelthuzad_frost_blast);
bool Validate(SpellInfo const* /*spell*/) override
{
return ValidateSpellInfo({ SPELL_FROST_BLAST });
}
void FilterTargets(std::list<WorldObject*>& targets) void FilterTargets(std::list<WorldObject*>& targets)
{ {
Unit* caster = GetCaster(); Unit* caster = GetCaster();
@@ -726,3 +687,4 @@ void AddSC_boss_kelthuzad_40()
// RegisterSpellScript(spell_kelthuzad_frost_blast); // RegisterSpellScript(spell_kelthuzad_frost_blast);
// RegisterSpellScript(spell_kelthuzad_detonate_mana_aura); // RegisterSpellScript(spell_kelthuzad_detonate_mana_aura);
} }