TrinityCore
Loading...
Searching...
No Matches
instance_trial_of_the_champion.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/* ScriptData
19SDName: Instance Trial of the Champion
20SDComment:
21SDCategory: Trial Of the Champion
22EndScriptData */
23
24#include "ScriptMgr.h"
25#include "Creature.h"
26#include "CreatureAI.h"
27#include "GameObject.h"
28#include "InstanceScript.h"
29#include "Log.h"
30#include "Map.h"
31#include "MotionMaster.h"
32#include "Player.h"
34
36
38{
39public:
41
46
48 {
60
65
76
78
79 bool bDone;
80
81 void OnPlayerEnter(Player* player) override
82 {
83 if (!teamInInstance)
84 teamInInstance = player->GetTeam();
85 }
86
87 void OnCreatureCreate(Creature* creature) override
88 {
89 switch (creature->GetEntry())
90 {
93 VehicleList.push_back(creature->GetGUID());
94 break;
95 case NPC_EADRIC:
96 case NPC_PALETRESS:
97 uiArgentChampionGUID = creature->GetGUID();
98 break;
99 case NPC_JAEREN:
100 case NPC_ARELAS:
101 uiAnnouncerGUID = creature->GetGUID();
102 break;
103 default:
104 break;
105 }
106 }
107
137
139 {
140 switch (go->GetEntry())
141 {
142 case GO_MAIN_GATE:
143 uiMainGateGUID = go->GetGUID();
144 break;
148 break;
149 }
150 }
151
152 bool SetBossState(uint32 id, EncounterState state) override
153 {
154 if (!InstanceScript::SetBossState(id, state))
155 return false;
156
157 switch (id)
158 {
160 if (state == IN_PROGRESS)
161 {
162 for (ObjectGuid guid : VehicleList)
163 if (Creature* summon = instance->GetCreature(guid))
164 summon->RemoveFromWorld();
165 }
166 else if (state == DONE)
167 {
169 if (uiGrandChampionsDeaths == 3)
170 {
171 if (Creature* pAnnouncer = instance->GetCreature(uiAnnouncerGUID))
172 {
173 pAnnouncer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
174 pAnnouncer->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
175 pAnnouncer->SummonGameObject(instance->IsHeroic() ? GO_CHAMPIONS_LOOT_H : GO_CHAMPIONS_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, QuaternionData(), 25h);
176 }
177 }
178 }
179 break;
181 if (state == DONE)
182 {
183 if (Creature* pAnnouncer = instance->GetCreature(uiAnnouncerGUID))
184 {
185 pAnnouncer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
186 pAnnouncer->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
187 pAnnouncer->SummonGameObject(instance->IsHeroic() ? GO_EADRIC_LOOT_H : GO_EADRIC_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, QuaternionData(), 25h);
188 }
189 }
190 break;
192 if (state == DONE)
193 {
194 if (Creature* pAnnouncer = instance->GetCreature(uiAnnouncerGUID))
195 {
196 pAnnouncer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
197 pAnnouncer->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
198 pAnnouncer->SummonGameObject(instance->IsHeroic() ? GO_PALETRESS_LOOT_H : GO_PALETRESS_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, QuaternionData(), 25h);
199 }
200 }
201 break;
202 }
203 return true;
204 }
205
206 void SetData(uint32 uiType, uint32 uiData) override
207 {
208 switch (uiType)
209 {
211 uiMovementDone = uiData;
212 if (uiMovementDone == 3)
213 {
214 if (Creature* pAnnouncer = instance->GetCreature(uiAnnouncerGUID))
215 pAnnouncer->AI()->SetData(DATA_IN_POSITION, 0);
216 }
217 break;
219 uiArgentSoldierDeaths = uiData;
220 if (uiArgentSoldierDeaths == 9)
221 {
223 {
224 pBoss->GetMotionMaster()->MovePoint(0, 746.88f, 618.74f, 411.06f);
225 pBoss->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
226 pBoss->SetReactState(REACT_AGGRESSIVE);
227 }
228 }
229 break;
230 }
231
232 if (uiData == DONE)
233 SaveToDB();
234 }
235
236 uint32 GetData(uint32 uiData) const override
237 {
238 switch (uiData)
239 {
242 }
243
244 return 0;
245 }
246
247 ObjectGuid GetGuidData(uint32 uiData) const override
248 {
249 switch (uiData)
250 {
251 case DATA_ANNOUNCER: return uiAnnouncerGUID;
252 case DATA_MAIN_GATE: return uiMainGateGUID;
253
257 }
258
259 return ObjectGuid::Empty;
260 }
261
262 void SetGuidData(uint32 uiType, ObjectGuid uiData) override
263 {
264 switch (uiType)
265 {
267 uiGrandChampion1GUID = uiData;
268 break;
270 uiGrandChampion2GUID = uiData;
271 break;
273 uiGrandChampion3GUID = uiData;
274 break;
275 }
276 }
277
278 void WriteSaveDataMore(std::ostringstream& stream) override
279 {
280 stream << uiGrandChampionsDeaths << ' ' << uiMovementDone;
281 }
282
283 void ReadSaveDataMore(std::istringstream& stream) override
284 {
286 }
287 };
288};
289
uint8_t uint8
Definition Define.h:135
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
EncounterState
@ IN_PROGRESS
@ DONE
std::list< ObjectGuid > GuidList
Definition ObjectGuid.h:261
@ HORDE
@ REACT_AGGRESSIVE
@ UNIT_NPC_FLAG_GOSSIP
@ UNIT_FLAG_NON_ATTACKABLE
#define DataHeader
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
InstanceMap * instance
void SetHeaders(std::string const &dataHeaders)
bool isEmpty() const
Definition LinkedList.h:108
iterator begin()
bool IsHeroic() const
Definition Map.cpp:4256
PlayerList const & GetPlayers() const
Definition Map.h:448
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:4397
static ObjectGuid const Empty
Definition ObjectGuid.h:140
uint32 LowType
Definition ObjectGuid.h:142
uint32 GetEntry() const
Definition Object.h:81
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 GetTeam() const
Definition Player.h:1832
FROM * GetSource() const
Definition Reference.h:96
InstanceScript * GetInstanceScript(InstanceMap *map) const override
void AddSC_instance_trial_of_the_champion()
constexpr uint32 ToCEncounterCount
uint32 id
Definition SpawnData.h:96
@ GO_PALETRESS_LOOT
@ GO_PALETRESS_LOOT_H
@ GO_CHAMPIONS_LOOT_H
@ GO_EADRIC_LOOT
@ GO_CHAMPIONS_LOOT
@ GO_EADRIC_LOOT_H
@ VEHICLE_LANA_STOUTHAMMER_MOUNT
@ VEHICLE_COLOSOS_MOUNT
@ VEHICLE_MARSHAL_JACOB_ALERIUS_MOUNT
@ VEHICLE_EVENSONG_MOUNT
@ VEHICLE_ARGENT_BATTLEWORG
@ VEHICLE_RUNOK_WILDMANE_MOUNT
@ VEHICLE_ZUL_TORE_MOUNT
@ VEHICLE_DEATHSTALKER_VESCERI_MOUNT
@ VEHICLE_AMBROSE_BOLTSPARK_MOUNT
@ VEHICLE_MOKRA_SKILLCRUSHER_MOUNT
@ VEHICLE_ARGENT_WARHORSE
@ VEHICLE_ERESSEA_DAWNSINGER_MOUNT
@ NPC_PALETRESS
@ DATA_MAIN_GATE
@ DATA_GRAND_CHAMPION_2
@ DATA_GRAND_CHAMPION_1
@ DATA_GRAND_CHAMPION_3
@ DATA_ANNOUNCER
#define ToCScriptName
@ BOSS_GRAND_CHAMPIONS
@ DATA_ARGENT_SOLDIER_DEFEATED
@ DATA_MOVEMENT_DONE
@ BOSS_ARGENT_CHALLENGE_P
@ BOSS_ARGENT_CHALLENGE_E
@ DATA_IN_POSITION