TrinityCore
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
35{
39 SPELL_CLEAVE = 40504,
41 SPELL_CLONE = 74511,
44 SPELL_SPAWN_EFFECT = 64195
45};
46
48{
55};
56
58{
59 ACTION_CLONE = 1
60};
61
63{
67};
68
70{
72
73 void Reset() override
74 {
75 _Reset();
79 DoCast(channelTarget, SPELL_BARRIER_CHANNEL);
80 _cloneCount = 0;
81 }
82
83 void DoAction(int32 action) override
84 {
85 switch (action)
86 {
88 me->setActive(true);
89 me->SetFarVisible(true);
91 break;
92 case ACTION_CLONE:
93 {
98 break;
99 }
100 default:
101 break;
102 }
103 }
104
105 void JustEngagedWith(Unit* who) override
106 {
109 events.Reset();
115 }
116
117 void JustDied(Unit* /*killer*/) override
118 {
119 _JustDied();
121 if (Creature* xerestrasza = instance->GetCreature(DATA_XERESTRASZA))
122 xerestrasza->AI()->DoAction(ACTION_BALTHARUS_DEATH);
123 }
124
125 void KilledUnit(Unit* victim) override
126 {
127 if (victim->GetTypeId() == TYPEID_PLAYER)
128 Talk(SAY_KILL);
129 }
130
131 void JustSummoned(Creature* summon) override
132 {
133 summons.Summon(summon);
134 summon->SetHealth(me->GetHealth());
136 }
137
138 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
139 {
141 {
142 if (me->HealthBelowPctDamaged(50, damage) && _cloneCount == 0)
143 {
144 ++_cloneCount;
146 }
147 }
148 else
149 {
150 if (me->HealthBelowPctDamaged(66, damage) && _cloneCount == 0)
151 {
152 ++_cloneCount;
154 }
155 else if (me->HealthBelowPctDamaged(33, damage) && _cloneCount == 1)
156 {
157 ++_cloneCount;
159 }
160 }
161
162 if (me->GetHealth() > damage)
164 }
165
166 void EnterEvadeMode(EvadeReason /*why*/) override
167 {
169 events.Reset();
171 }
172
173 void UpdateAI(uint32 diff) override
174 {
175
177 return;
178
181
182 events.Update(diff);
183
185 return;
186
187 while (uint32 eventId = events.ExecuteEvent())
188 {
189 switch (eventId)
190 {
191 case EVENT_INTRO_TALK:
193 break;
194 case EVENT_CLEAVE:
196 events.Repeat(Seconds(20), Seconds(24));
197 break;
200 events.Repeat(Seconds(24));
201 break;
203 for (uint8 i = 0; i < RAID_MODE<uint8>(2, 4, 2, 4); i++)
204 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, false, -SPELL_ENERVATING_BRAND))
206 events.Repeat(Seconds(26));
207 break;
210 break;
211 case EVENT_CLONE:
213 break;
214 default:
215 break;
216 }
217
219 return;
220 }
221 }
222
223private:
225};
226
228{
230
231 void Reset() override
232 {
235 }
236
237 void JustEngagedWith(Unit* /*who*/) override
238 {
240 events.Reset();
244 }
245
246 void EnterEvadeMode(EvadeReason /*why*/) override { }
247
248 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
249 {
250 // Setting DATA_BALTHARUS_SHARED_HEALTH to 0 when killed would bug the boss.
251 if (me->GetHealth() > damage)
253 }
254
255 void JustDied(Unit* killer) override
256 {
257 // This is here because DamageTaken wont trigger if the damage is deadly.
259 Unit::Kill(killer, baltharus);
260 }
261
262 void UpdateAI(uint32 diff) override
263 {
264 if (!UpdateVictim())
265 return;
266
268
269 events.Update(diff);
270
272 return;
273
274 while (uint32 eventId = events.ExecuteEvent())
275 {
276 switch (eventId)
277 {
278 case EVENT_CLEAVE:
280 events.Repeat(Seconds(20), Seconds(24));
281 break;
284 events.Repeat(Seconds(24));
285 break;
287 for (uint8 i = 0; i < RAID_MODE<uint8>(2, 4, 2, 4); i++)
288 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, false, -SPELL_ENERVATING_BRAND))
290 events.Repeat(Seconds(26));
291 break;
292 default:
293 break;
294 }
295
297 return;
298 }
299 }
300};
301
302// 74505 - Enervating Brand
304{
305 bool Validate(SpellInfo const* /*spell*/) override
306 {
308 }
309
311 {
312 if (SpellInfo const* spellInfo = GetTriggeringSpell())
313 if (Aura* triggerAura = GetCaster()->GetAura(spellInfo->Id))
314 if (Unit* caster = triggerAura->GetCaster())
315 GetHitUnit()->CastSpell(caster, SPELL_SIPHONED_MIGHT, true);
316 }
317
318 void Register() override
319 {
321 }
322};
323
325{
329}
Texts
Actions
@ DIFFICULTY_10_N
Definition: DBCEnums.h:877
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
Spells
Definition: PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
#define SpellHitFn(F)
Definition: SpellScript.h:854
EvadeReason
Definition: UnitAICommon.h:30
@ REACT_DEFENSIVE
Definition: UnitDefines.h:507
DamageEffectType
Definition: UnitDefines.h:131
@ UNIT_STATE_CASTING
Definition: Unit.h:270
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 _JustDied()
void DoZoneInCombat()
Definition: CreatureAI.h:161
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr)
Definition: CreatureAI.cpp:56
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetReactState(ReactStates st)
Definition: Creature.h:160
uint32 ExecuteEvent()
Definition: EventMap.cpp:73
void Update(uint32 time)
Definition: EventMap.h:56
void Repeat(Milliseconds time)
Definition: EventMap.cpp:63
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition: EventMap.cpp:36
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:217
void SetPhase(uint8 phase)
Definition: EventMap.cpp:28
void Reset()
Definition: EventMap.cpp:21
Creature * GetCreature(uint32 type)
TypeID GetTypeId() const
Definition: Object.h:173
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
HookList< HitHandler > OnHit
Definition: SpellScript.h:850
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:159
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 SetHealth(uint64 val)
Definition: Unit.cpp:9346
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:3089
uint64 GetMaxHealth() const
Definition: Unit.h:777
uint64 GetHealth() const
Definition: Unit.h:776
bool HasUnitState(const uint32 f) const
Definition: Unit.h:732
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition: Unit.h:781
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition: Unit.cpp:10591
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
void setActive(bool isActiveObject)
Definition: Object.cpp:922
void SetFarVisible(bool on)
Definition: Object.cpp:973
virtual uint32 GetData(uint32) const
Definition: ZoneScript.h:91
virtual void SetData(uint32, uint32)
Definition: ZoneScript.h:92
#define RegisterRubySanctumCreatureAI(ai_name)
Definition: ruby_sanctum.h:138
@ DATA_CRYSTAL_CHANNEL_TARGET
Definition: ruby_sanctum.h:39
@ DATA_BALTHARUS_SHARED_HEALTH
Definition: ruby_sanctum.h:40
@ DATA_BALTHARUS_CLONE
Definition: ruby_sanctum.h:52
@ DATA_XERESTRASZA
Definition: ruby_sanctum.h:38
@ DATA_BALTHARUS_THE_WARBORN
Definition: ruby_sanctum.h:31
@ NPC_BALTHARUS_THE_WARBORN_CLONE
Definition: ruby_sanctum.h:68
@ ACTION_INTRO_BALTHARUS
Definition: ruby_sanctum.h:58
@ ACTION_BALTHARUS_DEATH
Definition: ruby_sanctum.h:59
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 UpdateAI(uint32 diff) override
void KilledUnit(Unit *victim) override
boss_baltharus_the_warborn(Creature *creature)
void JustEngagedWith(Unit *who) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override