TrinityCore
Loading...
Searching...
No Matches
boss_reliquary_of_souls.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 "ScriptMgr.h"
19#include "black_temple.h"
20#include "Containers.h"
21#include "InstanceScript.h"
22#include "MotionMaster.h"
23#include "Player.h"
24#include "ScriptedCreature.h"
25#include "SpellAuraEffects.h"
26#include "SpellScript.h"
27#include "TemporarySummon.h"
28
29enum Says
30{
31 // Essence of Suffering
36 //SUFF_SAY_AFTER = 4,
38
39 // Essence of Desire
44 //DESI_SAY_AFTER = 4,
45
46 // Essence of Anger
51 //ANGER_SAY_SPEC = 4,
53 //ANGER_SAY_DEATH = 6
54};
55
57{
58 // Reliquary
63
64 // Essence of Suffering
67 SPELL_FRENZY = 41305,
68
69 // Essence of Desire
73 SPELL_DEADEN = 41410,
75
76 // Essence of Anger
79 SPELL_SPITE = 41376,
81 SPELL_SEETHE = 41364,
82
83 // Enslaved Soul
86
87 // World Trigger
89};
90
100
107
124
125Position const DespawnPoint = { 497.4939f, 183.2081f, 94.53341f };
126
128{
129 public: EnslavedSoulEvent(Creature* owner) : _owner(owner) { }
130
131 bool Execute(uint64 /*time*/, uint32 /*diff*/) override
132 {
134 return true;
135 }
136
137 private:
139};
140
142{
144
145 void Reset() override
146 {
147 _Reset();
149 _inCombat = false;
151 }
152
153 void JustSummoned(Creature* summon) override
154 {
155 summons.Summon(summon);
156 summon->AI()->DoZoneInCombat();
157 }
158
170
171 void DoAction(int32 actionId) override
172 {
173 switch (actionId)
174 {
180 break;
186 break;
187 case ACTION_KILL_SELF:
188 me->KillSelf();
190 combatTrigger->AI()->DoAction(ACTION_KILL_SELF);
191 break;
193 _inCombat = true;
196 break;
197 default:
198 break;
199 }
200 }
201
203 {
204 std::vector<Creature*> _worldTriggerList;
206
207 if (_worldTriggerList.empty())
208 return;
209
210 //Get random creatures
211 Trinity::Containers::RandomShuffle(_worldTriggerList);
212 _worldTriggerList.resize(21);
213
214 for (uint8 i = 0; i < 21; i++)
215 {
216 Creature* wTrigger = _worldTriggerList[i];
217 if (i < 3)
218 wTrigger->m_Events.AddEventAtOffset(new EnslavedSoulEvent(wTrigger), 4s);
219 else if (i < 6)
220 wTrigger->m_Events.AddEventAtOffset(new EnslavedSoulEvent(wTrigger), 8s);
221 else if (i < 9)
222 wTrigger->m_Events.AddEventAtOffset(new EnslavedSoulEvent(wTrigger), 12s);
223 else if (i < 12)
224 wTrigger->m_Events.AddEventAtOffset(new EnslavedSoulEvent(wTrigger), 16s);
225 else if (i < 15)
226 wTrigger->m_Events.AddEventAtOffset(new EnslavedSoulEvent(wTrigger), 20s);
227 else if (i < 18)
228 wTrigger->m_Events.AddEventAtOffset(new EnslavedSoulEvent(wTrigger), 24s);
229 else
230 wTrigger->m_Events.AddEventAtOffset(new EnslavedSoulEvent(wTrigger), 28s);
231 }
232 }
233
235 {
236 std::vector<Creature*> _worldTriggerList;
238
239 if (_worldTriggerList.empty())
240 return;
241
242 for (Creature* trigger : _worldTriggerList)
243 trigger->m_Events.KillAllEvents(true);
244 }
245
246 void EnterEvadeMode(EvadeReason /*why*/) override
247 {
248 events.Reset();
252 }
253
254 void JustDied(Unit* /*killer*/) override
255 {
256 events.Reset();
258 }
259
260 void UpdateAI(uint32 diff) override
261 {
262 if (!_inCombat)
263 return;
264
265 events.Update(diff);
266
268 return;
269
270 while (uint32 eventId = events.ExecuteEvent())
271 {
272 if (eventId == EVENT_SUBMERGE)
273 {
278 }
279 }
280 }
281
282private:
284};
285
287{
292
293 void Reset() override
294 {
296 events.Reset();
297 _dead = false;
298 }
299
300 void MovementInform(uint32 motionType, uint32 pointId) override
301 {
302 if (motionType != POINT_MOTION_TYPE)
303 return;
304
305 if (pointId == RELIQUARY_DESPAWN_WAYPOINT)
306 {
308 reliquary->AI()->DoAction(ACTION_ESSENCE_OF_SUFFERING_DEAD);
309
312 }
313 }
314
315 void DamageTaken(Unit* /*done_by*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
316 {
317 if (damage >= me->GetHealth())
318 {
319 damage = 0;
320 if (!_dead)
321 {
322 _dead = true;
324 me->AttackStop();
326 events.Reset();
329 }
330 }
331 }
332
333 void JustEngagedWith(Unit* /*who*/) override
334 {
335 me->setActive(true);
336
340 }
341
342 void KilledUnit(Unit* victim) override
343 {
344 if (victim->GetTypeId() == TYPEID_PLAYER)
346 }
347
348 void UpdateAI(uint32 diff) override
349 {
350 if (!UpdateVictim())
351 return;
352
354 return;
355
356 events.Update(diff);
357
358 while (uint32 eventId = events.ExecuteEvent())
359 {
360 switch (eventId)
361 {
362 case EVENT_SOUL_DRAIN:
364 events.Repeat(Seconds(30), Seconds(35));
365 break;
366 case EVENT_FRENZY:
369 events.Repeat(Seconds(45), Seconds(50));
370 break;
371 default:
372 break;
373 }
374
376 return;
377 }
378 }
379private:
380 bool _dead;
381};
382
384{
389
390 void Reset() override
391 {
393 events.Reset();
394 _dead = false;
395 }
396
397 void JustEngagedWith(Unit* /*who*/) override
398 {
402
403 me->setActive(true);
405 }
406
407 void MovementInform(uint32 motionType, uint32 pointId) override
408 {
409 if (motionType != POINT_MOTION_TYPE)
410 return;
411
412 if (pointId == RELIQUARY_DESPAWN_WAYPOINT)
413 {
415 reliquary->AI()->DoAction(ACTION_ESSENCE_OF_DESIRE_DEAD);
416
419 }
420 }
421
422 void DamageTaken(Unit* /*done_by*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
423 {
424 if (damage >= me->GetHealth())
425 {
426 damage = 0;
427 if (!_dead)
428 {
429 _dead = true;
431 me->AttackStop();
433 events.Reset();
436 }
437 }
438 }
439
440 void KilledUnit(Unit* victim) override
441 {
442 if (victim->GetTypeId() == TYPEID_PLAYER)
444 }
445
446 void UpdateAI(uint32 diff) override
447 {
448 if (!UpdateVictim())
449 return;
450
452 return;
453
454 events.Update(diff);
455
456 while (uint32 eventId = events.ExecuteEvent())
457 {
458 switch (eventId)
459 {
462 events.Repeat(Seconds(10), Seconds(15));
463 break;
466 events.Repeat(Seconds(16));
467 break;
468 case EVENT_DEADEN:
471 events.Repeat(Seconds(31));
472 break;
473 default:
474 break;
475 }
476
478 return;
479 }
480 }
481private:
482 bool _dead;
483};
484
486{
491
492 void Reset() override
493 {
494 events.Reset();
497 }
498
510
511 void JustDied(Unit* /*killer*/) override
512 {
515 reliquary->AI()->DoAction(ACTION_KILL_SELF);
516 }
517
518 void UpdateAI(uint32 diff) override
519 {
520 if (!UpdateVictim())
521 return;
522
524 return;
525
526 events.Update(diff);
527
528 while (uint32 eventId = events.ExecuteEvent())
529 {
530 switch (eventId)
531 {
533 {
534 Unit* target = me->GetVictim();
535 if (!_targetGUID || !target)
536 return;
537
538 if (target->GetGUID() != _targetGUID)
539 {
542 _targetGUID = target->GetGUID();
544 }
545 break;
546 }
549 events.Repeat(Seconds(11));
550 break;
551 case EVENT_SPITE:
554 events.Repeat(Seconds(20));
555 break;
557 if (Unit* target = me->GetVictim())
558 {
559 _targetGUID = target->GetGUID();
561 }
562 else
564 break;
565 case EVENT_FREED_2:
567 break;
568 default:
569 break;
570 }
571
573 return;
574 }
575 }
576
577private:
579};
580
582{
583 npc_enslaved_soul(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()), _dead(false) { }
584
585 void Reset() override
586 {
589 reliquary->AI()->JustSummoned(me);
590
592
593 _scheduler.Schedule(Seconds(3), [this](TaskContext const& /*context*/)
594 {
597 });
598 _dead = false;
599 }
600
601 void DoAction(int32 actionId) override
602 {
603 if (actionId == ACTION_KILL_SELF)
605 }
606
608 {
610 me->AttackStop();
613 me->m_Events.AddEventAtOffset([this]() { me->KillSelf(); }, 500ms);
614 }
615
616 void DamageTaken(Unit* /*done_by*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
617 {
618 if (damage >= me->GetHealth())
619 {
620 damage = 0;
621 if (!_dead)
622 {
623 _dead = true;
625 }
626 }
627 }
628
629 void UpdateAI(uint32 diff) override
630 {
631 if (!UpdateVictim())
632 return;
633
634 _scheduler.Update(diff);
635 }
636
637private:
640 bool _dead;
641};
642
644{
645 npc_reliquary_combat_trigger(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript())
646 {
647 SetCombatMovement(false);
648 creature->m_SightDistance = 70.0f;
650 }
651
652 bool CanAIAttack(Unit const* who) const override
653 {
654 return ScriptedAI::CanAIAttack(who) && IsInBoundary(who);
655 }
656
663
664 void MoveInLineOfSight(Unit* who) override
665 {
666 if (!me->IsEngaged() && who->GetTypeId() == TYPEID_PLAYER && !who->ToPlayer()->IsGameMaster() && CanAIAttack(who))
667 {
669 {
671 reliquary->AI()->DoAction(ACTION_START_COMBAT);
672 }
673 }
674 }
675
676 void DamageTaken(Unit* /*done_by*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
677 {
678 damage = 0;
679 }
680
681 void EnterEvadeMode(EvadeReason why) override
682 {
685 reliquary->AI()->EnterEvadeMode(why);
686 }
687
688 void DoAction(int32 actionId) override
689 {
690 if (actionId == ACTION_KILL_SELF)
691 me->KillSelf();
692 }
693
694 void UpdateAI(uint32 /*diff*/) override
695 {
696 if (!UpdateVictim())
697 return;
698 }
699
700private:
702};
703
704// 41350 - Aura of Desire
706{
707 bool Validate(SpellInfo const* /*spellInfo*/) override
708 {
710 }
711
712 void OnProcSpell(AuraEffect* aurEff, ProcEventInfo& eventInfo)
713 {
715 DamageInfo* damageInfo = eventInfo.GetDamageInfo();
716 if (!damageInfo || !damageInfo->GetDamage())
717 return;
718
719 Unit* caster = eventInfo.GetActor();
720 caster->CastSpell(caster, SPELL_AURA_OF_DESIRE_DAMAGE, CastSpellExtraArgs(aurEff).AddSpellBP0(damageInfo->GetDamage() / 2));
721 }
722
723 void UpdateAmount(AuraEffect* /*aurEff*/)
724 {
725 if (AuraEffect* effect = GetAura()->GetEffect(EFFECT_1))
726 effect->ChangeAmount(effect->GetAmount() - 5);
727 }
728
734};
735
736// 41337 - Aura of Anger
738{
740 {
741 if (AuraEffect* aurEff1 = aurEff->GetBase()->GetEffect(EFFECT_1))
742 aurEff1->ChangeAmount(aurEff1->GetAmount() + 5);
743 aurEff->SetAmount(100.0 * aurEff->GetTickNumber());
744 }
745
750};
751
752// 28819 - Submerge Visual
771
772// 41376 - Spite
774{
775 bool Validate(SpellInfo const* /*spellInfo*/) override
776 {
778 }
779
780 void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
781 {
782 if (Unit* caster = GetCaster())
783 caster->CastSpell(GetTarget(), SPELL_SPITE_DAMAGE, true);
784 }
785
790};
791
792// 41305 - Frenzy
794{
796 {
797 if (Creature* caster = GetCaster()->ToCreature())
798 caster->AI()->Talk(SUFF_EMOTE_ENRAGE, caster);
799 }
800
805};
806
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
std::chrono::minutes Minutes
Minutes shorthand typedef.
Definition Duration.h:32
@ DONE
@ POINT_MOTION_TYPE
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
Spells
Definition PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PERIODIC_DAMAGE
@ SPELL_AURA_DUMMY
@ SPELL_AURA_MOD_HEALING_PCT
@ SPELL_AURA_DAMAGE_IMMUNITY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
@ SPELLVALUE_MAX_TARGETS
#define AuraEffectProcFn(F, I, N)
#define AuraEffectUpdatePeriodicFn(F, I, N)
#define SpellCastFn(F)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STAND_STATE_SUBMERGED
Definition UnitDefines.h:51
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:42
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
#define RegisterBlackTempleCreatureAI(ai_name)
@ DATA_ESSENCE_OF_SUFFERING
@ DATA_RELIQUARY_COMBAT_TRIGGER
@ DATA_ESSENCE_OF_ANGER
@ DATA_ESSENCE_OF_DESIRE
@ DATA_RELIQUARY_OF_SOULS
@ NPC_ENSLAVED_SOUL
@ NPC_RELIQUARY_WORLD_TRIGGER
@ ACTION_ESSENCE_OF_DESIRE_DEAD
@ RELIQUARY_DESPAWN_WAYPOINT
@ ACTION_ESSENCE_OF_SUFFERING_DEAD
void AddSC_boss_reliquary_of_souls()
@ SPELL_ENSLAVED_SOUL_PASSIVE
@ SPELL_SUMMON_ESSENCE_OF_DESIRE
@ SPELL_SUMMON_ESSENCE_OF_SUFFERING
@ SPELL_AURA_OF_DESIRE_DAMAGE
@ SPELL_SUMMON_ESSENCE_OF_ANGER
@ SPELL_SUBMERGE_VISUAL
@ SPELL_AURA_OF_SUFFERING
@ PHASE_ESSENCE_OF_SUFFERING
@ PHASE_ESSENCE_OF_DESIRE
Position const DespawnPoint
@ EVENT_START_CHECK_TANKER
uint32 GetTickNumber() const
void SetAmount(SpellEffectValue amount)
Aura * GetBase() const
void PreventDefaultAction()
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
AuraEffect * GetEffect(uint8 effIndex) const
Aura * GetAura() const
Unit * GetTarget() const
HookList< EffectProcHandler > OnEffectProc
AuraEffect * GetEffect(uint32 index) const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
InstanceScript *const instance
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool IsInBoundary(Position const *who=nullptr) const
bool UpdateVictim()
void SetBoundary(CreatureBoundary const *boundary, bool negativeBoundaries=false)
Creature *const me
Definition CreatureAI.h:63
bool IsEngaged() const override
void SetReactState(ReactStates st)
Definition Creature.h:174
float m_SightDistance
Definition Creature.h:427
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
CreatureAI * AI() const
Definition Creature.h:228
uint32 GetDamage() const
Definition Unit.h:452
EnslavedSoulEvent(Creature *owner)
bool Execute(uint64, uint32) override
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
bool IsInPhase(uint8 phase) const
Definition EventMap.h:222
void SetPhase(uint8 phase)
Definition EventMap.cpp:32
void Reset()
Definition EventMap.cpp:25
void AddEventAtOffset(BasicEvent *event, Milliseconds offset)
virtual bool SetBossState(uint32 id, EncounterState state)
Creature * GetCreature(uint32 type)
CreatureBoundary const * GetBossBoundary(uint32 id) const
EncounterState GetBossState(uint32 id) const
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
Player * ToPlayer()
Definition Object.h:126
bool IsGameMaster() const
Definition Player.h:1309
DamageInfo * GetDamageInfo() const
Definition Unit.h:511
Unit * GetActor() const
Definition Unit.h:499
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
HookList< CastHandler > AfterCast
Unit * GetCaster() const
void Summon(Creature const *summon)
void DoAction(int32 info, Predicate &&predicate, uint16 max=0)
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 bool CanAIAttack(Unit const *) const
Definition UnitAI.h:58
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:162
Definition Unit.h:635
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition Unit.cpp:10731
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3231
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
uint64 GetHealth() const
Definition Unit.h:788
Unit * GetVictim() const
Definition Unit.h:726
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void KillSelf(bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition Unit.h:936
bool AttackStop()
Definition Unit.cpp:5965
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
void GetCreatureListWithEntryInGrid(Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
Definition Object.cpp:2658
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
void setActive(bool isActiveObject)
Definition Object.cpp:276
EventProcessor m_Events
Definition Object.h:561
void OnProcSpell(AuraEffect *aurEff, ProcEventInfo &eventInfo)
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
void OnApply(AuraEffect const *, AuraEffectHandleModes)
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void RandomShuffle(Iterator begin, Iterator end)
Reorder the elements of the iterator range randomly.
Definition Containers.h:171
void SetCombatMovement(bool allowMovement)
void DoPlaySoundToSet(WorldObject *source, uint32 soundId)
void UpdateAI(uint32 diff) override
boss_essence_of_anger(Creature *creature)
void JustEngagedWith(Unit *) override
boss_essence_of_desire(Creature *creature)
void MovementInform(uint32 motionType, uint32 pointId) override
void KilledUnit(Unit *victim) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
void UpdateAI(uint32 diff) override
boss_essence_of_suffering(Creature *creature)
void KilledUnit(Unit *victim) override
void MovementInform(uint32 motionType, uint32 pointId) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
boss_reliquary_of_souls(Creature *creature)
void UpdateAI(uint32 diff) override
void JustSummoned(Creature *summon) override
void EnterEvadeMode(EvadeReason) override
void DoAction(int32 actionId) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
npc_enslaved_soul(Creature *creature)
void DoAction(int32 actionId) override
void UpdateAI(uint32 diff) override
void DoAction(int32 actionId) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
bool CanAIAttack(Unit const *who) const override
void MoveInLineOfSight(Unit *who) override
void EnterEvadeMode(EvadeReason why) override