TrinityCore
Loading...
Searching...
No Matches
instance_trial_of_the_crusader.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#include "ScriptMgr.h"
19#include "AreaBoundary.h"
20#include "GameObject.h"
21#include "InstanceScript.h"
22#include "Log.h"
23#include "Map.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
27
28 // ToDo: Remove magic numbers of events
29
31{
32 { DATA_NORTHREND_BEASTS, new CircleBoundary(Position(563.26f, 139.6f), 75.0f) },
33 { DATA_JARAXXUS, new CircleBoundary(Position(563.26f, 139.6f), 75.0f) },
34 { DATA_FACTION_CRUSADERS, new CircleBoundary(Position(563.26f, 139.6f), 75.0f) },
35 { DATA_TWIN_VALKIRIES, new CircleBoundary(Position(563.26f, 139.6f), 75.0f) },
36 { DATA_ANUBARAK, new EllipseBoundary(Position(746.0f, 135.0f), 100.0f, 75.0f) }
37};
38
60
80
90
91static constexpr DungeonEncounterData encounters[] =
92{
93 { DATA_NORTHREND_BEASTS, {{ 1088 }} },
94 { DATA_JARAXXUS, {{ 1087 }} },
95 { DATA_FACTION_CRUSADERS, {{ 1086 }} },
96 { DATA_TWIN_VALKIRIES, {{ 1089 }} },
97 { DATA_ANUBARAK, {{ 1085 }} }
98};
99
101{
102 public:
104
106 {
128
129 void OnPlayerEnter(Player* player) override
130 {
133 }
134
135 void OnCreatureCreate(Creature* creature) override
136 {
138 if (creature->GetEntry() == NPC_SNOBOLD_VASSAL)
139 snoboldGUIDS.push_back(creature->GetGUID());
140 }
141
149
150 void OnUnitDeath(Unit* unit) override
151 {
153 {
156 }
157 }
158
159 bool SetBossState(uint32 type, EncounterState state) override
160 {
161 if (!InstanceScript::SetBossState(type, state))
162 return false;
163
164 switch (type)
165 {
167 break;
168 case DATA_JARAXXUS:
169 if (state == FAIL)
170 {
171 if (Creature* fordring = GetCreature(DATA_FORDRING))
172 fordring->AI()->DoAction(ACTION_JARAXXUS_WIPE);
174 }
175 else if (state == DONE)
176 {
177 if (Creature* fordring = GetCreature(DATA_FORDRING))
178 fordring->AI()->DoAction(ACTION_JARAXXUS_DEFEATED);
179 EventStage = 2000;
180 }
181 break;
183 switch (state)
184 {
185 case IN_PROGRESS:
187 break;
188 case FAIL:
189 CrusadersSpecialState = false;
190 if (Creature* fordring = GetCreature(DATA_FORDRING))
191 fordring->AI()->DoAction(ACTION_FACTION_WIPE);
192 break;
193 case DONE:
199 cache->RemoveFlag(GO_FLAG_NOT_SELECTABLE);
200 if (Creature* fordring = GetCreature(DATA_FORDRING))
201 fordring->AI()->DoAction(ACTION_CHAMPIONS_DEFEATED);
202 EventStage = 3100;
203 break;
204 default:
205 break;
206 }
207 break;
209 // Cleanup chest
211 cache->Delete();
212 switch (state)
213 {
214 case FAIL:
215 if (Creature* fordring = GetCreature(DATA_FORDRING))
216 fordring->AI()->DoAction(ACTION_VALKYR_WIPE);
217 break;
218 case DONE:
219 if (Creature* fordring = GetCreature(DATA_FORDRING))
220 fordring->AI()->DoAction(ACTION_VALKYR_DEFEATED);
221 break;
222 default:
223 break;
224 }
225 break;
226 case DATA_LICH_KING:
227 break;
228 case DATA_ANUBARAK:
229 switch (state)
230 {
231 case DONE:
232 {
233 EventStage = 6000;
234 break;
235 }
236 default:
237 break;
238 }
239 break;
240 default:
241 break;
242 }
243
244 if (type < EncounterCount)
245 {
246 TC_LOG_DEBUG("scripts", "[ToCr] BossState(type {}) {} = state {};", type, GetBossState(type), state);
247 if (state == FAIL)
248 {
249 EventStage = (type == DATA_NORTHREND_BEASTS ? 666 : 0);
250 state = NOT_STARTED;
251 }
252 }
253 return true;
254 }
255
257 {
260 {
264 EventStage = 400;
265 if (Creature* combatStalker = GetCreature(DATA_BEASTS_COMBAT_STALKER))
266 combatStalker->DespawnOrUnsummon();
267 HandlePlayerVehicle(false);
268 if (Creature* fordring = GetCreature(DATA_FORDRING))
269 fordring->AI()->DoAction(ACTION_NORTHREND_BEASTS_DEFEATED);
270 }
271 }
272
273 void HandlePlayerVehicle(bool apply)
274 {
275 Map::PlayerList const &players = instance->GetPlayers();
276 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
277 if (Player* player = itr->GetSource())
278 {
279 if (apply)
280 player->CreateVehicleKit(PLAYER_VEHICLE_ID, 0);
281 else
282 player->RemoveVehicleKit();
283 }
284 }
285
286 void SetData(uint32 type, uint32 data) override
287 {
288 switch (type)
289 {
290 case TYPE_EVENT:
291 EventStage = data;
292 data = NOT_STARTED;
293 break;
294 case TYPE_EVENT_TIMER:
295 EventTimer = data;
296 data = NOT_STARTED;
297 break;
299 NorthrendBeasts = data;
300 switch (data)
301 {
306 break;
307 case GORMOK_DONE:
308 if (Creature* tirion = GetCreature(DATA_FORDRING))
309 tirion->AI()->DoAction(ACTION_START_JORMUNGARS);
311 break;
314 break;
315 case SNAKES_SPECIAL:
318 break;
319 case SNAKES_DONE:
322 if (Creature* tirion = GetCreature(DATA_FORDRING))
323 tirion->AI()->DoAction(ACTION_START_ICEHOWL);
325 break;
326 case ICEHOWL_DONE:
328 break;
329 case FAIL:
330 HandlePlayerVehicle(false);
332 if (Creature* tirion = GetCreature(DATA_FORDRING))
333 tirion->AI()->DoAction(ACTION_NORTHREND_BEASTS_WIPE);
334 SnoboldCount = 0;
335 break;
336 default:
337 break;
338 }
339 break;
341 for (ObjectGuid guid : snoboldGUIDS)
342 if (Creature* snobold = instance->GetCreature(guid))
343 snobold->DespawnOrUnsummon();
344 snoboldGUIDS.clear();
345 break;
346 //Achievements
348 if (data == INCREASE)
349 ++SnoboldCount;
350 else if (data == DECREASE)
351 --SnoboldCount;
352 break;
354 if (data == INCREASE)
356 else if (data == DECREASE)
358 break;
359 case DATA_FACTION_CRUSADERS: // Achivement Resilience will Fix
362 break;
363 default:
364 break;
365 }
366 }
367
368 uint32 GetData(uint32 type) const override
369 {
370 switch (type)
371 {
372 case TYPE_EVENT:
373 return EventStage;
375 return NorthrendBeasts;
376 case TYPE_EVENT_TIMER:
377 return EventTimer;
378 case TYPE_EVENT_NPC:
379 switch (EventStage)
380 {
381 case 110:
382 case 140:
383 case 150:
384 case 155:
385 case 200:
386 case 205:
387 case 210:
388 case 220:
389 case 300:
390 case 305:
391 case 310:
392 case 315:
393 case 400:
394 case 666:
395 case 1010:
396 case 1180:
397 case 2000:
398 case 2030:
399 case 3000:
400 case 3001:
401 case 3060:
402 case 3061:
403 case 3090:
404 case 3091:
405 case 3092:
406 case 3100:
407 case 3110:
408 case 4000:
409 case 4010:
410 case 4015:
411 case 4016:
412 case 4040:
413 case 4050:
414 case 5000:
415 case 5005:
416 case 5020:
417 case 6000:
418 case 6005:
419 case 6010:
420 return NPC_TIRION_FORDRING;
421 break;
422 case 5010:
423 case 5030:
424 case 5040:
425 case 5050:
426 case 5060:
427 case 5070:
428 case 5080:
429 return NPC_LICH_KING;
430 break;
431 case 120:
432 case 122:
433 case 2020:
434 case 3080:
435 case 3051:
436 case 3071:
437 case 4020:
438 return NPC_VARIAN;
439 break;
440 case 130:
441 case 132:
442 case 2010:
443 case 3050:
444 case 3070:
445 case 3081:
446 case 4030:
447 return NPC_GARROSH;
448 break;
449 case 1110:
450 case 1120:
451 case 1130:
452 case 1132:
453 case 1134:
454 case 1135:
455 case 1140:
456 case 1142:
457 case 1144:
458 case 1150:
459 return NPC_FIZZLEBANG;
460 break;
461 default:
462 return NPC_TIRION_FORDRING;
463 break;
464 };
465 default:
466 break;
467 }
468
469 return 0;
470 }
471
472 void Update(uint32 diff) override
473 {
475 {
476 if (NotOneButTwoJormungarsTimer <= diff)
478 else
480 }
481
483 {
484 if (ResilienceWillFixItTimer <= diff)
486 else
488 }
489 }
490
491 bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/, uint32 /*miscvalue1*/) override
492 {
493 switch (criteria_id)
494 {
497 return SnoboldCount >= 2;
500 return SnoboldCount >= 4;
505 return MistressOfPainCount >= 2;
507 return false; // no longer obtainable
508 default:
509 break;
510 }
511
512 return false;
513 }
514
515 protected:
521
522 // Achievement stuff
530 };
531
536};
537
@ IN_MILLISECONDS
Definition Common.h:38
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
EncounterState
@ IN_PROGRESS
@ FAIL
@ DONE
@ NOT_STARTED
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:181
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:434
@ GO_DESTRUCTIBLE_DAMAGED
@ GO_FLAG_NOT_SELECTABLE
#define DataHeader
uint32 const EncounterCount
@ DATA_ANUBARAK
Definition azjol_nerub.h:33
@ NPC_ANUBARAK
Definition azjol_nerub.h:48
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
void SetDestructibleState(GameObjectDestructibleState state, WorldObject *attackerOrHealer=nullptr, bool setHealth=false)
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
Creature * GetCreature(uint32 type)
void DoUpdateWorldState(int32 worldStateId, int32 value)
virtual ObjectGuid GetGuidData(uint32 type) const override
void LoadObjectData(std::span< ObjectData const > creatureData, std::span< ObjectData const > gameObjectData)
InstanceMap * instance
void SetHeaders(std::string_view dataHeaders)
void LoadDungeonEncounterData(std::span< DungeonEncounterData const > encounters)
void DoUpdateCriteria(CriteriaType type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
EncounterState GetBossState(uint32 id) const
void DoRespawnGameObject(ObjectGuid guid, Seconds timeToDespawn=1min)
virtual void OnGameObjectCreate(GameObject *go) override
virtual bool IsEncounterInProgress() const
void LoadDoorData(std::span< DoorData const > data)
GameObject * GetGameObject(uint32 type)
void LoadBossBoundaries(BossBoundaryData const &data)
bool IsHeroic() const
Definition Map.cpp:3311
PlayerList const & GetPlayers() const
Definition Map.h:403
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
uint32 GetEntry() const
Definition Object.h:89
iterator end()
Definition RefManager.h:36
iterator begin()
Definition RefManager.h:35
Definition Unit.h:635
bool CreateVehicleKit(uint32 id, uint32 creatureEntry, bool loading=false)
Definition Unit.cpp:12074
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
static constexpr DoorData doorData[]
static BossBoundaryData const boundaries
static constexpr ObjectData gameObjectData[]
static constexpr DungeonEncounterData encounters[]
void AddSC_instance_trial_of_the_crusader()
bool CheckAchievementCriteriaMeet(uint32 criteria_id, Player const *, Unit const *, uint32) override
@ DATA_MAIN_GATE
@ NPC_CHAMPIONS_CONTROLLER
@ NPC_SNOBOLD_VASSAL
@ NPC_FJOLA_LIGHTBANE
@ NPC_BEASTS_COMBAT_STALKER
@ NPC_EYDIS_DARKBANE
@ NPC_TIRION_FORDRING_ANUBARAK
@ NPC_FURIOUS_CHARGE_STALKER
@ NPC_TIRION_FORDRING
@ NPC_LICH_KING_VOICE
@ ACTION_START_JORMUNGARS
@ ACTION_FACTION_WIPE
@ ACTION_JARAXXUS_WIPE
@ ACTION_NORTHREND_BEASTS_DEFEATED
@ ACTION_NORTHREND_BEASTS_WIPE
@ ACTION_JARAXXUS_DEFEATED
@ ACTION_CHAMPIONS_DEFEATED
@ ACTION_START_ICEHOWL
@ ACTION_VALKYR_DEFEATED
@ ACTION_VALKYR_WIPE
@ PLAYER_VEHICLE_ID
@ THREE_SIXTY_PAIN_SPIKE_25_PLAYER
@ THREE_SIXTY_PAIN_SPIKE_10_PLAYER
@ THREE_SIXTY_PAIN_SPIKE_25_PLAYER_HEROIC
@ SPELL_DEFEAT_FACTION_CHAMPIONS
@ SPELL_CHAMPIONS_KILLED_IN_MINUTE
@ UPPER_BACK_PAIN_25_PLAYER
@ THREE_SIXTY_PAIN_SPIKE_10_PLAYER_HEROIC
@ UPPER_BACK_PAIN_25_PLAYER_HEROIC
@ UPPER_BACK_PAIN_10_PLAYER
@ A_TRIBUTE_TO_DEDICATED_INSANITY
@ UPPER_BACK_PAIN_10_PLAYER_HEROIC
@ SPELL_WORMS_KILLED_IN_10_SECONDS
@ DATA_EAST_PORTCULLIS
@ DATA_TWIN_VALKIRIES
@ DATA_WEB_DOOR
@ DATA_TRIBUTE_CHEST
@ DATA_DESPAWN_SNOBOLDS
@ DATA_DREADSCALE
@ DATA_COLISEUM_FLOOR
@ DATA_GORMOK_THE_IMPALER
@ DATA_FORDRING_ANUBARAK
@ TYPE_EVENT_NPC
@ DATA_JARAXXUS
@ DATA_NORTHREND_BEASTS
@ DATA_MISTRESS_OF_PAIN_COUNT
@ DATA_LICH_KING
@ DATA_FACTION_CRUSADERS
@ DATA_FORDRING
@ TYPE_NORTHREND_BEASTS
@ DATA_SNOBOLD_COUNT
@ DATA_LICH_KING_VOICE
@ DATA_CRUSADERS_CHEST
@ DATA_EYDIS_DARKBANE
@ TYPE_EVENT_TIMER
@ DATA_FIZZLEBANG
@ DATA_FJOLA_LIGHTBANE
@ DATA_BEASTS_COMBAT_STALKER
@ DATA_FURIOUS_CHARGE
@ GORMOK_IN_PROGRESS
@ SNAKES_IN_PROGRESS
@ UPDATE_STATE_UI_SHOW
@ WORLD_STATE_PLAYER_DEATHS
@ GO_TRIBUTE_CHEST_10H_99
@ GO_TRIBUTE_CHEST_25H_25
@ GO_TRIBUTE_CHEST_25H_99
@ GO_TRIBUTE_CHEST_25H_45
@ GO_CRUSADERS_CACHE_10_H
@ GO_TRIBUTE_CHEST_10H_45
@ GO_TRIBUTE_CHEST_25H_50
@ GO_CRUSADERS_CACHE_10
@ GO_CRUSADERS_CACHE_25_H
@ GO_TRIBUTE_CHEST_10H_25
@ GO_EAST_PORTCULLIS
@ GO_CRUSADERS_CACHE_25
@ GO_ARGENT_COLISEUM_FLOOR
@ GO_MAIN_GATE_DOOR
@ GO_TRIBUTE_CHEST_10H_50
#define ToCrScriptName