TrinityCore
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
24{
27 SPELL_FEAR = 12096,
28 SPELL_HEAL = 12039,
30 SPELL_SLEEP = 8399
31};
32
34{
40};
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
76 void JustEngagedWith(Unit* who) override
77 {
84 }
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 }
124
125 void ExecuteEvent(uint32 eventId) override
126 {
127 switch (eventId)
128 {
131 events.Repeat(25s);
132 break;
135 DoCast(target, SPELL_DISPEL_MAGIC);
136 events.Repeat(30s);
137 break;
138 case EVENT_FEAR:
139 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 20.f, true))
140 DoCast(target, SPELL_FEAR);
141 events.Repeat(40s);
142 break;
143 case EVENT_SLEEP:
144 if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 0, 30.f, true, false))
145 DoCast(target, SPELL_SLEEP);
146 events.Repeat(30s);
147 break;
148 default:
149 break;
150 }
151 }
152
153private:
156};
157
159{
161}
uint32_t uint32
Definition: Define.h:142
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
@ DISPEL_MAGIC
@ UNIT_STAND_STATE_DEAD
Definition: UnitDefines.h:49
@ UNIT_STAND_STATE_STAND
Definition: UnitDefines.h:42
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
std::vector< DispelableAura > DispelChargesList
Definition: Unit.h:146
void AddSC_boss_high_inquisitor_fairbanks()
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
TypeID GetTypeId() const
Definition: Object.h:173
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:79
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition: Unit.cpp:10100
bool IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled=false, bool skipAutorepeat=false, bool isAutoshoot=false, bool skipInstant=true) const
Definition: Unit.cpp:3059
void GetDispellableAuraList(WorldObject const *caster, uint32 dispelMask, DispelChargesList &dispelList, bool isReflect=false) const
Definition: Unit.cpp:4596
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1078
@ 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