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
|
/*
* This file is part of the TrinityCore 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, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "InstanceScript.h"
#include "SpellScript.h"
#include "SpellInfo.h"
#include "Creature.h"
#include "firelands.h"
#include "GridNotifiers.h"
#include "Vehicle.h"
#include "MotionMaster.h"
enum Spells
{
// Baleroc Trash
SPELL_FLAME_TORRENT = 100795,
SPELL_FIERY_TORMENT = 100797,
SPELL_FIERY_TORMENT_DAMAGE = 100802,
SPELL_EARTHQUAKE = 100724,
SPELL_MAGMA_CONDUIT = 100728,
SPELL_ERUPTION = 100755,
SPELL_SUMMON_MAGMAKIN = 100746,
// Legendary questline
SPELL_SMOULDERING_QUEST_CHECK_A = 101089, // Alliance - Unverified
SPELL_SMOULDERING_QUEST_CHECK_H = 101092 // Horde - Unverified
};
bool DelayedAttackStartEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
_owner->AI()->DoZoneInCombat(_owner);
return true;
}
bool DelayedSpellCastEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
_owner->CastSpell(_target, _spellId, _triggered);
return true;
}
void firelands_bossAI::JustEngagedWith(Unit* target)
{
BossAI::JustEngagedWith(target);
instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
}
void firelands_bossAI::JustDied(Unit* killer)
{
BossAI::JustDied(killer);
instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
me->m_Events.AddEventAtOffset(new DelayedSpellCastEvent(me, static_cast<Unit*>(nullptr), SPELL_SMOULDERING_1, false), 2s);
me->m_Events.AddEventAtOffset(new DelayedSpellCastEvent(me, static_cast<Unit*>(nullptr), SPELL_SMOULDERING_2, false), 2s);
}
void firelands_bossAI::EnterEvadeMode(EvadeReason why)
{
instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
// Copy paste ScriptedAI::EnterEvadeMode functionality to exclude Reset function call
if (!_EnterEvadeMode(why))
return;
if (!me->GetVehicle()) // otherwise me will be in evade mode forever
{
if (Unit* owner = me->GetCharmerOrOwner())
{
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), {}, MOTION_SLOT_ACTIVE);
}
else
{
// Required to prevent attacking creatures that are evading and cause them to reenter combat
// Does not apply to MoveFollow
me->AddUnitState(UNIT_STATE_EVADE);
me->GetMotionMaster()->MoveTargetedHome();
}
}
// Copy paste reason
//Reset();
if (me->IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
me->GetVehicleKit()->Reset(true);
_DespawnAtEvade();
}
// http://www.wowhead.com/npc=54161/flame-archon
struct npc_firelands_flame_archon : public ScriptedAI
{
npc_firelands_flame_archon(Creature* creature) : ScriptedAI(creature)
{
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void JustEngagedWith(Unit* /*attacker*/) override
{
scheduler.Schedule(Seconds(10), Seconds(12), [this](TaskContext context)
{
DoCastAOE(SPELL_FLAME_TORRENT);
context.Repeat(Seconds(15), Seconds(17));
});
scheduler.Schedule(Seconds(25), [this](TaskContext context)
{
DoCastAOE(SPELL_FIERY_TORMENT);
context.Repeat(Seconds(45));
});
}
void JustDied(Unit* killer) override
{
scheduler.CancelAll();
ScriptedAI::JustDied(killer);
}
void EnterEvadeMode(EvadeReason why) override
{
scheduler.CancelAll();
ScriptedAI::EnterEvadeMode(why);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
scheduler.Update(diff);
}
private:
TaskScheduler scheduler;
};
// http://www.wowhead.com/npc=54143/molten-flamefather
struct npc_firelands_molten_flamefather : public ScriptedAI
{
npc_firelands_molten_flamefather(Creature* creature) : ScriptedAI(creature)
{
scheduler.SetValidator([this]
{
return !me->HasUnitState(UNIT_STATE_CASTING);
});
}
void JustSummoned(Creature* summon) override
{
if (summon->GetEntry() != NPC_MAGMA_CONDUIT)
return;
summon->CastSpell(summon, SPELL_SUMMON_MAGMAKIN);
}
void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override
{
if (summon->GetEntry() != NPC_MAGMA_CONDUIT)
return;
summon->DespawnOrUnsummon();
}
void JustEngagedWith(Unit* /*attacker*/) override
{
scheduler.Schedule(Seconds(5), [this](TaskContext context)
{
DoCastAOE(SPELL_MAGMA_CONDUIT);
if (Is25ManRaid())
DoCastAOE(SPELL_MAGMA_CONDUIT);
context.Repeat(Seconds(25));
});
scheduler.Schedule(Milliseconds(12800), [this](TaskContext context)
{
DoCastAOE(SPELL_EARTHQUAKE);
context.Repeat(Milliseconds(32500));
});
}
void JustDied(Unit* killer) override
{
scheduler.CancelAll();
ScriptedAI::JustDied(killer);
}
void EnterEvadeMode(EvadeReason why) override
{
scheduler.CancelAll();
ScriptedAI::EnterEvadeMode(why);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
scheduler.Update(diff);
}
private:
TaskScheduler scheduler;
};
// http://www.wowhead.com/npc=54144/magmakin
struct npc_firelands_magmakin : public ScriptedAI
{
npc_firelands_magmakin(Creature* creature) : ScriptedAI(creature)
{
me->SetCanMelee(false); // DoSpellAttackIfReady
}
void IsSummonedBy(WorldObject* /*summoner*/) override
{
//Not actually sniffed behavior
Unit* target = me->SelectNearestTarget(50.0f, true);
if (!target)
return;
AddThreat(target, 50000000.0f);
// TODO: Fixate mechanic
}
void UpdateAI(uint32 /*diff*/) override
{
if (!UpdateVictim())
return;
DoSpellAttackIfReady(SPELL_ERUPTION);
}
};
// http://www.wowhead.com/spell=100799/fiery-torment
class spell_firelands_fiery_torment : public SpellScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_FIERY_TORMENT_DAMAGE });
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
GetCaster()->CastSpell(GetHitUnit(), SPELL_FIERY_TORMENT_DAMAGE, true);
}
void FilterTargets(std::list<WorldObject*>& targets)
{
if (targets.empty())
return;
targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster(), true));
targets.resize(1);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_firelands_fiery_torment::HandleScript, EFFECT_0, SPELL_EFFECT_DUMMY);
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_firelands_fiery_torment::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
}
};
// http://www.wowhead.com/spell=101089/smouldering
// http://www.wowhead.com/spell=101092/smouldering
class spell_firelands_smouldering : public SpellScript
{
void CheckQuestStatus(std::list<WorldObject*>& targets)
{
uint32 questId = 0;
switch (GetSpellInfo()->Id)
{
case SPELL_SMOULDERING_QUEST_CHECK_A:
questId = QUEST_HEART_OF_FLAME_A;
break;
case SPELL_SMOULDERING_QUEST_CHECK_H:
questId = QUEST_HEART_OF_FLAME_H;
break;
default:
break;
}
bool raidHasQuest = targets.end() != std::find_if(targets.begin(), targets.end(), [questId](WorldObject* worldObject)
{
if (Player* player = worldObject->ToPlayer())
if (player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE)
return true;
return false;
});
targets.clear();
if (raidHasQuest)
targets.push_back(GetCaster());
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_firelands_smouldering::CheckQuestStatus, EFFECT_0, TARGET_UNIT_SRC_AREA_ENTRY);
}
};
// http://www.wowhead.com/spell=101093/smouldering
class spell_firelands_smouldering_aura : public SpellScript
{
void SetTarget(WorldObject*& target)
{
target = GetCaster();
}
void Register() override
{
OnObjectTargetSelect += SpellObjectTargetSelectFn(spell_firelands_smouldering_aura::SetTarget, EFFECT_0, TARGET_UNIT_NEARBY_ENTRY);
}
};
void AddSC_firelands()
{
RegisterFirelandsAI(npc_firelands_flame_archon);
RegisterFirelandsAI(npc_firelands_molten_flamefather);
RegisterFirelandsAI(npc_firelands_magmakin);
RegisterSpellScript(spell_firelands_fiery_torment);
RegisterSpellScript(spell_firelands_smouldering);
RegisterSpellScript(spell_firelands_smouldering_aura);
}
|