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

Revision 44, 6.6 kB (checked in by yumileroy, 17 years ago)

[svn] * Merge Temp dev SVN with Assembla.
* Changes include:

  • Implementation of w12x's Outdoor PvP and Game Event Systems.
  • Temporary removal of IRC Chat Bot (until infinite loop when disabled is fixed).
  • All mangos -> trinity (to convert your mangos_string table, please run mangos_string_to_trinity_string.sql).
  • Improved Config cleanup.
  • And many more changes.

Original author: Seline
Date: 2008-10-14 11:57:03-05:00

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