TrinityCore
Loading...
Searching...
No Matches
boss_archimonde.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 * Is SAY_CHARM used somehow?
20 * The way In-Combat Finger of Death is used requires additional research, it is not handled entirely
21 correctly but the correct approach is unknown
22 * Combat timers requires to be revisited
23 * Archimonde should have big aggro radius
24 * SPELL_SOUL_CHARGE_AURA is used but the exact usage and purpose is unknown
25 * The way souls are unleashed requires additional research. Proc of auras is disabled, doesn't seem like they proc
26 * The way Hand of Death is handled if Archimonde reaches Nordrassil requires additional research (exact distance or position are unknown)
27 */
28
29#include "ScriptMgr.h"
30#include "hyjal.h"
31#include "InstanceScript.h"
32#include "MotionMaster.h"
33#include "ObjectAccessor.h"
34#include "ScriptedCreature.h"
35#include "SpellInfo.h"
36#include "SpellScript.h"
37#include "TemporarySummon.h"
38
50
92
122
133
134static Position const EpiloguePosition = { 5600.375f, -3458.6353f, 1577.3046f, 0.0f };
135static Position const NordrassilPosition = { 5503.713f, -3523.436f, 1608.781f, 0.0f };
136
137// 17968 - Archimonde
138struct boss_archimonde : public BossAI
139{
141
142 void JustAppeared() override
143 {
145 }
146
164
165 void OnSpellCast(SpellInfo const* spellInfo) override
166 {
167 switch (spellInfo->Id)
168 {
169 case SPELL_AIR_BURST:
170 if (roll_chance_i(50))
172 break;
174 if (roll_chance_i(50))
176 break;
179 break;
182 break;
185 break;
188 break;
189 default:
190 break;
191 }
192 }
193
194 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
195 {
196 switch (spellInfo->Id)
197 {
200 break;
203 break;
206 break;
209 break;
210 default:
211 break;
212 }
213 }
214
215 void DamageTaken(Unit* who, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
216 {
217 if (damage >= me->GetHealth() && who != me)
218 damage = me->GetHealth() - 1;
219
220 if (!_isEpilogueStarted && me->HealthBelowPctDamaged(10, damage))
221 {
222 _isEpilogueStarted = true;
223
225 }
226 }
227
228 void MovementInform(uint32 type, uint32 pointId) override
229 {
230 if (type == POINT_MOTION_TYPE && pointId == POINT_EPILOGUE)
232 }
233
234 void JustSummoned(Creature* summoned) override
235 {
236 switch (summoned->GetEntry())
237 {
239 _doomfireSpiritGUID = summoned->GetGUID();
240 break;
241 case NPC_DOOMFIRE:
244 break;
245 default:
246 break;
247 }
248 }
249
250 void DoAction(int32 action) override
251 {
252 if (action == ACTION_ARCHIMONDE_INTRO)
254 }
255
256 void EnterEvadeMode(EvadeReason /*why*/) override
257 {
259 }
260
261 void KilledUnit(Unit* victim) override
262 {
263 if (victim->GetTypeId() == TYPEID_PLAYER)
264 {
265 Talk(SAY_SLAY);
266
267 switch (victim->GetClass())
268 {
269 case CLASS_PRIEST:
270 case CLASS_PALADIN:
271 case CLASS_WARLOCK:
272 victim->CastSpell(victim, SPELL_SOUL_CHARGE_RED, true);
273 break;
274 case CLASS_MAGE:
275 case CLASS_ROGUE:
276 case CLASS_WARRIOR:
277 victim->CastSpell(victim, SPELL_SOUL_CHARGE_YELLOW, true);
278 break;
279 case CLASS_DRUID:
280 case CLASS_SHAMAN:
281 case CLASS_HUNTER:
282 victim->CastSpell(victim, SPELL_SOUL_CHARGE_GREEN, true);
283 break;
284 }
285 }
286 }
287
288 void UpdateAI(uint32 diff) override
289 {
290 if (!UpdateVictim())
291 {
292 events.Update(diff);
293
294 while (uint32 eventId = events.ExecuteEvent())
295 {
296 switch (eventId)
297 {
300 events.Repeat(16900ms);
301 break;
302 default:
303 break;
304 }
305 }
306 return;
307 }
308
309 events.Update(diff);
310
312 return;
313
314 while (uint32 eventId = events.ExecuteEvent())
315 {
316 switch (eventId)
317 {
318 // Combat
322 events.Repeat(10s, 20s);
323 break;
326 {
327 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 200.0f, true))
329 events.Repeat(1200ms);
330 }
331 break;
332 case EVENT_FEAR:
334 events.Repeat(30s, 50s);
335 break;
337 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 60.0f, true, true, -SPELL_GRIP_OF_THE_LEGION))
339 events.Repeat(5s, 25s);
340 break;
341 case EVENT_AIR_BURST:
342 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 60.0f, true))
343 DoCast(target, SPELL_AIR_BURST);
344 events.Repeat(25s, 40s);
345 break;
346 case EVENT_DOOMFIRE:
348 events.Repeat(7s, 9s);
349 break;
352 break;
354 if (me->GetDistance(NordrassilPosition) < 60.0f)
356 else
357 events.Repeat(5s);
358 break;
359
362 break;
365 break;
368 break;
369
370 // Epilogue
371 case EVENT_EPILOGUE_1:
376 events.Reset();
377 break;
378 case EVENT_EPILOGUE_2:
387 break;
388 case EVENT_EPILOGUE_3:
391 break;
392
393 // Epilogue: Repeatable
395 for (uint8 i = 0; i < 4; ++i)
397 events.Repeat(2400ms);
398 break;
401 events.Repeat(1200ms);
402 break;
405 events.Repeat(4s);
406 break;
407 default:
408 break;
409 }
410
412 return;
413 }
414
416 }
417
418private:
421};
422
423// 18095 - Doomfire
425{
426 npc_doomfire(Creature* creature) : ScriptedAI(creature) { }
427
428 void InitializeAI() override
429 {
431 }
432
433 void JustAppeared() override
434 {
436 .Schedule(1200ms, [this](TaskContext /*task*/)
437 {
440 })
441 .Schedule(1200ms, [this](TaskContext task)
442 {
444 {
445 float x, y, z;
446 target->GetClosePoint(x, y, z, 0.0f, 1.0f, float(M_PI));
448 task.Repeat(1200ms);
449 }
450 });
451 }
452
453 void SetGUID(ObjectGuid const& guid, int32 id) override
454 {
455 if (id == GUID_DOOMFIRE)
456 _doomfireSpiritGUID = guid;
457 }
458
459 void UpdateAI(uint32 diff) override
460 {
461 _scheduler.Update(diff);
462 }
463
464private:
467};
468
469// 18104 - Doomfire Spirit
471{
472 npc_doomfire_spirit(Creature* creature) : ScriptedAI(creature) { }
473
474 void JustAppeared() override
475 {
476 _scheduler.Schedule(0s, [this](TaskContext task)
477 {
478 Position pos = me->GetPosition();
479 float orientation = Position::NormalizeOrientation(me->GetOrientation() + RAND(0.0f, -1.0f, 1.0f) * static_cast<float>(M_PI_4));
480 me->MovePositionToFirstCollision(pos, 8.0f, orientation);
481 me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), orientation);
482 task.Repeat(1200ms);
483 });
484 }
485
486 void UpdateAI(uint32 diff) override
487 {
488 _scheduler.Update(diff);
489 }
490
491private:
493};
494
495// 17946 - Ancient Wisp
497{
498 npc_ancient_wisp(Creature* creature) : ScriptedAI(creature) { }
499
500 void InitializeAI() override
501 {
503 me->SetCorpseDelay(20, true);
504 }
505
506 void JustAppeared() override
507 {
508 if (TempSummon* summon = me->ToTempSummon())
509 if (Unit* summoner = summon->GetSummonerUnit())
510 AttackStart(summoner);
511 }
512
513 void Reset() override
514 {
516 }
517
518 void JustEngagedWith(Unit* /*who*/) override
519 {
520 _scheduler.Schedule(0s, [this](TaskContext task)
521 {
522 if (me->IsWithinDistInMap(me->GetVictim(), 10.0f))
524 task.Repeat(2400ms);
525 });
526 }
527
528 void UpdateAI(uint32 diff) override
529 {
530 if (!UpdateVictim())
531 return;
532
533 _scheduler.Update(diff);
534
536 }
537
538private:
540};
541
542// 39142 - Drain World Tree Dummy
562
563// 42201 - Eternal Silence
583
#define M_PI
Definition Common.h:72
#define M_PI_4
Definition Common.h:76
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
bool roll_chance_i(int chance)
Definition Random.h:59
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ CLASS_HUNTER
@ CLASS_DRUID
@ CLASS_SHAMAN
@ CLASS_PRIEST
@ CLASS_WARRIOR
@ CLASS_WARLOCK
@ CLASS_MAGE
@ CLASS_PALADIN
@ CLASS_ROGUE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_MOD_SILENCE
#define SpellEffectFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:608
@ UNIT_STATE_ROOT
Definition Unit.h:230
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
void AddSC_boss_archimonde()
ArchimondeTexts
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_AIR_BURST
@ SAY_CHARM
@ SAY_SLAY
@ SAY_DOOMFIRE
@ SAY_ENRAGE
@ SAY_INTRO
static Position const NordrassilPosition
ArchimondeEvents
@ EVENT_DISTANCE_CHECK
@ EVENT_AIR_BURST
@ EVENT_SUMMON_WHISP
@ EVENT_EPILOGUE_1
@ EVENT_GRIP_OF_THE_LEGION
@ EVENT_FINGER_OF_DEATH
@ EVENT_UNLEASH_SOUL_RED
@ EVENT_FINGER_OF_DEATH_COOLUP
@ EVENT_DRAIN_WORLD_TREE
@ EVENT_DOOMFIRE
@ EVENT_FINGER_OF_DEATH_NPC
@ EVENT_FEAR
@ EVENT_UNLEASH_SOUL_YELLOW
@ EVENT_UNLEASH_SOUL_GREEN
@ EVENT_EPILOGUE_2
@ EVENT_HAND_OF_DEATH
@ EVENT_EPILOGUE_3
@ EVENT_FINGER_OF_DEATH_PLAYER
static Position const EpiloguePosition
ArchimondeMisc
@ SOUND_HORN
@ POINT_DOOMFIRE
@ NPC_DOOMFIRE
@ MUSIC_EPILOGUE
@ POINT_EPILOGUE
@ NPC_DOOMFIRE_SPIRIT
@ GUID_DOOMFIRE
ArchimondeSpells
@ SPELL_SOUL_CHARGE_RED
@ SPELL_DOOMFIRE
@ SPELL_FINGER_OF_DEATH_NPC
@ SPELL_PROTECTION_OF_ELUNE
@ SPELL_FINGER_OF_DEATH_PLAYER
@ SPELL_FINGER_OF_DEATH
@ SPELL_SOUL_CHARGE_AURA
@ SPELL_UNLEASH_SOUL_GREEN
@ SPELL_DOOMFIRE_SPAWN
@ SPELL_DRAIN_WORLD_TREE_VISUAL_2
@ SPELL_SOUL_CHARGE_GREEN
@ SPELL_FEAR
@ SPELL_UNLEASH_SOUL_RED
@ SPELL_SUMMON_WISP
@ SPELL_ANCIENT_SPARK
@ SPELL_FINGER_OF_DEATH_COOLUP
@ SPELL_DENOUEMENT_WISP
@ SPELL_RESIDUE_OF_ETERNITY
@ SPELL_DOOMFIRE_STRIKE
@ SPELL_HAND_OF_DEATH
@ SPELL_GRIP_OF_THE_LEGION
@ SPELL_UNLEASH_SOUL_YELLOW
@ SPELL_DRAIN_WORLD_TREE_VISUAL
@ SPELL_DENOUEMENT
@ SPELL_AIR_BURST
@ SPELL_SOUL_CHARGE_YELLOW
HookList< EffectApplyHandler > AfterEffectRemove
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:119
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:89
CreatureAI * AI() const
Definition Creature.h:154
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:52
void CancelEvent(EventId eventId)
Definition EventMap.cpp:151
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
void Clear()
Definition ObjectGuid.h:150
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 Id
Definition SpellInfo.h:289
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
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
virtual void SetGUID(ObjectGuid const &, int32=0)
Definition UnitAI.h:157
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:844
void SetControlled(bool apply, UnitState state)
Definition Unit.cpp:11256
uint8 GetClass() const
Definition Unit.h:895
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
TempSummon * ToTempSummon()
Definition Unit.h:1794
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true, SpellCastResult result=SPELL_FAILED_INTERRUPTED, Optional< SpellCastResult > resultOther={})
Definition Unit.cpp:3021
uint32 GetHealth() const
Definition Unit.h:913
void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3800
void NearTeleportTo(Position const &pos, bool casting=false)
Definition Unit.cpp:12832
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition Object.cpp:3323
void PlayDirectMusic(uint32 musicId, Player *target=nullptr)
Definition Object.cpp:3441
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1192
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1123
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_archimonde_drain_world_tree_dummy)
bool Validate(SpellInfo const *) override
PrepareAuraScript(spell_archimonde_eternal_silence)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
@ DATA_ARCHIMONDE
Definition hyjal.h:34
@ ACTION_ARCHIMONDE_INTRO
Definition hyjal.h:93
#define RegisterHyjalCreatureAI(ai_name)
Definition hyjal.h:126
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
static float NormalizeOrientation(float o)
Definition Position.cpp:156
float GetPositionZ() const
Definition Position.h:81
float GetOrientation() const
Definition Position.h:82
float GetPositionX() const
Definition Position.h:79
void GetPosition(float &x, float &y) const
Definition Position.h:84
float GetPositionY() const
Definition Position.h:80
void AttackStart(Unit *) override
void DoPlaySoundToSet(WorldObject *source, uint32 soundId)
void JustEngagedWith(Unit *who) override
boss_archimonde(Creature *creature)
void EnterEvadeMode(EvadeReason) override
ObjectGuid _doomfireSpiritGUID
void JustSummoned(Creature *summoned) override
void OnSpellCast(SpellInfo const *spellInfo) override
void KilledUnit(Unit *victim) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void DamageTaken(Unit *who, uint32 &damage, DamageEffectType, SpellInfo const *) override
void DoAction(int32 action) override
void MovementInform(uint32 type, uint32 pointId) override
void JustAppeared() override
void UpdateAI(uint32 diff) override
void Reset() override
TaskScheduler _scheduler
void UpdateAI(uint32 diff) override
npc_ancient_wisp(Creature *creature)
void JustEngagedWith(Unit *) override
void InitializeAI() override
void JustAppeared() override
npc_doomfire_spirit(Creature *creature)
void JustAppeared() override
void UpdateAI(uint32 diff) override
void InitializeAI() override
void JustAppeared() override
ObjectGuid _doomfireSpiritGUID
void SetGUID(ObjectGuid const &guid, int32 id) override
npc_doomfire(Creature *creature)
void UpdateAI(uint32 diff) override
TaskScheduler _scheduler