TrinityCore
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 "ObjectAccessor.h"
20#include "ScriptedCreature.h"
21#include "ScriptMgr.h"
22
24{
28 SAY_POUNDING = 3
29};
30
32{
36 SPELL_BERSERK = 27680
37};
38
40{
45};
46
47struct boss_void_reaver : public BossAI
48{
49 boss_void_reaver(Creature* creature) : BossAI(creature, DATA_VOID_REAVER), _enraged(false) { }
50
51 void Reset() override
52 {
53 _Reset();
54 _enraged = false;
55 }
56
57 void JustEngagedWith(Unit* who) override
58 {
61 me->CallForHelp(120.0f);
62
67 }
68
69 void KilledUnit(Unit* /*victim*/) override
70 {
72 }
73
74 void JustDied(Unit* /*killer*/) override
75 {
77 _JustDied();
78 }
79
80 void UpdateAI(uint32 diff) override
81 {
82 if (!UpdateVictim())
83 return;
84
85 events.Update(diff);
86
88 return;
89
90 while (uint32 eventId = events.ExecuteEvent())
91 {
92 switch (eventId)
93 {
94 case EVENT_POUNDING:
98 break;
100 {
101 std::vector<Unit*> target_list;
102 for (auto* ref : me->GetThreatManager().GetUnsortedThreatList())
103 {
104 Unit* target = ref->GetVictim();
105 if (target->GetTypeId() == TYPEID_PLAYER && target->IsAlive() && !target->IsWithinDist(me, 18, false))
106 target_list.push_back(target);
107 }
108
109 Unit* target;
110 if (!target_list.empty())
111 target = *(target_list.begin() + rand32() % target_list.size());
112 else
113 target = me->GetVictim();
114
115 if (target)
116 me->CastSpell(target, SPELL_ARCANE_ORB);
117
119 break;
120 }
121 case EVENT_KNOCK_AWAY:
123 // Drop 25% aggro
124 if (GetThreat(me->GetVictim()))
126
128 break;
129 case EVENT_BERSERK:
130 if (!_enraged)
131 {
133 _enraged = true;
134 }
135 break;
136 default:
137 break;
138 }
139
141 return;
142 }
143
145 }
146
147private:
149};
150
152{
154}
uint32_t uint32
Definition: Define.h:133
@ TYPEID_PLAYER
Definition: ObjectGuid.h:39
uint32 rand32()
Definition: Random.cpp:70
@ UNIT_STATE_CASTING
Definition: Unit.h:235
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:48
bool UpdateVictim()
Definition: CreatureAI.cpp:240
Creature *const me
Definition: CreatureAI.h:81
void CallForHelp(float fRadius)
Definition: Creature.cpp:2334
void Update(uint32 time)
Definition: EventMap.h:67
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:92
Trinity::IteratorPair< ThreatListIterator, std::nullptr_t > GetUnsortedThreatList() const
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:62
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:174
Definition: Unit.h:769
ThreatManager & GetThreatManager()
Definition: Unit.h:1153
bool IsAlive() const
Definition: Unit.h:1234
Unit * GetVictim() const
Definition: Unit.h:857
bool HasUnitState(const uint32 f) const
Definition: Unit.h:874
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2831
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1180
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