Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
instance_razorfen_downs.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 "razorfen_downs.h"
9#include "Player.h"
10#include "TemporarySummon.h"
11
12#define MAX_ENCOUNTER 1
13
15{
16public:
17 instance_razorfen_downs() : InstanceMapScript("instance_razorfen_downs", 129) { }
18
23
25 {
29
31
33
35
36 std::string str_data;
37
39 {
40 uiGongGUID = 0;
41
42 uiGongWaves = 0;
43
44 memset(&m_auiEncounter, 0, sizeof(m_auiEncounter));
45 }
46
47 std::string GetSaveData() OVERRIDE
48 {
50
51 std::ostringstream saveStream;
52
53 saveStream << "T C " << m_auiEncounter[0]
54 << ' ' << uiGongWaves;
55
56 str_data = saveStream.str();
57
59 return str_data;
60 }
61
62 void Load(const char* in) OVERRIDE
63 {
64 if (!in)
65 {
67 return;
68 }
69
71
72 char dataHead1, dataHead2;
73 uint16 data0, data1;
74
75 std::istringstream loadStream(in);
76 loadStream >> dataHead1 >> dataHead2 >> data0 >> data1;
77
78 if (dataHead1 == 'T' && dataHead2 == 'C')
79 {
80 m_auiEncounter[0] = data0;
81
82 for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
85
86 uiGongWaves = data1;
88
90 }
91
93 {
94 switch (go->GetEntry())
95 {
96 case GO_GONG:
97 uiGongGUID = go->GetGUID();
98 if (m_auiEncounter[0] == DONE)
100 break;
101 default:
102 break;
103 }
104 }
105
106 void SetData(uint32 uiType, uint32 uiData) OVERRIDE
107 {
108 if (uiType == DATA_GONG_WAVES)
109 {
110 uiGongWaves = uiData;
111
112 switch (uiGongWaves)
113 {
114 case 9:
115 case 14:
116 if (GameObject* go = instance->GetGameObject(uiGongGUID))
118 break;
119 case 1:
120 case 10:
121 case 16:
122 {
123 GameObject* go = instance->GetGameObject(uiGongGUID);
124
125 if (!go)
126 return;
127
129
130 uint32 uiCreature = 0;
131 uint8 uiSummonTimes = 0;
132
133 switch (uiGongWaves)
134 {
135 case 1:
136 uiCreature = NPC_TOMB_FIEND;
137 uiSummonTimes = 7;
138 break;
139 case 10:
140 uiCreature = NPC_TOMB_REAVER;
141 uiSummonTimes = 3;
142 break;
143 case 16:
144 uiCreature = NPC_TUTEN_KASH;
145 break;
146 default:
147 break;
148 }
149
150 if (Creature* creature = go->SummonCreature(uiCreature, 2502.635f, 844.140f, 46.896f, 0.633f))
151 {
152 if (uiGongWaves == 10 || uiGongWaves == 1)
153 {
154 for (uint8 i = 0; i < uiSummonTimes; ++i)
155 {
156 if (Creature* summon = go->SummonCreature(uiCreature, 2502.635f + float(std::rand() % 5 + -5), 844.140f + float(std::rand() % 5 + -5), 46.896f, 0.633f))
157 summon->GetMotionMaster()->MovePoint(0, 2533.479f + float(std::rand() % 5 + -5), 870.020f + float(std::rand() % 5 + -5), 47.678f);
158 }
159 }
160 creature->GetMotionMaster()->MovePoint(0, 2533.479f + float(std::rand() % 5 + -5), 870.020f + float(std::rand() % 5 + -5), 47.678f);
161 }
162 break;
163 }
164 default:
165 break;
166 }
167 }
168
169 if (uiType == BOSS_TUTEN_KASH)
170 {
171 m_auiEncounter[0] = uiData;
172
173 if (uiData == DONE)
174 SaveToDB();
175 }
176 }
177
179 {
180 switch (uiType)
181 {
182 case DATA_GONG_WAVES:
183 return uiGongWaves;
184 }
185
186 return 0;
187 }
188
190 {
191 switch (uiType)
192 {
193 case DATA_GONG: return uiGongGUID;
194 }
195
196 return 0;
197 }
198 };
199};
200
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
std::uint16_t uint16
Definition Define.h:78
#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)
@ GO_FLAG_NOT_SELECTABLE
@ GAMEOBJECT_FIELD_FLAGS
InstanceMapScript(const char *name, uint32 mapId)
InstanceScript(Map *map)
Definition Map.h:238
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:1261
TempSummon * SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype=TempSummonType::TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
Definition Object.cpp:2703
InstanceScript * GetInstanceScript(InstanceMap *map) const OVERRIDE
void AddSC_instance_razorfen_downs()
#define MAX_ENCOUNTER
@ DATA_GONG
@ GO_GONG
@ NPC_TOMB_FIEND
@ NPC_TUTEN_KASH
@ NPC_TOMB_REAVER
@ BOSS_TUTEN_KASH
@ DATA_GONG_WAVES