Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
boss_black_knight.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/* ScriptData
7SDName: Boss Black Knight
8SD%Complete: 80%
9SDComment: missing yells. not sure about timers.
10SDCategory: Trial of the Champion
11EndScriptData */
12
13#include "ScriptMgr.h"
14#include "ScriptedCreature.h"
15#include "ScriptedEscortAI.h"
17
19{
20 //phase 1
30 //in this phase should rise herald (the spell is missing)
31
32 //phase 2 - During this phase, the Black Knight will use the same abilities as in phase 1, except for Death's Respite
37
38 //phase 3
43
45
46 SPELL_LEAP = 67749,
47 SPELL_LEAP_H = 67880,
48
50};
51
53{
56};
57
64
66{
67public:
68 boss_black_knight() : CreatureScript("boss_black_knight") { }
69
71 {
73 {
74 instance = creature->GetInstanceScript();
75 }
76
78
79 std::list<uint64> SummonList;
80
82 bool bEvent;
85
87
98
100 {
102 me->SetDisplayId(me->GetNativeDisplayId());
103 me->ClearUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED);
104
105 bEventInProgress = false;
106 bEvent = false;
107 bSummonArmy = false;
108 bDeathArmyDone = false;
109
111
112 uiIcyTouchTimer = std::rand() % 9000 + 5000;
113 uiPlagueStrikeTimer = std::rand() % 13000 + 10000;
114 uiDeathRespiteTimer = std::rand() % 16000 + 15000;
115 uiObliterateTimer = std::rand() % 19000 + 17000;
116 uiDesecration = std::rand() % 16000 + 15000;
118 uiResurrectTimer = 4000;
119 uiGhoulExplodeTimer = 8000;
120 uiDeathBiteTimer = std::rand() % 4000 + 2000;
121 uiMarkedDeathTimer = std::rand() % 7000 + 5000;
122 }
123
125 {
126 if (SummonList.empty())
127 return;
128
129 for (std::list<uint64>::const_iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
130 {
131 if (Creature* temp = Unit::GetCreature(*me, *itr))
132 if (temp)
133 temp->DisappearAndDie();
134 }
135 SummonList.clear();
136 }
137
139 {
140 SummonList.push_back(summon->GetGUID());
141 summon->AI()->AttackStart(me->GetVictim());
142 }
143
145 {
146 //Return since we have no target
147 if (!UpdateVictim())
148 return;
149
151 {
152 if (uiResurrectTimer <= uiDiff)
153 {
154 me->SetFullHealth();
156 uiPhase++;
157 uiResurrectTimer = 4000;
158 bEventInProgress = false;
159 me->ClearUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED);
160 } else uiResurrectTimer -= uiDiff;
161 }
162
163 switch (uiPhase)
164 {
165 case PHASE_UNDEAD:
166 case PHASE_SKELETON:
167 {
168 if (uiIcyTouchTimer <= uiDiff)
169 {
171 uiIcyTouchTimer = std::rand() % 7000 + 5000;
172 } else uiIcyTouchTimer -= uiDiff;
173 if (uiPlagueStrikeTimer <= uiDiff)
174 {
176 uiPlagueStrikeTimer = std::rand() % 15000 + 12000;
177 } else uiPlagueStrikeTimer -= uiDiff;
178 if (uiObliterateTimer <= uiDiff)
179 {
181 uiObliterateTimer = std::rand() % 19000 + 17000;
182 } else uiObliterateTimer -= uiDiff;
183 switch (uiPhase)
184 {
185 case PHASE_UNDEAD:
186 {
187 if (uiDeathRespiteTimer <= uiDiff)
188 {
189 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
190 {
191 if (target && target->IsAlive())
193 }
194 uiDeathRespiteTimer = std::rand() % 16000 + 15000;
195 } else uiDeathRespiteTimer -= uiDiff;
196 break;
197 }
198 case PHASE_SKELETON:
199 {
200 if (!bSummonArmy)
201 {
202 bSummonArmy = true;
203 me->AddUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED);
205 }
206 if (!bDeathArmyDone)
207 {
208 if (uiDeathArmyCheckTimer <= uiDiff)
209 {
210 me->ClearUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED);
212 bDeathArmyDone = true;
213 } else uiDeathArmyCheckTimer -= uiDiff;
214 }
215 if (uiDesecration <= uiDiff)
216 {
217 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
218 {
219 if (target && target->IsAlive())
220 DoCast(target, SPELL_DESECRATION);
221 }
222 uiDesecration = std::rand() % 16000 + 15000;
223 } else uiDesecration -= uiDiff;
224 if (uiGhoulExplodeTimer <= uiDiff)
225 {
227 uiGhoulExplodeTimer = 8000;
228 } else uiGhoulExplodeTimer -= uiDiff;
229 break;
230 }
231 break;
232 }
233 break;
234 }
235 case PHASE_GHOST:
236 {
237 if (uiDeathBiteTimer <= uiDiff)
238 {
240 uiDeathBiteTimer = std::rand() % 4000 + 2000;
241 } else uiDeathBiteTimer -= uiDiff;
242 if (uiMarkedDeathTimer <= uiDiff)
243 {
244 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
245 {
246 if (target && target->IsAlive())
247 DoCast(target, SPELL_MARKED_DEATH);
248 }
249 uiMarkedDeathTimer = std::rand() % 7000 + 5000;
250 } else uiMarkedDeathTimer -= uiDiff;
251 break;
252 }
253 }
254
255 if (!me->HasUnitState(UNIT_STATE_ROOT) && !me->HealthBelowPct(1))
257 }
258
259 void DamageTaken(Unit* /*pDoneBy*/, uint32& uiDamage) OVERRIDE
260 {
261 if (uiDamage > me->GetHealth() && uiPhase <= PHASE_SKELETON)
262 {
263 uiDamage = 0;
264 me->SetHealth(0);
265 me->AddUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED);
267 switch (uiPhase)
268 {
269 case PHASE_UNDEAD:
270 me->SetDisplayId(MODEL_SKELETON);
271 break;
272 case PHASE_SKELETON:
273 me->SetDisplayId(MODEL_GHOST);
274 break;
275 }
276 bEventInProgress = true;
277 }
278 }
279
280 void JustDied(Unit* /*killer*/) OVERRIDE
281 {
283
284 if (instance)
286 }
287 };
288
290 {
291 return new boss_black_knightAI(creature);
292 }
293};
294
296{
297public:
298 npc_risen_ghoul() : CreatureScript("npc_risen_ghoul") { }
299
301 {
302 npc_risen_ghoulAI(Creature* creature) : ScriptedAI(creature) { }
303
305
307 {
308 uiAttackTimer = 3500;
309 }
310
312 {
313 if (!UpdateVictim())
314 return;
315
316 if (uiAttackTimer <= uiDiff)
317 {
318 if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true))
319 {
320 if (target && target->IsAlive())
321 DoCast(target, (SPELL_LEAP));
322 }
323 uiAttackTimer = 3500;
324 } else uiAttackTimer -= uiDiff;
325
327 }
328 };
329
331 {
332 return new npc_risen_ghoulAI(creature);
333 }
334};
335
337{
338public:
339 npc_black_knight_skeletal_gryphon() : CreatureScript("npc_black_knight_skeletal_gryphon") { }
340
342 {
344 {
345 Start(false, true, 0, NULL);
346 }
347
348 void WaypointReached(uint32 /*waypointId*/) OVERRIDE { }
349
351 {
353
354 if (!UpdateVictim())
355 return;
356 }
357 };
358
360 {
361 return new npc_black_knight_skeletal_gryphonAI(creature);
362 }
363};
364
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ DONE
@ UNIT_STATE_ROOT
Definition Unit.h:522
@ UNIT_STATE_STUNNED
Definition Unit.h:515
@ SELECT_TARGET_RANDOM
Definition UnitAI.h:23
@ SPELL_MARKED_DEATH_2
@ 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()
@ SPELL_KILL_CREDIT
@ SPELL_PLAGUE_STRIKE
Definition chapter1.cpp:32
@ SPELL_ICY_TOUCH
Definition chapter1.cpp:31
bool UpdateVictim()
CreatureScript(const char *name)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:28
void DoCast(uint32 spellId)
Definition UnitAI.cpp:110
Unit * SelectTarget(SelectAggroTarget targetType, uint32 position=0, float dist=0.0f, bool playerOnly=false, int32 aura=0)
Definition UnitAI.cpp:66
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:168
void DoCastAOE(uint32 spellId, bool triggered=false)
Definition UnitAI.cpp:176
Definition Unit.h:1367
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition Unit.cpp:4905
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Creature * me
ScriptedAI(Creature *creature)
void JustSummoned(Creature *summon) OVERRIDE
void DamageTaken(Unit *, uint32 &uiDamage) OVERRIDE
void UpdateAI(uint32 uiDiff) OVERRIDE
== Triggered Actions Requested ==================
void UpdateAI(uint32 uiDiff) OVERRIDE
== Triggered Actions Requested ==================
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
npc_escortAI(Creature *creature)
void Start(bool isActiveAttacker=true, bool run=false, uint64 playerGUID=0, Quest const *quest=NULL, bool instantRespawn=false, bool canLoopPath=false, bool resetWaypoints=true)
void UpdateAI(uint32 uiDiff) OVERRIDE
== Triggered Actions Requested ==================
@ BOSS_BLACK_KNIGHT