TrinityCore
Loading...
Searching...
No Matches
instance_karazhan.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 "Creature.h"
20#include "CreatureAI.h"
21#include "GameObject.h"
22#include "InstanceScript.h"
23#include "karazhan.h"
24#include "Map.h"
25
26/*
270 - Attumen + Midnight (optional)
281 - Moroes
292 - Maiden of Virtue (optional)
303 - Hyakiss the Lurker / Rokad the Ravager / Shadikith the Glider
314 - Opera Event
325 - Curator
336 - Shade of Aran (optional)
347 - Terestian Illhoof (optional)
358 - Netherspite (optional)
369 - Chess Event
3710 - Prince Malchezzar
3811 - Nightbane
39*/
40
41static constexpr ObjectData creatureData[] =
42{
46};
47
55
57{
58 { DATA_ATTUMEN, {{ 652 }} },
59 { DATA_MOROES, {{ 653 }} },
60 { DATA_MAIDEN_OF_VIRTUE, {{ 654 }} },
61 { DATA_OPERA_PERFORMANCE, {{ 655 }} },
62 { DATA_CURATOR, {{ 656 }} },
63 { DATA_ARAN, {{ 658 }} },
64 { DATA_TERESTIAN, {{ 657 }} },
65 { DATA_NETHERSPITE, {{ 659 }} },
66 { DATA_CHESS, {{ 660 }} },
67 { DATA_MALCHEZZAR, {{ 661 }} },
68 { DATA_NIGHTBANE, {{ 662 }} }
69};
70
72{
73 { -10960.981445f, -1940.138428f, 46.178097f, 4.12f }, // Hyakiss the Lurker
74 { -10945.769531f, -2040.153320f, 49.474438f, 0.077f }, // Shadikith the Glider
75 { -10899.903320f, -2085.573730f, 49.474449f, 1.38f } // Rokad the Ravager
76};
77
79{
80public:
82
84 {
86 }
87
89 {
101
102 void OnCreatureCreate(Creature* creature) override
103 {
105
106 switch (creature->GetEntry())
107 {
108 case NPC_KILREK:
109 KilrekGUID = creature->GetGUID();
110 break;
112 TerestianGUID = creature->GetGUID();
113 break;
114 case NPC_MOROES:
115 MoroesGUID = creature->GetGUID();
116 break;
117 case NPC_NIGHTBANE:
118 NightbaneGUID = creature->GetGUID();
119 break;
120 default:
121 break;
122 }
123 }
124
125 void OnUnitDeath(Unit* unit) override
126 {
127 Creature* creature = unit->ToCreature();
128 if (!creature)
129 return;
130
131 switch (creature->GetEntry())
132 {
135 case NPC_SHADOWBAT:
138 case NPC_PHASE_HOUND:
139 case NPC_DREADBEAST:
140 case NPC_SHADOWBEAST:
142 {
145 {
147 {
150 break;
153 break;
156 break;
157 }
158 }
159 }
160 break;
165 break;
166 default:
167 break;
168 }
169 }
170
171 void SetData(uint32 type, uint32 data) override
172 {
173 switch (type)
174 {
176 OperaEvent = data;
177 break;
179 if (data == SPECIAL)
180 ++OzDeathCount;
181 break;
182 default:
183 break;
184 }
185 }
186
187 bool SetBossState(uint32 type, EncounterState state) override
188 {
189 if (!InstanceScript::SetBossState(type, state))
190 return false;
191
192 switch (type)
193 {
195 if (state == DONE)
196 {
202 go->ActivateObject(GameObjectActions::Unlock, 0);
203 if (Creature* barnes = GetCreature(DATA_BARNES))
204 barnes->AI()->DoAction(ACTION_OPERA_FINISHED);
205 }
206 else if (state == FAIL)
207 {
208 OzDeathCount = 0;
213 if (Creature* barnes = GetCreature(DATA_BARNES))
214 barnes->AI()->DoAction(ACTION_OPERA_FINISHED);
215 }
216 break;
217 case DATA_CHESS:
218 if (state == DONE)
220 break;
221 default:
222 break;
223 }
224
225 return true;
226 }
227
228 void SetGuidData(uint32 type, ObjectGuid data) override
229 {
230 if (type == DATA_IMAGE_OF_MEDIVH)
231 ImageGUID = data;
232 }
233
235 {
237
238 switch (go->GetEntry())
239 {
243 break;
247 break;
249 LibraryDoor = go->GetGUID();
250 break;
251 case GO_MASSIVE_DOOR:
252 MassiveDoor = go->GetGUID();
253 break;
255 GamesmansDoor = go->GetGUID();
256 break;
259 break;
261 NetherspaceDoor = go->GetGUID();
262 break;
264 MastersTerraceDoor[0] = go->GetGUID();
265 break;
267 MastersTerraceDoor[1] = go->GetGUID();
268 break;
272 break;
275 break;
276 case GO_BLACKENED_URN:
278 break;
279 }
280 }
281
282 uint32 GetData(uint32 type) const override
283 {
284 switch (type)
285 {
287 return OperaEvent;
289 return OzDeathCount;
290 }
291
292 return 0;
293 }
294
295 ObjectGuid GetGuidData(uint32 type) const override
296 {
297 switch (type)
298 {
299 case DATA_KILREK:
300 return KilrekGUID;
301 case DATA_TERESTIAN:
302 return TerestianGUID;
303 case DATA_MOROES:
304 return MoroesGUID;
305 case DATA_NIGHTBANE:
306 return NightbaneGUID;
308 return LibraryDoor;
310 return MassiveDoor;
312 return GamesmansDoor;
314 return GamesmansExitDoor;
316 return NetherspaceDoor;
318 return MastersTerraceDoor[0];
320 return MastersTerraceDoor[1];
322 return ImageGUID;
324 return BlackenedUrnGUID;
325 }
326
327 return ObjectGuid::Empty;
328 }
329
330 private:
336 ObjectGuid LibraryDoor; // Door at Shade of Aran
337 ObjectGuid MassiveDoor; // Door at Netherspite
338 ObjectGuid GamesmansDoor; // Door before Chess
339 ObjectGuid GamesmansExitDoor; // Door after Chess
340 ObjectGuid NetherspaceDoor; // Door at Malchezaar
345
346 protected:
349 };
350};
351
353{
354 new instance_karazhan();
355}
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint32_t uint32
Definition Define.h:154
EncounterState
@ FAIL
@ DONE
@ SPECIAL
@ TO_BE_DECIDED
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:43
#define DataHeader
uint32 const EncounterCount
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
void ActivateObject(GameObjectActions action, int32 param, WorldObject *spellCaster=nullptr, uint32 spellId=0, int32 effectIndex=-1)
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
Creature * GetCreature(uint32 type)
void HandleGameObject(ObjectGuid guid, bool open, GameObject *go=nullptr)
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)
EncounterState GetBossState(uint32 id) const
void DoRespawnGameObject(ObjectGuid guid, Seconds timeToDespawn=1min)
virtual void OnGameObjectCreate(GameObject *go) override
GameObject * GetGameObject(uint32 type)
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, Milliseconds duration=0ms, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
Definition Object.cpp:1191
static ObjectGuid const Empty
Definition ObjectGuid.h:314
uint32 GetEntry() const
Definition Object.h:89
Creature * ToCreature()
Definition Object.h:121
Definition Unit.h:647
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
const Position OptionalSpawn[]
static constexpr ObjectData gameObjectData[]
void AddSC_instance_karazhan()
DungeonEncounterData const encounters[]
@ NPC_VAMPIRIC_SHADOWBAT
Definition karazhan.h:94
@ NPC_JULIANNE
Definition karazhan.h:83
@ NPC_PHASE_HOUND
Definition karazhan.h:96
@ NPC_GREATER_SHADOWBAT
Definition karazhan.h:95
@ NPC_SHADOWBEAST
Definition karazhan.h:98
@ NPC_TERESTIAN_ILLHOOF
Definition karazhan.h:80
@ NPC_MOROES
Definition karazhan.h:81
@ NPC_ROKAD_THE_RAVAGER
Definition karazhan.h:78
@ NPC_SHADOWBAT
Definition karazhan.h:93
@ NPC_HYAKISS_THE_LURKER
Definition karazhan.h:77
@ NPC_KILREK
Definition karazhan.h:99
@ NPC_ROMULO
Definition karazhan.h:84
@ NPC_NIGHTBANE
Definition karazhan.h:85
@ NPC_BARNES
Definition karazhan.h:82
@ NPC_SHADIKITH_THE_GLIDER
Definition karazhan.h:79
@ NPC_DREADBEAST
Definition karazhan.h:97
@ NPC_COLDMIST_WIDOW
Definition karazhan.h:91
@ NPC_COLDMIST_STALKER
Definition karazhan.h:92
@ ACTION_OPERA_FINISHED
Definition karazhan.h:121
#define KZScriptName
Definition karazhan.h:23
@ OPTIONAL_BOSS_REQUIRED_DEATH_COUNT
Definition karazhan.h:126
@ EVENT_HOOD
Definition karazhan.h:70
@ EVENT_OZ
Definition karazhan.h:71
@ EVENT_RAJ
Definition karazhan.h:72
@ DATA_MALCHEZZAR
Definition karazhan.h:40
@ DATA_KILREK
Definition karazhan.h:43
@ DATA_GO_STAGE_CURTAIN
Definition karazhan.h:62
@ DATA_ROMULO
Definition karazhan.h:57
@ DATA_GO_MASSIVE_DOOR
Definition karazhan.h:45
@ DATA_ATTUMEN
Definition karazhan.h:30
@ DATA_GO_GAME_EXIT_DOOR
Definition karazhan.h:48
@ DATA_CURATOR
Definition karazhan.h:35
@ DATA_OPTIONAL_BOSS
Definition karazhan.h:33
@ DATA_JULIANNE
Definition karazhan.h:56
@ DATA_IMAGE_OF_MEDIVH
Definition karazhan.h:50
@ DATA_OPERA_OZ_DEATH_COUNT
Definition karazhan.h:60
@ DATA_CHESS
Definition karazhan.h:39
@ DATA_BARNES
Definition karazhan.h:55
@ DATA_MAIDEN_OF_VIRTUE
Definition karazhan.h:32
@ DATA_MASTERS_TERRACE_DOOR_1
Definition karazhan.h:51
@ DATA_NETHERSPITE
Definition karazhan.h:38
@ DATA_TERESTIAN
Definition karazhan.h:37
@ DATA_GO_GAME_DOOR
Definition karazhan.h:47
@ DATA_OPERA_VARIATION
Definition karazhan.h:59
@ DATA_MOROES
Definition karazhan.h:31
@ DATA_GO_SIDE_ENTRANCE_DOOR
Definition karazhan.h:65
@ DATA_ARAN
Definition karazhan.h:36
@ DATA_GO_LIBRARY_DOOR
Definition karazhan.h:44
@ DATA_GO_STAGE_DOOR_LEFT
Definition karazhan.h:63
@ DATA_GO_BLACKENED_URN
Definition karazhan.h:53
@ DATA_NIGHTBANE
Definition karazhan.h:41
@ DATA_MASTERS_TERRACE_DOOR_2
Definition karazhan.h:52
@ DATA_OPERA_PERFORMANCE
Definition karazhan.h:34
@ DATA_GO_STAGE_DOOR_RIGHT
Definition karazhan.h:64
@ DATA_GO_NETHER_DOOR
Definition karazhan.h:46
@ GO_BLACKENED_URN
Definition karazhan.h:116
@ GO_STAGE_DOOR_RIGHT
Definition karazhan.h:106
@ GO_STAGE_CURTAIN
Definition karazhan.h:104
@ GO_PRIVATE_LIBRARY_DOOR
Definition karazhan.h:107
@ GO_MASSIVE_DOOR
Definition karazhan.h:108
@ GO_STAGE_DOOR_LEFT
Definition karazhan.h:105
@ GO_NETHERSPACE_DOOR
Definition karazhan.h:111
@ GO_GAMESMAN_HALL_EXIT_DOOR
Definition karazhan.h:110
@ GO_SIDE_ENTRANCE_DOOR
Definition karazhan.h:114
@ GO_MASTERS_TERRACE_DOOR
Definition karazhan.h:112
@ GO_MASTERS_TERRACE_DOOR2
Definition karazhan.h:113
@ GO_GAMESMAN_HALL_DOOR
Definition karazhan.h:109
@ GO_DUST_COVERED_CHEST
Definition karazhan.h:115
bool SetBossState(uint32 type, EncounterState state) override
void SetGuidData(uint32 type, ObjectGuid data) override