Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_ragnaros.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/* ScriptData
7SDName: Boss_Ragnaros
8SD%Complete: 95
9SDComment: some spells doesnt work correctly
10SDCategory: Molten Core
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "ScriptedCreature.h"
15#include "molten_core.h"
16
31
33{
37 SPELL_MAGMA_BLAST = 20565, // Ranged attack
38 SPELL_SONS_OF_FLAME_DUMMY = 21108, // Server side effect
39 SPELL_RAGSUBMERGE = 21107, // Stealth aura
44};
45
62
64{
65 public:
66 boss_ragnaros() : CreatureScript("boss_ragnaros") { }
67
68 struct boss_ragnarosAI : public BossAI
69 {
71 {
72 _introState = 0;
73 me->SetReactState(REACT_PASSIVE);
75 }
76
78 {
80 _emergeTimer = 90000;
82 _hasSubmergedOnce = false;
83 _isBanished = false;
84 me->SetUInt32Value(UNIT_FIELD_NPC_EMOTESTATE, 0);
85 }
86
88 {
89 BossAI::EnterCombat(victim);
90 events.ScheduleEvent(EVENT_ERUPTION, 15000);
91 events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 30000);
92 events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 25000);
93 events.ScheduleEvent(EVENT_LAVA_BURST, 10000);
94 events.ScheduleEvent(EVENT_ELEMENTAL_FIRE, 3000);
95 events.ScheduleEvent(EVENT_MAGMA_BLAST, 2000);
96 events.ScheduleEvent(EVENT_SUBMERGE, 180000);
97 }
98
99 void KilledUnit(Unit* /*victim*/) OVERRIDE
100 {
101 if ((std::rand() % 99) < 25)
102 Talk(SAY_KILL);
103 }
104
106 {
107 if (_introState != 2)
108 {
109 if (!_introState)
110 {
111 me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
112 events.ScheduleEvent(EVENT_INTRO_1, 4000);
113 events.ScheduleEvent(EVENT_INTRO_2, 23000);
114 events.ScheduleEvent(EVENT_INTRO_3, 42000);
115 events.ScheduleEvent(EVENT_INTRO_4, 43000);
116 events.ScheduleEvent(EVENT_INTRO_5, 53000);
117 _introState = 1;
118 }
119
120 events.Update(diff);
121
122 while (uint32 eventId = events.ExecuteEvent())
123 {
124 switch (eventId)
125 {
126 case EVENT_INTRO_1:
128 break;
129 case EVENT_INTRO_2:
131 break;
132 case EVENT_INTRO_3:
133 me->HandleEmoteCommand(EMOTE_ONESHOT_ATTACK1H);
134 break;
135 case EVENT_INTRO_4:
137 if (instance)
138 if (Creature* executus = Unit::GetCreature(*me, instance->GetData64(BOSS_MAJORDOMO_EXECUTUS)))
139 me->Kill(executus);
140 break;
141 case EVENT_INTRO_5:
142 me->SetReactState(REACT_AGGRESSIVE);
144 _introState = 2;
145 break;
146 default:
147 break;
148 }
149 }
150 }
151 else
152 {
153 if (instance)
154 {
155 if (_isBanished && ((_emergeTimer <= diff) || (instance->GetData(DATA_RAGNAROS_ADDS)) > 8))
156 {
157 //Become unbanished again
158 me->SetReactState(REACT_AGGRESSIVE);
159 me->setFaction(14);
161 me->SetUInt32Value(UNIT_FIELD_NPC_EMOTESTATE, 0);
162 me->HandleEmoteCommand(EMOTE_ONESHOT_EMERGE);
163 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
164 AttackStart(target);
165 instance->SetData(DATA_RAGNAROS_ADDS, 0);
166
167 //DoCast(me, SPELL_RAGEMERGE); //"phase spells" didnt worked correctly so Ive commented them and wrote solution witch doesnt need core support
168 _isBanished = false;
169 }
170 else if (_isBanished)
171 {
172 _emergeTimer -= diff;
173 //Do nothing while banished
174 return;
175 }
176 }
177
178 //Return since we have no target
179 if (!UpdateVictim())
180 return;
181
182 events.Update(diff);
183
184 while (uint32 eventId = events.ExecuteEvent())
185 {
186 switch (eventId)
187 {
188 case EVENT_ERUPTION:
190 events.ScheduleEvent(EVENT_ERUPTION, std::rand() % 45000 + 20000);
191 break;
194 if (std::rand() % 1)
196 events.ScheduleEvent(EVENT_WRATH_OF_RAGNAROS, 25000);
197 break;
200 if (std::rand() % 1)
201 Talk(SAY_HAND);
202 events.ScheduleEvent(EVENT_HAND_OF_RAGNAROS, 20000);
203 break;
204 case EVENT_LAVA_BURST:
206 events.ScheduleEvent(EVENT_LAVA_BURST, 10000);
207 break;
210 events.ScheduleEvent(EVENT_ELEMENTAL_FIRE, std::rand() % 14000 + 10000);
211 break;
213 if (me->IsWithinMeleeRange(me->GetVictim()))
214 {
217 {
218 //Say our dialog
221 }
222 }
223 events.ScheduleEvent(EVENT_MAGMA_BLAST, 2500);
224 break;
225 case EVENT_SUBMERGE:
226 {
227 if (instance && !_isBanished)
228 {
229 //Creature spawning and ragnaros becomming unattackable
230 //is not very well supported in the core //no it really isnt
231 //so added normaly spawning and banish workaround and attack again after 90 secs.
232 me->AttackStop();
234 me->SetReactState(REACT_PASSIVE);
235 me->InterruptNonMeleeSpells(false);
236 //Root self
237 //DoCast(me, 23973);
238 me->setFaction(35);
241 me->HandleEmoteCommand(EMOTE_ONESHOT_SUBMERGE);
242 instance->SetData(DATA_RAGNAROS_ADDS, 0);
243
245 {
247
248 // summon 8 elementals
249 for (uint8 i = 0; i < 8; ++i)
250 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
251 if (Creature* summoned = me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TempSummonType::TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 900000))
252 summoned->AI()->AttackStart(target);
253
254 _hasSubmergedOnce = true;
255 _isBanished = true;
256 //DoCast(me, SPELL_RAGSUBMERGE);
257 _emergeTimer = 90000;
258 }
259 else
260 {
262
263 for (uint8 i = 0; i < 8; ++i)
264 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
265 if (Creature* summoned = me->SummonCreature(12143, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TempSummonType::TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 900000))
266 summoned->AI()->AttackStart(target);
267
268 _isBanished = true;
269 //DoCast(me, SPELL_RAGSUBMERGE);
270 _emergeTimer = 90000;
271 }
272 }
273 events.ScheduleEvent(EVENT_SUBMERGE, 180000);
274 break;
275 }
276 default:
277 break;
278 }
279 }
280
282 }
283 }
284
285 private:
291 };
292
294 {
295 return new boss_ragnarosAI(creature);
296 }
297};
298
300{
301 public:
302 npc_son_of_flame() : CreatureScript("npc_SonOfFlame") { }
303
304 struct npc_son_of_flameAI : public ScriptedAI //didnt work correctly in EAI for me...
305 {
307 {
308 instance = me->GetInstanceScript();
309 }
310
311 void JustDied(Unit* /*killer*/) OVERRIDE
312 {
313 if (instance)
314 instance->SetData(DATA_RAGNAROS_ADDS, 1);
315 }
316
317 void UpdateAI(uint32 /*diff*/) OVERRIDE
318 {
319 if (!UpdateVictim())
320 return;
321
323 }
324
325 private:
327 };
328
330 {
331 return new npc_son_of_flameAI(creature);
332 }
333};
334
336{
337 new boss_ragnaros();
338 new npc_son_of_flame();
339}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN
Definition Object.h:69
@ EMOTE_ONESHOT_ATTACK1H
@ EMOTE_ONESHOT_EMERGE
@ EMOTE_ONESHOT_SUBMERGE
@ EMOTE_STATE_SUBMERGED
@ REACT_PASSIVE
Definition Unit.h:1156
@ REACT_AGGRESSIVE
Definition Unit.h:1158
@ UNIT_FLAG_NON_ATTACKABLE
Definition Unit.h:626
@ UNIT_FLAG_NOT_SELECTABLE
Definition Unit.h:650
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
@ UNIT_FIELD_FLAGS
@ UNIT_FIELD_NPC_EMOTESTATE
#define SAY_KILL
@ 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_HAND
@ SAY_MAGMABURST
@ SAY_REINFORCEMENTS1
@ SAY_ARRIVAL1_RAG
@ SAY_KILL
@ SAY_REINFORCEMENTS2
@ SAY_ARRIVAL3_RAG
@ 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
EventMap events
void Reset() OVERRIDE
BossAI(Creature *creature, uint32 bossId)
void EnterCombat(Unit *) OVERRIDE
void Talk(uint8 id, WorldObject const *whisperTarget=NULL)
bool UpdateVictim()
CreatureScript(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
Definition Unit.h:1367
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition Unit.cpp:4905
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
@ BOSS_RAGNAROS
Definition molten_core.h:20
@ BOSS_MAJORDOMO_EXECUTUS
Definition molten_core.h:19
@ DATA_RAGNAROS_ADDS
Definition molten_core.h:56
Creature * me
ScriptedAI(Creature *creature)
void AttackStart(Unit *) OVERRIDE
void EnterCombat(Unit *victim) OVERRIDE
void KilledUnit(Unit *) OVERRIDE
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
boss_ragnarosAI(Creature *creature)
void UpdateAI(uint32) OVERRIDE
== Triggered Actions Requested ==================