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
26static constexpr ObjectData creatureData[] =
27{
35 { 0, 0 } // END
36};
37
39{
40 std::string_view StringId;
42};
43
44static constexpr std::array<RajaxxWave, 7> RajaxxWaves =
45{{
46 { "GeneralRajaxxWave1", 0 },
47 { "GeneralRajaxxWave2", ACTION_WAVE_STARTS_3 },
48 { "GeneralRajaxxWave3", ACTION_WAVE_STARTS_4 },
49 { "GeneralRajaxxWave4", ACTION_WAVE_STARTS_5 },
50 { "GeneralRajaxxWave5", ACTION_WAVE_STARTS_6 },
51 { "GeneralRajaxxWave6", ACTION_WAVE_STARTS_7 },
52 { "GeneralRajaxxWave7", ACTION_RAJAXX_ENTER }
53}};
54
56{
57 public:
59
61 {
70
71 void OnCreatureCreate(Creature* creature) override
72 {
74
75 auto rajaxxWave = std::ranges::find_if(RajaxxWaves, [creature](std::string_view stringId) { return creature->HasStringId(stringId); }, &RajaxxWave::StringId);
76 if (rajaxxWave != RajaxxWaves.end())
77 WaveGuidList[std::ranges::distance(RajaxxWaves.begin(), rajaxxWave)].insert(creature->GetGUID());
78 }
79
80 void OnUnitDeath(Unit* unit) override
81 {
83
84 if (unit->GetTypeId() != TYPEID_UNIT)
85 return;
86
87 auto rajaxxWave = std::ranges::find_if(RajaxxWaves, [creature = unit->ToCreature()](std::string_view stringId) { return creature->HasStringId(stringId); }, &RajaxxWave::StringId);
88 if (rajaxxWave != RajaxxWaves.end())
89 {
90 std::ptrdiff_t waveIndex = std::ranges::distance(RajaxxWaves.begin(), rajaxxWave);
91 if (WaveGuidList[waveIndex].erase(unit->GetGUID()) && WaveGuidList[waveIndex].empty())
92 {
93 // start next wave
94 if (waveIndex + 1 < std::ranges::ssize(WaveGuidList))
95 for (ObjectGuid guid : WaveGuidList[waveIndex + 1])
96 if (Creature* creature = instance->GetCreature(guid))
97 if (creature->IsAlive() && !creature->IsInCombat())
98 creature->AI()->DoZoneInCombat();
99
100 if (rajaxxWave->BossActionIdOnClear)
101 if (Creature* rajaxx = GetCreature(DATA_RAJAXX))
102 rajaxx->AI()->DoAction(rajaxxWave->BossActionIdOnClear);
103 }
104 }
105 }
106
107 bool SetBossState(uint32 bossId, EncounterState state) override
108 {
109 if (!InstanceScript::SetBossState(bossId, state))
110 return false;
111
112 switch (bossId)
113 {
114 case DATA_KURINNAXX:
115 if (state == DONE)
116 {
118
119 if (Creature* ossirian = GetCreature(DATA_OSSIRIAN))
120 ossirian->AI()->DoAction(ACTION_KURINNAXX_DEFEATED);
121 }
122 break;
123 case DATA_RAJAXX:
124 if (state == DONE)
125 {
130 {
132
133 if (Creature* andorov = GetCreature(DATA_ANDOROV))
134 andorov->AI()->DoAction(ACTION_RAJAXX_DEFEATED);
135 }
136 }
137 break;
138 }
139
140 return true;
141 }
142
143 void SetData(uint32 type, uint32 data) override
144 {
145 if (type == DATA_ANDOROV_EVENT_STATE)
146 {
147 AndorovEventState = data;
148 if (data == IN_PROGRESS)
149 {
150 // Wave 1
151 for (ObjectGuid guid : WaveGuidList[0])
152 if (Creature* creature = instance->GetCreature(guid))
153 if (creature->IsAlive() && !creature->IsInCombat())
154 creature->AI()->DoZoneInCombat();
155 }
156 }
157 }
158
159 uint32 GetData(uint32 type) const override
160 {
161 if (type == DATA_ANDOROV_EVENT_STATE)
162 return AndorovEventState;
163
164 return 0;
165 }
166
167 void SetGuidData(uint32 type, ObjectGuid data) override
168 {
169 if (type == DATA_PARALYZED)
170 ParalyzedGUID = data;
171 }
172
173 ObjectGuid GetGuidData(uint32 type) const override
174 {
175 if (type == DATA_PARALYZED)
176 return ParalyzedGUID;
177
178 return ObjectGuid::Empty;
179 }
180
181 protected:
185 };
186
188 {
190 }
191};
192
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
EncounterState
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
@ TYPEID_UNIT
Definition ObjectGuid.h:38
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:260
#define DataHeader
uint32 const EncounterCount
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)
InstanceMap * instance
void SetHeaders(std::string const &dataHeaders)
void LoadObjectData(ObjectData const *creatureData, ObjectData const *gameObjectData)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:3382
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:4397
static ObjectGuid const Empty
Definition ObjectGuid.h:140
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
Definition Unit.h:769
virtual void OnUnitDeath(Unit *)
Definition ZoneScript.h:45
InstanceScript * GetInstanceScript(InstanceMap *map) const override
static constexpr ObjectData creatureData[]
void AddSC_instance_ruins_of_ahnqiraj()
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