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,
};
class boss_ahune : public CreatureScript
enum Misc
{
public:
boss_ahune() : CreatureScript("boss_ahune") { }
SET_GUID_INVOKER = 1
};
CreatureAI* GetAI(Creature* pCreature) const override
struct boss_ahune : public ScriptedAI
{
return GetTheSlavePensAI<boss_ahuneAI>(pCreature);
}
struct boss_ahuneAI : public ScriptedAI
{
boss_ahuneAI(Creature* c) : ScriptedAI(c), summons(me)
boss_ahune(Creature* c) : ScriptedAI(c), summons(me)
{
SetCombatMovement(false);
SetEquipmentSlots(false, 54806, EQUIP_UNEQUIP, EQUIP_UNEQUIP);
@@ -125,6 +120,14 @@ public:
StartPhase1();
}
void SetGUID(ObjectGuid guid, int32 id) override
{
if (id == SET_GUID_INVOKER)
{
InvokerGUID = guid;
}
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim() && !me->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE))
@@ -189,7 +192,7 @@ public:
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->CastSpell(me, SPELL_SUBMERGE_0, 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());
}
@@ -294,10 +297,8 @@ public:
me->RemoveGameObject(chest, false);
bool finished = false;
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.IsEmpty())
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
if (Player* player = i->GetSource())
me->GetMap()->DoForAllPlayers([&](Player* player)
{
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, 25740, 1, me);
@@ -306,9 +307,8 @@ public:
finished = true;
sLFGMgr->FinishDungeon(player->GetGroup()->GetGUID(), lfg::LFG_DUNGEON_FROST_LORD_AHUNE, me->FindMap());
}
});
}
}
};
};
class go_ahune_ice_stone : public GameObjectScript
@@ -369,7 +369,11 @@ public:
c->SetVisible(false);
c->SetDisplayId(AHUNE_DEFAULT_MODEL);
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* 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);
@@ -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()
{
new go_ahune_ice_stone();
new boss_ahune();
new npc_ahune_frozen_core();
RegisterTheSlavePensCreatureAI(boss_ahune);
}