TrinityCore
trial_of_the_champion.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: Trial Of the Champion
20SD%Complete:
21SDComment:
22SDCategory: trial_of_the_champion
23EndScriptData */
24
25/* ContentData
26npc_announcer_toc5
27EndContentData */
28
29#include "ScriptMgr.h"
30#include "GameObject.h"
31#include "InstanceScript.h"
32#include "Map.h"
33#include "MotionMaster.h"
34#include "ObjectAccessor.h"
35#include "Player.h"
36#include "ScriptedCreature.h"
37#include "ScriptedGossip.h"
38#include "TemporarySummon.h"
40#include "Vehicle.h"
41
43{
51 SAY_DEATH = 7
52};
53
55{
56 GOSSIP_START_EVENT1_MID = 10614, // I'm ready to start challenge.
58 GOSSIP_START_EVENT2_MID = 10614, // I'm ready for the next challenge.
60};
61
62#define ORIENTATION 4.714f
63
64/*######
65## npc_announcer_toc5
66######*/
67
68const Position SpawnPosition = {746.261f, 657.401f, 411.681f, 4.65f};
69
71{
72public:
73 npc_announcer_toc5() : CreatureScript("npc_announcer_toc5") { }
74
76 {
78 {
79 instance = creature->GetInstanceScript();
80
81 uiSummonTimes = 0;
82 uiPosition = 0;
84
85 uiFirstBoss = 0;
86 uiSecondBoss = 0;
87 uiThirdBoss = 0;
88
90
91 uiPhase = 0;
92 uiTimer = 0;
93
97
100 }
101
103
107
109
113
116
120
124
125 void NextStep(uint32 uiTimerStep, bool bNextStep = true, uint8 uiPhaseStep = 0)
126 {
127 uiTimer = uiTimerStep;
128 if (bNextStep)
129 ++uiPhase;
130 else
131 uiPhase = uiPhaseStep;
132 }
133
134 void SetData(uint32 uiType, uint32 /*uiData*/) override
135 {
136 switch (uiType)
137 {
138 case DATA_START:
140 NextStep(10000, false, 1);
141 break;
142 case DATA_IN_POSITION: //movement done.
143 me->GetMotionMaster()->MovePoint(1, 735.81f, 661.92f, 412.39f);
145 instance->HandleGameObject(go->GetGUID(), false);
146 NextStep(10000, false, 3);
147 break;
149 {
151 GuidList TempList;
152 if (uiLesserChampions == 3 || uiLesserChampions == 6)
153 {
154 switch (uiLesserChampions)
155 {
156 case 3:
157 TempList = Champion2List;
158 break;
159 case 6:
160 TempList = Champion3List;
161 break;
162 }
163
164 for (GuidList::const_iterator itr = TempList.begin(); itr != TempList.end(); ++itr)
165 if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
166 AggroAllPlayers(summon);
167 }else if (uiLesserChampions == 9)
169
170 break;
171 }
172 }
173 }
174
176 {
180
181 if (pGrandChampion1 && pGrandChampion2 && pGrandChampion3)
182 {
183 AggroAllPlayers(pGrandChampion1);
184 AggroAllPlayers(pGrandChampion2);
185 AggroAllPlayers(pGrandChampion3);
186 }
187 }
188
189 void MovementInform(uint32 uiType, uint32 uiPointId) override
190 {
191 if (uiType != POINT_MOTION_TYPE)
192 return;
193
194 if (uiPointId == 1)
196 }
197
199 {
201 uint32 VEHICLE_TO_SUMMON1 = 0;
202 uint32 VEHICLE_TO_SUMMON2 = 0;
203 switch (uiBoss)
204 {
205 case 0:
206 VEHICLE_TO_SUMMON1 = VEHICLE_MOKRA_SKILLCRUSHER_MOUNT;
207 VEHICLE_TO_SUMMON2 = VEHICLE_ORGRIMMAR_WOLF;
208 break;
209 case 1:
210 VEHICLE_TO_SUMMON1 = VEHICLE_ERESSEA_DAWNSINGER_MOUNT;
211 VEHICLE_TO_SUMMON2 = VEHICLE_SILVERMOON_HAWKSTRIDER;
212 break;
213 case 2:
214 VEHICLE_TO_SUMMON1 = VEHICLE_RUNOK_WILDMANE_MOUNT;
215 VEHICLE_TO_SUMMON2 = VEHICLE_THUNDER_BLUFF_KODO;
216 break;
217 case 3:
218 VEHICLE_TO_SUMMON1 = VEHICLE_ZUL_TORE_MOUNT;
219 VEHICLE_TO_SUMMON2 = VEHICLE_DARKSPEAR_RAPTOR;
220 break;
221 case 4:
222 VEHICLE_TO_SUMMON1 = VEHICLE_DEATHSTALKER_VESCERI_MOUNT;
223 VEHICLE_TO_SUMMON2 = VEHICLE_FORSAKE_WARHORSE;
224 break;
225 default:
226 return;
227 }
228
229 if (Creature* pBoss = me->SummonCreature(VEHICLE_TO_SUMMON1, SpawnPosition))
230 {
231 switch (uiSummonTimes)
232 {
233 case 1:
234 {
235 uiVehicle1GUID = pBoss->GetGUID();
236 ObjectGuid uiGrandChampionBoss1;
237 if (Vehicle* pVehicle = pBoss->GetVehicleKit())
238 if (Unit* unit = pVehicle->GetPassenger(0))
239 uiGrandChampionBoss1 = unit->GetGUID();
241 instance->SetGuidData(DATA_GRAND_CHAMPION_1, uiGrandChampionBoss1);
242 pBoss->AI()->SetData(1, 0);
243 break;
244 }
245 case 2:
246 {
247 uiVehicle2GUID = pBoss->GetGUID();
248 ObjectGuid uiGrandChampionBoss2;
249 if (Vehicle* pVehicle = pBoss->GetVehicleKit())
250 if (Unit* unit = pVehicle->GetPassenger(0))
251 uiGrandChampionBoss2 = unit->GetGUID();
253 instance->SetGuidData(DATA_GRAND_CHAMPION_2, uiGrandChampionBoss2);
254 pBoss->AI()->SetData(2, 0);
255 break;
256 }
257 case 3:
258 {
259 uiVehicle3GUID = pBoss->GetGUID();
260 ObjectGuid uiGrandChampionBoss3;
261 if (Vehicle* pVehicle = pBoss->GetVehicleKit())
262 if (Unit* unit = pVehicle->GetPassenger(0))
263 uiGrandChampionBoss3 = unit->GetGUID();
265 instance->SetGuidData(DATA_GRAND_CHAMPION_3, uiGrandChampionBoss3);
266 pBoss->AI()->SetData(3, 0);
267 break;
268 }
269 default:
270 return;
271 }
272
273 for (uint8 i = 0; i < 3; ++i)
274 {
275 if (Creature* pAdd = me->SummonCreature(VEHICLE_TO_SUMMON2, SpawnPosition, TEMPSUMMON_CORPSE_DESPAWN))
276 {
277 switch (uiSummonTimes)
278 {
279 case 1:
280 Champion1List.push_back(pAdd->GetGUID());
281 break;
282 case 2:
283 Champion2List.push_back(pAdd->GetGUID());
284 break;
285 case 3:
286 Champion3List.push_back(pAdd->GetGUID());
287 break;
288 }
289
290 switch (i)
291 {
292 case 0:
293 pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, float(M_PI));
294 break;
295 case 1:
296 pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, float(M_PI) / 2);
297 break;
298 case 2:
299 pAdd->GetMotionMaster()->MoveFollow(pBoss, 2.0f, float(M_PI) / 2 + float(M_PI));
300 break;
301 }
302 }
303
304 }
305 }
306 }
307
309 {
310 me->GetMotionMaster()->MovePoint(1, 735.81f, 661.92f, 412.39f);
311
313 {
314 for (uint8 i = 0; i < 3; ++i)
315 {
317 pTrash->AI()->SetData(i, 0);
319 pTrash->AI()->SetData(i, 0);
321 pTrash->AI()->SetData(i, 0);
322 }
323 }
324 }
325
327 {
328 uiFirstBoss = urand(0, 4);
329
331 {
332 uiSecondBoss = urand(0, 4);
333 uiThirdBoss = urand(0, 4);
334 }
335 }
336
338 {
339 uint8 uiTempBoss = urand(0, 1);
340
341 switch (uiTempBoss)
342 {
343 case 0:
345 break;
346 case 1:
348 break;
349 }
350 }
351
353 {
355
357 {
359 {
362
365 }
366
370 me->SummonCreature(VEHICLE_BLACK_KNIGHT, 769.834f, 651.915f, 447.035f, 0);
371 }
372 }
373
375 {
376 Map::PlayerList const& PlList = me->GetMap()->GetPlayers();
377 if (PlList.isEmpty())
378 return;
379
380 for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
381 {
382 if (Player* player = i->GetSource())
383 {
384 if (player->IsGameMaster())
385 continue;
386
387 if (player->IsAlive())
388 {
392 AddThreat(player, 0.0f, temp);
393 }
394 }
395 }
396 }
397
398 void UpdateAI(uint32 uiDiff) override
399 {
400 ScriptedAI::UpdateAI(uiDiff);
401
402 if (uiTimer <= uiDiff)
403 {
404 switch (uiPhase)
405 {
406 case 1:
408 NextStep(10000, true);
409 break;
410 case 2:
412 NextStep(0, false);
413 break;
414 case 3:
415 if (!Champion1List.empty())
416 {
417 for (GuidList::const_iterator itr = Champion1List.begin(); itr != Champion1List.end(); ++itr)
418 if (Creature* summon = ObjectAccessor::GetCreature(*me, *itr))
419 AggroAllPlayers(summon);
420 NextStep(0, false);
421 }
422 break;
423 }
424 } else uiTimer -= uiDiff;
425
426 if (!UpdateVictim())
427 return;
428 }
429
430 void JustSummoned(Creature* summon) override
431 {
433 {
436 }
437 }
438
439 void SummonedCreatureDespawn(Creature* summon) override
440 {
441 switch (summon->GetEntry())
442 {
454 break;
455 }
456 }
457
458 bool OnGossipHello(Player* player) override
459 {
464 return false;
465
470 {
474 }
475 else
476 {
480 }
481
482 return true;
483 }
484
485 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
486 {
487 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
488 ClearGossipMenuFor(player);
489 if (action == GOSSIP_ACTION_INFO_DEF + 1)
490 {
491 CloseGossipMenuFor(player);
493 }
494 return true;
495 }
496 };
497
498 CreatureAI* GetAI(Creature* creature) const override
499 {
500 return GetTrialOfTheChampionAI<npc_announcer_toc5AI>(creature);
501 }
502};
503
505{
506 new npc_announcer_toc5();
507}
#define M_PI
Definition: Common.h:115
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
@ DONE
@ NOT_STARTED
@ POINT_MOTION_TYPE
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: ObjectDefines.h:67
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
void AddGossipItemFor(Player *player, GossipOptionNpc optionNpc, std::string text, uint32 sender, uint32 action)
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
void ClearGossipMenuFor(Player *player)
void InitGossipMenuFor(Player *player, uint32 menuId)
void CloseGossipMenuFor(Player *player)
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_INFO_DEF
@ REACT_PASSIVE
Definition: UnitDefines.h:506
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
@ UNIT_NPC_FLAG_GOSSIP
Definition: UnitDefines.h:297
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:145
Gossip
Yells
bool UpdateVictim()
Definition: CreatureAI.cpp:245
Creature *const me
Definition: CreatureAI.h:61
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:371
void SetReactState(ReactStates st)
Definition: Creature.h:160
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
virtual ObjectGuid GetGuidData(uint32 type) const override
EncounterState GetBossState(uint32 id) const
bool isEmpty() const
Definition: LinkedList.h:110
iterator end()
Definition: MapRefManager.h:35
iterator begin()
Definition: MapRefManager.h:34
PlayerList const & GetPlayers() const
Definition: Map.h:367
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={})
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition: Player.cpp:14367
std::unique_ptr< PlayerMenu > PlayerTalkClass
Definition: Player.h:2380
Definition: Unit.h:627
MotionMaster * GetMotionMaster()
Definition: Unit.h:1652
void RemoveNpcFlag(NPCFlags flags)
Definition: Unit.h:983
void SetNpcFlag(NPCFlags flags)
Definition: Unit.h:982
void SetFacingTo(float const ori, bool force=true)
Definition: Unit.cpp:12653
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:833
void RemoveUnitFlag(UnitFlags flags)
Definition: Unit.h:834
Map * GetMap() const
Definition: Object.h:624
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1042
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition: Object.cpp:2025
virtual void SetGuidData(uint32, ObjectGuid)
Definition: ZoneScript.h:84
CreatureAI * GetAI(Creature *creature) const override
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
constexpr float GetPositionX() const
Definition: Position.h:76
constexpr float GetPositionY() const
Definition: Position.h:77
constexpr float GetOrientation() const
Definition: Position.h:79
constexpr float GetPositionZ() const
Definition: Position.h:78
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
virtual void UpdateAI(uint32 diff) override
void SummonedCreatureDespawn(Creature *summon) override
void JustSummoned(Creature *summon) override
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
void MovementInform(uint32 uiType, uint32 uiPointId) override
void NextStep(uint32 uiTimerStep, bool bNextStep=true, uint8 uiPhaseStep=0)
void SetData(uint32 uiType, uint32) override
@ SAY_KILL_PLAYER
const Position SpawnPosition
void AddSC_trial_of_the_champion()
#define ORIENTATION
@ GOSSIP_START_EVENT2_OID
@ GOSSIP_START_EVENT1_MID
@ GOSSIP_START_EVENT2_MID
@ GOSSIP_START_EVENT1_OID
@ 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_EADRIC
@ NPC_PRIESTESS
@ 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
@ BOSS_BLACK_KNIGHT
@ BOSS_GRAND_CHAMPIONS
@ DATA_LESSER_CHAMPIONS_DEFEATED
@ BOSS_ARGENT_CHALLENGE_P
@ BOSS_ARGENT_CHALLENGE_E
@ DATA_START
@ DATA_IN_POSITION