root/trunk/src/game/OutdoorPvP.h @ 131

Revision 102, 7.4 kB (checked in by yumileroy, 17 years ago)

[svn] Fixed copyright notices to comply with GPL.

Original author: w12x
Date: 2008-10-23 03:29:52-05:00

Line 
1/*
2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#ifndef OUTDOOR_PVP_H_
20#define OUTDOOR_PVP_H_
21
22#include "Util.h"
23
24#include <map>
25#include <set>
26
27#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000
28
29#define OPVP_TRIGGER_CREATURE_ENTRY 12999
30
31enum ObjectiveStates{
32    OBJECTIVESTATE_NEUTRAL = 0,
33    OBJECTIVESTATE_ALLIANCE = 1,
34    OBJECTIVESTATE_HORDE = 2,
35    OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE = 3,
36    OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE = 4,
37    OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE = 5,
38    OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE = 6
39};
40
41enum OutdoorPvPTypes{
42    OUTDOOR_PVP_HP = 1,
43    OUTDOOR_PVP_NA = 2,
44    OUTDOOR_PVP_TF = 3,
45    OUTDOOR_PVP_ZM = 4,
46    OUTDOOR_PVP_SI = 5,
47    OUTDOOR_PVP_EP = 6
48};
49
50// struct for go spawning
51struct go_type{
52    uint32 entry;
53    uint32 map;
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
65struct creature_type{
66    uint32 entry;
67    uint32 teamval;
68    uint32 map;
69    float x;
70    float y;
71    float z;
72    float o;
73};
74
75// some class predefs
76class Player;
77class GameObject;
78class WorldPacket;
79class Creature;
80class Unit;
81struct GossipOption;
82
83class OutdoorPvP;
84class OutdoorPvPObjective
85{
86public:
87    OutdoorPvPObjective(OutdoorPvP * pvp);
88
89    virtual void FillInitialWorldStates(WorldPacket & data) {}
90
91    // send world state update to all players present
92    virtual void SendUpdateWorldState(uint32 field, uint32 value);
93    // send kill notify to players in the controlling faction
94    virtual void SendObjectiveComplete(uint32 id, uint64 guid);
95
96    // used when player is activated/inactivated in the area
97    virtual bool HandlePlayerEnter(Player * plr);
98    virtual void HandlePlayerLeave(Player * plr);
99    virtual void HandlePlayerActivityChanged(Player * plr);
100
101    // checks if player is in range of a capture credit marker
102    virtual bool IsInsideObjective(Player * plr);
103
104    virtual bool HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go);
105    virtual int32 HandleOpenGo(Player *plr, uint64 guid);
106
107    // returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
108    virtual bool Update(uint32 diff);
109
110    virtual bool HandleCapturePointEvent(Player * plr, uint32 eventId) { return false; }
111
112    virtual bool HandleCaptureCreaturePlayerMoveInLos(Player * p, Creature * c);
113
114    virtual bool HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid);
115
116    virtual bool CanTalkTo(Player * plr, Creature * c, GossipOption &gso);
117
118    virtual bool HandleDropFlag(Player * plr, uint32 spellId);
119
120    virtual void DeleteSpawns();
121protected:
122
123    virtual bool AddCapturePoint(uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3);
124    virtual bool AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3);
125    virtual bool AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
126
127    virtual bool DelCreature(uint32 type);
128    virtual bool DelObject(uint32 type);
129    virtual bool DelCapturePoint();
130
131protected:
132    // active players in the area of the objective
133    std::set<uint64> m_ActivePlayerGuids;
134    int32 m_AllianceActivePlayerCount;
135    int32 m_HordeActivePlayerCount;
136    // time left to capture the objective
137    uint32 m_ShiftTimer;
138    // total shift needed to capture the objective
139    float m_ShiftMaxPhase;
140    // maximum speed of capture
141    float m_ShiftMaxCaptureSpeed;
142    // the status of the objective
143    float m_ShiftPhase;
144    // phase before update, used to check which faction is in conquer / control
145    float m_OldPhase;
146    // objective states
147    uint32 m_OldState;
148    uint32 m_State;
149    // neutral value on capture bar
150    uint32 m_NeutralValue;
151
152    // pointer to the OutdoorPvP this objective belongs to
153    OutdoorPvP* m_PvP;
154
155    // map to store the various gameobjects and creatures spawned by the objective
156    //        type , guid
157    std::map<uint32,uint64> m_Objects;
158    std::map<uint32,uint64> m_Creatures;
159    std::map<uint64,uint32> m_ObjectTypes;
160    std::map<uint64,uint32> m_CreatureTypes;
161    uint64 m_CapturePoint;
162    uint64 m_CapturePointCreature;
163};
164
165// base class for specific outdoor pvp handlers
166class OutdoorPvP
167{
168public:
169    // ctor
170    OutdoorPvP();
171    // dtor
172    ~OutdoorPvP();
173    // deletes all gos/creatures spawned by the pvp
174    void DeleteSpawns();
175
176    typedef std::set<OutdoorPvPObjective *> OutdoorPvPObjectiveSet;
177
178    // called from Player::UpdateZone to add / remove buffs given by outdoor pvp events
179    virtual void HandlePlayerEnterZone(Player * plr, uint32 zone);
180    virtual void HandlePlayerLeaveZone(Player * plr, uint32 zone);
181    virtual void HandlePlayerActivityChanged(Player * plr);
182    // called when a player triggers an areatrigger
183    virtual bool HandleAreaTrigger(Player * plr, uint32 trigger);
184    // called on custom spell
185    virtual bool HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go);
186    // called on go use
187    virtual bool HandleOpenGo(Player *plr, uint64 guid);
188    // called from moveinlineofsight
189    virtual bool HandleCaptureCreaturePlayerMoveInLos(Player * p, Creature * c);
190
191    // setup stuff
192    virtual bool SetupOutdoorPvP() {return true;}
193
194    // world state stuff
195    virtual void SendRemoveWorldStates(Player * plr) {}
196    virtual void FillInitialWorldStates(WorldPacket & data) {}
197
198    // send world state update to all players present
199    virtual void SendUpdateWorldState(uint32 field, uint32 value);
200
201    // called by OutdoorPvPMgr, updates the objectives and if needed, sends new worldstateui information
202    virtual bool Update(uint32 diff);
203
204    // handle npc/player kill
205    virtual void HandleKill(Player * killer, Unit * killed);
206    virtual void HandleKillImpl(Player * killer, Unit * killed) {}
207
208    // checks if player is in range of a capture credit marker
209    virtual bool IsInsideObjective(Player * plr);
210
211    // awards rewards for player kill
212    virtual void AwardKillBonus(Player * plr) {}
213
214    uint32 GetTypeId() {return m_TypeId;}
215
216    virtual bool HandleDropFlag(Player * plr, uint32 spellId);
217
218    virtual bool HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid);
219
220    virtual bool CanTalkTo(Player * plr, Creature * c, GossipOption &gso);
221protected:
222    // the map of the objectives belonging to this outdoorpvp
223    OutdoorPvPObjectiveSet m_OutdoorPvPObjectives;
224    // players in the zones of this outdoorpvp, 0 - alliance, 1 - horde
225    std::set<uint64> m_PlayerGuids[2];
226    uint32 m_TypeId;
227};
228
229#endif /*OUTDOOR_PVP_H_*/
Note: See TracBrowser for help on using the browser.