TrinityCore
Loading...
Searching...
No Matches
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 "ruins_of_ahnqiraj.h"
21#include "ScriptedCreature.h"
22#include "SpellInfo.h"
23#include "SpellScript.h"
24
26{
27 EMOTE_TARGET = 0
28};
29
31{
32 // Phase 1
36
37 // Phase 2
39
40 // Misc
41 SPELL_THORNS = 25640,
45
46 // Buru Egg
49
50 // Scripts
51 SPELL_EXPLOSION = 5255
52};
53
65
71
72// 15370 - Buru the Gorger
73struct boss_buru : public BossAI
74{
75 boss_buru(Creature* creature) : BossAI(creature, DATA_BURU), _phase(PHASE_EGG) { }
76
77 void Reset() override
78 {
79 _Reset();
82 }
83
96
97 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
98 {
99 switch (spellInfo->Id)
100 {
101 case SPELL_EXPLOSION:
105 break;
108 break;
109 default:
110 break;
111 }
112 }
113
114 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
115 {
116 if (_phase == PHASE_EGG && me->HealthBelowPctDamaged(20, damage))
117 {
120 }
121 }
122
123 void KilledUnit(Unit* /*victim*/) override
124 {
125 // Triggers even if victim is a creature. Victim can be a creature if it reaches first position in threat list
127 }
128
130 {
131 if (_phase != PHASE_EGG)
132 return;
133
136
138
139 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true))
140 {
141 AddThreat(target, 1000000.0f);
142 AttackStart(target);
143 Talk(EMOTE_TARGET, target);
144 }
145 }
146
147 void JustDied(Unit* /*killer*/) override
148 {
149 _JustDied();
151 }
152
153 void UpdateAI(uint32 diff) override
154 {
155 if (!UpdateVictim())
156 return;
157
158 events.Update(diff);
159
161 return;
162
163 while (uint32 eventId = events.ExecuteEvent())
164 {
165 switch (eventId)
166 {
167 // Phase 1
168 case EVENT_DISMEMBER:
170 events.Repeat(6s, 8s);
171 break;
174 events.Repeat(9s);
175 break;
176 case EVENT_FULL_SPEED:
178 break;
179
180 // Phase 2
183 events.Repeat(6s);
184 break;
185
186 // Transform
195 break;
200 break;
205 break;
206 default:
207 break;
208 }
209
211 return;
212 }
213
215 }
216
217private:
219};
220
221// 15514 - Buru Egg
223{
224 npc_buru_egg(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
225
226 void InitializeAI() override
227 {
228 me->SetCorpseDelay(4, true);
230 }
231
232 void JustEngagedWith(Unit* who) override
233 {
235 if (!buru->IsInCombat())
236 buru->AI()->AttackStart(who);
237 }
238
239 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
240 {
241 if (spellInfo->Id == SPELL_BURU_TRANSFORM)
242 {
245 }
246 }
247
248 void JustDied(Unit* /*killer*/) override
249 {
252 }
253
254private:
256};
257
258// 19593 - Egg Explosion
260{
262
263 bool Validate(SpellInfo const* /*spellInfo*/) override
264 {
266 }
267
268 void HandleDummy(SpellEffIndex /*effIndex*/)
269 {
270 Unit* caster = GetCaster();
271 Unit* target = GetHitUnit();
272
273 int32 damage = 0;
274
275 if (target->IsPet() || target->IsPlayer())
276 // Damage from 100 - 500 based on proximity - max range 25. Pets are valid targets here
277 damage = 100 + ((25 - std::min(caster->GetExactDist2d(target), 25.f)) / 25.f) * 400;
278
279 // Buru has different formula
280 else if (target->GetEntry() == NPC_BURU)
281 if (target->GetHealthPct() > 20.0f)
283 damage = target->GetMaxHealth() * 15 / 100;
284
286 args.AddSpellBP0(damage);
287 caster->CastSpell(target, SPELL_EXPLOSION, args);
288 }
289
294};
295
296// 27027 - Cancel Creeping Plague
316
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
#define SpellEffectFn(F, I, N)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
BuruPhases
Definition boss_buru.cpp:67
@ PHASE_EGG
Definition boss_buru.cpp:68
@ PHASE_TRANSFORM
Definition boss_buru.cpp:69
BuruSpells
Definition boss_buru.cpp:31
@ SPELL_SUMMON_HATCHLING
Definition boss_buru.cpp:48
@ SPELL_EXPLOSION
Definition boss_buru.cpp:51
@ SPELL_FULL_SPEED
Definition boss_buru.cpp:35
@ SPELL_GATHERING_SPEED
Definition boss_buru.cpp:34
@ SPELL_CANCEL_CREEPING_PLAGUE
Definition boss_buru.cpp:44
@ SPELL_THORNS
Definition boss_buru.cpp:41
@ SPELL_CREATURE_SPECIAL
Definition boss_buru.cpp:42
@ SPELL_EGG_EXPLOSION
Definition boss_buru.cpp:47
@ SPELL_DISMEMBER
Definition boss_buru.cpp:33
@ SPELL_CREEPING_PLAGUE
Definition boss_buru.cpp:38
@ SPELL_BURU_TRANSFORM
Definition boss_buru.cpp:43
BuruEvents
Definition boss_buru.cpp:55
@ EVENT_TRANSFORM_2
Definition boss_buru.cpp:62
@ EVENT_DISMEMBER
Definition boss_buru.cpp:56
@ EVENT_GATHERING_SPEED
Definition boss_buru.cpp:57
@ EVENT_FULL_SPEED
Definition boss_buru.cpp:58
@ EVENT_CREEPING_PLAGUE
Definition boss_buru.cpp:59
@ EVENT_TRANSFORM_1
Definition boss_buru.cpp:61
@ EVENT_TRANSFORM_3
Definition boss_buru.cpp:63
void AddSC_boss_buru()
BuruTexts
Definition boss_buru.cpp:26
@ EMOTE_TARGET
Definition boss_buru.cpp:27
void JustEngagedWith(Unit *who) override
EventMap events
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:119
void ResetPlayerDamageReq()
Definition Creature.h:323
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:89
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:52
void CancelEvent(EventId eventId)
Definition EventMap.cpp:151
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
Creature * GetCreature(uint32 type)
bool IsPlayer() const
Definition Object.h:179
uint32 GetEntry() const
Definition Object.h:81
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
Definition Unit.h:769
float GetHealthPct() const
Definition Unit.h:921
bool IsPet() const
Definition Unit.h:884
uint32 GetMaxHealth() const
Definition Unit.h:914
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_buru_cancel_creeping_plague)
bool Validate(SpellInfo const *) override
void HandleDummy(SpellEffIndex)
bool Validate(SpellInfo const *) override
PrepareSpellScript(spell_buru_egg_explosion)
void Register() override
void HandleDummy(SpellEffIndex)
#define RegisterAQ20CreatureAI(ai_name)
@ NPC_BURU
@ DATA_BURU
CastSpellExtraArgs & AddSpellBP0(int32 val)
float GetExactDist2d(const float x, const float y) const
Definition Position.h:109
void AttackStart(Unit *) override
void ResetThreatList(Unit *who=nullptr)
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void KilledUnit(Unit *) override
void ChaseNewVictim()
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
boss_buru(Creature *creature)
Definition boss_buru.cpp:75
void JustEngagedWith(Unit *who) override
Definition boss_buru.cpp:84
void Reset() override
Definition boss_buru.cpp:77
uint8 _phase
void JustDied(Unit *) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
Definition boss_buru.cpp:97
void UpdateAI(uint32 diff) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void JustDied(Unit *) override
InstanceScript * _instance
npc_buru_egg(Creature *creature)
void JustEngagedWith(Unit *who) override
void InitializeAI() override