fix(Scripts/ZulAman): Remove Eletrical Storm hacks (#20553)

* fix(Scripts/ZulAman): Remove Eletrical Storm hacks

* Update boss_akilzon.cpp

* Create rev_1731545993422354000.sql
This commit is contained in:
Andrew
2024-11-13 22:58:33 -03:00
committed by GitHub
parent bdb6ef8937
commit 1bea402e5c
2 changed files with 132 additions and 154 deletions
@@ -0,0 +1,4 @@
--
DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_electrial_storm' AND `spell_id` = 43648;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(43648, 'spell_electrial_storm');
@@ -15,20 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* ScriptData
SDName: boss_Akilzon
SD%Complete: 75%
SDComment: Missing timer for Call Lightning and Sound ID's
SQLUpdate:
#Temporary fix for Soaring Eagles
EndScriptData */
#include "Cell.h" #include "Cell.h"
#include "CreatureScript.h" #include "CreatureScript.h"
#include "GridNotifiers.h" #include "GridNotifiers.h"
#include "GridNotifiersImpl.h" #include "GridNotifiersImpl.h"
#include "ScriptedCreature.h" #include "ScriptedCreature.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
#include "Weather.h" #include "Weather.h"
#include "zulaman.h" #include "zulaman.h"
@@ -39,6 +32,7 @@ enum Spells
SPELL_CALL_LIGHTNING = 43661, // Missing timer SPELL_CALL_LIGHTNING = 43661, // Missing timer
SPELL_GUST_OF_WIND = 43621, SPELL_GUST_OF_WIND = 43621,
SPELL_ELECTRICAL_STORM = 43648, SPELL_ELECTRICAL_STORM = 43648,
SPELL_ELECTRICAL_STORM_AREA = 44007, // Safe within the eye of the storm
SPELL_BERSERK = 45078, SPELL_BERSERK = 45078,
SPELL_ELECTRICAL_OVERLOAD = 43658, SPELL_ELECTRICAL_OVERLOAD = 43658,
SPELL_EAGLE_SWOOP = 44732, SPELL_EAGLE_SWOOP = 44732,
@@ -56,6 +50,11 @@ enum Says
SAY_DEATH = 5 SAY_DEATH = 5
}; };
enum Misc
{
ACTION_INCREASE_STORM_COUNT = 1
};
constexpr auto NPC_SOARING_EAGLE = 24858; constexpr auto NPC_SOARING_EAGLE = 24858;
class boss_akilzon : public CreatureScript class boss_akilzon : public CreatureScript
@@ -71,12 +70,12 @@ public:
{ {
_Reset(); _Reset();
TargetGUID.Clear(); _targetGUID.Clear();
CloudGUID.Clear(); _cloudGUID.Clear();
CycloneGUID.Clear(); _cycloneGUID.Clear();
StormCount = 0; _stormCount = 0;
isRaining = false; _isRaining = false;
SetWeather(WEATHER_STATE_FINE, 0.0f); SetWeather(WEATHER_STATE_FINE, 0.0f);
@@ -93,7 +92,7 @@ public:
target = me->GetVictim(); target = me->GetVictim();
if (target) if (target)
{ {
TargetGUID = target->GetGUID(); _targetGUID = target->GetGUID();
DoCast(target, SPELL_STATIC_DISRUPTION, false); DoCast(target, SPELL_STATIC_DISRUPTION, false);
me->SetInFront(me->GetVictim()); me->SetInFront(me->GetVictim());
} }
@@ -118,8 +117,8 @@ public:
EnterEvadeMode(); EnterEvadeMode();
return; return;
} }
target->CastSpell(target, 44007, true); // cloud visual target->CastSpell(target, SPELL_ELECTRICAL_STORM_AREA, true); // cloud visual
DoCast(target, SPELL_ELECTRICAL_STORM, false); // storm cyclon + visual DoCast(target, SPELL_ELECTRICAL_STORM); // storm cyclon + visual
float x, y, z; float x, y, z;
target->GetPosition(x, y, z); target->GetPosition(x, y, z);
@@ -128,7 +127,7 @@ public:
{ {
target->GetMotionMaster()->MoveJump(Cloud->GetPosition(), 1.0f, 1.0f); target->GetMotionMaster()->MoveJump(Cloud->GetPosition(), 1.0f, 1.0f);
CloudGUID = Cloud->GetGUID(); _cloudGUID = Cloud->GetGUID();
Cloud->SetDisableGravity(true); Cloud->SetDisableGravity(true);
Cloud->StopMoving(); Cloud->StopMoving();
Cloud->SetObjectScale(1.0f); Cloud->SetObjectScale(1.0f);
@@ -137,27 +136,27 @@ public:
Cloud->SetHealth(9999999); Cloud->SetHealth(9999999);
Cloud->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); Cloud->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->m_Events.AddEventAtOffset([&, Cloud] { me->m_Events.AddEventAtOffset([&] {
HandleStormSequence(Cloud); HandleStormSequence();
}, 3s); }, 3s);
} }
StormCount = 1; _stormCount = 1;
me->m_Events.AddEventAtOffset([&] { me->m_Events.AddEventAtOffset([&] {
if (!isRaining) if (!_isRaining)
{ {
SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f); SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f);
isRaining = true; _isRaining = true;
} }
}, Seconds(urand(47, 52))); }, Seconds(urand(47, 52)));
}, 1min); }, 1min);
ScheduleTimedEvent(47s, 52s, [&] { ScheduleTimedEvent(47s, 52s, [&] {
if (!isRaining) if (!_isRaining)
{ {
SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f); SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f);
isRaining = true; _isRaining = true;
} }
}, 47s, 52s); }, 47s, 52s);
@@ -187,81 +186,44 @@ public:
me->GetMap()->SetZoneWeather(me->GetZoneId(), WeatherState(weather), grade); me->GetMap()->SetZoneWeather(me->GetZoneId(), WeatherState(weather), grade);
} }
void HandleStormSequence(Unit* Cloud) // 1: begin, 2-9: tick, 10: end void HandleStormSequence() // 1: begin, 2-9: tick, 10: end
{ {
Creature* Cloud = ObjectAccessor::GetCreature(*me, _cloudGUID);
if (!Cloud) if (!Cloud)
return; return;
if (StormCount < 10 && StormCount > 1) if (_stormCount > 10)
{ {
// deal damage _stormCount = 0; // finish
int32 bp0 = 800;
for (uint8 i = 2; i < StormCount; ++i)
bp0 *= 2;
std::list<Unit*> tempUnitMap;
Acore::AnyAoETargetUnitInObjectRangeCheck u_check(me, me, SIZE_OF_GRIDS);
Acore::UnitListSearcher<Acore::AnyAoETargetUnitInObjectRangeCheck> searcher(me, tempUnitMap, u_check);
Cell::VisitAllObjects(me, searcher, SIZE_OF_GRIDS);
// deal damage
for (auto const& target : tempUnitMap)
{
if (target)
{
if (Cloud && !Cloud->IsWithinDist(target, 6, false))
Cloud->CastCustomSpell(target, SPELL_ZAP, &bp0, nullptr, nullptr, true, 0, 0, me->GetGUID());
}
}
// visual
float x, y, z;
z = me->GetPositionZ();
for (uint8 i = 0; i < 5 + rand() % 5; ++i)
{
x = 343.0f + rand() % 60;
y = 1380.0f + rand() % 60;
if (Unit* trigger = me->SummonTrigger(x, y, z, 0, 2000))
{
trigger->SetFaction(FACTION_FRIENDLY);
trigger->SetMaxHealth(100000);
trigger->SetHealth(100000);
trigger->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
if (Cloud)
Cloud->CastCustomSpell(trigger, /*43661*/SPELL_ZAP, &bp0, nullptr, nullptr, true, 0, 0, Cloud->GetGUID());
}
}
}
++StormCount;
if (StormCount > 10)
{
StormCount = 0; // finish
me->m_Events.AddEventAtOffset([&] { me->m_Events.AddEventAtOffset([&] {
SummonEagles(); SummonEagles();
}, 5s); }, 5s);
me->InterruptNonMeleeSpells(false); me->InterruptNonMeleeSpells(false);
CloudGUID.Clear(); _cloudGUID.Clear();
if (Cloud) if (Cloud)
Cloud->KillSelf(); Cloud->KillSelf();
SetWeather(WEATHER_STATE_FINE, 0.0f); SetWeather(WEATHER_STATE_FINE, 0.0f);
isRaining = false; _isRaining = false;
} }
me->m_Events.AddEventAtOffset([&] { me->m_Events.AddEventAtOffset([&] {
Unit* target = ObjectAccessor::GetUnit(*me, CloudGUID); Unit* target = ObjectAccessor::GetUnit(*me, _cloudGUID);
if (!target || !target->IsAlive()) if (!target || !target->IsAlive())
return; return;
else if (Unit* Cyclone = ObjectAccessor::GetUnit(*me, CycloneGUID)) else if (Unit* Cyclone = ObjectAccessor::GetUnit(*me, _cycloneGUID))
Cyclone->CastSpell(target, SPELL_SAND_STORM, true); // keep casting or... Cyclone->CastSpell(target, SPELL_SAND_STORM, true); // keep casting or...
HandleStormSequence(target); HandleStormSequence();
}, 1s); }, 1s);
} }
void DoAction(int32 actionId) override
{
if (actionId == ACTION_INCREASE_STORM_COUNT)
++_stormCount;
}
void SummonEagles() void SummonEagles()
{ {
Talk(SAY_SUMMON); Talk(SAY_SUMMON);
@@ -271,7 +233,7 @@ public:
for (uint8 i = 0; i < 8; ++i) for (uint8 i = 0; i < 8; ++i)
{ {
Unit* bird = ObjectAccessor::GetUnit(*me, BirdGUIDs[i]); Unit* bird = ObjectAccessor::GetUnit(*me, _birdGUIDs[i]);
if (!bird) //they despawned on die if (!bird) //they despawned on die
{ {
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0)) if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
@@ -287,19 +249,19 @@ public:
{ {
creature->AddThreat(me->GetVictim(), 1.0f); creature->AddThreat(me->GetVictim(), 1.0f);
creature->AI()->AttackStart(me->GetVictim()); creature->AI()->AttackStart(me->GetVictim());
BirdGUIDs[i] = creature->GetGUID(); _birdGUIDs[i] = creature->GetGUID();
} }
} }
} }
} }
private: private:
ObjectGuid BirdGUIDs[8]; ObjectGuid _birdGUIDs[8];
ObjectGuid TargetGUID; ObjectGuid _targetGUID;
ObjectGuid CycloneGUID; ObjectGuid _cycloneGUID;
ObjectGuid CloudGUID; ObjectGuid _cloudGUID;
uint8 StormCount; uint8 _stormCount;
bool isRaining; bool _isRaining;
}; };
CreatureAI* GetAI(Creature* creature) const override CreatureAI* GetAI(Creature* creature) const override
@@ -308,89 +270,101 @@ public:
} }
}; };
class npc_akilzon_eagle : public CreatureScript struct npc_akilzon_eagle : public ScriptedAI
{ {
public: npc_akilzon_eagle(Creature* creature) : ScriptedAI(creature) { }
npc_akilzon_eagle() : CreatureScript("npc_akilzon_eagle") { }
struct npc_akilzon_eagleAI : public ScriptedAI uint32 EagleSwoop_Timer;
bool arrived;
ObjectGuid TargetGUID;
void Reset() override
{ {
npc_akilzon_eagleAI(Creature* creature) : ScriptedAI(creature) { } EagleSwoop_Timer = urand(5000, 10000);
arrived = true;
TargetGUID.Clear();
me->SetDisableGravity(true);
}
uint32 EagleSwoop_Timer; void JustEngagedWith(Unit* /*who*/) override
bool arrived; {
ObjectGuid TargetGUID; DoZoneInCombat();
}
void Reset() override void MoveInLineOfSight(Unit* /*who*/) override { }
void MovementInform(uint32, uint32) override
{
arrived = true;
if (TargetGUID)
{ {
EagleSwoop_Timer = urand(5000, 10000); if (Unit* target = ObjectAccessor::GetUnit(*me, TargetGUID))
arrived = true; DoCast(target, SPELL_EAGLE_SWOOP, true);
TargetGUID.Clear(); TargetGUID.Clear();
me->SetDisableGravity(true); me->SetSpeed(MOVE_RUN, 1.2f);
EagleSwoop_Timer = urand(5000, 10000);
} }
}
void JustEngagedWith(Unit* /*who*/) override void UpdateAI(uint32 diff) override
{
DoZoneInCombat();
}
void MoveInLineOfSight(Unit* /*who*/) override { }
void MovementInform(uint32, uint32) override
{
arrived = true;
if (TargetGUID)
{
if (Unit* target = ObjectAccessor::GetUnit(*me, TargetGUID))
DoCast(target, SPELL_EAGLE_SWOOP, true);
TargetGUID.Clear();
me->SetSpeed(MOVE_RUN, 1.2f);
EagleSwoop_Timer = urand(5000, 10000);
}
}
void UpdateAI(uint32 diff) override
{
if (EagleSwoop_Timer <= diff)
EagleSwoop_Timer = 0;
else
EagleSwoop_Timer -= diff;
if (arrived)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{
float x, y, z;
if (EagleSwoop_Timer)
{
x = target->GetPositionX() + irand(-10, 10);
y = target->GetPositionY() + irand(-10, 10);
z = target->GetPositionZ() + urand(10, 15);
if (z > 95)
z = 95.0f - urand(0, 5);
}
else
{
target->GetContactPoint(me, x, y, z);
z += 2;
me->SetSpeed(MOVE_RUN, 5.0f);
TargetGUID = target->GetGUID();
}
me->GetMotionMaster()->MovePoint(0, x, y, z);
arrived = false;
}
}
}
};
CreatureAI* GetAI(Creature* creature) const override
{ {
return GetZulAmanAI<npc_akilzon_eagleAI>(creature); if (EagleSwoop_Timer <= diff)
EagleSwoop_Timer = 0;
else
EagleSwoop_Timer -= diff;
if (arrived)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{
float x, y, z;
if (EagleSwoop_Timer)
{
x = target->GetPositionX() + irand(-10, 10);
y = target->GetPositionY() + irand(-10, 10);
z = target->GetPositionZ() + urand(10, 15);
if (z > 95)
z = 95.0f - urand(0, 5);
}
else
{
target->GetContactPoint(me, x, y, z);
z += 2;
me->SetSpeed(MOVE_RUN, 5.0f);
TargetGUID = target->GetGUID();
}
me->GetMotionMaster()->MovePoint(0, x, y, z);
arrived = false;
}
}
}
};
// 43648 - Electrical Storm
class spell_electrial_storm : public AuraScript
{
PrepareAuraScript(spell_electrial_storm);
bool Load() override
{
return GetCaster() && GetCaster()->IsCreature();
}
void OnPeriodic(AuraEffect const* /*aurEff*/)
{
if (GetCaster())
GetCaster()->ToCreature()->AI()->DoAction(ACTION_INCREASE_STORM_COUNT);
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_electrial_storm::OnPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
} }
}; };
void AddSC_boss_akilzon() void AddSC_boss_akilzon()
{ {
new boss_akilzon(); new boss_akilzon();
new npc_akilzon_eagle(); RegisterZulAmanCreatureAI(npc_akilzon_eagle);
RegisterSpellScript(spell_electrial_storm);
} }