TrinityCore
boss_balinda.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 "ObjectAccessor.h"
20#include "ScriptedCreature.h"
21
23{
29 SPELL_ICEBLOCK = 46604
30};
31
33{
37};
38
40{
41 ACTION_BUFF_YELL = -30001 // shared from Battleground
42};
43
45{
46 // Balinda
52 EVENT_CHECK_RESET, // Checks if Balinda or the Water Elemental are outside of building.
53};
54
55struct boss_balinda : public ScriptedAI
56{
57 boss_balinda(Creature* creature) : ScriptedAI(creature), summons(me)
58 {
59 Initialize();
60 }
61
63 {
65 HasCastIceblock = false;
66 }
67
68 void Reset() override
69 {
70 Initialize();
71 events.Reset();
73 }
74
75 void JustEngagedWith(Unit* /*who*/) override
76 {
84 }
85
86 void JustSummoned(Creature* summoned) override
87 {
88 summoned->AI()->AttackStart(SelectTarget(SelectTargetMethod::Random, 0, 50, true));
89 summoned->SetFaction(me->GetFaction());
90 WaterElementalGUID = summoned->GetGUID();
91 summons.Summon(summoned);
92 }
93
94 void SummonedCreatureDespawn(Creature* summoned) override
95 {
96 summons.Despawn(summoned);
97 }
98
99 void JustDied(Unit* /*killer*/) override
100 {
102 }
103
104 void DoAction(int32 actionId) override
105 {
106 if (actionId == ACTION_BUFF_YELL)
108 }
109
110 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
111 {
112 if (me->HealthBelowPctDamaged(40, damage) && !HasCastIceblock)
113 {
115 HasCastIceblock = true;
116 }
117 }
118
119 void UpdateAI(uint32 diff) override
120 {
121 if (!UpdateVictim())
122 return;
123
124 events.Update(diff);
125
127 return;
128
129 while (uint32 eventId = events.ExecuteEvent())
130 {
131 switch (eventId)
132 {
136 break;
140 break;
141 case EVENT_FIREBOLT:
144 break;
145 case EVENT_FROSTBOLT:
148 break;
150 if (summons.empty())
153 break;
155 if (me->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 50)
156 {
159 }
161 if (elemental->GetDistance2d(me->GetHomePosition().GetPositionX(), me->GetHomePosition().GetPositionY()) > 50)
162 elemental->AI()->EnterEvadeMode();
164 break;
165 default:
166 break;
167 }
168
170 return;
171 }
172 }
173
174private:
179};
180
182{
184}
Texts
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
Spells
Definition: PlayerAI.cpp:32
#define RegisterCreatureAI(ai_name)
Definition: ScriptMgr.h:1380
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
@ SPELL_FROSTBOLT
@ SPELL_ICEBLOCK
@ SPELL_ARCANE_EXPLOSION
@ SPELL_FIREBALL
@ SPELL_CONE_OF_COLD
@ SPELL_SUMMON_WATER_ELEMENTAL
Action
@ ACTION_BUFF_YELL
@ SAY_SALVATION
@ SAY_AGGRO
@ SAY_EVADE
void AddSC_boss_balinda()
@ EVENT_SUMMON_WATER_ELEMENTAL
@ EVENT_ARCANE_EXPLOSION
@ EVENT_CHECK_RESET
@ EVENT_FROSTBOLT
@ EVENT_CONE_OF_COLD
@ EVENT_FIREBOLT
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
Definition: CreatureAI.cpp:219
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:373
CreatureAI * AI() const
Definition: Creature.h:214
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
void Reset()
Definition: EventMap.cpp:21
void Clear()
Definition: ObjectGuid.h:286
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
bool empty() const
void Despawn(Creature const *summon)
void Summon(Creature const *summon)
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 SetFaction(uint32 faction) override
Definition: Unit.h:859
uint32 GetFaction() const override
Definition: Unit.h:858
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
float GetDistance2d(WorldObject const *obj) const
Definition: Object.cpp:1096
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
void Initialize()
void Reset() override
boss_balinda(Creature *creature)
void JustSummoned(Creature *summoned) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
SummonList summons
void JustEngagedWith(Unit *) override
EventMap events
ObjectGuid WaterElementalGUID
void DoAction(int32 actionId) override
void SummonedCreatureDespawn(Creature *summoned) override
void JustDied(Unit *) override
void UpdateAI(uint32 diff) override