TrinityCore
Loading...
Searching...
No Matches
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
70
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
118
139
154
155 void MovementInform(uint32 /*type*/, uint32 id) override
156 {
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)
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
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
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
343};
344
@ DIFFICULTY_NORMAL
Definition DBCEnums.h:934
uint32_t uint32
Definition Define.h:154
@ ENCOUNTER_FRAME_DISENGAGE
@ ENCOUNTER_FRAME_ENGAGE
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_0
@ 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)
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:276
@ UNIT_STATE_STUNNED
Definition Unit.h:264
@ SPELL_SUMMON_BLOOD_TICK_VISUAL
@ SPELL_POWER_ENERGIZE_TANTRUM
@ SPELL_POWER_DISPLAY_TANTRUM
@ POINT_TANTRUM_START_RND_MOVEMENT
Position const FetidMaggotSpawn
@ EVENT_CHECK_ENERGY_TANTRUM
void AddSC_boss_cragmaw_the_infested()
AreaTrigger *const at
Unit * GetCaster() const
uint32 GetTickNumber() const
uint32 GetTotalTicks() const
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
bool IsPlayer() const
Definition BaseEntity.h:173
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
virtual void JustSummoned(Creature *)
Definition CreatureAI.h:113
bool _EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition Creature.h:388
void SetReactState(ReactStates st)
Definition Creature.h:174
CreatureAI * AI() const
Definition Creature.h:228
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
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={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::ForceWalk, MovementSlot slot=MOTION_SLOT_DEFAULT, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void SetPower(Powers power, int32 val, bool withPowerUpdate=true)
Definition Unit.cpp:10046
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
void SetEmoteState(Emote emote)
Definition Unit.h:865
bool IsAIEnabled() const
Definition Unit.h:666
int32 GetPower(Powers power) const
Definition Unit.cpp:10028
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void SetPowerType(Powers power, bool sendUpdate=true, bool onInit=false)
Definition Unit.cpp:5697
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
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:1398
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:99
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:100
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:92
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