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
58{
59 ACTION_CLONE = 1
60};
61
68
70{
72
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
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
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
322};
323
@ DIFFICULTY_10_N
Definition DBCEnums.h:936
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
Spells
Definition PlayerAI.cpp:32
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
#define SpellHitFn(F)
EvadeReason
@ REACT_DEFENSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
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:174
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
bool IsInPhase(uint8 phase) const
Definition EventMap.h:222
void SetPhase(uint8 phase)
Definition EventMap.cpp:32
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: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:635
void SetHealth(uint64 val)
Definition Unit.cpp:9973
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3231
uint64 GetMaxHealth() const
Definition Unit.h:789
uint64 GetHealth() const
Definition Unit.h:788
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:793
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
static void Kill(Unit *attacker, Unit *victim, bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition Unit.cpp:11225
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
void setActive(bool isActiveObject)
Definition Object.cpp:276
void SetFarVisible(bool on)
Definition Object.cpp:327
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