TrinityCore
Loading...
Searching...
No Matches
boss_baltharus_the_warborn.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 "ruby_sanctum.h"
21#include "ScriptedCreature.h"
22#include "SpellAuraEffects.h"
23#include "SpellScript.h"
24
26{
27 SAY_BALTHARUS_INTRO = 0, // Your power wanes, ancient one.... Soon you will join your friends.
28 SAY_AGGRO = 1, // Ah, the entertainment has arrived.
29 SAY_KILL = 2, // Baltharus leaves no survivors! - This world has enough heroes.
30 SAY_CLONE = 3, // Twice the pain and half the fun.
31 SAY_DEATH = 4 // I... didn't see that coming....
32};
33
46
56
61
68
69// 39751 - Baltharus the Warborn
71{
73
83
84 void DoAction(int32 action) override
85 {
86 switch (action)
87 {
89 me->setActive(true);
90 me->SetFarVisible(true);
92 break;
93 case ACTION_CLONE:
94 {
99 break;
100 }
101 default:
102 break;
103 }
104 }
105
117
118 void JustDied(Unit* /*killer*/) override
119 {
120 _JustDied();
122 if (Creature* xerestrasza = instance->GetCreature(DATA_XERESTRASZA))
123 xerestrasza->AI()->DoAction(ACTION_BALTHARUS_DEATH);
124 }
125
126 void KilledUnit(Unit* victim) override
127 {
128 if (victim->GetTypeId() == TYPEID_PLAYER)
129 Talk(SAY_KILL);
130 }
131
132 void JustSummoned(Creature* summon) override
133 {
134 summons.Summon(summon);
135 summon->SetHealth(me->GetHealth());
137 }
138
139 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
140 {
142 {
143 if (me->HealthBelowPctDamaged(50, damage) && _cloneCount == 0)
144 {
145 ++_cloneCount;
147 }
148 }
149 else
150 {
151 if (me->HealthBelowPctDamaged(66, damage) && _cloneCount == 0)
152 {
153 ++_cloneCount;
155 }
156 else if (me->HealthBelowPctDamaged(33, damage) && _cloneCount == 1)
157 {
158 ++_cloneCount;
160 }
161 }
162
163 if (me->GetHealth() > damage)
165 }
166
167 void EnterEvadeMode(EvadeReason /*why*/) override
168 {
170 events.Reset();
172 }
173
174 void UpdateAI(uint32 diff) override
175 {
176
178 return;
179
182
183 events.Update(diff);
184
186 return;
187
188 while (uint32 eventId = events.ExecuteEvent())
189 {
190 switch (eventId)
191 {
192 case EVENT_INTRO_TALK:
194 break;
195 case EVENT_CLEAVE:
197 events.Repeat(20s, 24s);
198 break;
201 events.Repeat(24s);
202 break;
204 for (uint8 i = 0; i < RAID_MODE<uint8>(2, 4, 2, 4); i++)
205 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, false, -SPELL_ENERVATING_BRAND))
207 events.Repeat(26s);
208 break;
211 break;
212 case EVENT_CLONE:
214 break;
215 default:
216 break;
217 }
218
220 return;
221 }
222
224 }
225
226private:
228};
229
230// 39899 - Baltharus the Warborn
232{
234
235 void Reset() override
236 {
239 }
240
249
250 void EnterEvadeMode(EvadeReason /*why*/) override { }
251
252 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
253 {
254 // Setting DATA_BALTHARUS_SHARED_HEALTH to 0 when killed would bug the boss.
255 if (me->GetHealth() > damage)
257 }
258
259 void JustDied(Unit* killer) override
260 {
261 // This is here because DamageTaken wont trigger if the damage is deadly.
263 Unit::Kill(killer, baltharus);
264 }
265
266 void UpdateAI(uint32 diff) override
267 {
268 if (!UpdateVictim())
269 return;
270
272
273 events.Update(diff);
274
276 return;
277
278 while (uint32 eventId = events.ExecuteEvent())
279 {
280 switch (eventId)
281 {
282 case EVENT_CLEAVE:
284 events.Repeat(20s, 24s);
285 break;
288 events.Repeat(24s);
289 break;
291 for (uint8 i = 0; i < RAID_MODE<uint8>(2, 4, 2, 4); i++)
292 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, false, -SPELL_ENERVATING_BRAND))
294 events.Repeat(26s);
295 break;
296 default:
297 break;
298 }
299
301 return;
302 }
303
305 }
306};
307
308// 74505 - Enervating Brand
310{
312
313 bool Validate(SpellInfo const* /*spell*/) override
314 {
316 }
317
319 {
320 if (SpellInfo const* spellInfo = GetTriggeringSpell())
321 if (Aura* triggerAura = GetCaster()->GetAura(spellInfo->Id))
322 if (Unit* caster = triggerAura->GetCaster())
323 GetHitUnit()->CastSpell(caster, SPELL_SIPHONED_MIGHT, true);
324 }
325
330};
331
@ RAID_DIFFICULTY_10MAN_NORMAL
Definition DBCEnums.h:286
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
#define SpellHitFn(F)
@ REACT_DEFENSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
void AddSC_boss_baltharus_the_warborn()
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:119
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
Creature * GetCreature(uint32 type)
TypeID GetTypeId() const
Definition Object.h:93
Unit * GetCaster() const
HookList< HitHandler > OnHit
SpellInfo const * GetTriggeringSpell() const
Unit * GetHitUnit() const
void Summon(Creature const *summon)
void DoZoneInCombat(uint32 entry=0)
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
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3093
uint32 GetMaxHealth() const
Definition Unit.h:914
void SetHealth(uint32 val)
Definition Unit.cpp:9361
uint32 GetHealth() const
Definition Unit.h:913
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true)
Definition Unit.cpp:10930
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
void setActive(bool isActiveObject)
Definition Object.cpp:991
void SetFarVisible(bool on)
Definition Object.cpp:1014
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:55
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:56
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareSpellScript(spell_baltharus_enervating_brand_trigger)
#define RegisterRubySanctumCreatureAI(ai_name)
@ DATA_CRYSTAL_CHANNEL_TARGET
@ DATA_BALTHARUS_SHARED_HEALTH
@ DATA_BALTHARUS_CLONE
@ DATA_XERESTRASZA
@ DATA_BALTHARUS_THE_WARBORN
@ NPC_BALTHARUS_THE_WARBORN_CLONE
@ ACTION_INTRO_BALTHARUS
@ ACTION_BALTHARUS_DEATH
Difficulty GetDifficulty() const
void JustSummoned(Creature *summon) override
void EnterEvadeMode(EvadeReason) override
void DoAction(int32 action) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void KilledUnit(Unit *victim) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override