Scripts/MoltenCore: Update Golemagg encounter to current coding standards (#25183)
* Scripts/MoltenCore: Update Golemagg to current coding standards * no functional changes * Scripts/MoltenCore: Update Core Ranger to current coding standards * no functional changes (cherry picked from commit c88234727b47c037557eba6db8ae8ef1dee4eed7)
This commit is contained in:
committed by
Shauren
parent
7e0fb710ad
commit
0c65abe7a0
+97
-124
@@ -52,148 +52,121 @@ enum Events
|
||||
EVENT_EARTHQUAKE = 2,
|
||||
};
|
||||
|
||||
class boss_golemagg : public CreatureScript
|
||||
struct boss_golemagg : public BossAI
|
||||
{
|
||||
public:
|
||||
boss_golemagg() : CreatureScript("boss_golemagg") { }
|
||||
boss_golemagg(Creature* creature) : BossAI(creature, BOSS_GOLEMAGG_THE_INCINERATOR) { }
|
||||
|
||||
struct boss_golemaggAI : public BossAI
|
||||
void Reset() override
|
||||
{
|
||||
BossAI::Reset();
|
||||
DoCast(me, SPELL_MAGMASPLASH, true);
|
||||
}
|
||||
|
||||
void JustEngagedWith(Unit* victim) override
|
||||
{
|
||||
BossAI::JustEngagedWith(victim);
|
||||
events.ScheduleEvent(EVENT_PYROBLAST, 7s);
|
||||
}
|
||||
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override
|
||||
{
|
||||
if (!HealthBelowPct(10) || me->HasAura(SPELL_ENRAGE))
|
||||
return;
|
||||
|
||||
DoCast(me, SPELL_ENRAGE, true);
|
||||
events.ScheduleEvent(EVENT_EARTHQUAKE, 3s);
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
events.Update(diff);
|
||||
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
|
||||
while (uint32 eventId = events.ExecuteEvent())
|
||||
{
|
||||
boss_golemaggAI(Creature* creature) : BossAI(creature, BOSS_GOLEMAGG_THE_INCINERATOR)
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_PYROBLAST:
|
||||
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
|
||||
DoCast(target, SPELL_PYROBLAST);
|
||||
events.ScheduleEvent(EVENT_PYROBLAST, 7s);
|
||||
break;
|
||||
case EVENT_EARTHQUAKE:
|
||||
DoCastVictim(SPELL_EARTHQUAKE);
|
||||
events.ScheduleEvent(EVENT_EARTHQUAKE, 3s);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
BossAI::Reset();
|
||||
DoCast(me, SPELL_MAGMASPLASH, true);
|
||||
}
|
||||
|
||||
void JustEngagedWith(Unit* victim) override
|
||||
{
|
||||
BossAI::JustEngagedWith(victim);
|
||||
events.ScheduleEvent(EVENT_PYROBLAST, 7s);
|
||||
}
|
||||
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override
|
||||
{
|
||||
if (!HealthBelowPct(10) || me->HasAura(SPELL_ENRAGE))
|
||||
return;
|
||||
|
||||
DoCast(me, SPELL_ENRAGE, true);
|
||||
events.ScheduleEvent(EVENT_EARTHQUAKE, 3s);
|
||||
}
|
||||
|
||||
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_PYROBLAST:
|
||||
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
|
||||
DoCast(target, SPELL_PYROBLAST);
|
||||
events.ScheduleEvent(EVENT_PYROBLAST, 7s);
|
||||
break;
|
||||
case EVENT_EARTHQUAKE:
|
||||
DoCastVictim(SPELL_EARTHQUAKE);
|
||||
events.ScheduleEvent(EVENT_EARTHQUAKE, 3s);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
}
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return GetMoltenCoreAI<boss_golemaggAI>(creature);
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING))
|
||||
return;
|
||||
}
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
};
|
||||
|
||||
class npc_core_rager : public CreatureScript
|
||||
struct npc_core_rager : public ScriptedAI
|
||||
{
|
||||
public:
|
||||
npc_core_rager() : CreatureScript("npc_core_rager") { }
|
||||
npc_core_rager(Creature* creature) : ScriptedAI(creature)
|
||||
{
|
||||
_instance = creature->GetInstanceScript();
|
||||
}
|
||||
|
||||
struct npc_core_ragerAI : public ScriptedAI
|
||||
void Reset() override
|
||||
{
|
||||
_scheduler.CancelAll();
|
||||
}
|
||||
|
||||
void JustEngagedWith(Unit* /*who*/) override
|
||||
{
|
||||
_scheduler.Schedule(7s, [this](TaskContext task) // These times are probably wrong
|
||||
{
|
||||
npc_core_ragerAI(Creature* creature) : ScriptedAI(creature)
|
||||
{
|
||||
Initialize();
|
||||
instance = creature->GetInstanceScript();
|
||||
}
|
||||
DoCastVictim(SPELL_MANGLE);
|
||||
task.Repeat(10s);
|
||||
});
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
mangleTimer = 7 * IN_MILLISECONDS; // These times are probably wrong
|
||||
}
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override
|
||||
{
|
||||
if (HealthAbovePct(50) || !_instance)
|
||||
return;
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) override
|
||||
{
|
||||
if (HealthAbovePct(50) || !instance)
|
||||
return;
|
||||
|
||||
if (Creature* pGolemagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(BOSS_GOLEMAGG_THE_INCINERATOR)))
|
||||
{
|
||||
if (pGolemagg->IsAlive())
|
||||
{
|
||||
me->AddAura(SPELL_GOLEMAGG_TRUST, me);
|
||||
Talk(EMOTE_LOWHP);
|
||||
me->SetFullHealth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
// Mangle
|
||||
if (mangleTimer <= diff)
|
||||
{
|
||||
DoCastVictim(SPELL_MANGLE);
|
||||
mangleTimer = 10*IN_MILLISECONDS;
|
||||
}
|
||||
else
|
||||
mangleTimer -= diff;
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
|
||||
private:
|
||||
InstanceScript* instance;
|
||||
uint32 mangleTimer;
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
if (Creature* pGolemagg = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(BOSS_GOLEMAGG_THE_INCINERATOR)))
|
||||
{
|
||||
return GetMoltenCoreAI<npc_core_ragerAI>(creature);
|
||||
if (pGolemagg->IsAlive())
|
||||
{
|
||||
me->AddAura(SPELL_GOLEMAGG_TRUST, me);
|
||||
Talk(EMOTE_LOWHP);
|
||||
me->SetFullHealth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
_scheduler.Update(diff, [this]
|
||||
{
|
||||
DoMeleeAttackIfReady();
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
InstanceScript* _instance;
|
||||
TaskScheduler _scheduler;
|
||||
};
|
||||
|
||||
void AddSC_boss_golemagg()
|
||||
{
|
||||
new boss_golemagg();
|
||||
new npc_core_rager();
|
||||
RegisterMoltenCoreCreatureAI(boss_golemagg);
|
||||
RegisterMoltenCoreCreatureAI(npc_core_rager);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user