fix(Scripts/MoltenCore): Implement Ragnaros' Lava Bursts (#9526)

This commit is contained in:
Skjalf
2021-12-08 15:02:32 -03:00
committed by GitHub
parent 8fd8075ccc
commit 4982c4eeb7
4 changed files with 110 additions and 1 deletions
@@ -0,0 +1,18 @@
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1638745963138176600');
-- Positions are sniffed, but position/spell relation cant be confirmed (serverside spells)
DELETE FROM `spell_target_position` WHERE ID IN (21886, 21900, 21901, 21902, 21903, 21904, 21905, 21906, 21907);
INSERT INTO `spell_target_position` (`ID`, `EffectIndex`, `MapID`, `PositionX`, `PositionY`, `PositionZ`, `Orientation`, `VerifiedBuild`) VALUES
(21886, 0, 409, 871.53997802734375, -839.114990234375, -228.99200439453125, 0, 0),
(21900, 0, 409, 843.50897216796875, -798.31298828125, -229.4320068359375, 0, 0),
(21901, 0, 409, 827.2760009765625, -874.02801513671875, -229.593994140625, 0, 0),
(21902, 0, 409, 864.572998046875, -806.4630126953125, -229.785995483398437, 0, 0),
(21903, 0, 409, 819.75701904296875, -807.176025390625, -229.033004760742187, 0, 0),
(21904, 0, 409, 811.0009765625, -822.281982421875, -229.311004638671875, 0, 0),
(21905, 0, 409, 892.63299560546875, -790.40997314453125, -228.927993774414062, 0, 0),
(21906, 0, 409, 906.69500732421875, -828.61102294921875, -229.927993774414062, 0, 0),
(21907, 0, 409, 862.86199951171875, -866.95501708984375, -228.9429931640625, 0, 0);
DELETE FROM `spell_script_names` WHERE `spell_id` = 21908;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(21908, 'spell_ragnaros_lava_burst_randomizer');
@@ -17,6 +17,7 @@
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "ScriptedCreature.h" #include "ScriptedCreature.h"
#include "SpellScript.h"
#include "molten_core.h" #include "molten_core.h"
enum Texts enum Texts
@@ -49,6 +50,16 @@ enum Spells
SPELL_MIGHT_OF_RAGNAROS = 21154, SPELL_MIGHT_OF_RAGNAROS = 21154,
SPELL_INTENSE_HEAT = 21155, SPELL_INTENSE_HEAT = 21155,
SPELL_SUMMON_SONS_FLAME = 21108, // Trigger the eight spells summoning the Son of Flame adds (TODO) SPELL_SUMMON_SONS_FLAME = 21108, // Trigger the eight spells summoning the Son of Flame adds (TODO)
SPELL_LAVA_BURST_A = 21886,
SPELL_LAVA_BURST_B = 21900,
SPELL_LAVA_BURST_C = 21901,
SPELL_LAVA_BURST_D = 21902,
SPELL_LAVA_BURST_E = 21903,
SPELL_LAVA_BURST_F = 21905,
SPELL_LAVA_BURST_G = 21906,
SPELL_LAVA_BURST_H = 21907,
SPELL_LAVA_BURST_TRAP = 21158
}; };
enum Events enum Events
@@ -61,6 +72,7 @@ enum Events
EVENT_MAGMA_BLAST_MELEE_CHECK, EVENT_MAGMA_BLAST_MELEE_CHECK,
EVENT_MAGMA_BLAST, EVENT_MAGMA_BLAST,
EVENT_SUBMERGE, EVENT_SUBMERGE,
EVENT_LAVA_BURST_TRIGGER,
// Submerge // Submerge
EVENT_EMERGE, EVENT_EMERGE,
@@ -125,6 +137,7 @@ public:
_hasSubmergedOnce = false; _hasSubmergedOnce = false;
_isKnockbackEmoteAllowed = true; _isKnockbackEmoteAllowed = true;
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
_lavaBurstGUIDS.clear();
} }
void DoAction(int32 action) override void DoAction(int32 action) override
@@ -145,6 +158,19 @@ public:
} }
} }
void SetGUID(ObjectGuid guid, int32 index) override
{
if (index == GO_LAVA_BURST)
{
if (_lavaBurstGUIDS.empty())
{
extraEvents.ScheduleEvent(EVENT_LAVA_BURST_TRIGGER, 1);
}
_lavaBurstGUIDS.insert(guid);
}
}
void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override
{ {
summons.Despawn(summon); summons.Despawn(summon);
@@ -222,6 +248,28 @@ public:
_isKnockbackEmoteAllowed = true; _isKnockbackEmoteAllowed = true;
break; break;
} }
case EVENT_LAVA_BURST_TRIGGER:
{
if (!_lavaBurstGUIDS.empty())
{
ObjectGuid lavaBurstGUID = Acore::Containers::SelectRandomContainerElement(_lavaBurstGUIDS);
if (GameObject* go = ObjectAccessor::GetGameObject(*me, lavaBurstGUID))
{
go->CastSpell(nullptr, SPELL_LAVA_BURST_TRAP);
go->SendCustomAnim(0);
}
_lavaBurstGUIDS.erase(lavaBurstGUID);
extraEvents.RepeatEvent(1000);
}
else
{
events.RescheduleEvent(EVENT_LAVA_BURST, 10000, PHASE_EMERGED, PHASE_EMERGED);
}
break;
}
} }
} }
} }
@@ -246,6 +294,7 @@ public:
case EVENT_WRATH_OF_RAGNAROS: case EVENT_WRATH_OF_RAGNAROS:
{ {
DoCastVictim(SPELL_WRATH_OF_RAGNAROS); DoCastVictim(SPELL_WRATH_OF_RAGNAROS);
if (urand(0, 1)) if (urand(0, 1))
{ {
Talk(SAY_WRATH); Talk(SAY_WRATH);
@@ -268,7 +317,6 @@ public:
case EVENT_LAVA_BURST: case EVENT_LAVA_BURST:
{ {
DoCastAOE(SPELL_LAVA_BURST); DoCastAOE(SPELL_LAVA_BURST);
events.RepeatEvent(10000);
break; break;
} }
case EVENT_MAGMA_BLAST_MELEE_CHECK: case EVENT_MAGMA_BLAST_MELEE_CHECK:
@@ -377,6 +425,8 @@ public:
bool _hasSubmergedOnce; bool _hasSubmergedOnce;
bool _isKnockbackEmoteAllowed; // Prevents possible text overlap bool _isKnockbackEmoteAllowed; // Prevents possible text overlap
GuidSet _lavaBurstGUIDS;
void HandleEmerge() void HandleEmerge()
{ {
if (events.IsInPhase(PHASE_EMERGED)) if (events.IsInPhase(PHASE_EMERGED))
@@ -425,7 +475,39 @@ public:
} }
}; };
constexpr std::array<uint32, 8> RagnarosLavaBurstSpells = { SPELL_LAVA_BURST_A, SPELL_LAVA_BURST_B, SPELL_LAVA_BURST_C, SPELL_LAVA_BURST_D, SPELL_LAVA_BURST_E, SPELL_LAVA_BURST_F, SPELL_LAVA_BURST_G, SPELL_LAVA_BURST_H };
// 21908 - Lava Burst Randomizer
class spell_ragnaros_lava_burst_randomizer : public SpellScript
{
PrepareSpellScript(spell_ragnaros_lava_burst_randomizer);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo(RagnarosLavaBurstSpells);
}
void HandleScript()
{
if (Unit* caster = GetCaster())
{
// Select three random spells. Can select the same spell twice.
for (uint8 i = 0; i < 3; ++i)
{
uint32 spell = Acore::Containers::SelectRandomContainerElement(RagnarosLavaBurstSpells);
caster->CastSpell(caster, spell, true);
}
}
}
void Register() override
{
AfterCast += SpellCastFn(spell_ragnaros_lava_burst_randomizer::HandleScript);
}
};
void AddSC_boss_ragnaros() void AddSC_boss_ragnaros()
{ {
new boss_ragnaros(); new boss_ragnaros();
RegisterSpellScript(spell_ragnaros_lava_burst_randomizer);
} }
@@ -210,6 +210,14 @@ public:
_lavaSplashGUID = go->GetGUID(); _lavaSplashGUID = go->GetGUID();
break; break;
} }
case GO_LAVA_BURST:
{
if (Creature* ragnaros = instance->GetCreature(_ragnarosGUID))
{
ragnaros->AI()->SetGUID(go->GetGUID(), GO_LAVA_BURST);
}
break;
}
} }
} }
@@ -109,6 +109,7 @@ enum MCGameObjects
// Ragnaros event related // Ragnaros event related
GO_LAVA_STEAM = 178107, GO_LAVA_STEAM = 178107,
GO_LAVA_SPLASH = 178108, GO_LAVA_SPLASH = 178108,
GO_LAVA_BURST = 178088,
}; };
enum MCSpells enum MCSpells