TrinityCore
Loading...
Searching...
No Matches
OutdoorPvP.h
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#ifndef OUTDOOR_PVP_H_
19#define OUTDOOR_PVP_H_
20
21#include "GameObjectData.h"
22#include "Position.h"
23#include "SharedDefines.h"
24#include "ZoneScript.h"
25#include <map>
26
38
49
50#define OTHER_TEAM(a) (a == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE)
51
52// struct for go spawning
60
61// struct for creature spawning
68
69namespace WorldPackets
70{
71 namespace WorldState
72 {
73 class InitWorldStates;
74 }
75}
76
77class Creature;
78class GameObject;
79class Map;
80class OutdoorPvP;
81class Player;
82class Unit;
83class WorldPacket;
84struct GossipMenuItems;
85
87{
88 public:
89
91
92 virtual ~OPvPCapturePoint() { }
93
95
96 // send world state update to all players present
97 void SendUpdateWorldState(uint32 field, uint32 value);
98
99 // send kill notify to players in the controlling faction
100 void SendObjectiveComplete(uint32 id, ObjectGuid guid);
101
102 // used when player is activated/inactivated in the area
103 virtual bool HandlePlayerEnter(Player* player);
104 virtual void HandlePlayerLeave(Player* player);
105
106 // checks if player is in range of a capture credit marker
107 bool IsInsideObjective(Player* player) const;
108
109 virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
110
111 virtual int32 HandleOpenGo(Player* player, GameObject* go);
112
113 // returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
114 virtual bool Update(uint32 diff);
115
116 virtual void ChangeState() = 0;
117
118 virtual void ChangeTeam(TeamId /*oldTeam*/) { }
119
120 virtual void SendChangePhase();
121
122 virtual bool HandleGossipOption(Player* player, Creature* guid, uint32 gossipid);
123
124 virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
125
126 virtual bool HandleDropFlag(Player* player, uint32 spellId);
127
128 virtual void DeleteSpawns();
129
131
133
134 void AddGO(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0);
135 void AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry = 0);
136
137 bool SetCapturePointData(uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot);
138
139 protected:
140
141 bool AddObject(uint32 type, uint32 entry, uint32 map, Position const& pos, QuaternionData const& rot);
142 bool AddCreature(uint32 type, uint32 entry, uint32 map, Position const& pos, TeamId teamId = TEAM_NEUTRAL, uint32 spawntimedelay = 0);
143
144 bool DelObject(uint32 type);
145 bool DelCreature(uint32 type);
146
147 bool DelCapturePoint();
148
149 protected:
150
151 // active players in the area of the objective, 0 - alliance, 1 - horde
152 GuidSet m_activePlayers[2];
153
154 // total shift needed to capture the objective
157
158 // maximum speed of capture
160
161 // the status of the objective
162 float m_value;
163
165
166 // objective states
169
170 // neutral value on capture bar
172
173 // pointer to the OutdoorPvP this objective belongs to
175
176 // map to store the various gameobjects and creatures spawned by the objective
177 // type, guid
178 std::map<uint32, ObjectGuid::LowType> m_Objects;
179 std::map<uint32, ObjectGuid::LowType> m_Creatures;
180 std::map<ObjectGuid::LowType, uint32> m_ObjectTypes;
181 std::map<ObjectGuid::LowType, uint32> m_CreatureTypes;
182};
183
184// base class for specific outdoor pvp handlers
186{
187 friend class OutdoorPvPMgr;
188
189 public:
190
191 // ctor
192 OutdoorPvP();
193
194 // dtor
195 virtual ~OutdoorPvP();
196
197 // deletes all gos/creatures spawned by the pvp
198 void DeleteSpawns();
199
201 typedef std::pair<ObjectGuid::LowType, GameObject*> GoScriptPair;
202 typedef std::pair<ObjectGuid::LowType, Creature*> CreatureScriptPair;
203
205
206 // called when a player triggers an areatrigger
207 virtual bool HandleAreaTrigger(Player* player, uint32 trigger);
208
209 // called on custom spell
210 virtual bool HandleCustomSpell(Player* player, uint32 spellId, GameObject* go);
211
212 // called on go use
213 virtual bool HandleOpenGo(Player* player, GameObject* go);
214
215 // setup stuff
216 virtual bool SetupOutdoorPvP() {return true;}
217
218 void OnGameObjectCreate(GameObject* go) override;
219 void OnGameObjectRemove(GameObject* go) override;
220 void OnCreatureCreate(Creature*) override;
221 void OnCreatureRemove(Creature*) override;
222
223 // send world state update to all players present
224 void SendUpdateWorldState(uint32 field, uint32 value);
225
226 // called by OutdoorPvPMgr, updates the objectives and if needed, sends new worldstateui information
227 virtual bool Update(uint32 diff);
228
229 // handle npc/player kill
230 virtual void HandleKill(Player* killer, Unit* killed);
231 virtual void HandleKillImpl(Player* /*killer*/, Unit* /*killed*/) { }
232
233 // checks if player is in range of a capture credit marker
234 bool IsInsideObjective(Player* player) const;
235
236 // awards rewards for player kill
237 virtual void AwardKillBonus(Player* /*player*/) { }
238
239 uint32 GetTypeId() const {return m_TypeId;}
240
241 virtual bool HandleDropFlag(Player* player, uint32 spellId);
242
243 virtual bool HandleGossipOption(Player* player, Creature* creature, uint32 gossipid);
244
245 virtual bool CanTalkTo(Player* player, Creature* c, GossipMenuItems const& gso);
246
247 void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0);
248
250 {
251 switch (team)
252 {
253 case ALLIANCE:
254 return TEAM_ALLIANCE;
255 case HORDE:
256 return TEAM_HORDE;
257 default:
258 return TEAM_NEUTRAL;
259 }
260 }
261
262 void SendDefenseMessage(uint32 zoneId, uint32 id);
263
264 Map* GetMap() const { return m_map; }
265
266 protected:
267
268 // the map of the objectives belonging to this outdoorpvp
270
271 GuidSet m_players[2];
272
274
276
277 // world state stuff
278 virtual void SendRemoveWorldStates(Player* /*player*/) { }
279
280 void BroadcastPacket(WorldPacket & data) const;
281
282 virtual void HandlePlayerEnterZone(Player* player, uint32 zone);
283 virtual void HandlePlayerLeaveZone(Player* player, uint32 zone);
284
285 virtual void HandlePlayerResurrects(Player* player, uint32 zone);
286
288 {
289 m_capturePoints[cp->m_capturePointSpawnId] = cp;
290 }
291
293 {
294 OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(guid);
295 if (itr != m_capturePoints.end())
296 return itr->second;
297 return nullptr;
298 }
299
300 void RegisterZone(uint32 zoneid);
301
302 bool HasPlayer(Player const* player) const;
303
304 void TeamCastSpell(TeamId team, int32 spellId);
305
306 template<class Worker>
307 void BroadcastWorker(Worker& _worker, uint32 zoneId);
308
309 // Hack to store map because this code is just shit
310 void SetMapFromZone(uint32 zone);
311 std::map<ObjectGuid::LowType, GameObject*> m_GoScriptStore;
312 std::map<ObjectGuid::LowType, Creature*> m_CreatureScriptStore;
313
315};
316
317#endif /*OUTDOOR_PVP_H_*/
#define TC_GAME_API
Definition Define.h:114
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:260
OutdoorPvPTypes
Definition OutdoorPvP.h:28
@ OUTDOOR_PVP_SI
Definition OutdoorPvP.h:33
@ MAX_OUTDOORPVP_TYPES
Definition OutdoorPvP.h:36
@ OUTDOOR_PVP_TF
Definition OutdoorPvP.h:31
@ OUTDOOR_PVP_ZM
Definition OutdoorPvP.h:32
@ OUTDOOR_PVP_EP
Definition OutdoorPvP.h:34
@ OUTDOOR_PVP_NA
Definition OutdoorPvP.h:30
@ OUTDOOR_PVP_HP
Definition OutdoorPvP.h:29
ObjectiveStates
Definition OutdoorPvP.h:40
@ OBJECTIVESTATE_HORDE
Definition OutdoorPvP.h:43
@ OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE
Definition OutdoorPvP.h:45
@ OBJECTIVESTATE_ALLIANCE
Definition OutdoorPvP.h:42
@ OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE
Definition OutdoorPvP.h:44
@ OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE
Definition OutdoorPvP.h:47
@ OBJECTIVESTATE_NEUTRAL
Definition OutdoorPvP.h:41
@ OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE
Definition OutdoorPvP.h:46
TeamId
@ TEAM_NEUTRAL
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ ALLIANCE
@ HORDE
WorldState
Definition Map.h:281
std::map< uint32, ObjectGuid::LowType > m_Creatures
Definition OutdoorPvP.h:179
virtual void ChangeState()=0
ObjectiveStates m_OldState
Definition OutdoorPvP.h:167
OutdoorPvP * m_PvP
Definition OutdoorPvP.h:174
std::map< ObjectGuid::LowType, uint32 > m_ObjectTypes
Definition OutdoorPvP.h:180
std::map< ObjectGuid::LowType, uint32 > m_CreatureTypes
Definition OutdoorPvP.h:181
ObjectiveStates m_State
Definition OutdoorPvP.h:168
uint32 m_neutralValuePct
Definition OutdoorPvP.h:171
std::map< uint32, ObjectGuid::LowType > m_Objects
Definition OutdoorPvP.h:178
virtual void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &)
Definition OutdoorPvP.h:94
virtual ~OPvPCapturePoint()
Definition OutdoorPvP.h:92
GameObject * m_capturePoint
Definition OutdoorPvP.h:132
ObjectGuid::LowType m_capturePointSpawnId
Definition OutdoorPvP.h:130
virtual void ChangeTeam(TeamId)
Definition OutdoorPvP.h:118
uint32 LowType
Definition ObjectGuid.h:142
OPvPCapturePointMap m_capturePoints
Definition OutdoorPvP.h:269
uint32 m_TypeId
Definition OutdoorPvP.h:273
std::map< ObjectGuid::LowType, OPvPCapturePoint * > OPvPCapturePointMap
Definition OutdoorPvP.h:200
std::pair< ObjectGuid::LowType, Creature * > CreatureScriptPair
Definition OutdoorPvP.h:202
virtual void SendRemoveWorldStates(Player *)
Definition OutdoorPvP.h:278
static TeamId GetTeamIdByTeam(uint32 team)
Definition OutdoorPvP.h:249
OPvPCapturePoint * GetCapturePoint(ObjectGuid::LowType guid) const
Definition OutdoorPvP.h:292
virtual void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &)
Definition OutdoorPvP.h:204
virtual bool SetupOutdoorPvP()
Definition OutdoorPvP.h:216
Map * GetMap() const
Definition OutdoorPvP.h:264
std::map< ObjectGuid::LowType, Creature * > m_CreatureScriptStore
Definition OutdoorPvP.h:312
virtual void AwardKillBonus(Player *)
Definition OutdoorPvP.h:237
virtual void HandleKillImpl(Player *, Unit *)
Definition OutdoorPvP.h:231
std::pair< ObjectGuid::LowType, GameObject * > GoScriptPair
Definition OutdoorPvP.h:201
bool m_sendUpdate
Definition OutdoorPvP.h:275
std::map< ObjectGuid::LowType, GameObject * > m_GoScriptStore
Definition OutdoorPvP.h:311
void AddCapturePoint(OPvPCapturePoint *cp)
Definition OutdoorPvP.h:287
uint32 GetTypeId() const
Definition OutdoorPvP.h:239
Map * m_map
Definition OutdoorPvP.h:314
Definition Unit.h:769
Position pos
Definition OutdoorPvP.h:66
uint32 map
Definition OutdoorPvP.h:56
uint32 entry
Definition OutdoorPvP.h:55
Position pos
Definition OutdoorPvP.h:57
QuaternionData rot
Definition OutdoorPvP.h:58