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
54
55#define SPELL_MORTAL_STRIKES DUNGEON_MODE<uint32>(SPELL_MORTAL_STRIKES_NORMAL, SPELL_MORTAL_STRIKES_HEROIC)
56
63
68
75
80
85
90
92{
96
97 void Reset() override
98 {
99 _Reset();
100
103
105 }
106
107 void EnterEvadeMode(EvadeReason /*why*/) override
108 {
111 }
112
113 void JustEngagedWith(Unit* who) override
114 {
115 _JustEngagedWith(who);
117 }
118
119 void DoAction(int32 action) override
120 {
121 switch (action)
122 {
125 return;
126
127 me->SetImmuneToPC(false);
131 if (me->IsEngaged())
132 {
133 if (Unit* victim = me->SelectVictim())
134 AttackStart(victim);
135 }
136 else
138 break;
139 }
140 }
141
142 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
143 {
144 if (me->IsImmuneToPC())
145 {
146 damage = 0;
147 return;
148 }
149
151 {
153 {
154 if ((int64(me->GetHealth()) - int64(damage)) <= 0)
155 damage = me->GetHealth() - 1;
157
158 // Freeze Colossus
160 DoStopAttack();
162 me->SetImmuneToPC(true);
164
167 }
168 }
169 }
170
171 uint32 GetData(uint32 data) const override
172 {
173 if (data == DATA_COLOSSUS_PHASE)
174 return events.GetPhaseMask();
175
176 return 0;
177 }
178
179 void UpdateAI(uint32 diff) override
180 {
181 if (!UpdateVictim())
182 return;
183
184 events.Update(diff);
185
187 return;
188
189 switch (events.ExecuteEvent())
190 {
194 break;
195 }
196 }
197
198 void JustSummoned(Creature* summon) override
199 {
201 {
202 summon->SetHealth(summon->GetMaxHealth() / 2);
203 summon->LowerPlayerDamageReq(1);
204 DoZoneInCombat(summon);
205 }
206 else
207 BossAI::JustSummoned(summon);
208 }
209};
210
212{
214 {
215 instance = creature->GetInstanceScript();
216 }
217
225
226 void Reset() override
227 {
228 events.Reset();
229 }
230
231 void JustEngagedWith(Unit* /*who*/) override
232 {
235 }
236
237 void JustDied(Unit* killer) override
238 {
240
242 Unit::Kill(killer, colossus);
243 }
244
245 void UpdateAI(uint32 diff) override
246 {
247 if (!UpdateVictim())
248 return;
249
250 events.Update(diff);
251
253 return;
254
255 switch (events.ExecuteEvent())
256 {
257 case EVENT_SURGE:
258 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
259 {
260 DoStopAttack();
263 else
265 }
267 break;
269 if (Unit* victim = me->SelectVictim())
270 AttackStart(victim);
271 }
272 }
273
274 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
275 {
276 if (me->HealthBelowPctDamaged(50, damage))
277 {
279 {
280 if (colossus->AI()->GetData(DATA_COLOSSUS_PHASE) == COLOSSUS_PHASE_FIRST_ELEMENTAL_SUMMON)
281 {
282 damage = 0;
283
284 // to prevent spell spaming
286 return;
287
288 // not sure about this, the idea of this code is to prevent bug the elemental
289 // if it is not in a acceptable distance to cast the charge spell.
290 /*if (me->GetDistance(colossus) > 80.0f)
291 {
292 if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
293 return;
294
295 me->GetMotionMaster()->MovePoint(0, colossus->GetPositionX(), colossus->GetPositionY(), colossus->GetPositionZ());
296 return;
297 }*/
301 DoStopAttack();
305 // what if the elemental is more than 80 yards from drakkari colossus ?
306 DoCast(colossus, SPELL_MERGE, true);
307 }
308 }
309 }
310 }
311
312 void EnterEvadeMode(EvadeReason /*why*/) override
313 {
315 }
316
317 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
318 {
319 if (spellInfo->Id == SPELL_MERGE)
320 {
321 if (Creature* colossus = target->ToCreature())
322 {
323 colossus->AI()->DoAction(ACTION_UNFREEZE_COLOSSUS);
325 }
326 }
327 }
328
334
335private:
338};
339
341{
342 npc_living_mojo(Creature* creature) : ScriptedAI(creature)
343 {
344 _instance = creature->GetInstanceScript();
345 if (SpawnMetadata const* data = sObjectMgr->GetSpawnMetadata(SpawnObjectType::SPAWN_TYPE_CREATURE, me->GetSpawnId()))
346 if (data->spawnGroupData && data->spawnGroupData->groupId == SPAWN_GROUP_MOJO)
348 }
349
350 void Reset() override
351 {
353 }
354
355 void JustEngagedWith(Unit* /*who*/) override
356 {
358 {
360 {
361 for (auto& pair : sObjectMgr->GetSpawnMetadataForGroup(SPAWN_GROUP_MOJO))
362 if (Creature* mojo = _instance->instance->GetCreatureBySpawnId(pair.second->spawnId))
363 if (mojo->GetMotionMaster()->GetCurrentMovementGeneratorType() == MovementGeneratorType::IDLE_MOTION_TYPE)
364 mojo->GetMotionMaster()->MovePoint(POINT_COLOSSUS, colossus->GetHomePosition());
365 return;
366 }
367 else
369 }
370
371 _scheduler.Schedule(2s, [this](TaskContext& task)
372 {
374 task.Repeat(15s);
375 })
376 .Schedule(7s, [this](TaskContext& task)
377 {
379 task.Repeat(18s);
380 });
381 }
382
383 void MovementInform(uint32 type, uint32 id) override
384 {
385 if (type == POINT_MOTION_TYPE && id == POINT_COLOSSUS)
386 {
388 colossus->AI()->DoAction(ACTION_UNFREEZE_COLOSSUS);
389
391 }
392 }
393
394 void UpdateAI(uint32 diff) override
395 {
396 //Return since we have no target
397 if (!UpdateVictim())
398 return;
399
400 _scheduler.Update(diff);
401 }
402
403private:
406};
407
408// 54801 - Surge
410{
411 bool Validate(SpellInfo const* /*spell*/) override
412 {
414 }
415
416 void HandleVisual(SpellEffIndex /*effIndex*/)
417 {
419 }
420
425};
426
int64_t int64
Definition Define.h:149
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ MOTION_PRIORITY_NORMAL
@ IDLE_MOTION_TYPE
@ POINT_MOTION_TYPE
#define sObjectMgr
Definition ObjectMgr.h:1873
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_1
@ SPELL_EFFECT_CHARGE_DEST
@ EVENT_CHARGE
@ SPELL_CAST_OK
@ SPAWN_TYPE_CREATURE
Definition SpawnData.h:36
#define SpellEffectFn(F, I, N)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
DamageEffectType
@ UNIT_STATE_CHARGING
Definition Unit.h:292
@ UNIT_STATE_CASTING
Definition Unit.h:290
@ ACTION_UNFREEZE_COLOSSUS
void AddSC_boss_drakkari_colossus()
@ SPELL_ELEMENTAL_SPAWN_EFFECT
@ SPELL_MORTAL_STRIKES_NORMAL
@ SPELL_MORTAL_STRIKES_HEROIC
#define SPELL_MORTAL_STRIKES
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()
Definition CreatureAI.h:169
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetImmuneToPC(bool apply) override
Definition Creature.h:190
bool HasReactState(ReactStates state) const
Definition Creature.h:182
void DoNotReacquireSpellFocusTarget()
bool IsEngaged() const override
void SetReactState(ReactStates st)
Definition Creature.h:180
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:110
Unit * SelectVictim()
ReactStates GetReactState() const
Definition Creature.h:181
void LowerPlayerDamageReq(uint64 unDamage)
bool IsImmuneToPC() const
Definition Unit.h:1060
bool HasEventScheduled(EventId eventId) const
Definition EventMap.cpp:209
void Update(uint32 time)
Definition EventMap.h:77
PhaseMask GetPhaseMask() const
Definition EventMap.h:96
EventId ExecuteEvent()
Definition EventMap.cpp:77
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:246
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:56
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:32
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
Creature * GetCreature(uint32 type)
InstanceMap * instance
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2360
Creature * GetCreatureBySpawnId(ObjectGuid::LowType spawnId) const
Definition Map.cpp:3607
uint32 GetEntry() const
Definition Object.h:89
Creature * ToCreature()
Definition Object.h:121
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
HookList< EffectHandler > OnEffectLaunch
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
virtual void InitializeAI()
Definition UnitAI.cpp:35
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
void SetHealth(uint64 val)
Definition Unit.cpp:10041
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3846
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
Aura * AddAura(uint32 spellId, Unit *target)
Definition Unit.cpp:12344
uint64 GetMaxHealth() const
Definition Unit.h:801
uint64 GetHealth() const
Definition Unit.h:800
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition Unit.cpp:11311
InstanceScript * GetInstanceScript() const
Definition Object.cpp:394
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
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
== Triggered Actions Requested ==================
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