TrinityCore
Loading...
Searching...
No Matches
instance_ruins_of_ahnqiraj.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 "InstanceScript.h"
22#include "Map.h"
23#include "ruins_of_ahnqiraj.h"
24#include <algorithm>
25
36
37static constexpr DungeonEncounterData encounters[] =
38{
39 { DATA_KURINNAXX, {{ 718 }} },
40 { DATA_RAJAXX, {{ 719 }} },
41 { DATA_MOAM, {{ 720 }} },
42 { DATA_BURU, {{ 721 }} },
43 { DATA_AYAMISS, {{ 722 }} },
44 { DATA_OSSIRIAN, {{ 723 }} }
45};
46
48{
49 std::string_view StringId;
51};
52
53static constexpr std::array<RajaxxWave, 7> RajaxxWaves =
54{{
55 { "GeneralRajaxxWave1", 0 },
56 { "GeneralRajaxxWave2", ACTION_WAVE_STARTS_3 },
57 { "GeneralRajaxxWave3", ACTION_WAVE_STARTS_4 },
58 { "GeneralRajaxxWave4", ACTION_WAVE_STARTS_5 },
59 { "GeneralRajaxxWave5", ACTION_WAVE_STARTS_6 },
60 { "GeneralRajaxxWave6", ACTION_WAVE_STARTS_7 },
61 { "GeneralRajaxxWave7", ACTION_RAJAXX_ENTER }
62}};
63
65{
66 public:
68
70 {
80
81 void OnCreatureCreate(Creature* creature) override
82 {
84
85 auto rajaxxWave = std::ranges::find_if(RajaxxWaves, [creature](std::string_view stringId) { return creature->HasStringId(stringId); }, &RajaxxWave::StringId);
86 if (rajaxxWave != RajaxxWaves.end())
87 WaveGuidList[std::ranges::distance(RajaxxWaves.begin(), rajaxxWave)].insert(creature->GetGUID());
88 }
89
90 void OnUnitDeath(Unit* unit) override
91 {
93
94 if (unit->GetTypeId() != TYPEID_UNIT)
95 return;
96
97 auto rajaxxWave = std::ranges::find_if(RajaxxWaves, [creature = unit->ToCreature()](std::string_view stringId) { return creature->HasStringId(stringId); }, &RajaxxWave::StringId);
98 if (rajaxxWave != RajaxxWaves.end())
99 {
100 std::ptrdiff_t waveIndex = std::ranges::distance(RajaxxWaves.begin(), rajaxxWave);
101 if (WaveGuidList[waveIndex].erase(unit->GetGUID()) && WaveGuidList[waveIndex].empty())
102 {
103 // start next wave
104 if (waveIndex + 1 < std::ranges::ssize(WaveGuidList))
105 for (ObjectGuid guid : WaveGuidList[waveIndex + 1])
106 if (Creature* creature = instance->GetCreature(guid))
107 if (creature->IsAlive() && !creature->IsInCombat())
108 creature->AI()->DoZoneInCombat();
109
110 if (rajaxxWave->BossActionIdOnClear)
111 if (Creature* rajaxx = GetCreature(DATA_RAJAXX))
112 rajaxx->AI()->DoAction(rajaxxWave->BossActionIdOnClear);
113 }
114 }
115 }
116
117 bool SetBossState(uint32 bossId, EncounterState state) override
118 {
119 if (!InstanceScript::SetBossState(bossId, state))
120 return false;
121
122 switch (bossId)
123 {
124 case DATA_KURINNAXX:
125 if (state == DONE)
126 {
128
129 if (Creature* ossirian = GetCreature(DATA_OSSIRIAN))
130 ossirian->AI()->DoAction(ACTION_KURINNAXX_DEFEATED);
131 }
132 break;
133 case DATA_RAJAXX:
134 if (state == DONE)
135 {
140 {
142
143 if (Creature* andorov = GetCreature(DATA_ANDOROV))
144 andorov->AI()->DoAction(ACTION_RAJAXX_DEFEATED);
145 }
146 }
147 break;
148 }
149
150 return true;
151 }
152
153 void SetData(uint32 type, uint32 data) override
154 {
155 if (type == DATA_ANDOROV_EVENT_STATE)
156 {
157 AndorovEventState = data;
158 if (data == IN_PROGRESS)
159 {
160 // Wave 1
161 for (ObjectGuid guid : WaveGuidList[0])
162 if (Creature* creature = instance->GetCreature(guid))
163 if (creature->IsAlive() && !creature->IsInCombat())
164 creature->AI()->DoZoneInCombat();
165 }
166 }
167 }
168
169 uint32 GetData(uint32 type) const override
170 {
171 if (type == DATA_ANDOROV_EVENT_STATE)
172 return AndorovEventState;
173
174 return 0;
175 }
176
177 void SetGuidData(uint32 type, ObjectGuid data) override
178 {
179 if (type == DATA_PARALYZED)
180 ParalyzedGUID = data;
181 }
182
183 ObjectGuid GetGuidData(uint32 type) const override
184 {
185 if (type == DATA_PARALYZED)
186 return ParalyzedGUID;
187
188 return ObjectGuid::Empty;
189 }
190
191 protected:
195 };
196
198 {
200 }
201};
202
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
EncounterState
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ TYPEID_UNIT
Definition ObjectGuid.h:43
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:432
#define DataHeader
uint32 const EncounterCount
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
bool HasStringId(std::string_view id) const
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
virtual void OnCreatureCreate(Creature *creature) override
Creature * GetCreature(uint32 type)
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)
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
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[]
void AddSC_instance_ruins_of_ahnqiraj()
static constexpr DungeonEncounterData encounters[]
static constexpr std::array< RajaxxWave, 7 > RajaxxWaves
@ ACTION_WAVE_STARTS_6
@ ACTION_RAJAXX_ENTER
@ ACTION_WAVE_STARTS_7
@ ACTION_WAVE_STARTS_3
@ ACTION_WAVE_STARTS_5
@ ACTION_KURINNAXX_DEFEATED
@ ACTION_RAJAXX_DEFEATED
@ ACTION_WAVE_STARTS_4
@ NPC_MOAM
@ NPC_RAJAXX
@ NPC_ANDOROV
@ NPC_AYAMISS
@ NPC_OSSIRIAN
@ NPC_BURU
@ NPC_KURINAXX
@ DATA_PARALYZED
@ DATA_OSSIRIAN
@ DATA_RAJAXX
@ DATA_BURU
@ DATA_ANDOROV_EVENT_STATE
@ DATA_AYAMISS
@ DATA_ANDOROV
@ DATA_MOAM
@ DATA_KURINNAXX
#define AQ20ScriptName
@ SPAWN_GROUP_ANDOROV
std::string_view StringId