-
Notifications
You must be signed in to change notification settings - Fork 294
/
boss_ragnaros.cpp
353 lines (312 loc) · 12.5 KB
/
boss_ragnaros.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/* This file is part of the ScriptDev2 Project. See AUTHORS file for Copyright information
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* ScriptData
SDName: Boss_Ragnaros
SD%Complete: 99
SDComment: Submerge emote is not played
SDCategory: Molten Core
EndScriptData */
#include "AI/ScriptDevAI/include/precompiled.h"
#include "molten_core.h"
enum
{
SAY_ARRIVAL5_RAG = -1409012,
SAY_REINFORCEMENTS_1 = -1409013,
SAY_REINFORCEMENTS_2 = -1409014,
SAY_HAMMER = -1409015,
SAY_WRATH = -1409016,
SAY_KILL = -1409017,
SAY_MAGMABURST = -1409018,
SPELL_WRATH_OF_RAGNAROS = 20566,
SPELL_ELEMENTAL_FIRE = 20563, // Aura, proc spell 20564 when doing melee damage
SPELL_MAGMA_BLAST = 20565, // Ranged attack if nobody is in melee range
SPELL_MELT_WEAPON = 21387,
SPELL_RAGNA_SUBMERGE = 21107, // Stealth aura
SPELL_RAGNA_EMERGE = 20568, // Emerge from lava
SPELL_SUBMERGE_EFFECT = 21859, // Make Ragnaros immune and passive while submerged
SPELL_ELEMENTAL_FIRE_KILL = 19773,
SPELL_MIGHT_OF_RAGNAROS = 21154,
SPELL_INTENSE_HEAT = 21155,
SPELL_LAVA_BURST = 21908, // Randomly trigger one of spells 21886, 21900 - 21907 which summons Go 178088
SPELL_SUMMON_SONS_FLAME = 21108, // Trigger the eight spells summoning the Son of Flame adds
NB_ADDS_IN_SUBMERGE = 8,
NPC_SON_OF_FLAME = 12143,
NPC_FLAME_OF_RAGNAROS = 13148,
};
struct boss_ragnarosAI : public Scripted_NoMovementAI
{
boss_ragnarosAI(Creature* pCreature) : Scripted_NoMovementAI(pCreature)
{
m_pInstance = (instance_molten_core*)pCreature->GetInstanceData();
m_uiEnterCombatTimer = 0;
m_bHasAggroYelled = false;
Reset();
}
instance_molten_core* m_pInstance;
uint32 m_uiEnterCombatTimer;
uint32 m_uiWrathOfRagnarosTimer;
uint32 m_uiHammerTimer;
uint32 m_uiMagmaBlastTimer;
uint32 m_uiSubmergeTimer;
uint32 m_uiLavaBurstTimer;
uint32 m_uiAttackTimer;
uint32 m_uiAddCount;
bool m_bHasAggroYelled;
bool m_bHasYelledMagmaBurst;
bool m_bHasSubmergedOnce;
bool m_bIsSubmerged;
void Reset() override
{
m_uiWrathOfRagnarosTimer = 30000;
m_uiHammerTimer = 11000;
m_uiMagmaBlastTimer = 2000;
m_uiLavaBurstTimer = 20 * IN_MILLISECONDS;
m_uiSubmergeTimer = 3 * MINUTE * IN_MILLISECONDS;
m_uiAttackTimer = 90 * IN_MILLISECONDS;
m_uiAddCount = 0;
m_bHasYelledMagmaBurst = false;
m_bHasSubmergedOnce = false;
m_bIsSubmerged = false;
}
void KilledUnit(Unit* pVictim) override
{
if (pVictim->GetTypeId() != TYPEID_PLAYER)
return;
if (urand(0, 3))
return;
DoScriptText(SAY_KILL, m_creature);
}
void JustDied(Unit* /*pKiller*/) override
{
if (m_pInstance)
m_pInstance->SetData(TYPE_RAGNAROS, DONE);
}
void Aggro(Unit* pWho) override
{
if (pWho->GetTypeId() == TYPEID_UNIT && pWho->GetEntry() == NPC_MAJORDOMO)
return;
DoCastSpellIfCan(m_creature, SPELL_MELT_WEAPON);
DoCastSpellIfCan(m_creature, SPELL_ELEMENTAL_FIRE);
if (m_pInstance)
m_pInstance->SetData(TYPE_RAGNAROS, IN_PROGRESS);
}
void EnterEvadeMode() override
{
if (m_pInstance)
m_pInstance->SetData(TYPE_RAGNAROS, FAIL);
// Reset flag if Ragnaros had been submerged
if (m_bIsSubmerged)
DoCastSpellIfCan(m_creature, SPELL_RAGNA_EMERGE);
if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
ScriptedAI::EnterEvadeMode();
}
void SummonedCreatureJustDied(Creature* pSummmoned) override
{
// If all Sons of Flame are dead, trigger emerge
if (pSummmoned->GetEntry() == NPC_SON_OF_FLAME)
{
m_uiAddCount--;
// If last add killed then emerge soonish
if (m_uiAddCount == 0)
m_uiAttackTimer = std::min(m_uiAttackTimer, (uint32)1000);
}
}
void JustSummoned(Creature* pSummoned) override
{
if (pSummoned->GetEntry() == NPC_SON_OF_FLAME)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
pSummoned->AI()->AttackStart(pTarget);
}
else if (pSummoned->GetEntry() == NPC_FLAME_OF_RAGNAROS)
pSummoned->CastSpell(pSummoned, SPELL_INTENSE_HEAT, TRIGGERED_OLD_TRIGGERED, NULL, NULL, m_creature->GetObjectGuid());
}
void SpellHitTarget(Unit* pTarget, const SpellEntry* pSpell) override
{
// As Majordomo is now killed, the last timer (until attacking) must be handled with ragnaros script
if (pSpell->Id == SPELL_ELEMENTAL_FIRE_KILL && pTarget->GetTypeId() == TYPEID_UNIT && pTarget->GetEntry() == NPC_MAJORDOMO)
m_uiEnterCombatTimer = 10000;
}
// Custom threat management for targets in melee range
bool CanMeleeTargetInRange()
{
// If a target is found in melee range (descending threat), attack it
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 0, uint32(0), SELECT_FLAG_IN_MELEE_RANGE))
{
// Target is not current victim, force select and attack it
if (pTarget != m_creature->getVictim())
{
AttackStart(pTarget);
m_creature->SetInFront(pTarget);
}
// Make sure our attack is ready
if (m_creature->isAttackReady())
{
m_creature->AttackerStateUpdate(pTarget);
m_creature->resetAttackTimer();
m_bHasYelledMagmaBurst = false;
}
return true;
}
return false;
}
void UpdateAI(const uint32 uiDiff) override
{
if (m_uiEnterCombatTimer)
{
if (m_uiEnterCombatTimer <= uiDiff)
{
if (!m_bHasAggroYelled)
{
m_uiEnterCombatTimer = 3000;
m_bHasAggroYelled = true;
DoScriptText(SAY_ARRIVAL5_RAG, m_creature);
}
else
{
m_uiEnterCombatTimer = 0;
// If we don't remove this passive flag, he will be unattackable after evading, this way he will enter combat
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
if (m_pInstance)
{
if (Player* pPlayer = m_pInstance->GetPlayerInMap(true, false))
{
m_creature->AI()->AttackStart(pPlayer);
return;
}
}
}
}
else
m_uiEnterCombatTimer -= uiDiff;
}
// Return since we have no target
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
if (m_bIsSubmerged)
{
// Timer to check when Ragnaros should emerge (is set to soonish, when last add is killed)
if (m_uiAttackTimer < uiDiff)
{
// Become emerged again
m_creature->RemoveAurasDueToSpell(SPELL_RAGNA_SUBMERGE);
m_creature->RemoveAurasDueToSpell(SPELL_SUBMERGE_EFFECT);
DoCastSpellIfCan(m_creature, SPELL_RAGNA_EMERGE);
m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
m_uiSubmergeTimer = 3 * MINUTE * IN_MILLISECONDS;
m_uiMagmaBlastTimer = 3000; // Delay the magma blast after emerge
m_bIsSubmerged = false;
}
else
m_uiAttackTimer -= uiDiff;
// Do nothing while submerged
return;
}
// Wrath Of Ragnaros Timer
if (m_uiWrathOfRagnarosTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_WRATH_OF_RAGNAROS) == CAST_OK)
{
DoScriptText(SAY_WRATH, m_creature);
m_uiWrathOfRagnarosTimer = 25000;
}
}
else
m_uiWrathOfRagnarosTimer -= uiDiff;
// Lava Burst Timer
if (m_uiLavaBurstTimer < uiDiff)
{
if (DoCastSpellIfCan(m_creature, SPELL_LAVA_BURST) == CAST_OK)
m_uiLavaBurstTimer = urand(5000, 25000); // Upper value is guess work based on videos. It could be up to 45 secs
}
else
m_uiLavaBurstTimer -= uiDiff;
// Hammer of Ragnaros
if (m_uiHammerTimer < uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, SPELL_MIGHT_OF_RAGNAROS, SELECT_FLAG_POWER_MANA))
{
if (DoCastSpellIfCan(pTarget, SPELL_MIGHT_OF_RAGNAROS) == CAST_OK)
{
DoScriptText(SAY_HAMMER, m_creature);
m_uiHammerTimer = urand(11000, 30000);
}
}
else
m_uiHammerTimer = urand(11000, 30000);
}
else
m_uiHammerTimer -= uiDiff;
// Submerge Timer
if (m_uiSubmergeTimer < uiDiff)
{
// Submerge and attack again after 90 secs
m_creature->HandleEmote(EMOTE_ONESHOT_SUBMERGE);
DoCastSpellIfCan(m_creature, SPELL_RAGNA_SUBMERGE, CAST_INTERRUPT_PREVIOUS);
m_bIsSubmerged = true;
m_uiAttackTimer = 90 * IN_MILLISECONDS;
DoCastSpellIfCan(m_creature, SPELL_SUBMERGE_EFFECT, CAST_INTERRUPT_PREVIOUS);
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
// Say dependend if first time or not
DoScriptText(!m_bHasSubmergedOnce ? SAY_REINFORCEMENTS_1 : SAY_REINFORCEMENTS_2, m_creature);
m_bHasSubmergedOnce = true;
// Summon 8 elementals around the boss
if (DoCastSpellIfCan(m_creature, SPELL_SUMMON_SONS_FLAME) == CAST_OK)
m_uiAddCount = NB_ADDS_IN_SUBMERGE;
return;
}
else
m_uiSubmergeTimer -= uiDiff;
// Range check for melee target, if nobody is found in range, then cast magma blast on random target
// If we are within range melee the target (done in CanMeleeTargetInRange())
if (m_creature->IsNonMeleeSpellCasted(false) || !m_creature->getVictim())
return;
if (!CanMeleeTargetInRange())
{
// Magma Burst Timer
if (m_uiMagmaBlastTimer < uiDiff)
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
{
if (DoCastSpellIfCan(pTarget, SPELL_MAGMA_BLAST) == CAST_OK)
{
if (!m_bHasYelledMagmaBurst)
{
DoScriptText(SAY_MAGMABURST, m_creature);
m_bHasYelledMagmaBurst = true;
}
m_uiMagmaBlastTimer = 1000; // Spamm this!
}
}
}
else
m_uiMagmaBlastTimer -= uiDiff;
}
}
};
CreatureAI* GetAI_boss_ragnaros(Creature* pCreature)
{
return new boss_ragnarosAI(pCreature);
}
void AddSC_boss_ragnaros()
{
Script* pNewScript;
pNewScript = new Script;
pNewScript->Name = "boss_ragnaros";
pNewScript->GetAI = &GetAI_boss_ragnaros;
pNewScript->RegisterSelf();
}