Scripts/Ruby Sanctum: Update Zarithrian to new register model (#26697)

This commit is contained in:
offl
2021-07-15 01:53:48 +03:00
committed by GitHub
parent 4aee969228
commit 6f8a7c5641

View File

@@ -64,217 +64,195 @@ enum MinionsMovement
POINT_GENERAL_ROOM = 3
};
class boss_general_zarithrian : public CreatureScript
struct boss_general_zarithrian : public BossAI
{
public:
boss_general_zarithrian() : CreatureScript("boss_general_zarithrian") { }
boss_general_zarithrian(Creature* creature) : BossAI(creature, DATA_GENERAL_ZARITHRIAN) { }
struct boss_general_zarithrianAI : public BossAI
void Reset() override
{
_Reset();
if (instance->GetBossState(DATA_SAVIANA_RAGEFIRE) == DONE && instance->GetBossState(DATA_BALTHARUS_THE_WARBORN) == DONE)
{
boss_general_zarithrianAI(Creature* creature) : BossAI(creature, DATA_GENERAL_ZARITHRIAN) { }
void Reset() override
{
_Reset();
if (instance->GetBossState(DATA_SAVIANA_RAGEFIRE) == DONE && instance->GetBossState(DATA_BALTHARUS_THE_WARBORN) == DONE)
{
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetImmuneToPC(false);
}
}
bool CanAIAttack(Unit const* target) const override
{
return (instance->GetBossState(DATA_SAVIANA_RAGEFIRE) == DONE && instance->GetBossState(DATA_BALTHARUS_THE_WARBORN) == DONE && BossAI::CanAIAttack(target));
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_CLEAVE, 8s);
events.ScheduleEvent(EVENT_INTIDMDATING_ROAR, 14s);
events.ScheduleEvent(EVENT_SUMMON_ADDS, 15s);
if (Is25ManRaid())
events.ScheduleEvent(EVENT_SUMMON_ADDS2, Seconds(16));
}
// Override to not set adds in combat yet.
void JustSummoned(Creature* summon) override
{
summons.Summon(summon);
}
void JustDied(Unit* /*killer*/) override
{
_JustDied();
Talk(SAY_DEATH);
}
void EnterEvadeMode(EvadeReason /*why*/) override
{
summons.DespawnAll();
_DespawnAtEvade();
}
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
Talk(SAY_KILL);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SUMMON_ADDS:
Talk(SAY_ADDS);
[[fallthrough]];
case EVENT_SUMMON_ADDS2:
{
if (Creature* stalker1 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ZARITHRIAN_SPAWN_STALKER_1)))
stalker1->CastSpell(stalker1, SPELL_SUMMON_FLAMECALLER, true);
if (Creature* stalker2 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ZARITHRIAN_SPAWN_STALKER_2)))
stalker2->CastSpell(stalker2, SPELL_SUMMON_FLAMECALLER, true);
events.Repeat(Seconds(45));
break;
}
case EVENT_INTIDMDATING_ROAR:
DoCastSelf(SPELL_INTIMIDATING_ROAR);
events.Repeat(Seconds(35), Seconds(40));
break;
case EVENT_CLEAVE:
DoCastVictim(SPELL_CLEAVE_ARMOR);
events.ScheduleEvent(EVENT_CLEAVE, 15s);
break;
default:
break;
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetRubySanctumAI<boss_general_zarithrianAI>(creature);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->SetImmuneToPC(false);
}
}
bool CanAIAttack(Unit const* target) const override
{
return (instance->GetBossState(DATA_SAVIANA_RAGEFIRE) == DONE && instance->GetBossState(DATA_BALTHARUS_THE_WARBORN) == DONE && BossAI::CanAIAttack(target));
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_CLEAVE, 8s);
events.ScheduleEvent(EVENT_INTIDMDATING_ROAR, 14s);
events.ScheduleEvent(EVENT_SUMMON_ADDS, 15s);
if (Is25ManRaid())
events.ScheduleEvent(EVENT_SUMMON_ADDS2, Seconds(16));
}
// Override to not set adds in combat yet.
void JustSummoned(Creature* summon) override
{
summons.Summon(summon);
}
void JustDied(Unit* /*killer*/) override
{
_JustDied();
Talk(SAY_DEATH);
}
void EnterEvadeMode(EvadeReason /*why*/) override
{
summons.DespawnAll();
_DespawnAtEvade();
}
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() == TYPEID_PLAYER)
Talk(SAY_KILL);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SUMMON_ADDS:
Talk(SAY_ADDS);
[[fallthrough]];
case EVENT_SUMMON_ADDS2:
{
if (Creature* stalker1 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ZARITHRIAN_SPAWN_STALKER_1)))
stalker1->CastSpell(stalker1, SPELL_SUMMON_FLAMECALLER, true);
if (Creature* stalker2 = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_ZARITHRIAN_SPAWN_STALKER_2)))
stalker2->CastSpell(stalker2, SPELL_SUMMON_FLAMECALLER, true);
events.Repeat(Seconds(45));
break;
}
case EVENT_INTIDMDATING_ROAR:
DoCastSelf(SPELL_INTIMIDATING_ROAR);
events.Repeat(Seconds(35), Seconds(40));
break;
case EVENT_CLEAVE:
DoCastVictim(SPELL_CLEAVE_ARMOR);
events.ScheduleEvent(EVENT_CLEAVE, 15s);
break;
default:
break;
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
DoMeleeAttackIfReady();
}
};
class npc_onyx_flamecaller : public CreatureScript
struct npc_onyx_flamecaller : public ScriptedAI
{
public:
npc_onyx_flamecaller() : CreatureScript("npc_onyx_flamecaller") { }
npc_onyx_flamecaller(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), _lavaGoutCount(0) { }
struct npc_onyx_flamecallerAI : public ScriptedAI
void Reset() override
{
_events.Reset();
_lavaGoutCount = 0;
me->SetReactState(REACT_DEFENSIVE);
MoveToGeneral();
}
void JustEngagedWith(Unit* /*who*/) override
{
_events.ScheduleEvent(EVENT_BLAST_NOVA, 17s);
_events.ScheduleEvent(EVENT_LAVA_GOUT, 3s);
}
void EnterEvadeMode(EvadeReason /*why*/) override { }
void IsSummonedBy(WorldObject* /*summoner*/) override
{
// Let Zarithrian count as summoner.
if (Creature* zarithrian = _instance->GetCreature(DATA_GENERAL_ZARITHRIAN))
zarithrian->AI()->JustSummoned(me);
}
void MovementInform(uint32 type, uint32 pointId) override
{
if (type != SPLINE_CHAIN_MOTION_TYPE && pointId != POINT_GENERAL_ROOM)
return;
DoZoneInCombat();
}
void MoveToGeneral()
{
if (me->GetPositionY() < 500.0f)
me->GetMotionMaster()->MoveAlongSplineChain(POINT_GENERAL_ROOM, SPLINE_GENERAL_WEST, false);
else
me->GetMotionMaster()->MoveAlongSplineChain(POINT_GENERAL_ROOM, SPLINE_GENERAL_EAST, false);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
npc_onyx_flamecallerAI(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), _lavaGoutCount(0) { }
void Reset() override
switch (eventId)
{
_events.Reset();
_lavaGoutCount = 0;
me->SetReactState(REACT_DEFENSIVE);
MoveToGeneral();
}
void JustEngagedWith(Unit* /*who*/) override
{
_events.ScheduleEvent(EVENT_BLAST_NOVA, 17s);
_events.ScheduleEvent(EVENT_LAVA_GOUT, 3s);
}
void EnterEvadeMode(EvadeReason /*why*/) override { }
void IsSummonedBy(WorldObject* /*summoner*/) override
{
// Let Zarithrian count as summoner.
if (Creature* zarithrian = _instance->GetCreature(DATA_GENERAL_ZARITHRIAN))
zarithrian->AI()->JustSummoned(me);
}
void MovementInform(uint32 type, uint32 pointId) override
{
if (type != SPLINE_CHAIN_MOTION_TYPE && pointId != POINT_GENERAL_ROOM)
return;
DoZoneInCombat();
}
void MoveToGeneral()
{
if (me->GetPositionY() < 500.0f)
me->GetMotionMaster()->MoveAlongSplineChain(POINT_GENERAL_ROOM, SPLINE_GENERAL_WEST, false);
else
me->GetMotionMaster()->MoveAlongSplineChain(POINT_GENERAL_ROOM, SPLINE_GENERAL_EAST, false);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
_events.Update(diff);
while (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
case EVENT_BLAST_NOVA:
DoCastAOE(SPELL_BLAST_NOVA);
_events.Repeat(Seconds(15), Seconds(20));
break;
case EVENT_LAVA_GOUT:
if (_lavaGoutCount >= 3)
{
case EVENT_BLAST_NOVA:
DoCastAOE(SPELL_BLAST_NOVA);
_events.Repeat(Seconds(15), Seconds(20));
break;
case EVENT_LAVA_GOUT:
if (_lavaGoutCount >= 3)
{
_lavaGoutCount = 0;
_events.Repeat(Seconds(8));
break;
}
DoCastVictim(SPELL_LAVA_GOUT);
_lavaGoutCount++;
_events.Repeat(Seconds(1));
break;
default:
break;
_lavaGoutCount = 0;
_events.Repeat(Seconds(8));
break;
}
}
DoMeleeAttackIfReady();
DoCastVictim(SPELL_LAVA_GOUT);
_lavaGoutCount++;
_events.Repeat(Seconds(1));
break;
default:
break;
}
private:
EventMap _events;
InstanceScript* _instance;
uint8 _lavaGoutCount;
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetRubySanctumAI<npc_onyx_flamecallerAI>(creature);
}
DoMeleeAttackIfReady();
}
private:
EventMap _events;
InstanceScript* _instance;
uint8 _lavaGoutCount;
};
void AddSC_boss_general_zarithrian()
{
new boss_general_zarithrian();
new npc_onyx_flamecaller();
RegisterRubySanctumCreatureAI(boss_general_zarithrian);
RegisterRubySanctumCreatureAI(npc_onyx_flamecaller);
}