TrinityCore
Loading...
Searching...
No Matches
boss_high_inquisitor_fairbanks.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 "scarlet_monastery.h"
19#include "ScriptedCreature.h"
20#include "ScriptMgr.h"
21#include "Timer.h"
22
32
41
43{
44public:
46
47 bool operator()(Unit* unit) const
48 {
49 if (unit->GetTypeId() != TYPEID_PLAYER || _me->GetDistance(unit) > 30.f)
50 return false;
51
52 DispelChargesList dispelList;
53 unit->GetDispellableAuraList(_me, DISPEL_MAGIC, dispelList);
54 if (dispelList.empty())
55 return false;
56
57 return true;
58 }
59
60private:
61 Unit const* _me;
62};
63
65{
67
68 void Reset() override
69 {
70 _Reset();
71 _healTimer.Reset(0s);
72 _powerWordShield = false;
74 }
75
85
86 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
87 {
88 if (me->HealthBelowPctDamaged(25, damage))
89 {
91 {
93 _powerWordShield = true;
94 }
95
96 if (!me->IsNonMeleeSpellCast(false) && _healTimer.Passed())
97 {
98 _healTimer.Reset(30s);
100 }
101 }
102 }
103
104 void UpdateAI(uint32 diff) override
105 {
106 if (!UpdateVictim())
107 return;
108
109 events.Update(diff);
110
112 return;
113
114 while (uint32 eventId = events.ExecuteEvent())
115 {
116 ExecuteEvent(eventId);
118 return;
119 }
120
121 if (!_healTimer.Passed())
122 _healTimer.Update(diff);
123
125 }
126
127 void ExecuteEvent(uint32 eventId) override
128 {
129 switch (eventId)
130 {
133 events.Repeat(25s);
134 break;
137 DoCast(target, SPELL_DISPEL_MAGIC);
138 events.Repeat(30s);
139 break;
140 case EVENT_FEAR:
141 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 20.f, true))
142 DoCast(target, SPELL_FEAR);
143 events.Repeat(40s);
144 break;
145 case EVENT_SLEEP:
146 if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 0, 30.f, true, false))
147 DoCast(target, SPELL_SLEEP);
148 events.Repeat(30s);
149 break;
150 default:
151 break;
152 }
153 }
154
155private:
158};
159
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
@ DISPEL_MAGIC
@ UNIT_STAND_STATE_DEAD
Definition UnitDefines.h:41
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:34
@ UNIT_STATE_CASTING
Definition Unit.h:235
std::vector< DispelableAura > DispelChargesList
Definition Unit.h:132
DamageEffectType
Definition Unit.h:352
void AddSC_boss_high_inquisitor_fairbanks()
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
TypeID GetTypeId() const
Definition Object.h:93
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
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
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition Unit.cpp:3063
void GetDispellableAuraList(WorldObject const *caster, uint32 dispelMask, DispelChargesList &dispelList, bool isReflect=false) const
Definition Unit.cpp:4463
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
void SetStandState(UnitStandStateType state)
Definition Unit.cpp:10363
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1123
@ DATA_HIGH_INQUISITOR_FAIRBANKS
#define RegisterScarletMonasteryCreatureAI(ai)
void Update(int32 diff)
Definition Timer.h:121
bool Passed() const
Definition Timer.h:131
void Reset(int32 expiry)
Definition Timer.h:136
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override