fix(Scripts/TheEye): Kael'thas advisors, refactor and RP (#20188)

refactor to use base advisor class

refactor doaction

extract phase enchanted weapons

sql delete script kael_phase_two
This commit is contained in:
Jelle Meeus
2024-11-14 10:06:42 +01:00
committed by GitHub
parent 87fbdb7967
commit 980b9246c8
2 changed files with 151 additions and 342 deletions

View File

@@ -0,0 +1,5 @@
--
DELETE FROM `spell_script_names` WHERE `spell_id`=36450 AND `ScriptName`='spell_kaelthas_resurrection';
DELETE FROM `spell_script_names` WHERE `spell_id`=36709 AND `ScriptName`='spell_kaelthas_kael_phase_two';
-- fix entry from 19871 to Kael'thas for ID - 36709 Kael Phase Two
UPDATE `conditions` SET `ConditionValue2` = 19622 WHERE (`SourceTypeOrReferenceId` = 13) AND (`SourceGroup` = 1) AND (`SourceEntry` = 36709) AND (`SourceId` = 0) AND (`ConditionTypeOrReference` = 31);

View File

@@ -43,14 +43,8 @@ enum KTYells
SAY_PYROBLAST = 14,
// Advisors
SAY_THALADRED_AGGRO = 0,
SAY_SANGUINAR_AGGRO = 0,
SAY_CAPERNIAN_AGGRO = 0,
SAY_TELONICUS_AGGRO = 0,
SAY_THALADRED_DEATH = 1,
SAY_SANGUINAR_DEATH = 1,
SAY_CAPERNIAN_DEATH = 1,
SAY_TELONICUS_DEATH = 1,
SAY_ADVISOR_AGGRO = 0,
SAY_ADVISOR_DEATH = 1,
EMOTE_THALADRED_FIXATE = 2
};
@@ -120,6 +114,7 @@ enum KTSpells
// Advisors
// Universal
SPELL_KAEL_PHASE_TWO = 36709,
SPELL_PERMANENT_FEIGN_DEATH = 29266, // placed upon advisors on fake death
// Sanguinar
SPELL_BELLOWING_ROAR = 44863,
@@ -166,11 +161,10 @@ enum KTMisc
enum KTPreFightEvents
{
EVENT_PREFIGHT_PHASE1_01 = 1,
EVENT_PREFIGHT_PHASE1_02 = 2,
EVENT_PREFIGHT_PHASE5_01 = 3,
EVENT_PREFIGHT_PHASE5_02 = 4,
EVENT_PREFIGHT_PHASE6_02 = 5,
EVENT_PREFIGHT_PHASE6_03 = 6,
EVENT_PREFIGHT_PHASE5_01 = 2,
EVENT_PREFIGHT_PHASE5_02 = 3,
EVENT_PREFIGHT_PHASE6_02 = 4,
EVENT_PREFIGHT_PHASE6_03 = 5,
};
enum KTTransitionScene
@@ -197,11 +191,12 @@ enum KTTransitionScene
enum KTActions
{
ACTION_START_SANGUINAR = 0,
ACTION_START_CAPERNIAN = 1,
ACTION_START_TELONICUS = 2,
ACTION_START_WEAPONS = 3,
ACTION_PROGRESS_PHASE_CHECK = 4
ACTION_START_THALADRED = 0,
ACTION_START_SANGUINAR = 1,
ACTION_START_CAPERNIAN = 2,
ACTION_START_TELONICUS = 3,
ACTION_START_WEAPONS = 4,
ACTION_PROGRESS_PHASE_CHECK = 5
};
enum KTSpellGroups
@@ -241,24 +236,6 @@ struct boss_kaelthas : public BossAI
}
}
void SetData(uint32 type, uint32 data) override
{
if (type == DATA_RESURRECT_CAST && data == DATA_RESURRECT_CAST)
{
summons.DoForAllSummons([&](WorldObject* summon){
if (Creature* summonedCreature = summon->ToCreature())
{
if (summonedCreature->GetEntry() >= NPC_LORD_SANGUINAR && summonedCreature->GetEntry() <= NPC_THALADRED)
{
summonedCreature->SetReactState(REACT_PASSIVE);
summonedCreature->setDeathState(DeathState::JustRespawned);
summonedCreature->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
}
}
});
}
}
void SetRoomState(GOState state)
{
//TODO: handle door closing
@@ -280,6 +257,7 @@ struct boss_kaelthas : public BossAI
_phase = PHASE_NONE;
_transitionSceneReached = false;
_advisorsAlive = 4;
me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_HOVER, true); // hover effect 36550 - Floating Drowned
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
@@ -304,21 +282,10 @@ struct boss_kaelthas : public BossAI
me->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_DISABLE_MOVE);
Talk(SAY_INTRO);
DoCastAOE(SPELL_REMOVE_ENCHANTED_WEAPONS, true);
ScheduleUniqueTimedEvent(23s, [&]
ScheduleUniqueTimedEvent(21s, [&]
{
Talk(SAY_INTRO_THALADRED);
IntroduceNewAdvisor(SAY_INTRO_THALADRED, ACTION_START_THALADRED);
}, EVENT_PREFIGHT_PHASE1_01);
ScheduleUniqueTimedEvent(30s, [&]
{
if (Creature* thaladred = summons.GetCreatureWithEntry(NPC_THALADRED))
{
thaladred->SetReactState(REACT_AGGRESSIVE);
thaladred->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
thaladred->AI()->AttackStart(target);
thaladred->SetInCombatWithZone();
}
}, EVENT_PREFIGHT_PHASE1_02);
}
}
@@ -337,70 +304,35 @@ struct boss_kaelthas : public BossAI
summon->SetReactState(REACT_PASSIVE);
}
void DoAction(int32 action) override
void SpellHit(Unit* caster, SpellInfo const* spell) override
{
switch (action)
if (_phase == PHASE_SINGLE_ADVISOR && spell->Id == SPELL_KAEL_PHASE_TWO)
{
case ACTION_START_SANGUINAR:
IntroduceNewAdvisor(SAY_INTRO_SANGUINAR, ACTION_START_SANGUINAR);
break;
case ACTION_START_CAPERNIAN:
IntroduceNewAdvisor(SAY_INTRO_CAPERNIAN, ACTION_START_CAPERNIAN);
break;
case ACTION_START_TELONICUS:
IntroduceNewAdvisor(SAY_INTRO_TELONICUS, ACTION_START_TELONICUS);
break;
case ACTION_START_WEAPONS:
ScheduleUniqueTimedEvent(3s, [&]{
Talk(SAY_PHASE2_WEAPON);
DoCastSelf(SPELL_SUMMON_WEAPONS);
_phase = PHASE_WEAPONS;
}, EVENT_PREFIGHT_PHASE5_01);
ScheduleUniqueTimedEvent(9s, [&]{
summons.DoForAllSummons([&](WorldObject* summon)
{
if (Creature* summonedCreature = summon->ToCreature())
{
if (!summonedCreature->GetSpawnId())
{
summonedCreature->SetReactState(REACT_AGGRESSIVE);
summonedCreature->SetInCombatWithZone();
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{
summonedCreature->AI()->AttackStart(target);
}
}
}
});
scheduler.Schedule(90s, GROUP_PROGRESS_PHASE, [this](TaskContext)
{
PhaseAllAdvisorsExecute();
});
}, EVENT_PREFIGHT_PHASE5_02);
break;
case ACTION_PROGRESS_PHASE_CHECK:
if (_phase == PHASE_ALL_ADVISORS)
{
bool advisorAlive = false;
summons.DoForAllSummons([&advisorAlive](WorldObject* summon)
{
if (Creature* summonedCreature = summon->ToCreature())
{
if (summonedCreature->IsAlive())
{
if (summonedCreature->GetEntry() >= NPC_LORD_SANGUINAR && summonedCreature->GetEntry() <= NPC_THALADRED)
{
advisorAlive = true;
return;
}
}
}
});
if (!advisorAlive)
PhaseKaelExecute();
}
default:
break;
switch (caster->GetEntry())
{
case NPC_THALADRED:
IntroduceNewAdvisor(SAY_INTRO_SANGUINAR, ACTION_START_SANGUINAR);
break;
case NPC_LORD_SANGUINAR:
IntroduceNewAdvisor(SAY_INTRO_CAPERNIAN, ACTION_START_CAPERNIAN);
break;
case NPC_CAPERNIAN:
IntroduceNewAdvisor(SAY_INTRO_TELONICUS, ACTION_START_TELONICUS);
break;
case NPC_TELONICUS:
PhaseEnchantedWeaponsExecute();
break;
default:
break;
}
}
else if (_phase == PHASE_ALL_ADVISORS && spell->Id == SPELL_KAEL_PHASE_TWO)
{
--_advisorsAlive;
if (_advisorsAlive == 0)
{
PhaseKaelExecute();
}
}
}
@@ -626,6 +558,10 @@ struct boss_kaelthas : public BossAI
//switch because talk times are different
switch (kaelAction)
{
case ACTION_START_THALADRED:
attackStartTimer = 7000ms;
advisorNPCId = NPC_THALADRED;
break;
case ACTION_START_SANGUINAR:
attackStartTimer = 14500ms;
advisorNPCId = NPC_LORD_SANGUINAR;
@@ -650,28 +586,26 @@ struct boss_kaelthas : public BossAI
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
advisor->AI()->AttackStart(target);
advisor->SetInCombatWithZone();
advisor->AI()->Talk(SAY_ADVISOR_AGGRO);
}
});
}
void PhaseAllAdvisorsExecute()
void PhaseEnchantedWeaponsExecute()
{
_phase = PHASE_TRANSITION;
scheduler.CancelGroup(GROUP_PROGRESS_PHASE);
Talk(SAY_PHASE3_ADVANCE);
ScheduleUniqueTimedEvent(6s, [&]{
DoCastSelf(SPELL_RESURRECTION);
}, EVENT_PREFIGHT_PHASE6_02);
ScheduleUniqueTimedEvent(12s, [&]{
_phase = PHASE_ALL_ADVISORS;
ScheduleUniqueTimedEvent(3s, [&]{
Talk(SAY_PHASE2_WEAPON);
DoCastSelf(SPELL_SUMMON_WEAPONS);
_phase = PHASE_WEAPONS;
}, EVENT_PREFIGHT_PHASE5_01);
ScheduleUniqueTimedEvent(9s, [&]{
summons.DoForAllSummons([&](WorldObject* summon)
{
if (Creature* summonedCreature = summon->ToCreature())
{
if (summonedCreature->GetSpawnId())
if (!summonedCreature->GetSpawnId())
{
summonedCreature->SetReactState(REACT_AGGRESSIVE);
summonedCreature->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
summonedCreature->SetInCombatWithZone();
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{
@@ -682,9 +616,24 @@ struct boss_kaelthas : public BossAI
});
scheduler.Schedule(3min, GROUP_PROGRESS_PHASE, [this](TaskContext)
{
PhaseKaelExecute();
PhaseAllAdvisorsExecute();
});
}, EVENT_PREFIGHT_PHASE6_03);
}, EVENT_PREFIGHT_PHASE5_02);
}
void PhaseAllAdvisorsExecute()
{
_phase = PHASE_TRANSITION;
scheduler.CancelGroup(GROUP_PROGRESS_PHASE);
Talk(SAY_PHASE3_ADVANCE);
ScheduleUniqueTimedEvent(6s, [&]{
DoCastSelf(SPELL_RESURRECTION);
_phase = PHASE_ALL_ADVISORS;
}, EVENT_PREFIGHT_PHASE6_02);
scheduler.Schedule(192s, GROUP_PROGRESS_PHASE, [this](TaskContext)
{
PhaseKaelExecute();
});
}
void PhaseKaelExecute()
@@ -769,58 +718,89 @@ struct boss_kaelthas : public BossAI
}
private:
uint32 _phase;
uint8 _advisorsAlive;
bool _transitionSceneReached = false;
};
struct npc_lord_sanguinar : public ScriptedAI
struct advisor_baseAI : public ScriptedAI
{
npc_lord_sanguinar(Creature* creature) : ScriptedAI(creature) {
_instance = creature->GetInstanceScript();
advisor_baseAI(Creature* creature) : ScriptedAI(creature) {
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
virtual void ScheduleEvents() {}
void Reset() override
{
_preventDeath = true;
_feigning = false;
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
scheduler.CancelAll();
_hasDied = false;
me->SetReactState(REACT_PASSIVE);
}
void JustEngagedWith(Unit* /*who*/) override
void JustEngagedWith(Unit* /*who*/) override { ScheduleEvents(); }
void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageEffectType*/, SpellSchoolMask /*spellSchoolMask*/) override
{
if (!_hasDied)
if (!_preventDeath)
return;
if (damage >= me->GetHealth())
{
Talk(SAY_SANGUINAR_AGGRO);
damage = me->GetHealth() - 1; // prevent death
if (_feigning)
return;
scheduler.CancelAll();
me->AttackStop();
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
DoCastAOE(SPELL_KAEL_PHASE_TWO, true);
DoCastSelf(SPELL_PERMANENT_FEIGN_DEATH, true);
_feigning = true;
}
}
void SpellHit(Unit* caster, SpellInfo const* spell) override
{
if (spell->Id == SPELL_RESURRECTION && caster->GetEntry() == NPC_KAELTHAS)
{
me->RemoveAurasDueToSpell(SPELL_PERMANENT_FEIGN_DEATH);
me->SetStandState(UNIT_STAND_STATE_STAND);
scheduler.Schedule(6s, [&](TaskContext /*context*/)
{
_preventDeath = false;
_feigning = false;
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
DoResetThreatList();
me->SetInCombatWithZone();
me->SetReactState(REACT_AGGRESSIVE);
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{
AttackStart(target);
}
ScheduleEvents();
});
}
ScheduleTimedEvent(0s, 2s, [&]{
DoCastSelf(SPELL_BELLOWING_ROAR);
}, 30s, 40s);
}
void JustDied(Unit* /*killer*/) override
{
if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS))
{
kael->AI()->DoAction(ACTION_PROGRESS_PHASE_CHECK);
if (!_hasDied)
{
Talk(SAY_SANGUINAR_DEATH);
DoCastSelf(SPELL_KAEL_PHASE_TWO, true);
kael->AI()->DoAction(ACTION_START_CAPERNIAN);
_hasDied = true;
}
}
Talk(SAY_ADVISOR_DEATH);
scheduler.CancelAll();
DoCastAOE(SPELL_KAEL_PHASE_TWO, true);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
scheduler.Update(diff);
if (_feigning)
return;
scheduler.Update(diff);
if (!UpdateVictim())
return;
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
@@ -828,26 +808,20 @@ struct npc_lord_sanguinar : public ScriptedAI
DoMeleeAttackIfReady();
}
private:
InstanceScript* _instance;
bool _hasDied;
bool _preventDeath;
bool _feigning;
};
struct npc_capernian : public ScriptedAI
struct npc_lord_sanguinar : public advisor_baseAI
{
npc_capernian(Creature* creature) : ScriptedAI(creature) {
_instance = creature->GetInstanceScript();
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
npc_lord_sanguinar(Creature* creature) : advisor_baseAI(creature) { };
void Reset() override
{
scheduler.CancelAll();
_hasDied = false;
me->SetReactState(REACT_PASSIVE);
}
void ScheduleEvents() override {}
};
struct npc_capernian : public advisor_baseAI
{
npc_capernian(Creature* creature) : advisor_baseAI(creature) { }
void AttackStart(Unit* who) override
{
@@ -861,14 +835,10 @@ struct npc_capernian : public ScriptedAI
}
}
void JustEngagedWith(Unit* /*who*/) override
void ScheduleEvents() override
{
if (!_hasDied)
ScheduleTimedEvent(0ms, [&]
{
Talk(SAY_CAPERNIAN_AGGRO);
}
ScheduleTimedEvent(0ms, [&]{
if (!me->CanCastSpell(SPELL_CAPERNIAN_FIREBALL))
{
me->ResumeChasingVictim();
@@ -878,7 +848,6 @@ struct npc_capernian : public ScriptedAI
me->GetMotionMaster()->MoveChase(me->GetVictim(), 30.0f);
DoCastVictim(SPELL_CAPERNIAN_FIREBALL);
}
}, 2500ms);
ScheduleTimedEvent(7000ms, 10000ms, [&]{
DoCastRandomTarget(SPELL_CONFLAGRATION, 0, 30.0f);
@@ -887,63 +856,14 @@ struct npc_capernian : public ScriptedAI
DoCastRandomTarget(SPELL_ARCANE_BURST, 0, 8.0f);
}, 6s);
}
void JustDied(Unit* /*killer*/) override
{
if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS))
{
kael->AI()->DoAction(ACTION_PROGRESS_PHASE_CHECK);
if (!_hasDied)
{
Talk(SAY_CAPERNIAN_DEATH);
DoCastSelf(SPELL_KAEL_PHASE_TWO, true);
kael->AI()->DoAction(ACTION_START_TELONICUS);
_hasDied = true;
}
}
scheduler.CancelAll();
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
scheduler.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
DoMeleeAttackIfReady();
}
private:
InstanceScript* _instance;
bool _hasDied;
};
struct npc_telonicus : public ScriptedAI
struct npc_telonicus : public advisor_baseAI
{
npc_telonicus(Creature* creature) : ScriptedAI(creature) {
_instance = creature->GetInstanceScript();
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
npc_telonicus(Creature* creature) : advisor_baseAI(creature) { }
void Reset() override
void ScheduleEvents() override
{
scheduler.CancelAll();
_hasDied = false;
me->SetReactState(REACT_PASSIVE);
}
void JustEngagedWith(Unit* /*who*/) override
{
if (!_hasDied)
{
Talk(SAY_TELONICUS_AGGRO);
}
ScheduleTimedEvent(0ms, [&]{
DoCastVictim(SPELL_BOMB);
}, 3600ms, 7100ms);
@@ -951,63 +871,14 @@ struct npc_telonicus : public ScriptedAI
DoCastRandomTarget(SPELL_REMOTE_TOY, 0, 100.0f);
}, 15750ms);
}
void JustDied(Unit* /*killer*/) override
{
if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS))
{
kael->AI()->DoAction(ACTION_PROGRESS_PHASE_CHECK);
if (!_hasDied)
{
Talk(SAY_TELONICUS_DEATH);
DoCastSelf(SPELL_KAEL_PHASE_TWO, true);
kael->AI()->DoAction(ACTION_START_WEAPONS);
_hasDied = true;
}
}
scheduler.CancelAll();
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
scheduler.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
DoMeleeAttackIfReady();
}
private:
InstanceScript* _instance;
bool _hasDied;
};
struct npc_thaladred : public ScriptedAI
struct npc_thaladred : public advisor_baseAI
{
npc_thaladred(Creature* creature) : ScriptedAI(creature) {
_instance = creature->GetInstanceScript();
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
npc_thaladred(Creature* creature) : advisor_baseAI(creature) { }
void Reset() override
void ScheduleEvents() override
{
scheduler.CancelAll();
me->SetReactState(REACT_PASSIVE);
_hasDied = false;
}
void JustEngagedWith(Unit* /*who*/) override
{
if (!_hasDied)
{
Talk(SAY_THALADRED_AGGRO);
}
ScheduleTimedEvent(100ms, [&]
{
DoResetThreatList();
@@ -1036,56 +907,6 @@ struct npc_thaladred : public ScriptedAI
}
}, 3600ms, 15200ms);
}
void JustDied(Unit* /*killer*/) override
{
if (Creature* kael = _instance->GetCreature(DATA_KAELTHAS))
{
kael->AI()->DoAction(ACTION_PROGRESS_PHASE_CHECK);
if (!_hasDied)
{
Talk(SAY_THALADRED_DEATH);
DoCastSelf(SPELL_KAEL_PHASE_TWO, true);
kael->AI()->DoAction(ACTION_START_SANGUINAR);
_hasDied = true;
}
}
scheduler.CancelAll();
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
scheduler.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
DoMeleeAttackIfReady();
}
private:
InstanceScript* _instance;
bool _hasDied;
};
class spell_kaelthas_kael_phase_two : public SpellScript
{
PrepareSpellScript(spell_kaelthas_kael_phase_two);
bool Load() override
{
if (GetCaster()->IsCreature())
if (InstanceScript* instance = GetCaster()->GetInstanceScript())
if (Creature* kael = instance->GetCreature(DATA_KAELTHAS))
kael->AI()->SummonedCreatureDies(GetCaster()->ToCreature(), nullptr);
return true;
}
void Register() override
{
}
};
class spell_kaelthas_remote_toy : public AuraScript
@@ -1122,21 +943,6 @@ class spell_kaelthas_summon_weapons : public SpellScript
}
};
class spell_kaelthas_resurrection : public SpellScript
{
PrepareSpellScript(spell_kaelthas_resurrection);
void HandleBeforeCast()
{
GetCaster()->GetAI()->SetData(DATA_RESURRECT_CAST, DATA_RESURRECT_CAST);
}
void Register() override
{
BeforeCast += SpellCastFn(spell_kaelthas_resurrection::HandleBeforeCast);
}
};
class spell_kaelthas_mind_control : public SpellScript
{
PrepareSpellScript(spell_kaelthas_mind_control);
@@ -1380,10 +1186,8 @@ void AddSC_boss_kaelthas()
RegisterTheEyeAI(npc_capernian);
RegisterTheEyeAI(npc_telonicus);
RegisterTheEyeAI(npc_thaladred);
RegisterSpellScript(spell_kaelthas_kael_phase_two);
RegisterSpellScript(spell_kaelthas_remote_toy);
RegisterSpellScript(spell_kaelthas_summon_weapons);
RegisterSpellScript(spell_kaelthas_resurrection);
RegisterSpellScript(spell_kaelthas_mind_control);
RegisterSpellScript(spell_kaelthas_burn);
RegisterSpellScript(spell_kaelthas_flame_strike);