refactor(Scripts/SlavePens): Clean up Ahune script (#16613)

* refactor(Scripts/SlavePens): Clean up Ahune script

* Create rev_1687609506371262000.sql

* Update boss_ahune.cpp
This commit is contained in:
Skjalf
2023-06-24 17:32:11 -03:00
committed by GitHub
parent c83c64cdee
commit b45773ec31
2 changed files with 218 additions and 234 deletions
@@ -0,0 +1,2 @@
--
UPDATE `creature_template` SET `ScriptName` = '' WHERE `ScriptName` = 'npc_ahune_frozen_core';
@@ -81,19 +81,14 @@ enum eEvents
EVENT_SPELL_SUMMON_COLDWAVE, EVENT_SPELL_SUMMON_COLDWAVE,
}; };
class boss_ahune : public CreatureScript enum Misc
{ {
public: SET_GUID_INVOKER = 1
boss_ahune() : CreatureScript("boss_ahune") { } };
CreatureAI* GetAI(Creature* pCreature) const override struct boss_ahune : public ScriptedAI
{ {
return GetTheSlavePensAI<boss_ahuneAI>(pCreature); boss_ahune(Creature* c) : ScriptedAI(c), summons(me)
}
struct boss_ahuneAI : public ScriptedAI
{
boss_ahuneAI(Creature* c) : ScriptedAI(c), summons(me)
{ {
SetCombatMovement(false); SetCombatMovement(false);
SetEquipmentSlots(false, 54806, EQUIP_UNEQUIP, EQUIP_UNEQUIP); SetEquipmentSlots(false, 54806, EQUIP_UNEQUIP, EQUIP_UNEQUIP);
@@ -125,6 +120,14 @@ public:
StartPhase1(); StartPhase1();
} }
void SetGUID(ObjectGuid guid, int32 id) override
{
if (id == SET_GUID_INVOKER)
{
InvokerGUID = guid;
}
}
void UpdateAI(uint32 diff) override void UpdateAI(uint32 diff) override
{ {
if (!UpdateVictim() && !me->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE)) if (!UpdateVictim() && !me->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE))
@@ -135,7 +138,7 @@ public:
if (me->HasUnitState(UNIT_STATE_CASTING)) if (me->HasUnitState(UNIT_STATE_CASTING))
return; return;
switch(events.ExecuteEvent()) switch (events.ExecuteEvent())
{ {
case 0: case 0:
break; break;
@@ -189,7 +192,7 @@ public:
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->CastSpell(me, SPELL_SUBMERGE_0, true); me->CastSpell(me, SPELL_SUBMERGE_0, true);
me->CastSpell(me, SPELL_SELF_STUN, true); me->CastSpell(me, SPELL_SELF_STUN, true);
if (Creature* c = DoSummon(NPC_FROZEN_CORE, *me, 24000, TEMPSUMMON_TIMED_DESPAWN)) if (Creature* c = DoSummon(NPC_FROZEN_CORE, *me, 24000, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN))
{ {
c->SetHealth(me->GetHealth()); c->SetHealth(me->GetHealth());
} }
@@ -225,7 +228,7 @@ public:
{ {
float dist = (float)urand(3, 10); float dist = (float)urand(3, 10);
float angle = rand_norm() * 2 * M_PI; float angle = rand_norm() * 2 * M_PI;
me->CastSpell(MinionSummonPos.GetPositionX() + cos(angle)*dist, MinionSummonPos.GetPositionY() + std::sin(angle)*dist, MinionSummonPos.GetPositionZ(), SPELL_SUMMON_HAILSTONE, false); me->CastSpell(MinionSummonPos.GetPositionX() + cos(angle) * dist, MinionSummonPos.GetPositionY() + std::sin(angle) * dist, MinionSummonPos.GetPositionZ(), SPELL_SUMMON_HAILSTONE, false);
events.RepeatEvent(30000); events.RepeatEvent(30000);
} }
break; break;
@@ -234,12 +237,12 @@ public:
{ {
float dist = (float)urand(3, 10); float dist = (float)urand(3, 10);
float angle = rand_norm() * 2 * M_PI; float angle = rand_norm() * 2 * M_PI;
me->CastSpell(MinionSummonPos.GetPositionX() + cos(angle)*dist, MinionSummonPos.GetPositionY() + std::sin(angle)*dist, MinionSummonPos.GetPositionZ(), SPELL_SUMMON_COLDWAVE, false); me->CastSpell(MinionSummonPos.GetPositionX() + cos(angle) * dist, MinionSummonPos.GetPositionY() + std::sin(angle) * dist, MinionSummonPos.GetPositionZ(), SPELL_SUMMON_COLDWAVE, false);
} }
{ {
float dist = (float)urand(3, 10); float dist = (float)urand(3, 10);
float angle = rand_norm() * 2 * M_PI; float angle = rand_norm() * 2 * M_PI;
me->CastSpell(MinionSummonPos.GetPositionX() + cos(angle)*dist, MinionSummonPos.GetPositionY() + std::sin(angle)*dist, MinionSummonPos.GetPositionZ(), SPELL_SUMMON_FROSTWIND, false); me->CastSpell(MinionSummonPos.GetPositionX() + cos(angle) * dist, MinionSummonPos.GetPositionY() + std::sin(angle) * dist, MinionSummonPos.GetPositionZ(), SPELL_SUMMON_FROSTWIND, false);
} }
events.RepeatEvent(6000); events.RepeatEvent(6000);
break; break;
@@ -294,10 +297,8 @@ public:
me->RemoveGameObject(chest, false); me->RemoveGameObject(chest, false);
bool finished = false; bool finished = false;
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.IsEmpty()) me->GetMap()->DoForAllPlayers([&](Player* player)
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
if (Player* player = i->GetSource())
{ {
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, 25740, 1, me); player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, 25740, 1, me);
@@ -306,9 +307,8 @@ public:
finished = true; finished = true;
sLFGMgr->FinishDungeon(player->GetGroup()->GetGUID(), lfg::LFG_DUNGEON_FROST_LORD_AHUNE, me->FindMap()); sLFGMgr->FinishDungeon(player->GetGroup()->GetGUID(), lfg::LFG_DUNGEON_FROST_LORD_AHUNE, me->FindMap());
} }
});
} }
}
};
}; };
class go_ahune_ice_stone : public GameObjectScript class go_ahune_ice_stone : public GameObjectScript
@@ -369,7 +369,11 @@ public:
c->SetVisible(false); c->SetVisible(false);
c->SetDisplayId(AHUNE_DEFAULT_MODEL); c->SetDisplayId(AHUNE_DEFAULT_MODEL);
c->SetFloatValue(UNIT_FIELD_COMBATREACH, 18.0f); c->SetFloatValue(UNIT_FIELD_COMBATREACH, 18.0f);
CAST_AI(boss_ahune::boss_ahuneAI, c->AI())->InvokerGUID = player->GetGUID(); if (c->AI())
{
c->AI()->SetGUID(player->GetGUID(), SET_GUID_INVOKER);
}
if (Creature* bunny = go->SummonCreature(NPC_AHUNE_SUMMON_LOC_BUNNY, AhuneSummonPos, TEMPSUMMON_TIMED_DESPAWN, 12000)) if (Creature* bunny = go->SummonCreature(NPC_AHUNE_SUMMON_LOC_BUNNY, AhuneSummonPos, TEMPSUMMON_TIMED_DESPAWN, 12000))
if (Creature* crystal_trigger = go->SummonCreature(WORLD_TRIGGER, go->GetPositionX(), go->GetPositionY(), 5.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 12000)) if (Creature* crystal_trigger = go->SummonCreature(WORLD_TRIGGER, go->GetPositionX(), go->GetPositionY(), 5.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN, 12000))
crystal_trigger->CastSpell(bunny, SPELL_STARTING_BEAM, false); crystal_trigger->CastSpell(bunny, SPELL_STARTING_BEAM, false);
@@ -380,30 +384,8 @@ public:
} }
}; };
class npc_ahune_frozen_core : public CreatureScript
{
public:
npc_ahune_frozen_core() : CreatureScript("npc_ahune_frozen_core") { }
CreatureAI* GetAI(Creature* pCreature) const override
{
return GetTheSlavePensAI<npc_ahune_frozen_coreAI>(pCreature);
}
struct npc_ahune_frozen_coreAI : public NullCreatureAI
{
npc_ahune_frozen_coreAI(Creature* c) : NullCreatureAI(c) {}
void JustDied(Unit* /*killer*/) override
{
me->DespawnOrUnsummon();
}
};
};
void AddSC_boss_ahune() void AddSC_boss_ahune()
{ {
new go_ahune_ice_stone(); new go_ahune_ice_stone();
new boss_ahune(); RegisterTheSlavePensCreatureAI(boss_ahune);
new npc_ahune_frozen_core();
} }