Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
trial_of_the_champion.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: Trial Of the Champion
8SD%Complete:
9SDComment:
10SDCategory: trial_of_the_champion
11EndScriptData */
12
13/* ContentData
14npc_announcer_toc5
15EndContentData */
16
17#include "ScriptMgr.h"
18#include "ScriptedCreature.h"
19#include "ScriptedGossip.h"
21#include "Vehicle.h"
22#include "Player.h"
23
35
36#define GOSSIP_START_EVENT1 "I'm ready to start challenge."
37#define GOSSIP_START_EVENT2 "I'm ready for the next challenge."
38
39#define ORIENTATION 4.714f
40
41/*######
42## npc_announcer_toc5
43######*/
44
45const Position SpawnPosition = {746.261f, 657.401f, 411.681f, 4.65f};
46
48{
49public:
50 npc_announcer_toc5() : CreatureScript("npc_announcer_toc5") { }
51
53 {
55 {
56 instance = creature->GetInstanceScript();
57
58 uiSummonTimes = 0;
59 uiPosition = 0;
61
62 uiFirstBoss = 0;
63 uiSecondBoss = 0;
64 uiThirdBoss = 0;
65
67
68 uiPhase = 0;
69 uiTimer = 0;
70
74
75 Champion1List.clear();
76 Champion2List.clear();
77 Champion3List.clear();
78
79 me->SetReactState(REACT_PASSIVE);
82
85 }
86
88
92
94
98
101
105
107
108 std::list<uint64> Champion1List;
109 std::list<uint64> Champion2List;
110 std::list<uint64> Champion3List;
111
112 void NextStep(uint32 uiTimerStep, bool bNextStep = true, uint8 uiPhaseStep = 0)
113 {
114 uiTimer = uiTimerStep;
115 if (bNextStep)
116 ++uiPhase;
117 else
118 uiPhase = uiPhaseStep;
119 }
120
121 void SetData(uint32 uiType, uint32 /*uiData*/) OVERRIDE
122 {
123 switch (uiType)
124 {
125 case DATA_START:
127 NextStep(10000, false, 1);
128 break;
129 case DATA_IN_POSITION: //movement done.
130 me->GetMotionMaster()->MovePoint(1, 735.81f, 661.92f, 412.39f);
132 instance->HandleGameObject(go->GetGUID(), false);
133 NextStep(10000, false, 3);
134 break;
136 {
138 std::list<uint64> TempList;
139 if (uiLesserChampions == 3 || uiLesserChampions == 6)
140 {
141 switch (uiLesserChampions)
142 {
143 case 3:
144 TempList = Champion2List;
145 break;
146 case 6:
147 TempList = Champion3List;
148 break;
149 }
150
151 for (std::list<uint64>::const_iterator itr = TempList.begin(); itr != TempList.end(); ++itr)
152 if (Creature* summon = Unit::GetCreature(*me, *itr))
153 AggroAllPlayers(summon);
154 }else if (uiLesserChampions == 9)
156
157 break;
158 }
159 }
160 }
161
163 {
164 Creature* pGrandChampion1 = Unit::GetCreature(*me, uiVehicle1GUID);
165 Creature* pGrandChampion2 = Unit::GetCreature(*me, uiVehicle2GUID);
166 Creature* pGrandChampion3 = Unit::GetCreature(*me, uiVehicle3GUID);
167
168 if (pGrandChampion1 && pGrandChampion2 && pGrandChampion3)
169 {
170 AggroAllPlayers(pGrandChampion1);
171 AggroAllPlayers(pGrandChampion2);
172 AggroAllPlayers(pGrandChampion3);
173 }
174 }
175
176 void MovementInform(uint32 uiType, uint32 uiPointId) OVERRIDE
177 {
178 if (uiType != POINT_MOTION_TYPE)
179 return;
180
181 if (uiPointId == 1)
182 me->SetFacingTo(ORIENTATION);
183 }
184
186 {
188 uint32 VEHICLE_TO_SUMMON1 = 0;
189 uint32 VEHICLE_TO_SUMMON2 = 0;
190 switch (uiBoss)
191 {
192 case 0:
193 VEHICLE_TO_SUMMON1 = VEHICLE_MOKRA_SKILLCRUSHER_MOUNT;
194 VEHICLE_TO_SUMMON2 = VEHICLE_ORGRIMMAR_WOLF;
195 break;
196 case 1:
197 VEHICLE_TO_SUMMON1 = VEHICLE_ERESSEA_DAWNSINGER_MOUNT;
198 VEHICLE_TO_SUMMON2 = VEHICLE_SILVERMOON_HAWKSTRIDER;
199 break;
200 case 2:
201 VEHICLE_TO_SUMMON1 = VEHICLE_RUNOK_WILDMANE_MOUNT;
202 VEHICLE_TO_SUMMON2 = VEHICLE_THUNDER_BLUFF_KODO;
203 break;
204 case 3:
205 VEHICLE_TO_SUMMON1 = VEHICLE_ZUL_TORE_MOUNT;
206 VEHICLE_TO_SUMMON2 = VEHICLE_DARKSPEAR_RAPTOR;
207 break;
208 case 4:
209 VEHICLE_TO_SUMMON1 = VEHICLE_DEATHSTALKER_VESCERI_MOUNT;
210 VEHICLE_TO_SUMMON2 = VEHICLE_FORSAKE_WARHORSE;
211 break;
212 default:
213 return;
214 }
215
216 if (Creature* pBoss = me->SummonCreature(VEHICLE_TO_SUMMON1, SpawnPosition))
217 {
218 switch (uiSummonTimes)
219 {
220 case 1:
221 {
222 uiVehicle1GUID = pBoss->GetGUID();
224 if (Vehicle* pVehicle = pBoss->GetVehicleKit())
225 if (Unit* unit = pVehicle->GetPassenger(0))
226 uiGrandChampionBoss1 = unit->GetGUID();
227 if (instance)
228 {
231 }
232 pBoss->AI()->SetData(1, 0);
233 break;
234 }
235 case 2:
236 {
237 uiVehicle2GUID = pBoss->GetGUID();
238 uint64 uiGrandChampionBoss2 = 0;
239 if (Vehicle* pVehicle = pBoss->GetVehicleKit())
240 if (Unit* unit = pVehicle->GetPassenger(0))
241 uiGrandChampionBoss2 = unit->GetGUID();
242 if (instance)
243 {
245 instance->SetData64(DATA_GRAND_CHAMPION_2, uiGrandChampionBoss2);
246 }
247 pBoss->AI()->SetData(2, 0);
248 break;
249 }
250 case 3:
251 {
252 uiVehicle3GUID = pBoss->GetGUID();
253 uint64 uiGrandChampionBoss3 = 0;
254 if (Vehicle* pVehicle = pBoss->GetVehicleKit())
255 if (Unit* unit = pVehicle->GetPassenger(0))
256 uiGrandChampionBoss3 = unit->GetGUID();
257 if (instance)
258 {
260 instance->SetData64(DATA_GRAND_CHAMPION_3, uiGrandChampionBoss3);
261 }
262 pBoss->AI()->SetData(3, 0);
263 break;
264 }
265 default:
266 return;
267 }
268
269 for (uint8 i = 0; i < 3; ++i)
270 {
271 if (Creature* pAdd = me->SummonCreature(VEHICLE_TO_SUMMON2, SpawnPosition, TempSummonType::TEMPSUMMON_CORPSE_DESPAWN))
272 {
273 switch (uiSummonTimes)
274 {
275 case 1:
276 Champion1List.push_back(pAdd->GetGUID());
277 break;
278 case 2:
279 Champion2List.push_back(pAdd->GetGUID());
280 break;
281 case 3:
282 Champion3List.push_back(pAdd->GetGUID());
283 break;
284 }
285
286 switch (i)
287 {
288 case 0:
289 pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI);
290 break;
291 case 1:
292 pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI / 2);
293 break;
294 case 2:
295 pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, M_PI / 2 + M_PI);
296 break;
297 }
298 }
299 }
300 }
301 }
302
304 {
305 me->GetMotionMaster()->MovePoint(1, 735.81f, 661.92f, 412.39f);
306
307 if (me->SummonCreature(uiArgentChampion, SpawnPosition))
308 {
309 for (uint8 i = 0; i < 3; ++i)
310 {
311 if (Creature* pTrash = me->SummonCreature(NPC_ARGENT_LIGHWIELDER, SpawnPosition))
312 pTrash->AI()->SetData(i, 0);
313 if (Creature* pTrash = me->SummonCreature(NPC_ARGENT_MONK, SpawnPosition))
314 pTrash->AI()->SetData(i, 0);
315 if (Creature* pTrash = me->SummonCreature(NPC_PRIESTESS, SpawnPosition))
316 pTrash->AI()->SetData(i, 0);
317 }
318 }
319 }
320
322 {
323 uiFirstBoss = std::rand() % 4;
324
326 {
327 uiSecondBoss = std::rand() % 4;
328 uiThirdBoss = std::rand() % 4;
329 }
330 }
331
333 {
334 uint8 uiTempBoss = std::rand() % 1;
335
336 switch (uiTempBoss)
337 {
338 case 0:
340 break;
341 case 1:
343 break;
344 }
345 }
346
348 {
349 if (!instance)
350 return;
351
353
354 if (instance->GetData(BOSS_BLACK_KNIGHT) == NOT_STARTED)
355 {
357 {
359 me->AI()->SetData(DATA_START, 0);
360
361 if (instance->GetData(BOSS_GRAND_CHAMPIONS) == DONE)
363 }
364
365 if ((instance->GetData(BOSS_GRAND_CHAMPIONS) == DONE &&
366 instance->GetData(BOSS_ARGENT_CHALLENGE_E) == DONE) ||
368 me->SummonCreature(VEHICLE_BLACK_KNIGHT, 769.834f, 651.915f, 447.035f, 0);
369 }
370 }
371
373 {
374 Map::PlayerList const &PlList = me->GetMap()->GetPlayers();
375
376 if (PlList.isEmpty())
377 return;
378
379 for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
380 {
381 if (Player* player = i->GetSource())
382 {
383 if (player->IsGameMaster())
384 continue;
385
386 if (player->IsAlive())
387 {
388 temp->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
391 temp->SetInCombatWith(player);
392 player->SetInCombatWith(temp);
393 temp->AddThreat(player, 0.0f);
394 }
395 }
396 }
397 }
398
400 {
401 ScriptedAI::UpdateAI(uiDiff);
402
403 if (uiTimer <= uiDiff)
404 {
405 switch (uiPhase)
406 {
407 case 1:
409 NextStep(10000, true);
410 break;
411 case 2:
413 NextStep(0, false);
414 break;
415 case 3:
416 if (!Champion1List.empty())
417 {
418 for (std::list<uint64>::const_iterator itr = Champion1List.begin(); itr != Champion1List.end(); ++itr)
419 if (Creature* summon = Unit::GetCreature(*me, *itr))
420 AggroAllPlayers(summon);
421 NextStep(0, false);
422 }
423 break;
424 }
425 } else uiTimer -= uiDiff;
426
427 if (!UpdateVictim())
428 return;
429 }
430
432 {
434 {
436 summon->SetReactState(REACT_PASSIVE);
437 }
438 }
439
441 {
442 switch (summon->GetEntry())
443 {
454 me->AI()->SetData(DATA_LESSER_CHAMPIONS_DEFEATED, 0);
455 break;
456 }
457 }
458 };
459
461 {
462 return new npc_announcer_toc5AI(creature);
463 }
464
465 bool OnGossipHello(Player* player, Creature* creature) OVERRIDE
466 {
467 InstanceScript* instance = creature->GetInstanceScript();
468
469 if (instance &&
470 ((instance->GetData(BOSS_GRAND_CHAMPIONS) == DONE &&
471 instance->GetData(BOSS_BLACK_KNIGHT) == DONE &&
472 instance->GetData(BOSS_ARGENT_CHALLENGE_E) == DONE) ||
473 instance->GetData(BOSS_ARGENT_CHALLENGE_P) == DONE))
474 return false;
475
476 if (instance &&
482 else if (instance)
484
485 player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
486
487 return true;
488 }
489
490 bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) OVERRIDE
491 {
492 player->PlayerTalkClass->ClearMenus();
493 if (action == GOSSIP_ACTION_INFO_DEF+1)
494 {
495 player->CLOSE_GOSSIP_MENU();
496 CAST_AI(npc_announcer_toc5::npc_announcer_toc5AI, creature->AI())->StartEncounter();
497 }
498
499 return true;
500 }
501};
502
#define M_PI
Definition Common.h:192
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
@ GOSSIP_ICON_CHAT
Definition GossipDef.h:46
@ DONE
@ NOT_STARTED
@ POINT_MOTION_TYPE
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:72
#define CAST_AI(a, b)
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INFO_DEF
@ UNIT_NPC_FLAG_GOSSIP
Definition Unit.h:687
@ REACT_PASSIVE
Definition Unit.h:1156
@ REACT_AGGRESSIVE
Definition Unit.h:1158
@ UNIT_FLAG_NON_ATTACKABLE
Definition Unit.h:626
@ UNIT_FIELD_NPC_FLAGS
@ UNIT_FIELD_FLAGS
#define SAY_DEATH
#define SAY_AGGRO
bool UpdateVictim()
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:626
void SetReactState(ReactStates st)
Definition Creature.h:460
CreatureScript(const char *name)
static GameObject * GetGameObject(WorldObject &object, uint64 guid)
bool isEmpty() const
Definition LinkedList.h:86
MapRefManager PlayerList
Definition Map.h:406
iterator end()
iterator begin()
LinkedListHead::Iterator< MapReference const > const_iterator
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition Object.cpp:1280
Definition Unit.h:1367
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
Definition Unit.cpp:4463
static Creature * GetCreature(WorldObject &object, uint64 guid)
Definition Unit.cpp:4905
void SetInCombatWith(Unit *enemy)
InstanceScript * GetInstanceScript()
Definition Object.cpp:1612
virtual uint32 GetData(uint32) const
Definition ZoneScript.h:36
bool OnGossipHello(Player *player, Creature *creature) OVERRIDE
CreatureAI * GetAI(Creature *creature) const OVERRIDE
bool OnGossipSelect(Player *player, Creature *creature, uint32, uint32 action) OVERRIDE
const Position SpawnPosition[]
Creature * me
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
ScriptedAI(Creature *creature)
void UpdateAI(uint32 uiDiff) OVERRIDE
== Triggered Actions Requested ==================
void MovementInform(uint32 uiType, uint32 uiPointId) OVERRIDE
void SummonedCreatureDespawn(Creature *summon) OVERRIDE
void SetData(uint32 uiType, uint32) OVERRIDE
void NextStep(uint32 uiTimerStep, bool bNextStep=true, uint8 uiPhaseStep=0)
#define GOSSIP_START_EVENT1
const Position SpawnPosition
#define GOSSIP_START_EVENT2
void AddSC_trial_of_the_champion()
#define ORIENTATION
@ DATA_GRAND_CHAMPION_VEHICLE_1
@ DATA_MAIN_GATE
@ DATA_GRAND_CHAMPION_2
@ DATA_GRAND_CHAMPION_VEHICLE_2
@ DATA_GRAND_CHAMPION_1
@ DATA_GRAND_CHAMPION_VEHICLE_3
@ DATA_GRAND_CHAMPION_3
@ VEHICLE_IRONFORGE_RAM
@ VEHICLE_SILVERMOON_HAWKSTRIDER
@ VEHICLE_GNOMEREGAN_MECHANOSTRIDER
@ VEHICLE_BLACK_KNIGHT
@ VEHICLE_FORSAKE_WARHORSE
@ VEHICLE_STORMWIND_STEED
@ VEHICLE_ORGRIMMAR_WOLF
@ VEHICLE_RUNOK_WILDMANE_MOUNT
@ VEHICLE_ZUL_TORE_MOUNT
@ VEHICLE_DEATHSTALKER_VESCERI_MOUNT
@ VEHICLE_DARNASSIA_NIGHTSABER
@ VEHICLE_MOKRA_SKILLCRUSHER_MOUNT
@ VEHICLE_EXODAR_ELEKK
@ VEHICLE_DARKSPEAR_RAPTOR
@ VEHICLE_THUNDER_BLUFF_KODO
@ VEHICLE_ERESSEA_DAWNSINGER_MOUNT
@ NPC_ARGENT_LIGHWIELDER
@ NPC_PALETRESS
@ NPC_ARGENT_MONK
@ NPC_PRIESTESS
@ BOSS_BLACK_KNIGHT
@ BOSS_GRAND_CHAMPIONS
@ DATA_LESSER_CHAMPIONS_DEFEATED
@ BOSS_ARGENT_CHALLENGE_P
@ BOSS_ARGENT_CHALLENGE_E
@ DATA_IN_POSITION