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

View File

@@ -17,6 +17,7 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "molten_core.h"
enum Texts
@@ -49,6 +50,16 @@ enum Spells
SPELL_MIGHT_OF_RAGNAROS = 21154,
SPELL_INTENSE_HEAT = 21155,
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
@@ -61,6 +72,7 @@ enum Events
EVENT_MAGMA_BLAST_MELEE_CHECK,
EVENT_MAGMA_BLAST,
EVENT_SUBMERGE,
EVENT_LAVA_BURST_TRIGGER,
// Submerge
EVENT_EMERGE,
@@ -125,6 +137,7 @@ public:
_hasSubmergedOnce = false;
_isKnockbackEmoteAllowed = true;
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
_lavaBurstGUIDS.clear();
}
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
{
summons.Despawn(summon);
@@ -222,6 +248,28 @@ public:
_isKnockbackEmoteAllowed = true;
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:
{
DoCastVictim(SPELL_WRATH_OF_RAGNAROS);
if (urand(0, 1))
{
Talk(SAY_WRATH);
@@ -268,7 +317,6 @@ public:
case EVENT_LAVA_BURST:
{
DoCastAOE(SPELL_LAVA_BURST);
events.RepeatEvent(10000);
break;
}
case EVENT_MAGMA_BLAST_MELEE_CHECK:
@@ -377,6 +425,8 @@ public:
bool _hasSubmergedOnce;
bool _isKnockbackEmoteAllowed; // Prevents possible text overlap
GuidSet _lavaBurstGUIDS;
void HandleEmerge()
{
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()
{
new boss_ragnaros();
RegisterSpellScript(spell_ragnaros_lava_burst_randomizer);
}

View File

@@ -210,6 +210,14 @@ public:
_lavaSplashGUID = go->GetGUID();
break;
}
case GO_LAVA_BURST:
{
if (Creature* ragnaros = instance->GetCreature(_ragnarosGUID))
{
ragnaros->AI()->SetGUID(go->GetGUID(), GO_LAVA_BURST);
}
break;
}
}
}

View File

@@ -109,6 +109,7 @@ enum MCGameObjects
// Ragnaros event related
GO_LAVA_STEAM = 178107,
GO_LAVA_SPLASH = 178108,
GO_LAVA_BURST = 178088,
};
enum MCSpells