TrinityCore
firelands.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#include "ScriptMgr.h"
19#include "InstanceScript.h"
20#include "SpellScript.h"
21#include "SpellInfo.h"
22#include "Creature.h"
23#include "firelands.h"
24#include "GridNotifiers.h"
25#include "Vehicle.h"
26#include "MotionMaster.h"
27
29{
30 // Baleroc Trash
38
39 // Legendary questline
40 SPELL_SMOULDERING_QUEST_CHECK_A = 101089, // Alliance - Unverified
41 SPELL_SMOULDERING_QUEST_CHECK_H = 101092 // Horde - Unverified
42};
43
45{
47 return true;
48}
49
50bool DelayedSpellCastEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
51{
53 return true;
54}
55
57{
60}
61
63{
64 BossAI::JustDied(killer);
66 me->m_Events.AddEventAtOffset(new DelayedSpellCastEvent(me, static_cast<Unit*>(nullptr), SPELL_SMOULDERING_1, false), 2s);
67 me->m_Events.AddEventAtOffset(new DelayedSpellCastEvent(me, static_cast<Unit*>(nullptr), SPELL_SMOULDERING_2, false), 2s);
68}
69
71{
73
74 // Copy paste ScriptedAI::EnterEvadeMode functionality to exclude Reset function call
75 if (!_EnterEvadeMode(why))
76 return;
77
78 if (!me->GetVehicle()) // otherwise me will be in evade mode forever
79 {
80 if (Unit* owner = me->GetCharmerOrOwner())
81 {
84 }
85 else
86 {
87 // Required to prevent attacking creatures that are evading and cause them to reenter combat
88 // Does not apply to MoveFollow
91 }
92 }
93
94 // Copy paste reason
95 //Reset();
96
97 if (me->IsVehicle()) // use the same sequence of addtoworld, aireset may remove all summons!
98 me->GetVehicleKit()->Reset(true);
99
101}
102
103// http://www.wowhead.com/npc=54161/flame-archon
105{
107 {
109 {
111 });
112 }
113
114 void JustEngagedWith(Unit* /*attacker*/) override
115 {
116 scheduler.Schedule(Seconds(10), Seconds(12), [this](TaskContext context)
117 {
119 context.Repeat(Seconds(15), Seconds(17));
120 });
121 scheduler.Schedule(Seconds(25), [this](TaskContext context)
122 {
124 context.Repeat(Seconds(45));
125 });
126 }
127
128 void JustDied(Unit* killer) override
129 {
131 ScriptedAI::JustDied(killer);
132 }
133
134 void EnterEvadeMode(EvadeReason why) override
135 {
138 }
139
140 void UpdateAI(uint32 diff) override
141 {
142 if (!UpdateVictim())
143 return;
144
145 scheduler.Update(diff);
146 }
147
148private:
150};
151
152// http://www.wowhead.com/npc=54143/molten-flamefather
154{
156 {
158 {
160 });
161 }
162
163 void JustSummoned(Creature* summon) override
164 {
165 if (summon->GetEntry() != NPC_MAGMA_CONDUIT)
166 return;
167
168 summon->CastSpell(summon, SPELL_SUMMON_MAGMAKIN);
169 }
170
171 void SummonedCreatureDies(Creature* summon, Unit* /*killer*/) override
172 {
173 if (summon->GetEntry() != NPC_MAGMA_CONDUIT)
174 return;
175
176 summon->DespawnOrUnsummon();
177 }
178
179 void JustEngagedWith(Unit* /*attacker*/) override
180 {
181 scheduler.Schedule(Seconds(5), [this](TaskContext context)
182 {
184 if (Is25ManRaid())
186 context.Repeat(Seconds(25));
187 });
188 scheduler.Schedule(Milliseconds(12800), [this](TaskContext context)
189 {
191 context.Repeat(Milliseconds(32500));
192 });
193 }
194
195 void JustDied(Unit* killer) override
196 {
198 ScriptedAI::JustDied(killer);
199 }
200
201 void EnterEvadeMode(EvadeReason why) override
202 {
205 }
206
207 void UpdateAI(uint32 diff) override
208 {
209 if (!UpdateVictim())
210 return;
211
212 scheduler.Update(diff);
213 }
214
215private:
217};
218
219// http://www.wowhead.com/npc=54144/magmakin
221{
223 {
224 me->SetCanMelee(false); // DoSpellAttackIfReady
225 }
226
227 void IsSummonedBy(WorldObject* /*summoner*/) override
228 {
229 //Not actually sniffed behavior
230 Unit* target = me->SelectNearestTarget(50.0f, true);
231 if (!target)
232 return;
233
234 AddThreat(target, 50000000.0f);
235 // TODO: Fixate mechanic
236 }
237
238 void UpdateAI(uint32 /*diff*/) override
239 {
240 if (!UpdateVictim())
241 return;
242
244 }
245};
246
247// http://www.wowhead.com/spell=100799/fiery-torment
249{
250 bool Validate(SpellInfo const* /*spellInfo*/) override
251 {
253 }
254
255 void HandleScript(SpellEffIndex /*effIndex*/)
256 {
258 }
259
260 void FilterTargets(std::list<WorldObject*>& targets)
261 {
262 if (targets.empty())
263 return;
264
265 targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster(), true));
266 targets.resize(1);
267 }
268
269 void Register() override
270 {
273 }
274};
275
276// http://www.wowhead.com/spell=101089/smouldering
277// http://www.wowhead.com/spell=101092/smouldering
279{
280 void CheckQuestStatus(std::list<WorldObject*>& targets)
281 {
282 uint32 questId = 0;
283 switch (GetSpellInfo()->Id)
284 {
286 questId = QUEST_HEART_OF_FLAME_A;
287 break;
289 questId = QUEST_HEART_OF_FLAME_H;
290 break;
291 default:
292 break;
293 }
294
295 bool raidHasQuest = targets.end() != std::find_if(targets.begin(), targets.end(), [questId](WorldObject* worldObject)
296 {
297 if (Player* player = worldObject->ToPlayer())
298 if (player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE)
299 return true;
300
301 return false;
302 });
303
304 targets.clear();
305 if (raidHasQuest)
306 targets.push_back(GetCaster());
307 }
308
309 void Register() override
310 {
312 }
313};
314
315// http://www.wowhead.com/spell=101093/smouldering
317{
318 void SetTarget(WorldObject*& target)
319 {
320 target = GetCaster();
321 }
322
323 void Register() override
324 {
326 }
327};
328
330{
337}
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
@ MOTION_SLOT_ACTIVE
#define PET_FOLLOW_DIST
Definition: PetDefines.h:97
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENTRY
@ TARGET_UNIT_SRC_AREA_ENEMY
@ TARGET_UNIT_NEARBY_ENTRY
@ SPELL_EFFECT_DUMMY
#define SpellObjectTargetSelectFn(F, I, N)
Definition: SpellScript.h:869
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:864
EvadeReason
Definition: UnitAICommon.h:30
@ UNIT_STATE_EVADE
Definition: Unit.h:277
@ UNIT_STATE_CASTING
Definition: Unit.h:270
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void JustDied(Unit *) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
void DoZoneInCombat()
Definition: CreatureAI.h:161
virtual void JustDied(Unit *)
Definition: CreatureAI.h:105
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:299
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
Definition: Creature.cpp:2822
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
Definition: Creature.cpp:2415
Unit * SelectNearestTarget(float dist=0, bool playerOnly=false) const
Definition: Creature.cpp:2493
CreatureAI * AI() const
Definition: Creature.h:214
bool Execute(uint64, uint32) override
Definition: firelands.cpp:44
bool Execute(uint64, uint32) override
Definition: firelands.cpp:50
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
void MoveFollow(Unit *target, float dist, ChaseAngle angle, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_ACTIVE)
void MoveTargetedHome()
uint32 GetEntry() const
Definition: Object.h:161
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
Definition: SpellScript.h:868
SpellInfo const * GetSpellInfo() const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition: SpellScript.h:863
TaskContext & Repeat(std::chrono::duration< Rep, Period > duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< Rep, Period > time, task_handler_t task)
TaskScheduler & Update(success_t const &callback=nullptr)
TaskScheduler & SetValidator(P &&predicate)
Sets a validator which is asked if tasks are allowed to be executed.
bool DoSpellAttackIfReady(uint32 spellId)
Definition: UnitAI.cpp:61
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
Definition: Unit.h:627
bool IsVehicle() const
Definition: Unit.h:743
Vehicle * GetVehicle() const
Definition: Unit.h:1713
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void AddUnitState(uint32 f)
Definition: Unit.h:731
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1200
virtual float GetFollowAngle() const
Definition: Unit.h:1744
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
Vehicle * GetVehicleKit() const
Definition: Unit.h:1711
void Reset(bool evading=false)
Reapplies immunities and reinstalls accessories. Only has effect for creatures.
Definition: Vehicle.cpp:138
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
EventProcessor m_Events
Definition: Object.h:777
bool Validate(SpellInfo const *) override
Definition: firelands.cpp:250
void HandleScript(SpellEffIndex)
Definition: firelands.cpp:255
void FilterTargets(std::list< WorldObject * > &targets)
Definition: firelands.cpp:260
void SetTarget(WorldObject *&target)
Definition: firelands.cpp:318
void Register() override
Definition: firelands.cpp:309
void CheckQuestStatus(std::list< WorldObject * > &targets)
Definition: firelands.cpp:280
@ SPELL_FIERY_TORMENT_DAMAGE
Definition: firelands.cpp:33
@ SPELL_EARTHQUAKE
Definition: firelands.cpp:34
@ SPELL_FIERY_TORMENT
Definition: firelands.cpp:32
@ SPELL_SUMMON_MAGMAKIN
Definition: firelands.cpp:37
@ SPELL_SMOULDERING_QUEST_CHECK_A
Definition: firelands.cpp:40
@ SPELL_MAGMA_CONDUIT
Definition: firelands.cpp:35
@ SPELL_ERUPTION
Definition: firelands.cpp:36
@ SPELL_SMOULDERING_QUEST_CHECK_H
Definition: firelands.cpp:41
@ SPELL_FLAME_TORRENT
Definition: firelands.cpp:31
void AddSC_firelands()
Definition: firelands.cpp:329
@ NPC_MAGMA_CONDUIT
Definition: firelands.h:63
@ QUEST_HEART_OF_FLAME_H
Definition: firelands.h:81
@ QUEST_HEART_OF_FLAME_A
Definition: firelands.h:80
#define RegisterFirelandsAI(AI)
Definition: firelands.h:133
@ SPELL_SMOULDERING_2
Definition: firelands.h:75
@ SPELL_SMOULDERING_1
Definition: firelands.h:74
bool Is25ManRaid() const
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void JustEngagedWith(Unit *target) override
Definition: firelands.cpp:56
void JustDied(Unit *killer) override
Definition: firelands.cpp:62
void EnterEvadeMode(EvadeReason why) override
Definition: firelands.cpp:70
void EnterEvadeMode(EvadeReason why) override
Definition: firelands.cpp:134
void JustEngagedWith(Unit *) override
Definition: firelands.cpp:114
void UpdateAI(uint32 diff) override
Definition: firelands.cpp:140
void JustDied(Unit *killer) override
Definition: firelands.cpp:128
npc_firelands_flame_archon(Creature *creature)
Definition: firelands.cpp:106
void UpdateAI(uint32) override
Definition: firelands.cpp:238
npc_firelands_magmakin(Creature *creature)
Definition: firelands.cpp:222
void IsSummonedBy(WorldObject *) override
Definition: firelands.cpp:227
void UpdateAI(uint32 diff) override
Definition: firelands.cpp:207
npc_firelands_molten_flamefather(Creature *creature)
Definition: firelands.cpp:155
void SummonedCreatureDies(Creature *summon, Unit *) override
Definition: firelands.cpp:171
void EnterEvadeMode(EvadeReason why) override
Definition: firelands.cpp:201
void JustDied(Unit *killer) override
Definition: firelands.cpp:195
void JustEngagedWith(Unit *) override
Definition: firelands.cpp:179
void JustSummoned(Creature *summon) override
Definition: firelands.cpp:163