Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_nexus.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "InstanceScript.h"
8#include "nexus.h"
9#include "Player.h"
10
11#define NUMBER_OF_ENCOUNTERS 4
12
17
19{
20public:
21 instance_nexus() : InstanceMapScript("instance_nexus", 576) { }
22
27
29 {
31
33
36
40
41 std::string strInstData;
42
53
55 {
56 Map::PlayerList const &players = instance->GetPlayers();
57 uint32 TeamInInstance = 0;
58
59 if (!players.isEmpty())
60 {
61 if (Player* player = players.begin()->GetSource())
62 TeamInInstance = player->GetTeam();
63 }
64 switch (creature->GetEntry())
65 {
66 case 26763:
67 Anomalus = creature->GetGUID();
68 break;
69 case 26723:
70 Keristrasza = creature->GetGUID();
71 break;
72 // Alliance npcs are spawned by default, if you are alliance, you will fight against horde npcs.
73 case 26800:
74 {
76 creature->setFaction(FACTION_HOSTILE_FOR_ALL);
77 if (TeamInInstance == ALLIANCE)
78 creature->UpdateEntry(26799, HORDE);
79 break;
80 }
81 case 26802:
82 {
84 creature->setFaction(FACTION_HOSTILE_FOR_ALL);
85 if (TeamInInstance == ALLIANCE)
86 creature->UpdateEntry(26801, HORDE);
87 break;
88 }
89 case 26805:
90 {
92 creature->setFaction(FACTION_HOSTILE_FOR_ALL);
93 if (TeamInInstance == ALLIANCE)
94 creature->UpdateEntry(26803, HORDE);
95 break;
96 }
97 case 27949:
98 {
100 creature->setFaction(FACTION_HOSTILE_FOR_ALL);
101 if (TeamInInstance == ALLIANCE)
102 creature->UpdateEntry(27947, HORDE);
103 break;
104 }
105 case 26796:
106 {
108 creature->setFaction(FACTION_HOSTILE_FOR_ALL);
109 if (TeamInInstance == ALLIANCE)
110 creature->UpdateEntry(26798, HORDE);
111 break;
112 }
113 }
114 }
115
117 {
118 switch (go->GetEntry())
119 {
120 case 188527:
121 {
122 AnomalusContainmentSphere = go->GetGUID();
123 if (m_auiEncounter[1] == DONE)
125 break;
126 }
127 case 188528:
128 {
129 OrmoroksContainmentSphere = go->GetGUID();
130 if (m_auiEncounter[2] == DONE)
132 break;
133 }
134 case 188526:
135 {
136 TelestrasContainmentSphere = go->GetGUID();
137 if (m_auiEncounter[0] == DONE)
139 break;
140 }
141 }
142 }
143
144 uint32 GetData(uint32 identifier) const OVERRIDE
145 {
146 switch (identifier)
147 {
149 case DATA_ANOMALUS_EVENT: return m_auiEncounter[1];
150 case DATA_ORMOROK_EVENT: return m_auiEncounter[2];
152 }
153 return 0;
154 }
155
156 void SetData(uint32 identifier, uint32 data) OVERRIDE
157 {
158 switch (identifier)
159 {
161 {
162 if (data == DONE)
163 {
165 if (Sphere)
167 }
168 m_auiEncounter[0] = data;
169 break;
170 }
172 {
173 if (data == DONE)
174 {
177 }
178 m_auiEncounter[1] = data;
179 break;
180 }
182 {
183 if (data == DONE)
184 {
187 }
188 m_auiEncounter[2] = data;
189 break;
190 }
192 m_auiEncounter[3] = data;
193 break;
194 }
195
196 if (data == DONE)
197 {
199
200 std::ostringstream saveStream;
201 saveStream << m_auiEncounter[0] << ' ' << m_auiEncounter[1] << ' ' << m_auiEncounter[2] << ' '
202 << m_auiEncounter[3];
203
204 strInstData = saveStream.str();
205
206 SaveToDB();
208 }
209 }
210
211 uint64 GetData64(uint32 uiIdentifier) const OVERRIDE
212 {
213 switch (uiIdentifier)
214 {
215 case DATA_ANOMALUS: return Anomalus;
216 case DATA_KERISTRASZA: return Keristrasza;
220 }
221 return 0;
222 }
223
224 std::string GetSaveData() OVERRIDE
225 {
226 return strInstData;
227 }
228
229 void Load(const char *chrIn) OVERRIDE
230 {
231 if (!chrIn)
232 {
234 return;
235 }
236
237 OUT_LOAD_INST_DATA(chrIn);
238
239 std::istringstream loadStream(chrIn);
240 loadStream >> m_auiEncounter[0] >> m_auiEncounter[1] >> m_auiEncounter[2] >> m_auiEncounter[3];
241
242 for (uint8 i = 0; i < NUMBER_OF_ENCOUNTERS; ++i)
243 if (m_auiEncounter[i] == IN_PROGRESS)
245
247 }
248 };
249};
250
252{
253 new instance_nexus();
254}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
#define OUT_LOAD_INST_DATA_FAIL
@ IN_PROGRESS
@ DONE
@ NOT_STARTED
#define OUT_SAVE_INST_DATA_COMPLETE
#define OUT_LOAD_INST_DATA_COMPLETE
#define OUT_SAVE_INST_DATA
#define OUT_LOAD_INST_DATA(a)
@ ALLIANCE
@ HORDE
@ GO_FLAG_NOT_SELECTABLE
@ GAMEOBJECT_FIELD_FLAGS
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
bool ServerAllowsTwoSideGroups()
bool isEmpty() const
Definition LinkedList.h:86
Definition Map.h:238
MapRefManager PlayerList
Definition Map.h:406
iterator begin()
FROM * GetSource() const
Definition Reference.h:83
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
void AddSC_instance_nexus()
#define NUMBER_OF_ENCOUNTERS
@ FACTION_HOSTILE_FOR_ALL
@ DATA_MAGUS_TELESTRA_EVENT
Definition nexus.h:11
@ ORMOROKS_CONTAINMET_SPHERE
Definition nexus.h:20
@ ANOMALUS_CONTAINMET_SPHERE
Definition nexus.h:19
@ DATA_ORMOROK_EVENT
Definition nexus.h:13
@ DATA_ANOMALUS_EVENT
Definition nexus.h:12
@ DATA_ANOMALUS
Definition nexus.h:16
@ DATA_KERISTRASZA_EVENT
Definition nexus.h:14
@ TELESTRAS_CONTAINMET_SPHERE
Definition nexus.h:21
@ DATA_KERISTRASZA
Definition nexus.h:17
uint64 GetData64(uint32 uiIdentifier) const OVERRIDE
uint32 GetData(uint32 identifier) const OVERRIDE
void SetData(uint32 identifier, uint32 data) OVERRIDE
void OnCreatureCreate(Creature *creature) OVERRIDE