OregonCore  revision fb2a440-git
Your Favourite TBC server
OutdoorPvP.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore 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 "Utilities/Util.h"
22 #include "ZoneScript.h"
23 
24 class GameObject;
25 
27 {
34 };
35 
37 {
45 };
46 
47 #define OTHER_TEAM(a) (a == TEAM_ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE)
48 
49 // struct for go spawning
50 struct go_type
51 {
54  float x;
55  float y;
56  float z;
57  float o;
58  float rot0;
59  float rot1;
60  float rot2;
61  float rot3;
62 };
63 
64 // struct for creature spawning
66 {
70  float x;
71  float y;
72  float z;
73  float o;
74 };
75 
76 // some class predefs
77 class Player;
78 class GameObject;
79 class WorldPacket;
80 class Creature;
81 class Unit;
83 
84 typedef std::set<Player*> PlayerSet;
85 
86 class OutdoorPvP;
88 {
89  public:
91  virtual ~OPvPCapturePoint() {}
92 
93  virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
94 
95  // send world state update to all players present
96  void SendUpdateWorldState(uint32 field, uint32 value);
97  // send kill notify to players in the controlling faction
98  void SendObjectiveComplete(uint32 id, uint64 guid);
99 
100  // used when player is activated/inactivated in the area
101  virtual bool HandlePlayerEnter(Player* plr);
102  virtual void HandlePlayerLeave(Player* plr);
103  //virtual void HandlePlayerActivityChanged(Player* plr);
104 
105  // checks if player is in range of a capture credit marker
106  bool IsInsideObjective(Player* plr) const;
107 
108  virtual bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go);
109  virtual int32 HandleOpenGo(Player* plr, uint64 guid);
110 
111  // returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
112  virtual bool Update(uint32 diff);
113  virtual void ChangeState() = 0;
114  virtual void ChangeTeam(TeamId /*oldTeam*/) {}
115  virtual void SendChangePhase();
116 
117  virtual bool HandleGossipOption(Player* plr, uint64 guid, uint32 gossipid);
118 
119  virtual bool CanTalkTo(Player* plr, Creature* c, GossipMenuItems gso);
120 
121  virtual bool HandleDropFlag(Player* plr, uint32 spellId);
122 
123  virtual void DeleteSpawns();
124 
127 
128  void AddGO(uint32 type, uint32 guid, uint32 entry = 0);
129  void AddCre(uint32 type, uint32 guid, uint32 entry = 0);
130  bool SetCapturePointData(uint32 entry, uint32 map, float x, float y, float z, float o = 0, float rotation0 = 0, float rotation1 = 0, float rotation2 = 0, float rotation3 = 0);
131 
132  protected:
133 
134  bool AddObject(uint32 type, uint32 entry, uint32 artKit, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3);
135  bool AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
136 
137  bool DelCreature(uint32 type);
138  bool DelObject(uint32 type);
139  bool DelCapturePoint();
140 
141  protected:
142  // active players in the area of the objective, 0 - alliance, 1 - horde
143  PlayerSet m_activePlayers[2];
144  // total shift needed to capture the objective
145  float m_maxValue;
146  float m_minValue;
147  // maximum speed of capture
148  float m_maxSpeed;
149  // the status of the objective
150  float m_value;
152  // objective states
155  // neutral value on capture bar
157 
158  // pointer to the OutdoorPvP this objective belongs to
160 
161  // map to store the various gameobjects and creatures spawned by the objective
162  // type , guid
163  std::map<uint32, uint64> m_Objects;
164  std::map<uint32, uint64> m_Creatures;
165  std::map<uint64, uint32> m_ObjectTypes;
166  std::map<uint64, uint32> m_CreatureTypes;
167 };
168 
169 // base class for specific outdoor pvp handlers
170 class OutdoorPvP : public ZoneScript
171 {
172  friend class OutdoorPvPMgr;
173  public:
174  // ctor
175  OutdoorPvP();
176  // dtor
177  virtual ~OutdoorPvP();
178  // deletes all gos/creatures spawned by the pvp
179  void DeleteSpawns();
180 
181  typedef std::map<uint32/*lowguid*/, OPvPCapturePoint*> OPvPCapturePointMap;
182 
183  virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
184  // called when a player triggers an areatrigger
185  virtual bool HandleAreaTrigger(Player* plr, uint32 trigger);
186  // called on custom spell
187  virtual bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go);
188  // called on go use
189  virtual bool HandleOpenGo(Player* plr, uint64 guid);
190 
191  // setup stuff
192  virtual bool SetupOutdoorPvP()
193  {
194  return true;
195  }
196 
197  void OnGameObjectCreate(GameObject* go, bool add) override;
198  void OnGameObjectRemove(GameObject* go);
199  void OnCreatureCreate(Creature*, bool /*add*/) override {}
200 
201  // send world state update to all players present
202  void SendUpdateWorldState(uint32 field, uint32 value);
203 
204  // called by OutdoorPvPMgr, updates the objectives and if needed, sends new worldstateui information
205  virtual bool Update(uint32 diff);
206 
207  // handle npc/player kill
208  virtual void HandleKill(Player* killer, Unit* killed);
209  virtual void HandleKillImpl(Player* /*killer*/, Unit* /*killed*/) {}
210 
211  // checks if player is in range of a capture credit marker
212  bool IsInsideObjective(Player* plr) const;
213 
214  // awards rewards for player kill
215  virtual void AwardKillBonus(Player* /*plr*/) {}
216 
217  uint32 GetTypeId()
218  {
219  return m_TypeId;
220  }
221 
222  virtual bool HandleDropFlag(Player* plr, uint32 spellId);
223 
224  virtual bool HandleGossipOption(Player* plr, uint64 guid, uint32 gossipid);
225 
226  virtual bool CanTalkTo(Player* plr, Creature* c, GossipMenuItems gso);
227 
228  void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0);
229  protected:
230  // the map of the objectives belonging to this outdoorpvp
231  OPvPCapturePointMap m_capturePoints;
232 
233  PlayerSet m_players[2];
234  uint32 m_TypeId;
235 
236  // world state stuff
237  virtual void SendRemoveWorldStates(Player* /*plr*/) {}
238 
239  virtual void HandlePlayerEnterZone(Player* plr, uint32 zone);
240  virtual void HandlePlayerLeaveZone(Player* plr, uint32 zone);
241 
243  {
244  m_capturePoints[cp->m_capturePointGUID] = cp;
245  }
246 
247  OPvPCapturePoint* GetCapturePoint(uint32 lowguid) const
248  {
249  OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid);
250  if (itr != m_capturePoints.end())
251  return itr->second;
252  return NULL;
253  }
254 
255  void RegisterZone(uint32 zoneid);
256  bool HasPlayer(Player* plr) const;
257  void TeamCastSpell(TeamId team, int32 spellId);
258 };
259 
260 #endif /*OUTDOOR_PVP_H_*/
261 
float rot1
Definition: OutdoorPvP.h:59
float z
Definition: OutdoorPvP.h:56
uint32 map
Definition: OutdoorPvP.h:69
bool CanTalkTo(Player *player, Creature *creature, GossipMenuItems gso)
float y
Definition: OutdoorPvP.h:55
void Update(uint32 diff)
void OnCreatureCreate(Creature *, bool) override
Definition: OutdoorPvP.h:199
OutdoorPvP * m_PvP
Definition: OutdoorPvP.h:159
void HandleGossipOption(Player *player, uint64 guid, uint32 gossipid)
virtual void HandleKillImpl(Player *, Unit *)
Definition: OutdoorPvP.h:209
uint32 entry
Definition: OutdoorPvP.h:67
ObjectiveStates
Definition: OutdoorPvP.h:36
virtual void ChangeTeam(TeamId)
Definition: OutdoorPvP.h:114
virtual void SendRemoveWorldStates(Player *)
Definition: OutdoorPvP.h:237
virtual void AwardKillBonus(Player *)
Definition: OutdoorPvP.h:215
OPvPCapturePointMap m_capturePoints
Definition: OutdoorPvP.h:231
std::map< uint64, uint32 > m_ObjectTypes
Definition: OutdoorPvP.h:165
ACE_INT32 int32
Definition: Define.h:67
bool HandleOpenGo(Player *plr, uint64 guid)
float o
Definition: OutdoorPvP.h:57
uint32 m_capturePointGUID
Definition: OutdoorPvP.h:125
void HandlePlayerLeaveZone(Player *plr, uint32 areaflag)
bool HandleCustomSpell(Player *plr, uint32 spellId, GameObject *go)
float rot2
Definition: OutdoorPvP.h:60
virtual void FillInitialWorldStates(WorldPacket &)
Definition: OutdoorPvP.h:183
uint32 map
Definition: OutdoorPvP.h:53
float rot3
Definition: OutdoorPvP.h:61
uint32 teamval
Definition: OutdoorPvP.h:68
float rot0
Definition: OutdoorPvP.h:58
OPvPCapturePoint * GetCapturePoint(uint32 lowguid) const
Definition: OutdoorPvP.h:247
OutdoorPvPTypes
Definition: OutdoorPvP.h:26
std::map< uint32, OPvPCapturePoint * > OPvPCapturePointMap
Definition: OutdoorPvP.h:181
etc mysql my cnf *Then change max_allowed_packet to a bigger value
GameObject * m_capturePoint
Definition: OutdoorPvP.h:126
void AddCapturePoint(OPvPCapturePoint *cp)
Definition: OutdoorPvP.h:242
TeamId
std::map< uint32, uint64 > m_Objects
Definition: OutdoorPvP.h:163
ACE_UINT64 uint64
Definition: Define.h:70
uint32 m_neutralValuePct
Definition: OutdoorPvP.h:156
std::map< uint64, uint32 > m_CreatureTypes
Definition: OutdoorPvP.h:166
void HandlePlayerEnterZone(Player *plr, uint32 areaflag)
std::set< Player * > PlayerSet
Definition: OutdoorPvP.h:82
uint32 m_TypeId
Definition: OutdoorPvP.h:234
virtual void FillInitialWorldStates(WorldPacket &)
Definition: OutdoorPvP.h:93
uint32 entry
Definition: OutdoorPvP.h:52
virtual bool SetupOutdoorPvP()
Definition: OutdoorPvP.h:192
virtual ~OPvPCapturePoint()
Definition: OutdoorPvP.h:91
std::map< uint32, uint64 > m_Creatures
Definition: OutdoorPvP.h:164
void HandleDropFlag(Player *plr, uint32 spellId)
uint32 GetTypeId()
Definition: OutdoorPvP.h:217
ACE_UINT32 uint32
Definition: Define.h:71
ObjectiveStates m_OldState
Definition: OutdoorPvP.h:153
Definition: Unit.h:908
Definition: Player.h:922
ObjectiveStates m_State
Definition: OutdoorPvP.h:154
float x
Definition: OutdoorPvP.h:54