Scripts/Instances/DK: Update Trollgore to new register model (#26582)

This commit is contained in:
offl
2021-06-07 00:32:41 +03:00
committed by GitHub
parent f5a4b95a02
commit 2a556b900c

View File

@@ -69,267 +69,212 @@ enum Events
Position const Landing = { -263.0534f, -660.8658f, 26.50903f, 0.0f };
class boss_trollgore : public CreatureScript
struct boss_trollgore : public BossAI
{
public:
boss_trollgore() : CreatureScript("boss_trollgore") { }
boss_trollgore(Creature* creature) : BossAI(creature, DATA_TROLLGORE)
{
Initialize();
}
struct boss_trollgoreAI : public BossAI
void Initialize()
{
_consumptionJunction = true;
}
void Reset() override
{
_Reset();
Initialize();
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_CONSUME, 15s);
events.ScheduleEvent(EVENT_CRUSH, 1s, 5s);
events.ScheduleEvent(EVENT_INFECTED_WOUND, 10s, 60s);
events.ScheduleEvent(EVENT_CORPSE_EXPLODE, 3s);
events.ScheduleEvent(EVENT_SPAWN, 30s, 40s);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
boss_trollgoreAI(Creature* creature) : BossAI(creature, DATA_TROLLGORE)
switch (eventId)
{
Initialize();
case EVENT_CONSUME:
Talk(SAY_CONSUME);
DoCastAOE(SPELL_CONSUME);
events.ScheduleEvent(EVENT_CONSUME, 15s);
break;
case EVENT_CRUSH:
DoCastVictim(SPELL_CRUSH);
events.ScheduleEvent(EVENT_CRUSH, 10s, 15s);
break;
case EVENT_INFECTED_WOUND:
DoCastVictim(SPELL_INFECTED_WOUND);
events.ScheduleEvent(EVENT_INFECTED_WOUND, 25s, 35s);
break;
case EVENT_CORPSE_EXPLODE:
Talk(SAY_EXPLODE);
DoCastAOE(SPELL_CORPSE_EXPLODE);
events.ScheduleEvent(EVENT_CORPSE_EXPLODE, 15s, 19s);
break;
case EVENT_SPAWN:
for (uint8 i = 0; i < 3; ++i)
if (Creature* trigger = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TROLLGORE_INVADER_SUMMONER_1 + i)))
trigger->CastSpell(trigger, RAND(SPELL_SUMMON_INVADER_A, SPELL_SUMMON_INVADER_B, SPELL_SUMMON_INVADER_C), me->GetGUID());
events.ScheduleEvent(EVENT_SPAWN, 30s, 40s);
break;
default:
break;
}
void Initialize()
{
_consumptionJunction = true;
}
void Reset() override
{
_Reset();
Initialize();
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_CONSUME, 15s);
events.ScheduleEvent(EVENT_CRUSH, 1s, 5s);
events.ScheduleEvent(EVENT_INFECTED_WOUND, 10s, 60s);
events.ScheduleEvent(EVENT_CORPSE_EXPLODE, 3s);
events.ScheduleEvent(EVENT_SPAWN, 30s, 40s);
}
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_CONSUME:
Talk(SAY_CONSUME);
DoCastAOE(SPELL_CONSUME);
events.ScheduleEvent(EVENT_CONSUME, 15s);
break;
case EVENT_CRUSH:
DoCastVictim(SPELL_CRUSH);
events.ScheduleEvent(EVENT_CRUSH, 10s, 15s);
break;
case EVENT_INFECTED_WOUND:
DoCastVictim(SPELL_INFECTED_WOUND);
events.ScheduleEvent(EVENT_INFECTED_WOUND, 25s, 35s);
break;
case EVENT_CORPSE_EXPLODE:
Talk(SAY_EXPLODE);
DoCastAOE(SPELL_CORPSE_EXPLODE);
events.ScheduleEvent(EVENT_CORPSE_EXPLODE, 15s, 19s);
break;
case EVENT_SPAWN:
for (uint8 i = 0; i < 3; ++i)
if (Creature* trigger = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_TROLLGORE_INVADER_SUMMONER_1 + i)))
trigger->CastSpell(trigger, RAND(SPELL_SUMMON_INVADER_A, SPELL_SUMMON_INVADER_B, SPELL_SUMMON_INVADER_C), me->GetGUID());
events.ScheduleEvent(EVENT_SPAWN, 30s, 40s);
break;
default:
break;
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
if (_consumptionJunction)
{
Aura* ConsumeAura = me->GetAura(SPELL_CONSUME_BUFF_HELPER);
if (ConsumeAura && ConsumeAura->GetStackAmount() > 9)
_consumptionJunction = false;
}
DoMeleeAttackIfReady();
}
void JustDied(Unit* /*killer*/) override
{
_JustDied();
Talk(SAY_DEATH);
}
uint32 GetData(uint32 type) const override
{
if (type == DATA_CONSUMPTION_JUNCTION)
return _consumptionJunction ? 1 : 0;
return 0;
}
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() != TYPEID_PLAYER)
return;
Talk(SAY_KILL);
}
void JustSummoned(Creature* summon) override
{
summon->GetMotionMaster()->MovePoint(POINT_LANDING, Landing);
summons.Summon(summon);
}
private:
bool _consumptionJunction;
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetDrakTharonKeepAI<boss_trollgoreAI>(creature);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
if (_consumptionJunction)
{
Aura* ConsumeAura = me->GetAura(SPELL_CONSUME_BUFF_HELPER);
if (ConsumeAura && ConsumeAura->GetStackAmount() > 9)
_consumptionJunction = false;
}
DoMeleeAttackIfReady();
}
void JustDied(Unit* /*killer*/) override
{
_JustDied();
Talk(SAY_DEATH);
}
uint32 GetData(uint32 type) const override
{
if (type == DATA_CONSUMPTION_JUNCTION)
return _consumptionJunction ? 1 : 0;
return 0;
}
void KilledUnit(Unit* victim) override
{
if (victim->GetTypeId() != TYPEID_PLAYER)
return;
Talk(SAY_KILL);
}
void JustSummoned(Creature* summon) override
{
summon->GetMotionMaster()->MovePoint(POINT_LANDING, Landing);
summons.Summon(summon);
}
private:
bool _consumptionJunction;
};
class npc_drakkari_invader : public CreatureScript
struct npc_drakkari_invader : public ScriptedAI
{
public:
npc_drakkari_invader() : CreatureScript("npc_drakkari_invader") { }
npc_drakkari_invader(Creature* creature) : ScriptedAI(creature) { }
struct npc_drakkari_invaderAI : public ScriptedAI
void MovementInform(uint32 type, uint32 pointId) override
{
if (type == POINT_MOTION_TYPE && pointId == POINT_LANDING)
{
npc_drakkari_invaderAI(Creature* creature) : ScriptedAI(creature) { }
void MovementInform(uint32 type, uint32 pointId) override
{
if (type == POINT_MOTION_TYPE && pointId == POINT_LANDING)
{
me->Dismount();
me->SetImmuneToAll(false);
DoCastAOE(SPELL_INVADER_TAUNT);
}
}
};
CreatureAI* GetAI(Creature* creature) const override
{
return GetDrakTharonKeepAI<npc_drakkari_invaderAI>(creature);
me->Dismount();
me->SetImmuneToAll(false);
DoCastAOE(SPELL_INVADER_TAUNT);
}
}
};
// 49380, 59803 - Consume
class spell_trollgore_consume : public SpellScriptLoader
class spell_trollgore_consume : public SpellScript
{
public:
spell_trollgore_consume() : SpellScriptLoader("spell_trollgore_consume") { }
PrepareSpellScript(spell_trollgore_consume);
class spell_trollgore_consume_SpellScript : public SpellScript
{
PrepareSpellScript(spell_trollgore_consume_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_CONSUME_BUFF });
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_CONSUME_BUFF });
}
void HandleConsume(SpellEffIndex /*effIndex*/)
{
if (Unit* target = GetHitUnit())
target->CastSpell(GetCaster(), SPELL_CONSUME_BUFF, true);
}
void HandleConsume(SpellEffIndex /*effIndex*/)
{
if (Unit* target = GetHitUnit())
target->CastSpell(GetCaster(), SPELL_CONSUME_BUFF, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_trollgore_consume_SpellScript::HandleConsume, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_trollgore_consume_SpellScript();
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_trollgore_consume::HandleConsume, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
// 49555, 59807 - Corpse Explode
class spell_trollgore_corpse_explode : public SpellScriptLoader
class spell_trollgore_corpse_explode : public AuraScript
{
public:
spell_trollgore_corpse_explode() : SpellScriptLoader("spell_trollgore_corpse_explode") { }
PrepareAuraScript(spell_trollgore_corpse_explode);
class spell_trollgore_corpse_explode_AuraScript : public AuraScript
{
PrepareAuraScript(spell_trollgore_corpse_explode_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_CORPSE_EXPLODE_DAMAGE });
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_CORPSE_EXPLODE_DAMAGE });
}
void PeriodicTick(AuraEffect const* aurEff)
{
if (aurEff->GetTickNumber() == 2)
if (Unit* caster = GetCaster())
caster->CastSpell(GetTarget(), SPELL_CORPSE_EXPLODE_DAMAGE, aurEff);
}
void PeriodicTick(AuraEffect const* aurEff)
{
if (aurEff->GetTickNumber() == 2)
if (Unit* caster = GetCaster())
caster->CastSpell(GetTarget(), SPELL_CORPSE_EXPLODE_DAMAGE, aurEff);
}
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Creature* target = GetTarget()->ToCreature())
target->DespawnOrUnsummon();
}
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Creature* target = GetTarget()->ToCreature())
target->DespawnOrUnsummon();
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_trollgore_corpse_explode_AuraScript::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
AfterEffectRemove += AuraEffectRemoveFn(spell_trollgore_corpse_explode_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_trollgore_corpse_explode_AuraScript();
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_trollgore_corpse_explode::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY);
AfterEffectRemove += AuraEffectRemoveFn(spell_trollgore_corpse_explode::HandleRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};
// 49405 - Invader Taunt Trigger
class spell_trollgore_invader_taunt : public SpellScriptLoader
class spell_trollgore_invader_taunt : public SpellScript
{
public:
spell_trollgore_invader_taunt() : SpellScriptLoader("spell_trollgore_invader_taunt") { }
PrepareSpellScript(spell_trollgore_invader_taunt);
class spell_trollgore_invader_taunt_SpellScript : public SpellScript
{
PrepareSpellScript(spell_trollgore_invader_taunt_SpellScript);
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ static_cast<uint32>(spellInfo->Effects[EFFECT_0].CalcValue()) });
}
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ static_cast<uint32>(spellInfo->Effects[EFFECT_0].CalcValue()) });
}
void HandleTaunt(SpellEffIndex /*effIndex*/)
{
if (Unit* target = GetHitUnit())
target->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
void HandleTaunt(SpellEffIndex /*effIndex*/)
{
if (Unit* target = GetHitUnit())
target->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_trollgore_invader_taunt_SpellScript::HandleTaunt, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_trollgore_invader_taunt_SpellScript();
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_trollgore_invader_taunt::HandleTaunt, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
class achievement_consumption_junction : public AchievementCriteriaScript
@@ -354,10 +299,10 @@ class achievement_consumption_junction : public AchievementCriteriaScript
void AddSC_boss_trollgore()
{
new boss_trollgore();
new npc_drakkari_invader();
new spell_trollgore_consume();
new spell_trollgore_corpse_explode();
new spell_trollgore_invader_taunt();
RegisterDrakTharonKeepCreatureAI(boss_trollgore);
RegisterDrakTharonKeepCreatureAI(npc_drakkari_invader);
RegisterSpellScript(spell_trollgore_consume);
RegisterSpellScript(spell_trollgore_corpse_explode);
RegisterSpellScript(spell_trollgore_invader_taunt);
new achievement_consumption_junction();
}