TrinityCore
boss_void_reaver.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 "the_eye.h"
19#include "ScriptedCreature.h"
20#include "ScriptMgr.h"
21
23{
27 SAY_POUNDING = 3
28};
29
31{
35 SPELL_BERSERK = 27680
36};
37
39{
44};
45
46struct boss_void_reaver : public BossAI
47{
48 boss_void_reaver(Creature* creature) : BossAI(creature, DATA_VOID_REAVER), _enraged(false) { }
49
50 void Reset() override
51 {
52 _Reset();
53 _enraged = false;
54 }
55
56 void JustEngagedWith(Unit* who) override
57 {
60 me->CallForHelp(120.0f);
61
66 }
67
68 void KilledUnit(Unit* /*victim*/) override
69 {
71 }
72
73 void JustDied(Unit* /*killer*/) override
74 {
76 _JustDied();
77 }
78
79 void UpdateAI(uint32 diff) override
80 {
81 if (!UpdateVictim())
82 return;
83
84 events.Update(diff);
85
87 return;
88
89 while (uint32 eventId = events.ExecuteEvent())
90 {
91 switch (eventId)
92 {
93 case EVENT_POUNDING:
97 break;
99 {
100 std::vector<Unit*> target_list;
101 for (auto* ref : me->GetThreatManager().GetUnsortedThreatList())
102 {
103 Unit* target = ref->GetVictim();
104 if (target->GetTypeId() == TYPEID_PLAYER && target->IsAlive() && !target->IsWithinDist(me, 18, false))
105 target_list.push_back(target);
106 }
107
108 Unit* target;
109 if (!target_list.empty())
110 target = *(target_list.begin() + rand32() % target_list.size());
111 else
112 target = me->GetVictim();
113
114 if (target)
115 me->CastSpell(target, SPELL_ARCANE_ORB);
116
118 break;
119 }
120 case EVENT_KNOCK_AWAY:
122 // Drop 25% aggro
123 if (GetThreat(me->GetVictim()))
125
127 break;
128 case EVENT_BERSERK:
129 if (!_enraged)
130 {
132 _enraged = true;
133 }
134 break;
135 default:
136 break;
137 }
138
140 return;
141 }
142 }
143
144private:
146};
147
149{
151}
uint32_t uint32
Definition: Define.h:142
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
uint32 rand32()
Definition: Random.cpp:70
@ UNIT_STATE_CASTING
Definition: Unit.h:270
ReaverSpells
@ SPELL_ARCANE_ORB
@ SPELL_KNOCK_AWAY
@ SPELL_BERSERK
@ SPELL_POUNDING
ReaverEvents
@ EVENT_POUNDING
@ EVENT_ARCANE_ORB
@ EVENT_KNOCK_AWAY
@ EVENT_BERSERK
ReaverTexts
@ SAY_DEATH
@ SAY_AGGRO
@ SAY_POUNDING
@ SAY_SLAY
void AddSC_boss_void_reaver()
void JustEngagedWith(Unit *who) override
EventMap events
void _JustDied()
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void CallForHelp(float fRadius)
Definition: Creature.cpp:2563
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
TypeID GetTypeId() const
Definition: Object.h:173
Trinity::IteratorPair< ThreatListIterator, std::nullptr_t > GetUnsortedThreatList() const
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:159
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:180
Definition: Unit.h:627
ThreatManager & GetThreatManager()
Definition: Unit.h:1063
bool IsAlive() const
Definition: Unit.h:1164
Unit * GetVictim() const
Definition: Unit.h:715
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1142
float GetThreat(Unit const *victim, Unit const *who=nullptr)
void ModifyThreatByPercent(Unit *victim, int32 pct, Unit *who=nullptr)
void Reset() override
void UpdateAI(uint32 diff) override
void JustDied(Unit *) override
void JustEngagedWith(Unit *who) override
boss_void_reaver(Creature *creature)
void KilledUnit(Unit *) override
#define RegisterTheEyeCreatureAI(ai_name)
Definition: the_eye.h:74
@ DATA_VOID_REAVER
Definition: the_eye.h:32