TrinityCore
Loading...
Searching...
No Matches
boss_black_knight.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/* ScriptData
19SDName: Boss Black Knight
20SD%Complete: 80%
21SDComment: missing yells. not sure about timers.
22SDCategory: Trial of the Champion
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "InstanceScript.h"
27#include "ScriptedEscortAI.h"
28#include "SpellInfo.h"
29#include "SpellScript.h"
31
33{
34 //phase 1
44 //in this phase should rise herald (the spell is missing)
45
46 //phase 2 - During this phase, the Black Knight will use the same abilities as in phase 1, except for Death's Respite
51
52 //phase 3
57
59
60 SPELL_LEAP = 67749,
61 SPELL_LEAP_H = 67880,
62
63 SPELL_KILL_CREDIT = 68663
64};
65
67{
69 MODEL_GHOST = 21300
70};
71
73{
76 PHASE_GHOST = 3
77};
78
80{
81public:
82 boss_black_knight() : CreatureScript("boss_black_knight") { }
83
85 {
86 boss_black_knightAI(Creature* creature) : ScriptedAI(creature), summons(creature)
87 {
88 Initialize();
89 instance = creature->GetInstanceScript();
90 }
91
93 {
94 bEventInProgress = false;
95 bEvent = false;
96 bSummonArmy = false;
97 bDeathArmyDone = false;
98
100
101 uiIcyTouchTimer = urand(5000, 9000);
102 uiPlagueStrikeTimer = urand(10000, 13000);
103 uiDeathRespiteTimer = urand(15000, 16000);
104 uiObliterateTimer = urand(17000, 19000);
105 uiDesecration = urand(15000, 16000);
107 uiResurrectTimer = 4000;
108 uiGhoulExplodeTimer = 8000;
109 uiDeathBiteTimer = urand(2000, 4000);
110 uiMarkedDeathTimer = urand(5000, 7000);
111 }
112
114
116
118 bool bEvent;
121
123
134
135 void Reset() override
136 {
140
141 Initialize();
142 }
143
144 void JustSummoned(Creature* summon) override
145 {
146 summons.Summon(summon);
147 summon->AI()->AttackStart(me->GetVictim());
148 }
149
150 void SummonedCreatureDespawn(Creature* summon) override
151 {
152 summons.Despawn(summon);
153 }
154
155 void UpdateAI(uint32 uiDiff) override
156 {
157 //Return since we have no target
158 if (!UpdateVictim())
159 return;
160
162 {
163 if (uiResurrectTimer <= uiDiff)
164 {
165 me->SetFullHealth();
167 uiPhase++;
168 uiResurrectTimer = 4000;
169 bEventInProgress = false;
171 } else uiResurrectTimer -= uiDiff;
172 }
173
174 switch (uiPhase)
175 {
176 case PHASE_UNDEAD:
177 case PHASE_SKELETON:
178 {
179 if (uiIcyTouchTimer <= uiDiff)
180 {
182 uiIcyTouchTimer = urand(5000, 7000);
183 } else uiIcyTouchTimer -= uiDiff;
184 if (uiPlagueStrikeTimer <= uiDiff)
185 {
187 uiPlagueStrikeTimer = urand(12000, 15000);
188 } else uiPlagueStrikeTimer -= uiDiff;
189 if (uiObliterateTimer <= uiDiff)
190 {
192 uiObliterateTimer = urand(17000, 19000);
193 } else uiObliterateTimer -= uiDiff;
194 switch (uiPhase)
195 {
196 case PHASE_UNDEAD:
197 {
198 if (uiDeathRespiteTimer <= uiDiff)
199 {
200 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
201 {
202 if (target->IsAlive())
204 }
205 uiDeathRespiteTimer = urand(15000, 16000);
206 } else uiDeathRespiteTimer -= uiDiff;
207 break;
208 }
209 case PHASE_SKELETON:
210 {
211 if (!bSummonArmy)
212 {
213 bSummonArmy = true;
216 }
217 if (!bDeathArmyDone)
218 {
219 if (uiDeathArmyCheckTimer <= uiDiff)
220 {
223 bDeathArmyDone = true;
224 } else uiDeathArmyCheckTimer -= uiDiff;
225 }
226 if (uiDesecration <= uiDiff)
227 {
228 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
229 {
230 if (target->IsAlive())
231 DoCast(target, SPELL_DESECRATION);
232 }
233 uiDesecration = urand(15000, 16000);
234 } else uiDesecration -= uiDiff;
235 if (uiGhoulExplodeTimer <= uiDiff)
236 {
238 uiGhoulExplodeTimer = 8000;
239 } else uiGhoulExplodeTimer -= uiDiff;
240 break;
241 }
242 break;
243 }
244 break;
245 }
246 case PHASE_GHOST:
247 {
248 if (uiDeathBiteTimer <= uiDiff)
249 {
251 uiDeathBiteTimer = urand(2000, 4000);
252 } else uiDeathBiteTimer -= uiDiff;
253 if (uiMarkedDeathTimer <= uiDiff)
254 {
255 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
256 {
257 if (target->IsAlive())
258 DoCast(target, SPELL_MARKED_DEATH);
259 }
260 uiMarkedDeathTimer = urand(5000, 7000);
261 } else uiMarkedDeathTimer -= uiDiff;
262 break;
263 }
264 }
265
268 }
269
270 void DamageTaken(Unit* /*pDoneBy*/, uint32& uiDamage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
271 {
272 if (uiDamage > me->GetHealth() && uiPhase <= PHASE_SKELETON)
273 {
274 uiDamage = 0;
275 me->SetHealth(0);
278 switch (uiPhase)
279 {
280 case PHASE_UNDEAD:
282 break;
283 case PHASE_SKELETON:
285 break;
286 }
287 bEventInProgress = true;
288 }
289 }
290
291 void JustDied(Unit* /*killer*/) override
292 {
294
296 }
297 };
298
299 CreatureAI* GetAI(Creature* creature) const override
300 {
301 return GetTrialOfTheChampionAI<boss_black_knightAI>(creature);
302 }
303};
304
306{
307public:
308 npc_risen_ghoul() : CreatureScript("npc_risen_ghoul") { }
309
311 {
312 npc_risen_ghoulAI(Creature* creature) : ScriptedAI(creature)
313 {
314 Initialize();
315 }
316
318 {
319 uiAttackTimer = 3500;
320 }
321
323
324 void Reset() override
325 {
326 Initialize();
327 }
328
329 void UpdateAI(uint32 uiDiff) override
330 {
331 if (!UpdateVictim())
332 return;
333
334 if (uiAttackTimer <= uiDiff)
335 {
336 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100, true))
337 {
338 if (target->IsAlive())
339 DoCast(target, (SPELL_LEAP));
340 }
341 uiAttackTimer = 3500;
342 } else uiAttackTimer -= uiDiff;
343
345 }
346 };
347
348 CreatureAI* GetAI(Creature* creature) const override
349 {
350 return GetTrialOfTheChampionAI<npc_risen_ghoulAI>(creature);
351 }
352};
353
354static constexpr uint32 PATH_ESCORT_GRYPHON = 283930;
355
357{
358public:
359 npc_black_knight_skeletal_gryphon() : CreatureScript("npc_black_knight_skeletal_gryphon") { }
360
362 {
364 {
366 Start(false);
367 }
368
369 void UpdateAI(uint32 uiDiff) override
370 {
371 EscortAI::UpdateAI(uiDiff);
372
373 UpdateVictim();
374 }
375
376 };
377
378 CreatureAI* GetAI(Creature* creature) const override
379 {
380 return GetTrialOfTheChampionAI<npc_black_knight_skeletal_gryphonAI>(creature);
381 }
382};
383
384// 67751 - Ghoul Explode
386{
387 bool Validate(SpellInfo const* spellInfo) override
388 {
389 return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
390 }
391
392 void HandleScript(SpellEffIndex /*effIndex*/)
393 {
395 }
396
397 void Register() override
398 {
400 }
401};
402
403// 67754 - Ghoul Explode
404// 67889 - Ghoul Explode
406{
407 bool Validate(SpellInfo const* spellInfo) override
408 {
409 return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()) });
410 }
411
412 void HandleScript(SpellEffIndex /*effIndex*/)
413 {
415 }
416
417 void Register() override
418 {
420 }
421};
422
424{
425 new boss_black_knight();
426 new npc_risen_ghoul();
430}
uint8_t uint8
Definition: Define.h:145
uint32_t uint32
Definition: Define.h:143
@ DONE
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_1
Definition: SharedDefines.h:31
@ EFFECT_0
Definition: SharedDefines.h:30
@ SPELL_EFFECT_SCRIPT_EFFECT
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
DamageEffectType
Definition: UnitDefines.h:126
@ UNIT_STATE_ROOT
Definition: Unit.h:262
@ UNIT_STATE_STUNNED
Definition: Unit.h:255
static constexpr uint32 PATH_ESCORT_GRYPHON
@ SPELL_MARKED_DEATH_2
@ SPELL_PLAGUE_STRIKE
@ SPELL_GHOUL_EXPLODE
@ SPELL_DEATH_BITE
@ SPELL_DESECRATION
@ SPELL_ARMY_DEAD
@ SPELL_PLAGUE_STRIKE_2
@ SPELL_KILL_CREDIT
@ SPELL_BLACK_KNIGHT_RES
@ SPELL_DESECRATION_2
@ SPELL_DEATH_RESPITE
@ SPELL_ICY_TOUCH
@ SPELL_MARKED_DEATH
@ SPELL_LEAP_H
@ SPELL_OBLITERATE_H
@ SPELL_LEAP
@ SPELL_DEATH_BITE_H
@ SPELL_DEATH_RESPITE_2
@ SPELL_ICY_TOUCH_H
@ SPELL_DEATH_RESPITE_3
@ SPELL_OBLITERATE
@ PHASE_UNDEAD
@ PHASE_SKELETON
@ PHASE_GHOST
@ MODEL_SKELETON
@ MODEL_GHOST
void AddSC_boss_black_knight()
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetDisplayId(uint32 displayId, bool setNative=false) override
Definition: Creature.cpp:3312
CreatureAI * AI() const
Definition: Creature.h:184
virtual bool SetBossState(uint32 id, EncounterState state)
int32 CalcValue(WorldObject const *caster=nullptr, int32 const *basePoints=nullptr, Unit const *target=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
Definition: SpellInfo.cpp:499
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition: SpellInfo.h:577
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:839
Unit * GetHitUnit() const
int32 GetEffectValue() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
void Despawn(Creature const *summon)
void Summon(Creature const *summon)
void DoMeleeAttackIfReady()
Definition: UnitAI.cpp:61
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.cpp:215
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition: UnitAI.cpp:114
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:124
Definition: Unit.h:747
void ClearUnitState(uint32 f)
Definition: Unit.h:853
void SetHealth(uint64 val)
Definition: Unit.cpp:9161
void SetFullHealth()
Definition: Unit.h:910
void AddUnitState(uint32 f)
Definition: Unit.h:851
uint32 GetNativeDisplayId() const
Definition: Unit.h:1676
bool HealthBelowPct(int32 pct) const
Definition: Unit.h:900
uint64 GetHealth() const
Definition: Unit.h:896
Unit * GetVictim() const
Definition: Unit.h:835
bool HasUnitState(const uint32 f) const
Definition: Unit.h:852
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1033
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2881
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
CreatureAI * GetAI(Creature *creature) const override
bool Validate(SpellInfo const *spellInfo) override
bool Validate(SpellInfo const *spellInfo) override
void Start(bool isActiveAttacker=true, ObjectGuid playerGUID=ObjectGuid::Empty, Quest const *quest=nullptr, bool instantRespawn=false, bool canLoopPath=false)
void LoadPath(uint32 pathId)
void UpdateAI(uint32 diff) override
void JustSummoned(Creature *summon) override
void SummonedCreatureDespawn(Creature *summon) override
void DamageTaken(Unit *, uint32 &uiDamage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 uiDiff) override
void UpdateAI(uint32 uiDiff) override
@ BOSS_BLACK_KNIGHT