TrinityCore
Loading...
Searching...
No Matches
instance_uldaman.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 "Map.h"
24#include "uldaman.h"
25#include <algorithm>
26
34
35static constexpr ObjectData creatureData[] =
36{
38};
39
44
45static constexpr DungeonEncounterData Encounters[] =
46{
47 { DATA_REVELOSH, { { 547 } } },
48 { DATA_THE_LOST_DWARVES, { { 548 } } },
49 { DATA_IRONAYA, { { 549 } } },
50 { DATA_ANCIENT_STONE_KEEPER, { { 551 } } },
51 { DATA_GALGANN_FIREHAMMER, { { 552 } } },
52 { DATA_GRIMLOK, { { 553 } } },
53 { DATA_ARCHAEDAS, { { 554 } } },
54 { DATA_OBSIDIAN_SENTINEL, { { 1887 } } },
55};
56
58{
59 public:
61
63 {
74
75 void OnCreatureCreate(Creature* creature) override
76 {
78
79 switch (creature->GetEntry())
80 {
82 {
83 static constexpr std::array<std::string_view, 4> KeeperStringId = {{ "StoneKeeper1", "StoneKeeper2", "StoneKeeper3", "StoneKeeper4" }};
84 auto stringId = std::ranges::find_if(KeeperStringId, [creature](std::string_view stringId) { return creature->HasStringId(stringId); });
85 if (stringId != KeeperStringId.end())
86 StoneKeeperGuid[std::ranges::distance(KeeperStringId.begin(), stringId)] = creature->GetGUID();
87 break;
88 }
93 ArchaedasMinionsGuidSet.insert(creature->GetGUID());
94 break;
95 default:
96 break;
97 }
98 }
99
100 void OnCreatureRemove(Creature* creature) override
101 {
103
104 switch (creature->GetEntry())
105 {
109 case NPC_VAULT_WARDER:
110 ArchaedasMinionsGuidSet.erase(creature->GetGUID());
111 break;
112 default:
113 break;
114 }
115 }
116
118 {
120
121 switch (go->GetEntry())
122 {
126 break;
127 case GO_KEYSTONE:
129 {
132 }
133 break;
134 default:
135 break;
136 }
137 }
138
139 void OnUnitDeath(Unit* unit) override
140 {
142
143 Creature* creature = unit->ToCreature();
144 if (!creature)
145 return;
146
147 switch (creature->GetEntry())
148 {
150 //case ?: SetBossState(BOSS_THE_LOST_DWARVES, DONE); break;
155 case NPC_STONE_KEEPER:
156 {
157 for (std::size_t i = 0; i < StoneKeeperGuid.size() - 1; ++i)
158 {
159 if (creature->GetGUID() == StoneKeeperGuid[i])
160 {
161 if (Creature* keeper = instance->GetCreature(StoneKeeperGuid[i + 1]))
162 {
163 keeper->AI()->DoAction(ACTION_KEEPER_ACTIVATED);
164 break;
165 }
166 }
167 }
168
169 if (creature->GetGUID() == StoneKeeperGuid[3])
171 break;
172 }
173 default:
174 break;
175 }
176 }
177
178 bool SetBossState(uint32 bossId, EncounterState state) override
179 {
180 if (!InstanceScript::SetBossState(bossId, state))
181 return false;
182
183 switch (bossId)
184 {
185 case DATA_ARCHAEDAS:
186 if (state == FAIL)
187 {
189 if (Creature* minion = instance->GetCreature(guid))
190 {
191 if (minion->isDead())
192 minion->Respawn();
193 }
194 }
195 break;
197 if (state == FAIL)
198 {
199 for (std::size_t i = 0; i < StoneKeeperGuid.size() - 1; ++i)
200 {
201 if (Creature* keeper = instance->GetCreature(StoneKeeperGuid[i]))
202 {
203 if (!keeper->IsAlive())
204 {
205 StoneKeeperGuid[i].Clear();
206 keeper->Respawn();
207 }
208 }
209 }
210
212 }
213 break;
214 default:
215 break;
216 }
217
218 return true;
219 }
220
221 void SetData(uint32 type, uint32 data) override
222 {
223 switch (type)
224 {
226 IronayaIntroState = data;
227 switch (data)
228 {
229 case IN_PROGRESS:
231 break;
232 case DONE:
234 break;
235 default:
236 break;
237 }
238 break;
239 }
240 }
241
242 void ProcessEvent(WorldObject* /*gameObject*/, uint32 eventId, WorldObject* /*invoker*/) override
243 {
244 switch (eventId)
245 {
247 if (Creature* keeper = instance->GetCreature(StoneKeeperGuid[0]))
248 keeper->AI()->DoAction(ACTION_KEEPER_ACTIVATED);
249 break;
250 case EVENT_BOSS_AGGRO:
251 if (Creature* archaedas = GetCreature(DATA_ARCHAEDAS))
252 archaedas->AI()->DoAction(ACTION_ARCHAEDAS_AWAKEN);
253 break;
254 default:
255 break;
256 }
257 }
258
259 uint32 GetData(uint32 type) const override
260 {
261 switch (type)
262 {
264 return IronayaIntroState;
265 }
266 return 0;
267 }
268
269 protected:
270 std::array<ObjectGuid, 4> StoneKeeperGuid;
273 };
274
276 {
278 }
279};
280
282{
283 new instance_uldaman();
284}
uint32_t uint32
Definition Define.h:154
EncounterState
@ IN_PROGRESS
@ FAIL
@ DONE
@ NOT_STARTED
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:432
@ GO_FLAG_INTERACT_COND
#define DataHeader
uint32 const EncounterCount
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool HasStringId(std::string_view id) const
void SetFlag(GameObjectFlags flags)
Definition GameObject.h:283
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)
virtual void OnCreatureRemove(Creature *creature) 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)
virtual void OnGameObjectCreate(GameObject *go) override
void LoadDoorData(std::span< DoorData const > data)
GameObject * GetGameObject(uint32 type)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2360
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3578
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
virtual void OnUnitDeath(Unit *unit)
Definition ZoneScript.h:85
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
static constexpr DungeonEncounterData Encounters[]
void AddSC_instance_uldaman()
static constexpr DoorData doorData[]
static constexpr ObjectData gameObjectData[]
void ProcessEvent(WorldObject *, uint32 eventId, WorldObject *) override
void SetData(uint32 type, uint32 data) override
bool SetBossState(uint32 bossId, EncounterState state) override
@ ACTION_ARCHAEDAS_AWAKEN
Definition uldaman.h:78
@ ACTION_KEEPER_ACTIVATED
Definition uldaman.h:77
@ EVENT_SUB_BOSS_AGGRO
Definition uldaman.h:83
@ EVENT_BOSS_AGGRO
Definition uldaman.h:84
@ DATA_IRONAYA_SEAL_DOOR
Definition uldaman.h:42
@ DATA_GALGANN_FIREHAMMER
Definition uldaman.h:34
@ DATA_ARCHAEDAS
Definition uldaman.h:36
@ DATA_ANCIENT_STONE_KEEPER
Definition uldaman.h:33
@ DATA_STONE_KEEPERS
Definition uldaman.h:39
@ DATA_REVELOSH
Definition uldaman.h:30
@ DATA_GRIMLOK
Definition uldaman.h:35
@ DATA_THE_LOST_DWARVES
Definition uldaman.h:31
@ DATA_IRONAYA
Definition uldaman.h:32
@ DATA_OBSIDIAN_SENTINEL
Definition uldaman.h:37
@ DATA_IRONAYA_INTRO
Definition uldaman.h:41
#define UldamanScriptName
Definition uldaman.h:23
@ NPC_EARTHEN_CUSTODIAN
Definition uldaman.h:56
@ NPC_ANCIENT_STONE_KEEPER
Definition uldaman.h:48
@ NPC_OBSIDIAN_SENTINEL
Definition uldaman.h:51
@ NPC_GALGANN_FIREHAMMER
Definition uldaman.h:49
@ NPC_VAULT_WARDER
Definition uldaman.h:57
@ NPC_STONE_KEEPER
Definition uldaman.h:53
@ NPC_GRIMLOK
Definition uldaman.h:50
@ NPC_EARTHEN_GUARDIAN
Definition uldaman.h:54
@ NPC_REVELOSH
Definition uldaman.h:47
@ NPC_EARTHEN_HALLSHAPER
Definition uldaman.h:55
@ NPC_ARCHAEDAS
Definition uldaman.h:52
@ GO_ANCIENT_VAULT_DOOR
Definition uldaman.h:67
@ GO_TEMPLE_DOOR_ARCHAEDAS
Definition uldaman.h:66
@ GO_TEMPLE_DOOR_TO_ARCHAEDAS
Definition uldaman.h:65
@ GO_TEMPLE_DOOR_TO_KEEPERS
Definition uldaman.h:64
@ GO_KEYSTONE
Definition uldaman.h:63
@ GO_IRONAYA_SEAL_DOOR
Definition uldaman.h:62
@ SPAWN_GROUP_IRONAYA
Definition uldaman.h:72