TrinityCore
Loading...
Searching...
No Matches
boss_drakkari_colossus.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/*
19 * Comment: The event with the Living Mojos is not implemented, just is done that when one of the mojos around the boss take damage will make the boss enter in combat!
20 */
21
22#include "gundrak.h"
23#include "InstanceScript.h"
24#include "Map.h"
25#include "MotionMaster.h"
26#include "ObjectMgr.h"
27#include "ScriptedCreature.h"
28#include "ScriptMgr.h"
29#include "SpellInfo.h"
30#include "SpellScript.h"
31
33{
34 // Drakkari Elemental
37};
38
52
59
64
71
76
81
86
88{
92
93 void Reset() override
94 {
95 _Reset();
96
99 }
100
101 void EnterEvadeMode(EvadeReason /*why*/) override
102 {
105 }
106
107 void JustEngagedWith(Unit* who) override
108 {
109 _JustEngagedWith(who);
111 }
112
113 void DoAction(int32 action) override
114 {
115 switch (action)
116 {
119 return;
120
121 me->SetImmuneToPC(false);
125 if (me->IsEngaged())
126 {
127 if (Unit* victim = me->SelectVictim())
128 AttackStart(victim);
129 }
130 else
132 break;
133 }
134 }
135
136 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
137 {
138 if (me->IsImmuneToPC())
139 {
140 damage = 0;
141 return;
142 }
143
145 {
147 {
148 if ((int64(me->GetHealth()) - int64(damage)) <= 0)
149 damage = me->GetHealth() - 1;
151
152 // Freeze Colossus
154 DoStopAttack();
156 me->SetImmuneToPC(true);
158
161 }
162 }
163 }
164
165 uint32 GetData(uint32 data) const override
166 {
167 if (data == DATA_COLOSSUS_PHASE)
168 return events.GetPhaseMask();
169
170 return 0;
171 }
172
173 void UpdateAI(uint32 diff) override
174 {
175 if (!UpdateVictim())
176 return;
177
178 events.Update(diff);
179
181 return;
182
183 if (uint32 eventId = events.ExecuteEvent())
184 {
185 switch (eventId)
186 {
190 break;
191 }
192
194 return;
195 }
196
198 }
199
200 void JustSummoned(Creature* summon) override
201 {
203 {
204 summon->SetHealth(summon->GetMaxHealth() / 2);
205 summon->LowerPlayerDamageReq(1);
206 DoZoneInCombat(summon);
207 }
208 else
209 BossAI::JustSummoned(summon);
210 }
211};
212
214{
216 {
217 instance = creature->GetInstanceScript();
218 }
219
227
228 void Reset() override
229 {
230 events.Reset();
231 }
232
233 void JustEngagedWith(Unit* /*who*/) override
234 {
237 }
238
239 void JustDied(Unit* killer) override
240 {
242
244 Unit::Kill(killer, colossus);
245 }
246
247 void UpdateAI(uint32 diff) override
248 {
249 if (!UpdateVictim())
250 return;
251
252 events.Update(diff);
253
255 return;
256
257 if (uint32 eventId = events.ExecuteEvent())
258 {
259 switch (eventId)
260 {
261 case EVENT_SURGE:
262 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
263 {
264 DoStopAttack();
267 else
269 }
271 break;
273 if (Unit* victim = me->SelectVictim())
274 AttackStart(victim);
275 }
276
278 return;
279 }
280
282 }
283
284 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
285 {
286 if (me->HealthBelowPctDamaged(50, damage))
287 {
289 {
290 if (colossus->AI()->GetData(DATA_COLOSSUS_PHASE) == COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON)
291 {
292 damage = 0;
293
294 // to prevent spell spaming
296 return;
297
298 // not sure about this, the idea of this code is to prevent bug the elemental
299 // if it is not in a acceptable distance to cast the charge spell.
300 /*if (me->GetDistance(colossus) > 80.0f)
301 {
302 if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
303 return;
304
305 me->GetMotionMaster()->MovePoint(0, colossus->GetPositionX(), colossus->GetPositionY(), colossus->GetPositionZ());
306 return;
307 }*/
311 DoStopAttack();
315 // what if the elemental is more than 80 yards from drakkari colossus ?
316 DoCast(colossus, SPELL_MERGE, true);
317 }
318 }
319 }
320 }
321
322 void EnterEvadeMode(EvadeReason /*why*/) override
323 {
325 }
326
327 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
328 {
329 if (spellInfo->Id == SPELL_MERGE)
330 {
331 if (Creature* colossus = target->ToCreature())
332 {
333 colossus->AI()->DoAction(ACTION_UNFREEZE_COLOSSUS);
335 }
336 }
337 }
338
344
345private:
348};
349
351{
352 npc_living_mojo(Creature* creature) : ScriptedAI(creature)
353 {
354 _instance = creature->GetInstanceScript();
355 if (SpawnMetadata const* data = sObjectMgr->GetSpawnMetadata(SpawnObjectType::SPAWN_TYPE_CREATURE, me->GetSpawnId()))
356 if (data->spawnGroupData && data->spawnGroupData->groupId == SPAWN_GROUP_MOJO)
358 }
359
360 void Reset() override
361 {
363 }
364
365 void JustEngagedWith(Unit* /*who*/) override
366 {
368 {
370 {
371 for (auto& pair : sObjectMgr->GetSpawnMetadataForGroup(SPAWN_GROUP_MOJO))
372 if (Creature* mojo = _instance->instance->GetCreatureBySpawnId(pair.second->spawnId))
373 if (mojo->GetMotionMaster()->GetCurrentMovementGeneratorType() == MovementGeneratorType::IDLE_MOTION_TYPE)
374 mojo->GetMotionMaster()->MovePoint(POINT_COLOSSUS, colossus->GetHomePosition());
375 return;
376 }
377 else
379 }
380
381 _scheduler.Schedule(2s, [this](TaskContext task)
382 {
384 task.Repeat(15s);
385 })
386 .Schedule(7s, [this](TaskContext task)
387 {
389 task.Repeat(18s);
390 });
391 }
392
393 void MovementInform(uint32 type, uint32 id) override
394 {
395 if (type == POINT_MOTION_TYPE && id == POINT_COLOSSUS)
396 {
398 colossus->AI()->DoAction(ACTION_UNFREEZE_COLOSSUS);
399
401 }
402 }
403
404 void UpdateAI(uint32 diff) override
405 {
406 //Return since we have no target
407 if (!UpdateVictim())
408 return;
409
410 _scheduler.Update(diff, [this]
411 {
413 });
414 }
415
416private:
419};
420
421// 54801 - Surge
441
int64_t int64
Definition Define.h:128
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ MOTION_PRIORITY_NORMAL
@ IDLE_MOTION_TYPE
@ POINT_MOTION_TYPE
#define sObjectMgr
Definition ObjectMgr.h:1721
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_1
@ SPELL_EFFECT_CHARGE_DEST
@ EVENT_CHARGE
@ SPELL_CAST_OK
@ SPAWN_TYPE_CREATURE
Definition SpawnData.h:31
#define SpellEffectFn(F, I, N)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CHARGING
Definition Unit.h:237
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
@ ACTION_UNFREEZE_COLOSSUS
void AddSC_boss_drakkari_colossus()
@ SPELL_ELEMENTAL_SPAWN_EFFECT
DrakkariColossusSpawnGroups
@ COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON
@ COLOSSUS_PHASE_SECOND_ELEMENTAL_SUMMON
@ COLOSSUS_PHASE_NORMAL
@ DATA_COLOSSUS_PHASE
@ EMOTE_ACTIVATE_ALTAR
InstanceScript *const instance
void _JustEngagedWith(Unit *who)
void JustSummoned(Creature *summon) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetImmuneToPC(bool apply) override
Definition Creature.h:129
bool HasReactState(ReactStates state) const
Definition Creature.h:121
void DoNotReacquireSpellFocusTarget()
bool IsEngaged() const override
void SetReactState(ReactStates st)
Definition Creature.h:119
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:83
Unit * SelectVictim()
ReactStates GetReactState() const
Definition Creature.h:120
bool IsImmuneToPC() const
Definition Unit.h:1137
void LowerPlayerDamageReq(uint32 unDamage)
bool HasEventScheduled(EventId eventId) const
Definition EventMap.cpp:188
void Update(uint32 time)
Definition EventMap.h:67
PhaseMask GetPhaseMask() const
Definition EventMap.h:86
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:52
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
Creature * GetCreature(uint32 type)
InstanceMap * instance
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:3382
Creature * GetCreatureBySpawnId(ObjectGuid::LowType spawnId) const
Definition Map.cpp:4402
static Creature * ToCreature(Object *o)
Definition Object.h:186
uint32 GetEntry() const
Definition Object.h:81
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
HookList< EffectHandler > OnEffectLaunch
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
virtual void InitializeAI()
Definition UnitAI.cpp:36
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3638
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
uint32 GetMaxHealth() const
Definition Unit.h:914
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:11964
void SetHealth(uint32 val)
Definition Unit.cpp:9361
uint32 GetHealth() const
Definition Unit.h:913
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true)
Definition Unit.cpp:10930
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1087
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_drakkari_colossus_surge)
bool Validate(SpellInfo const *) override
#define RegisterGundrakCreatureAI(ai_name)
Definition gundrak.h:101
@ DATA_DRAKKARI_COLOSSUS
Definition gundrak.h:32
@ NPC_DRAKKARI_ELEMENTAL
Definition gundrak.h:65
void AttackStart(Unit *) override
void SetAggressiveStateAfter(Milliseconds timer, Creature *who=nullptr, bool startCombat=true, Creature *summoner=nullptr, StartCombatArgs const &combatArgs={ })
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
boss_drakkari_colossus(Creature *creature)
uint32 GetData(uint32 data) const override
void JustSummoned(Creature *summon) override
void EnterEvadeMode(EvadeReason) override
void DoAction(int32 action) override
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void MovementInform(uint32 type, uint32 id) override
void JustEngagedWith(Unit *) override
boss_drakkari_elemental(Creature *creature)
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void UpdateAI(uint32 diff) override
void JustDied(Unit *killer) override
void EnterEvadeMode(EvadeReason) override
void JustEngagedWith(Unit *) override
npc_living_mojo(Creature *creature)
void MovementInform(uint32 type, uint32 id) override
void UpdateAI(uint32 diff) override