TrinityCore
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 me->SetCanMelee(true);
141
142 Initialize();
143 }
144
145 void JustSummoned(Creature* summon) override
146 {
147 summons.Summon(summon);
148 summon->AI()->AttackStart(me->GetVictim());
149 }
150
151 void SummonedCreatureDespawn(Creature* summon) override
152 {
153 summons.Despawn(summon);
154 }
155
156 void UpdateAI(uint32 uiDiff) override
157 {
158 //Return since we have no target
159 if (!UpdateVictim())
160 return;
161
163 {
164 if (uiResurrectTimer <= uiDiff)
165 {
166 me->SetFullHealth();
168 uiPhase++;
169 uiResurrectTimer = 4000;
170 bEventInProgress = false;
172 me->SetCanMelee(true);
173 } else uiResurrectTimer -= uiDiff;
174 }
175
176 switch (uiPhase)
177 {
178 case PHASE_UNDEAD:
179 case PHASE_SKELETON:
180 {
181 if (uiIcyTouchTimer <= uiDiff)
182 {
184 uiIcyTouchTimer = urand(5000, 7000);
185 } else uiIcyTouchTimer -= uiDiff;
186 if (uiPlagueStrikeTimer <= uiDiff)
187 {
189 uiPlagueStrikeTimer = urand(12000, 15000);
190 } else uiPlagueStrikeTimer -= uiDiff;
191 if (uiObliterateTimer <= uiDiff)
192 {
194 uiObliterateTimer = urand(17000, 19000);
195 } else uiObliterateTimer -= uiDiff;
196 switch (uiPhase)
197 {
198 case PHASE_UNDEAD:
199 {
200 if (uiDeathRespiteTimer <= uiDiff)
201 {
202 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
203 {
204 if (target->IsAlive())
206 }
207 uiDeathRespiteTimer = urand(15000, 16000);
208 } else uiDeathRespiteTimer -= uiDiff;
209 break;
210 }
211 case PHASE_SKELETON:
212 {
213 if (!bSummonArmy)
214 {
215 bSummonArmy = true;
218 }
219 if (!bDeathArmyDone)
220 {
221 if (uiDeathArmyCheckTimer <= uiDiff)
222 {
225 bDeathArmyDone = true;
226 } else uiDeathArmyCheckTimer -= uiDiff;
227 }
228 if (uiDesecration <= uiDiff)
229 {
230 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
231 {
232 if (target->IsAlive())
233 DoCast(target, SPELL_DESECRATION);
234 }
235 uiDesecration = urand(15000, 16000);
236 } else uiDesecration -= uiDiff;
237 if (uiGhoulExplodeTimer <= uiDiff)
238 {
240 uiGhoulExplodeTimer = 8000;
241 } else uiGhoulExplodeTimer -= uiDiff;
242 break;
243 }
244 break;
245 }
246 break;
247 }
248 case PHASE_GHOST:
249 {
250 if (uiDeathBiteTimer <= uiDiff)
251 {
253 uiDeathBiteTimer = urand(2000, 4000);
254 } else uiDeathBiteTimer -= uiDiff;
255 if (uiMarkedDeathTimer <= uiDiff)
256 {
257 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true))
258 {
259 if (target->IsAlive())
260 DoCast(target, SPELL_MARKED_DEATH);
261 }
262 uiMarkedDeathTimer = urand(5000, 7000);
263 } else uiMarkedDeathTimer -= uiDiff;
264 break;
265 }
266 }
267 }
268
269 void DamageTaken(Unit* /*pDoneBy*/, uint32& uiDamage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
270 {
271 if (uiDamage > me->GetHealth() && uiPhase <= PHASE_SKELETON)
272 {
273 uiDamage = 0;
274 me->SetHealth(0);
276 me->SetCanMelee(false);
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 }
344 };
345
346 CreatureAI* GetAI(Creature* creature) const override
347 {
348 return GetTrialOfTheChampionAI<npc_risen_ghoulAI>(creature);
349 }
350};
351
352static constexpr uint32 PATH_ESCORT_GRYPHON = 283930;
353
355{
356public:
357 npc_black_knight_skeletal_gryphon() : CreatureScript("npc_black_knight_skeletal_gryphon") { }
358
360 {
362 {
364 Start(false);
365 }
366
367 void UpdateAI(uint32 uiDiff) override
368 {
369 EscortAI::UpdateAI(uiDiff);
370
371 UpdateVictim();
372 }
373
374 };
375
376 CreatureAI* GetAI(Creature* creature) const override
377 {
378 return GetTrialOfTheChampionAI<npc_black_knight_skeletal_gryphonAI>(creature);
379 }
380};
381
382// 67751 - Ghoul Explode
384{
385 bool Validate(SpellInfo const* spellInfo) override
386 {
387 return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) });
388 }
389
390 void HandleScript(SpellEffIndex /*effIndex*/)
391 {
393 }
394
395 void Register() override
396 {
398 }
399};
400
401// 67754 - Ghoul Explode
402// 67889 - Ghoul Explode
404{
405 bool Validate(SpellInfo const* spellInfo) override
406 {
407 return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()) });
408 }
409
410 void HandleScript(SpellEffIndex /*effIndex*/)
411 {
413 }
414
415 void Register() override
416 {
418 }
419};
420
422{
423 new boss_black_knight();
424 new npc_risen_ghoul();
428}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ DONE
Spells
Definition: PlayerAI.cpp:32
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1359
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:888
DamageEffectType
Definition: UnitDefines.h:154
@ UNIT_STATE_ROOT
Definition: Unit.h:266
@ UNIT_STATE_STUNNED
Definition: Unit.h:259
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
void AttackStart(Unit *victim) override
== Triggered Actions Requested ==================
Definition: CreatureAI.cpp:328
Creature *const me
Definition: CreatureAI.h:61
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
Definition: Creature.cpp:2812
void SetDisplayId(uint32 displayId, bool setNative=false) override
Definition: Creature.cpp:3401
CreatureAI * AI() const
Definition: Creature.h:216
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:495
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:885
Unit * GetHitUnit() const
int32 GetEffectValue() const
SpellEffectInfo const & GetEffectInfo() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:886
void Despawn(Creature const *summon)
void Summon(Creature const *summon)
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 DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
Definition: UnitAI.h:161
SpellCastResult DoCast(uint32 spellId)
Definition: UnitAI.cpp:89
Definition: Unit.h:628
void ClearUnitState(uint32 f)
Definition: Unit.h:737
void SetHealth(uint64 val)
Definition: Unit.cpp:9649
void SetFullHealth()
Definition: Unit.h:795
void AddUnitState(uint32 f)
Definition: Unit.h:735
uint32 GetNativeDisplayId() const
Definition: Unit.h:1585
uint64 GetHealth() const
Definition: Unit.h:781
Unit * GetVictim() const
Definition: Unit.h:719
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1056
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2936
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