TrinityCore
boss_ragnaros.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* ScriptData
19SDName: Boss_Ragnaros
20SD%Complete: 95
21SDComment: some spells doesnt work correctly
22SDCategory: Molten Core
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "InstanceScript.h"
27#include "molten_core.h"
28#include "ObjectAccessor.h"
29#include "ScriptedCreature.h"
30#include "TemporarySummon.h"
31
33{
45};
46
48{
52 SPELL_MAGMA_BLAST = 20565, // Ranged attack
53 SPELL_SONS_OF_FLAME_DUMMY = 21108, // Server side effect
54 SPELL_RAGSUBMERGE = 21107, // Stealth aura
58 SPELL_ERRUPTION = 17731
59};
60
62{
70
75 EVENT_INTRO_5 = 12
76};
77
78struct boss_ragnaros : public BossAI
79{
81 {
82 Initialize();
83 _introState = 0;
86 SetCombatMovement(false);
87 }
88
90 {
91 _emergeTimer = 90000;
93 _hasSubmergedOnce = false;
94 _isBanished = false;
95 }
96
97 void Reset() override
98 {
100 Initialize();
102 }
103
104 void JustEngagedWith(Unit* victim) override
105 {
114 }
115
116 void KilledUnit(Unit* /*victim*/) override
117 {
118 if (urand(0, 99) < 25)
119 Talk(SAY_KILL);
120 }
121
122 void UpdateAI(uint32 diff) override
123 {
124 if (_introState != 2)
125 {
126 if (!_introState)
127 {
134 _introState = 1;
135 }
136
137 events.Update(diff);
138
139 while (uint32 eventId = events.ExecuteEvent())
140 {
141 switch (eventId)
142 {
143 case EVENT_INTRO_1:
145 break;
146 case EVENT_INTRO_2:
148 break;
149 case EVENT_INTRO_3:
151 break;
152 case EVENT_INTRO_4:
155 Unit::Kill(me, executus);
156 break;
157 case EVENT_INTRO_5:
160 me->SetImmuneToPC(false);
161 _introState = 2;
162 break;
163 default:
164 break;
165 }
166 }
167 }
168 else
169 {
170 if (_isBanished && ((_emergeTimer <= diff) || (instance->GetData(DATA_RAGNAROS_ADDS)) > 8))
171 {
172 //Become unbanished again
175 me->SetUninteractible(false);
179 AttackStart(target);
181
182 //DoCast(me, SPELL_RAGEMERGE); //"phase spells" didnt worked correctly so Ive commented them and wrote solution witch doesnt need core support
183 _isBanished = false;
184 }
185 else if (_isBanished)
186 {
187 _emergeTimer -= diff;
188 //Do nothing while banished
189 return;
190 }
191
192 //Return since we have no target
193 if (!UpdateVictim())
194 return;
195
196 events.Update(diff);
197
198 while (uint32 eventId = events.ExecuteEvent())
199 {
200 switch (eventId)
201 {
202 case EVENT_ERUPTION:
205 break;
208 if (urand(0, 1))
211 break;
214 if (urand(0, 1))
215 Talk(SAY_HAND);
217 break;
218 case EVENT_LAVA_BURST:
221 break;
225 break;
228 {
231 {
232 //Say our dialog
235 }
236 }
238 break;
239 case EVENT_SUBMERGE:
240 {
241 if (!_isBanished)
242 {
243 //Creature spawning and ragnaros becomming unattackable
244 //is not very well supported in the core //no it really isnt
245 //so added normaly spawning and banish workaround and attack again after 90 secs.
246 me->AttackStop();
250 //Root self
251 //DoCast(me, 23973);
253 me->SetUninteractible(true);
257
259 {
261
262 // summon 8 elementals
263 for (uint8 i = 0; i < 8; ++i)
265 if (Creature* summoned = me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 15min))
266 summoned->AI()->AttackStart(target);
267
268 _hasSubmergedOnce = true;
269 _isBanished = true;
270 //DoCast(me, SPELL_RAGSUBMERGE);
271 _emergeTimer = 90000;
272
273 }
274 else
275 {
277
278 for (uint8 i = 0; i < 8; ++i)
280 if (Creature* summoned = me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 15min))
281 summoned->AI()->AttackStart(target);
282
283 _isBanished = true;
284 //DoCast(me, SPELL_RAGSUBMERGE);
285 _emergeTimer = 90000;
286 }
287 }
289 break;
290 }
291 default:
292 break;
293 }
294 }
295 }
296 }
297
298private:
304};
305
306struct npc_son_of_flame : public ScriptedAI //didnt work correctly in EAI for me...
307{
308 npc_son_of_flame(Creature* creature) : ScriptedAI(creature)
309 {
311 }
312
313 void JustDied(Unit* /*killer*/) override
314 {
316 }
317
318private:
320};
321
323{
326}
Texts
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN
Definition: ObjectDefines.h:64
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
@ EMOTE_ONESHOT_ATTACK1H
@ EMOTE_ONESHOT_EMERGE
@ EMOTE_ONESHOT_SUBMERGE
@ EMOTE_ONESHOT_NONE
@ EMOTE_STATE_SUBMERGED
@ FACTION_FRIENDLY
@ FACTION_MONSTER
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:145
@ SPELL_RAGSUBMERGE
@ SPELL_ELEMENTAL_FIRE
@ SPELL_RAGEMERGE
@ SPELL_WRATH_OF_RAGNAROS
@ SPELL_MAGMA_BLAST
@ SPELL_HAND_OF_RAGNAROS
@ SPELL_LAVA_BURST
@ SPELL_SONS_OF_FLAME_DUMMY
@ SPELL_ERRUPTION
@ SPELL_MELT_WEAPON
void AddSC_boss_ragnaros()
@ SAY_ARRIVAL5_RAG
@ SAY_ARRIVAL2_MAJ
@ SAY_HAND
@ SAY_MAGMABURST
@ SAY_REINFORCEMENTS1
@ SAY_ARRIVAL1_RAG
@ SAY_KILL
@ SAY_REINFORCEMENTS2
@ SAY_ARRIVAL3_RAG
@ SAY_SUMMON_MAJ
@ SAY_WRATH
@ EVENT_INTRO_4
@ EVENT_MAGMA_BLAST
@ EVENT_INTRO_1
@ EVENT_INTRO_2
@ EVENT_INTRO_5
@ EVENT_ELEMENTAL_FIRE
@ EVENT_WRATH_OF_RAGNAROS
@ EVENT_HAND_OF_RAGNAROS
@ EVENT_SUBMERGE
@ EVENT_INTRO_3
@ EVENT_LAVA_BURST
@ EVENT_ERUPTION
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
void Reset() override
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetImmuneToPC(bool apply) override
Definition: Creature.h:170
void SetReactState(ReactStates st)
Definition: Creature.h:160
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
virtual ObjectGuid GetGuidData(uint32 type) const override
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
bool IsWithinMeleeRange(Unit const *obj) const
Definition: Unit.h:699
void SetFaction(uint32 faction) override
Definition: Unit.h:859
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
void SetUninteractible(bool apply)
Definition: Unit.cpp:8147
void SetEmoteState(Emote emote)
Definition: Unit.h:852
Unit * GetVictim() const
Definition: Unit.h:715
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
Definition: Unit.cpp:1598
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:833
bool AttackStop()
Definition: Unit.cpp:5781
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition: Unit.cpp:10591
void RemoveUnitFlag(UnitFlags flags)
Definition: Unit.h:834
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:91
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
#define RegisterMoltenCoreCreatureAI(ai_name)
Definition: molten_core.h:84
@ DATA_RAGNAROS_ADDS
Definition: molten_core.h:75
@ BOSS_RAGNAROS
Definition: molten_core.h:39
@ BOSS_MAJORDOMO_EXECUTUS
Definition: molten_core.h:38
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void AttackStart(Unit *) override
== Triggered Actions Requested ==================
void SetCombatMovement(bool allowMovement)
void ResetThreatList(Unit *who=nullptr)
void JustEngagedWith(Unit *victim) override
void UpdateAI(uint32 diff) override
void KilledUnit(Unit *) override
void Reset() override
boss_ragnaros(Creature *creature)
InstanceScript * instance
npc_son_of_flame(Creature *creature)
void JustDied(Unit *) override