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 }
223
224private:
226};
227
228// 39899 - Baltharus the Warborn
230{
232
233 void Reset() override
234 {
237 }
238
247
248 void EnterEvadeMode(EvadeReason /*why*/) override { }
249
250 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
251 {
252 // Setting DATA_BALTHARUS_SHARED_HEALTH to 0 when killed would bug the boss.
253 if (me->GetHealth() > damage)
255 }
256
257 void JustDied(Unit* killer) override
258 {
259 // This is here because DamageTaken wont trigger if the damage is deadly.
261 Unit::Kill(killer, baltharus);
262 }
263
264 void UpdateAI(uint32 diff) override
265 {
266 if (!UpdateVictim())
267 return;
268
270
271 events.Update(diff);
272
274 return;
275
276 while (uint32 eventId = events.ExecuteEvent())
277 {
278 switch (eventId)
279 {
280 case EVENT_CLEAVE:
282 events.Repeat(20s, 24s);
283 break;
286 events.Repeat(24s);
287 break;
289 for (uint8 i = 0; i < RAID_MODE<uint8>(2, 4, 2, 4); i++)
290 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, false, -SPELL_ENERVATING_BRAND))
292 events.Repeat(26s);
293 break;
294 default:
295 break;
296 }
297
299 return;
300 }
301 }
302};
303
304// 74505 - Enervating Brand
306{
307 bool Validate(SpellInfo const* /*spell*/) override
308 {
310 }
311
313 {
314 if (SpellInfo const* spellInfo = GetTriggeringSpell())
315 if (Aura* triggerAura = GetCaster()->GetAura(spellInfo->Id))
316 if (Unit* caster = triggerAura->GetCaster())
317 GetHitUnit()->CastSpell(caster, SPELL_SIPHONED_MIGHT, true);
318 }
319
324};
325
@ DIFFICULTY_10_N
Definition DBCEnums.h:939
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
#define SpellHitFn(F)
EvadeReason
@ REACT_DEFENSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
void AddSC_boss_baltharus_the_warborn()
TypeID GetTypeId() const
Definition BaseEntity.h:166
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:180
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:246
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:32
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
Creature * GetCreature(uint32 type)
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
HookList< HitHandler > OnHit
SpellInfo const * GetTriggeringSpell() const
Unit * GetHitUnit() const
void Summon(Creature const *summon)
void DoZoneInCombat(uint32 entry=0)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
void SetHealth(uint64 val)
Definition Unit.cpp:10041
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3253
uint64 GetMaxHealth() const
Definition Unit.h:801
uint64 GetHealth() const
Definition Unit.h:800
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition Unit.cpp:11311
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
void setActive(bool isActiveObject)
Definition Object.cpp:274
void SetFarVisible(bool on)
Definition Object.cpp:325
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:99
virtual void SetData(uint32, uint32)
Definition ZoneScript.h:100
#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