TrinityCore
boss_buru.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 "InstanceScript.h"
20#include "ObjectAccessor.h"
21#include "ruins_of_ahnqiraj.h"
22#include "ScriptedCreature.h"
23#include "SpellScript.h"
24
26{
27 EMOTE_TARGET = 0
28};
29
31{
36 SPELL_THORNS = 25640,
42};
43
45{
51};
52
54{
57};
58
60{
62};
63
65{
66 public:
67 boss_buru() : CreatureScript("boss_buru") { }
68
69 struct boss_buruAI : public BossAI
70 {
71 boss_buruAI(Creature* creature) : BossAI(creature, DATA_BURU)
72 {
73 _phase = 0;
74 }
75
76 void EnterEvadeMode(EvadeReason why) override
77 {
79
80 for (ObjectGuid eggGuid : Eggs)
81 if (Creature* egg = ObjectAccessor::GetCreature(*me, eggGuid))
82 egg->Respawn();
83
84 Eggs.clear();
85 }
86
87 void JustEngagedWith(Unit* who) override
88 {
90 Talk(EMOTE_TARGET, who);
92
96
98 }
99
100 void DoAction(int32 action) override
101 {
102 if (action == ACTION_EXPLODE)
103 if (_phase == PHASE_EGG)
104 Unit::DealDamage(me, me, 45000);
105 }
106
107 void KilledUnit(Unit* victim) override
108 {
109 if (victim->GetTypeId() == TYPEID_PLAYER)
111 }
112
114 {
115 if (_phase != PHASE_EGG)
116 return;
117
122
123 if (Unit* victim = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
124 {
126 AttackStart(victim);
127 Talk(EMOTE_TARGET, victim);
128 }
129 }
130
132 {
134 Eggs.push_back(EggGUID);
136 }
137
138 void UpdateAI(uint32 diff) override
139 {
140 if (!UpdateVictim())
141 return;
142
143 events.Update(diff);
144
145 while (uint32 eventId = events.ExecuteEvent())
146 {
147 switch (eventId)
148 {
149 case EVENT_DISMEMBER:
152 break;
156 break;
157 case EVENT_FULL_SPEED:
159 break;
163 break;
165 if (Creature* egg = ObjectAccessor::GetCreature(*me, Eggs.front()))
166 {
167 egg->Respawn();
168 Eggs.pop_front();
169 }
170 break;
171 default:
172 break;
173 }
174 }
175
176 if (me->GetHealthPct() < 20.0f && _phase == PHASE_EGG)
177 {
178 DoCast(me, SPELL_BURU_TRANSFORM); // Enrage
179 DoCast(me, SPELL_FULL_SPEED, true);
182 }
183 }
184 private:
187 };
188
189 CreatureAI* GetAI(Creature* creature) const override
190 {
191 return GetAQ20AI<boss_buruAI>(creature);
192 }
193};
194
196{
197 public:
198 npc_buru_egg() : CreatureScript("npc_buru_egg") { }
199
201 {
202 npc_buru_eggAI(Creature* creature) : ScriptedAI(creature)
203 {
205 SetCombatMovement(false);
206 }
207
208 void JustEngagedWith(Unit* attacker) override
209 {
211 if (!buru->IsInCombat())
212 buru->AI()->AttackStart(attacker);
213 }
214
215 void JustSummoned(Creature* who) override
216 {
217 if (who->GetEntry() == NPC_HATCHLING)
219 if (Unit* target = buru->AI()->SelectTarget(SelectTargetMethod::Random))
220 who->AI()->AttackStart(target);
221 }
222
223 void JustDied(Unit* /*killer*/) override
224 {
227
229 if (boss_buru::boss_buruAI* buruAI = dynamic_cast<boss_buru::boss_buruAI*>(buru->AI()))
230 buruAI->ManageRespawn(me->GetGUID());
231 }
232 private:
234 };
235
236 CreatureAI* GetAI(Creature* creature) const override
237 {
238 return GetAQ20AI<npc_buru_eggAI>(creature);
239 }
240};
241
242// 19593 - Egg Explosion
244{
245 public:
246 spell_egg_explosion() : SpellScriptLoader("spell_egg_explosion") { }
247
249 {
251 {
252 if (Creature* buru = GetCaster()->FindNearestCreature(NPC_BURU, 5.f))
253 buru->AI()->DoAction(ACTION_EXPLODE);
254 }
255
257 {
258 if (Unit* target = GetHitUnit())
259 {
261 args.AddSpellBP0(std::max<int32>(0, -16 * GetCaster()->GetDistance(target) + 500));
263 }
264 }
265
266 void Register() override
267 {
270 }
271 };
272
273 SpellScript* GetSpellScript() const override
274 {
276 }
277};
278
280{
281 new boss_buru();
282 new npc_buru_egg();
284}
Actions
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_DUMMY
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
Definition: SpellDefines.h:266
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define SpellCastFn(F)
Definition: SpellScript.h:825
EvadeReason
Definition: UnitAICommon.h:30
@ ACTION_EXPLODE
Definition: boss_buru.cpp:61
@ EMOTE_TARGET
Definition: boss_buru.cpp:27
@ SPELL_SUMMON_HATCHLING
Definition: boss_buru.cpp:38
@ SPELL_FULL_SPEED
Definition: boss_buru.cpp:35
@ SPELL_GATHERING_SPEED
Definition: boss_buru.cpp:34
@ SPELL_THORNS
Definition: boss_buru.cpp:36
@ SPELL_EXPLOSION_DAMAGE
Definition: boss_buru.cpp:40
@ SPELL_EGG_EXPLOSION
Definition: boss_buru.cpp:39
@ SPELL_DISMEMBER
Definition: boss_buru.cpp:33
@ SPELL_BURU_EGG_TRIGGER
Definition: boss_buru.cpp:41
@ SPELL_CREEPING_PLAGUE
Definition: boss_buru.cpp:32
@ SPELL_BURU_TRANSFORM
Definition: boss_buru.cpp:37
@ PHASE_EGG
Definition: boss_buru.cpp:55
@ PHASE_TRANSFORM
Definition: boss_buru.cpp:56
void AddSC_boss_buru()
Definition: boss_buru.cpp:279
@ EVENT_DISMEMBER
Definition: boss_buru.cpp:46
@ EVENT_GATHERING_SPEED
Definition: boss_buru.cpp:47
@ EVENT_FULL_SPEED
Definition: boss_buru.cpp:48
@ EVENT_RESPAWN_EGG
Definition: boss_buru.cpp:50
@ EVENT_CREEPING_PLAGUE
Definition: boss_buru.cpp:49
void JustEngagedWith(Unit *who) override
EventMap events
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
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
virtual ObjectGuid GetGuidData(uint32 type) const override
TypeID GetTypeId() const
Definition: Object.h:173
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
HookList< CastHandler > AfterCast
Definition: SpellScript.h:824
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:627
static uint32 DealDamage(Unit *attacker, Unit *victim, uint32 damage, CleanDamage const *cleanDamage=nullptr, DamageEffectType damagetype=DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *spellProto=nullptr, bool durabilityLoss=true)
Definition: Unit.cpp:769
float GetHealthPct() const
Definition: Unit.h:784
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
CreatureAI * GetAI(Creature *creature) const override
Definition: boss_buru.cpp:189
CreatureAI * GetAI(Creature *creature) const override
Definition: boss_buru.cpp:236
SpellScript * GetSpellScript() const override
Definition: boss_buru.cpp:273
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
@ NPC_HATCHLING
@ NPC_BURU
@ DATA_BURU
CastSpellExtraArgs & AddSpellBP0(int32 val)
Definition: SpellDefines.h:475
void AttackStart(Unit *) override
== Triggered Actions Requested ==================
void SetCombatMovement(bool allowMovement)
void ResetThreatList(Unit *who=nullptr)
void DoAction(int32 action) override
Definition: boss_buru.cpp:100
void ManageRespawn(ObjectGuid EggGUID)
Definition: boss_buru.cpp:131
void KilledUnit(Unit *victim) override
Definition: boss_buru.cpp:107
void EnterEvadeMode(EvadeReason why) override
Definition: boss_buru.cpp:76
boss_buruAI(Creature *creature)
Definition: boss_buru.cpp:71
void UpdateAI(uint32 diff) override
Definition: boss_buru.cpp:138
void JustEngagedWith(Unit *who) override
Definition: boss_buru.cpp:87
npc_buru_eggAI(Creature *creature)
Definition: boss_buru.cpp:202
void JustEngagedWith(Unit *attacker) override
Definition: boss_buru.cpp:208
void JustDied(Unit *) override
Definition: boss_buru.cpp:223
void JustSummoned(Creature *who) override
Definition: boss_buru.cpp:215
InstanceScript * _instance
Definition: boss_buru.cpp:233