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(50))
172 break;
174 if (roll_chance(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 }
415
416private:
419};
420
421// 18095 - Doomfire
423{
424 npc_doomfire(Creature* creature) : ScriptedAI(creature) { }
425
426 void InitializeAI() override
427 {
429 }
430
431 void JustAppeared() override
432 {
434 .Schedule(1200ms, [this](TaskContext const& /*task*/)
435 {
438 })
439 .Schedule(1200ms, [this](TaskContext& task)
440 {
442 {
443 float x, y, z;
444 target->GetClosePoint(x, y, z, 0.0f, 1.0f, float(M_PI));
446 task.Repeat(1200ms);
447 }
448 });
449 }
450
451 void SetGUID(ObjectGuid const& guid, int32 id) override
452 {
453 if (id == GUID_DOOMFIRE)
454 _doomfireSpiritGUID = guid;
455 }
456
457 void UpdateAI(uint32 diff) override
458 {
459 _scheduler.Update(diff);
460 }
461
462private:
465};
466
467// 18104 - Doomfire Spirit
469{
470 npc_doomfire_spirit(Creature* creature) : ScriptedAI(creature) { }
471
472 void JustAppeared() override
473 {
474 _scheduler.Schedule(0s, [this](TaskContext& task)
475 {
476 Position pos = me->GetPosition();
477 float orientation = Position::NormalizeOrientation(me->GetOrientation() + RAND(0.0f, -1.0f, 1.0f) * static_cast<float>(M_PI_4));
478 me->MovePositionToFirstCollision(pos, 8.0f, orientation);
479 me->NearTeleportTo(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), orientation);
480 task.Repeat(1200ms);
481 });
482 }
483
484 void UpdateAI(uint32 diff) override
485 {
486 _scheduler.Update(diff);
487 }
488
489private:
491};
492
493// 17946 - Ancient Wisp
495{
496 npc_ancient_wisp(Creature* creature) : ScriptedAI(creature) { }
497
498 void InitializeAI() override
499 {
501 me->SetCorpseDelay(20, true);
502 }
503
504 void JustAppeared() override
505 {
506 if (TempSummon* summon = me->ToTempSummon())
507 if (Unit* summoner = summon->GetSummonerUnit())
508 AttackStart(summoner);
509 }
510
511 void Reset() override
512 {
514 }
515
516 void JustEngagedWith(Unit* /*who*/) override
517 {
518 _scheduler.Schedule(0s, [this](TaskContext& task)
519 {
520 if (me->IsWithinDistInMap(me->GetVictim(), 10.0f))
522 task.Repeat(2400ms);
523 });
524 }
525
526 void UpdateAI(uint32 diff) override
527 {
528 if (!UpdateVictim())
529 return;
530
531 _scheduler.Update(diff);
532 }
533
534private:
536};
537
538// 39142 - Drain World Tree Dummy
556
557// 42201 - Eternal Silence
575
#define M_PI
Definition Common.h:118
#define M_PI_4
Definition Common.h:122
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
bool roll_chance(float chance, PseudoRandomDistributionState &state)
Definition Random.cpp:131
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
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)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
DamageEffectType
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:611
@ UNIT_STATE_ROOT
Definition Unit.h:285
@ UNIT_STATE_CASTING
Definition Unit.h:290
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
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:180
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:118
CreatureAI * AI() const
Definition Creature.h:235
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:56
void CancelEvent(EventId eventId)
Definition EventMap.cpp:156
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
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={})
void Clear()
Definition ObjectGuid.h:329
uint32 GetEntry() const
Definition Object.h:89
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
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 SetGUID(ObjectGuid const &guid, int32 id)
Definition UnitAI.h:76
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
bool IsWithinMeleeRange(Unit const *obj) const
Definition Unit.h:722
void SetControlled(bool apply, UnitState state)
Definition Unit.cpp:11631
uint8 GetClass() const
Definition Unit.h:776
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true, SpellCastResult result=SPELL_FAILED_INTERRUPTED, Optional< SpellCastResult > resultOther={}, ObjectGuid const &interrupter=ObjectGuid::Empty)
Definition Unit.cpp:3158
TempSummon * ToTempSummon()
Definition Unit.h:1844
uint64 GetHealth() const
Definition Unit.h:800
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT, uint16 num=1)
Definition Unit.cpp:4008
Unit * GetVictim() const
Definition Unit.h:738
void NearTeleportTo(TeleportLocation const &target, bool casting=false)
Definition Unit.cpp:13054
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
void PlayDirectMusic(uint32 musicId, Player const *target=nullptr) const
Definition Object.cpp:2949
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:499
void MovePositionToFirstCollision(Position &pos, float dist, float angle) const
Definition Object.cpp:2833
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:430
bool Validate(SpellInfo const *) override
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)
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
static float NormalizeOrientation(float o)
Definition Position.cpp:207
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
constexpr float GetOrientation() const
Definition Position.h:90
constexpr float GetPositionZ() const
Definition Position.h:89
void AttackStart(Unit *) override
== Triggered Actions Requested ==================
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