TrinityCore
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 "Map.h"
30#include "MotionMaster.h"
31#include "Player.h"
33
35
37{
38 { BOSS_GRAND_CHAMPIONS, {{ 2022 }} },
39 { BOSS_ARGENT_CHALLENGE_E, {{ 2023 }} },
40 { BOSS_ARGENT_CHALLENGE_P, {{ 2023 }} },
41 { BOSS_BLACK_KNIGHT, {{ 2021 }} }
42};
43
45{
46public:
48
50 {
52 }
53
55 {
57 uiMovementDone(*this, "uiMovementDone"), uiGrandChampionsDeaths(*this, "uiGrandChampionsDeaths")
58 {
64
65 bDone = false;
66 }
67
72
83
85
86 bool bDone;
87
88 void OnPlayerEnter(Player* player) override
89 {
90 if (!teamInInstance)
91 teamInInstance = player->GetTeam();
92 }
93
94 void OnCreatureCreate(Creature* creature) override
95 {
96 switch (creature->GetEntry())
97 {
100 VehicleList.push_back(creature->GetGUID());
101 break;
102 case NPC_EADRIC:
103 case NPC_PALETRESS:
104 uiArgentChampionGUID = creature->GetGUID();
105 break;
106 case NPC_JAEREN:
107 case NPC_ARELAS:
108 uiAnnouncerGUID = creature->GetGUID();
109 break;
110 default:
111 break;
112 }
113 }
114
115 uint32 GetCreatureEntry(ObjectGuid::LowType /*guidLow*/, CreatureData const* data) override
116 {
117 if (!teamInInstance)
118 {
119 Map::PlayerList const& players = instance->GetPlayers();
120 if (!players.isEmpty())
121 if (Player* player = players.begin()->GetSource())
122 teamInInstance = player->GetTeam();
123 }
124
125 uint32 entry = data->id;
126 switch (entry)
127 {
138 case NPC_JAEREN:
140 default:
141 return entry;
142 }
143 }
144
146 {
147 switch (go->GetEntry())
148 {
149 case GO_MAIN_GATE:
150 uiMainGateGUID = go->GetGUID();
151 break;
155 break;
156 }
157 }
158
159 bool SetBossState(uint32 id, EncounterState state) override
160 {
161 if (!InstanceScript::SetBossState(id, state))
162 return false;
163
164 switch (id)
165 {
167 if (state == IN_PROGRESS)
168 {
169 for (ObjectGuid guid : VehicleList)
170 if (Creature* summon = instance->GetCreature(guid))
171 summon->RemoveFromWorld();
172 }
173 else if (state == DONE)
174 {
176 if (uiGrandChampionsDeaths == 3)
177 {
178 if (Creature* pAnnouncer = instance->GetCreature(uiAnnouncerGUID))
179 {
180 pAnnouncer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
181 pAnnouncer->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
182 pAnnouncer->SummonGameObject(instance->IsHeroic() ? GO_CHAMPIONS_LOOT_H : GO_CHAMPIONS_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, QuaternionData::fromEulerAnglesZYX(1.42f, 0.0f, 0.0f), 25h);
183 }
184 }
185 }
186 break;
188 if (state == DONE)
189 {
190 if (Creature* pAnnouncer = instance->GetCreature(uiAnnouncerGUID))
191 {
192 pAnnouncer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
193 pAnnouncer->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
194 pAnnouncer->SummonGameObject(instance->IsHeroic() ? GO_EADRIC_LOOT_H : GO_EADRIC_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, QuaternionData(), 25h);
195 }
196 }
197 break;
199 if (state == DONE)
200 {
201 if (Creature* pAnnouncer = instance->GetCreature(uiAnnouncerGUID))
202 {
203 pAnnouncer->GetMotionMaster()->MovePoint(0, 748.309f, 619.487f, 411.171f);
204 pAnnouncer->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
205 pAnnouncer->SummonGameObject(instance->IsHeroic() ? GO_PALETRESS_LOOT_H : GO_PALETRESS_LOOT, 746.59f, 618.49f, 411.09f, 1.42f, QuaternionData(), 25h);
206 }
207 }
208 break;
209 }
210 return true;
211 }
212
213 void SetData(uint32 uiType, uint32 uiData) override
214 {
215 switch (uiType)
216 {
218 uiMovementDone = uiData;
219 if (uiMovementDone == 3)
220 {
221 if (Creature* pAnnouncer = instance->GetCreature(uiAnnouncerGUID))
222 pAnnouncer->AI()->SetData(DATA_IN_POSITION, 0);
223 }
224 break;
226 uiArgentSoldierDeaths = uiData;
227 if (uiArgentSoldierDeaths == 9)
228 {
230 {
231 pBoss->GetMotionMaster()->MovePoint(0, 746.88f, 618.74f, 411.06f);
232 pBoss->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
233 pBoss->SetReactState(REACT_AGGRESSIVE);
234 }
235 }
236 break;
239 break;
240 }
241 }
242
243 uint32 GetData(uint32 uiData) const override
244 {
245 switch (uiData)
246 {
249 }
250
251 return 0;
252 }
253
254 ObjectGuid GetGuidData(uint32 uiData) const override
255 {
256 switch (uiData)
257 {
258 case DATA_ANNOUNCER: return uiAnnouncerGUID;
259 case DATA_MAIN_GATE: return uiMainGateGUID;
260
264 }
265
266 return ObjectGuid::Empty;
267 }
268
269 void SetGuidData(uint32 uiType, ObjectGuid uiData) override
270 {
271 switch (uiType)
272 {
274 uiGrandChampion1GUID = uiData;
275 break;
277 uiGrandChampion2GUID = uiData;
278 break;
280 uiGrandChampion3GUID = uiData;
281 break;
282 }
283 }
284 };
285};
286
288{
290}
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
EncounterState
@ IN_PROGRESS
@ DONE
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:394
@ HORDE
@ REACT_AGGRESSIVE
Definition: UnitDefines.h:508
@ UNIT_NPC_FLAG_GOSSIP
Definition: UnitDefines.h:297
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:145
#define DataHeader
void SetBossNumber(uint32 number)
virtual bool SetBossState(uint32 id, EncounterState state)
void LoadDungeonEncounterData(T const &encounters)
InstanceMap * instance
void SetHeaders(std::string const &dataHeaders)
bool isEmpty() const
Definition: LinkedList.h:110
iterator begin()
Definition: MapRefManager.h:34
bool IsHeroic() const
Definition: Map.cpp:3282
PlayerList const & GetPlayers() const
Definition: Map.h:367
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3479
static ObjectGuid const Empty
Definition: ObjectGuid.h:274
uint64 LowType
Definition: ObjectGuid.h:278
uint32 GetEntry() const
Definition: Object.h:161
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
Team GetTeam() const
Definition: Player.h:2235
FROM * GetSource() const
Definition: Reference.h:96
InstanceScript * GetInstanceScript(InstanceMap *map) const override
void AddSC_instance_trial_of_the_champion()
constexpr uint32 ToCEncounterCount
DungeonEncounterData const encounters[]
static QuaternionData fromEulerAnglesZYX(float Z, float Y, float X)
Definition: GameObject.cpp:118
uint32 id
Definition: SpawnData.h:104
uint32 GetCreatureEntry(ObjectGuid::LowType, CreatureData const *data) override
@ GO_PALETRESS_LOOT
@ GO_PALETRESS_LOOT_H
@ GO_CHAMPIONS_LOOT_H
@ GO_EADRIC_LOOT
@ GO_CHAMPIONS_LOOT
@ GO_MAIN_GATE
@ 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
@ NPC_ARELAS
@ NPC_JAEREN
@ NPC_EADRIC
@ DATA_MAIN_GATE
@ DATA_GRAND_CHAMPION_2
@ DATA_GRAND_CHAMPION_1
@ DATA_GRAND_CHAMPION_3
@ DATA_ANNOUNCER
#define ToCScriptName
@ BOSS_BLACK_KNIGHT
@ BOSS_GRAND_CHAMPIONS
@ DATA_ARGENT_SOLDIER_DEFEATED
@ DATA_MOVEMENT_DONE
@ BOSS_ARGENT_CHALLENGE_P
@ BOSS_ARGENT_CHALLENGE_E
@ DATA_IN_POSITION