TrinityCore
boss_cragmaw_the_infested.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 "AreaTrigger.h"
19#include "AreaTriggerAI.h"
20#include "CreatureAI.h"
21#include "CreatureAIImpl.h"
22#include "InstanceScript.h"
23#include "Map.h"
24#include "MotionMaster.h"
25#include "ObjectAccessor.h"
26#include "ScriptMgr.h"
27#include "ScriptedCreature.h"
28#include "SpellAuraEffects.h"
29#include "SpellScript.h"
30#include "SpellAuras.h"
31#include "SharedDefines.h"
32#include "TemporarySummon.h"
33#include "underrot.h"
34
36{
37 // Cragmaw
44
45 // Larva
50
51 // Blood Tick
54
55 // Fetid Maggot
56 SPELL_FEIGN_DEATH = 159474
57};
58
60{
61 // Cragmaw
66
67 // Blood Tick
69};
70
72{
74};
75
77{
78 NPC_FETID_MAGGOT = 130909
79};
80
81Position const FetidMaggotSpawn = { 857.864f, 984.981f, 39.231f, 4.68147f };
82
83// 131817 - Cragmaw the Infested
85{
87
88 void JustDied(Unit* /*killer*/) override
89 {
90 _JustDied();
92 }
93
94 void JustAppeared() override
95 {
98
100 return;
101
105 {
106 _fetidMaggotGuid = summon->GetGUID();
107 summon->CastSpell(nullptr, SPELL_FEIGN_DEATH, true);
108 }
109 }
110
111 void EnterEvadeMode(EvadeReason /*why*/) override
112 {
117 }
118
120 {
121 events.Reset();
122
125
126 if (urand(0, 1) == 0)
127 {
131 }
132 else
133 {
137 }
138 }
139
140 void JustEngagedWith(Unit* who) override
141 {
147
149 fetidMaggot->DespawnOrUnsummon();
150
151 if (IsHeroicOrHigher())
153 }
154
155 void MovementInform(uint32 /*type*/, uint32 id) override
156 {
158 me->GetMotionMaster()->MoveRandom(20.0f);
159 }
160
161 void OnChannelFinished(SpellInfo const* spell) override
162 {
163 if (spell->Id == SPELL_TANTRUM_INITIAL)
165 };
166
167 void UpdateAI(uint32 diff) override
168 {
169 if (!UpdateVictim())
170 return;
171
172 events.Update(diff);
173
175 return;
176
177 switch (events.ExecuteEvent())
178 {
181 break;
184 break;
187 break;
189 if (me->GetPower(POWER_ENERGY) >= 100)
190 {
195 }
196 events.Repeat(500ms);
197 break;
198 default:
199 break;
200 }
201 }
202private:
204};
205
206// 132051 - Blood Tick
208{
209 npc_cragmaw_blood_tick(Creature* creature) : ScriptedAI(creature) { }
210
211 void JustAppeared() override
212 {
214 if (!cragmaw || !cragmaw->IsAIEnabled())
215 return;
216
217 cragmaw->AI()->JustSummoned(me);
219 }
220
221 void JustEngagedWith(Unit* /*who*/) override
222 {
224 }
225
226 void UpdateAI(uint32 diff) override
227 {
228 if (!UpdateVictim())
229 return;
230
231 _events.Update(diff);
232
234 return;
235
236 switch (_events.ExecuteEvent())
237 {
241 break;
242 default:
243 break;
244 }
245 }
246private:
248};
249
250// 271775 - Tantrum Energy Bar (periodic)
252{
253 void HandlePeriodic(AuraEffect const* /*aurEff*/)
254 {
255 Unit* target = GetTarget();
256 target->SetPower(POWER_ENERGY, target->GetPower(POWER_ENERGY) + 2);
257 }
258
259 void Register() override
260 {
262 }
263};
264
265// 260411 - Summon Larva
267{
268 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
269 {
270 if (Creature* creature = GetTarget()->ToCreature())
271 creature->DespawnOrUnsummon(300ms);
272 }
273
274 void Register() override
275 {
277 }
278};
279
280// 260418 - Destroy Larva
282{
283 at_cragmaw_destroy_larva(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { }
284
285 void OnUnitEnter(Unit* unit) override
286 {
287 if (!unit->IsPlayer())
288 return;
289
290 at->GetCaster()->CastSpell(nullptr, SPELL_DESTROY_LARVA, true);
291 }
292};
293
294// 260416 - Metamorphosis
296{
297 bool Validate(SpellInfo const* /*spellInfo*/) override
298 {
299 return ValidateSpellInfo(
300 {
304 });
305 }
306
307 void HandlePeriodic(AuraEffect const* aurEff)
308 {
309 if (aurEff->GetTickNumber() == aurEff->GetTotalTicks() - 2)
310 GetTarget()->CastSpell(nullptr, SPELL_METAMORPHOSIS_2, true);
311 }
312
313 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
314 {
315 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
316 return;
317
318 Unit* target = GetTarget();
319 target->CastSpell(nullptr, SPELL_SUMMON_BLOOD_TICK_VISUAL, true);
320 target->CastSpell(target->GetPosition(), SPELL_SUMMON_BLOOD_TICK, true);
321 }
322
323 void Register() override
324 {
327 }
328};
329
330// 278641 - Blood Burst
332{
333 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
334 {
335 Unit* target = GetTarget();
336 target->CastSpell(target, SPELL_BLOOD_BURST_DAMAGE, true);
337 }
338
339 void Register() override
340 {
342 }
343};
344
346{
347 // Creature
350
351 // Spells
356
357 // AreaTrigger
359}
@ DIFFICULTY_NORMAL
Definition: DBCEnums.h:875
uint32_t uint32
Definition: Define.h:142
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
#define RegisterAreaTriggerAI(ai_name)
Definition: ScriptMgr.h:1416
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
@ EFFECT_0
Definition: SharedDefines.h:30
@ EMOTE_STATE_EAT
@ POWER_ENERGY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_EXPIRE
@ SPELL_AURA_DUMMY
@ SPELL_AURA_AREA_TRIGGER
@ SPELL_AURA_PERIODIC_DUMMY
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ UNIT_STATE_STUNNED
Definition: Unit.h:258
@ SPELL_SUMMON_BLOOD_TICK_VISUAL
@ SPELL_POWER_ENERGIZE_TANTRUM
@ SPELL_SUMMON_BLOOD_TICK
@ SPELL_POWER_DISPLAY_TANTRUM
@ SPELL_BLOOD_BURST_DAMAGE
@ POINT_TANTRUM_START_RND_MOVEMENT
Position const FetidMaggotSpawn
@ EVENT_CHECK_ENERGY_TANTRUM
void AddSC_boss_cragmaw_the_infested()
AreaTrigger *const at
Definition: AreaTriggerAI.h:33
Unit * GetCaster() const
uint32 GetTickNumber() const
uint32 GetTotalTicks() const
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
Unit * GetTarget() const
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void _JustDied()
void DoZoneInCombat()
Definition: CreatureAI.h:161
virtual void JustSummoned(Creature *)
Definition: CreatureAI.h:111
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:299
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:373
void SetReactState(ReactStates st)
Definition: Creature.h:160
CreatureAI * AI() const
Definition: Creature.h:214
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
void Reset()
Definition: EventMap.cpp:21
Creature * GetCreature(uint32 type)
void SendEncounterUnit(EncounterFrameType type, Unit const *unit, Optional< int32 > param1={}, Optional< int32 > param2={})
void MoveRandom(float wanderDistance=0.0f, Optional< Milliseconds > duration={}, MovementSlot slot=MOTION_SLOT_DEFAULT)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
bool IsPlayer() const
Definition: Object.h:212
uint32 const Id
Definition: SpellInfo.h:325
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void SetPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition: Unit.cpp:9419
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void SetEmoteState(Emote emote)
Definition: Unit.h:852
bool IsAIEnabled() const
Definition: Unit.h:658
void SetPowerType(Powers power, bool sendUpdate=true)
Definition: Unit.cpp:5534
int32 GetPower(Powers power) const
Definition: Unit.cpp:9401
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
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
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void HandlePeriodic(AuraEffect const *aurEff)
bool Validate(SpellInfo const *) override
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
constexpr void GetPosition(float &x, float &y) const
Definition: Position.h:81
Difficulty GetDifficulty() const
bool IsHeroicOrHigher() const
void OnUnitEnter(Unit *unit) override
at_cragmaw_destroy_larva(AreaTrigger *areatrigger)
void UpdateAI(uint32 diff) override
void OnChannelFinished(SpellInfo const *spell) override
void EnterEvadeMode(EvadeReason) override
boss_cragmaw_the_infested(Creature *creature)
void MovementInform(uint32, uint32 id) override
void JustEngagedWith(Unit *who) override
void JustEngagedWith(Unit *) override
npc_cragmaw_blood_tick(Creature *creature)
void UpdateAI(uint32 diff) override
@ DATA_CRAGMAW_CRAWG_EATING
Definition: underrot.h:36
@ DATA_CRAGMAW_THE_INFESTED
Definition: underrot.h:33
#define RegisterUnderrotCreatureAI(ai_name)
Definition: underrot.h:60