2009-02-04 10:33:18 -06:00
|
|
|
/*
|
2009-02-04 12:04:12 +01:00
|
|
|
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
|
2008-10-23 03:29:52 -05:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
#ifndef OUTDOOR_PVP_H_
|
|
|
|
|
#define OUTDOOR_PVP_H_
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
#include "Util.h"
|
2009-05-29 10:54:04 -05:00
|
|
|
#include "SharedDefines.h"
|
2009-05-30 22:15:05 -05:00
|
|
|
#include "ZoneScript.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-29 00:18:41 -05:00
|
|
|
class GameObject;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-22 10:29:48 -05:00
|
|
|
enum OutdoorPvPTypes
|
|
|
|
|
{
|
2008-10-14 11:57:03 -05:00
|
|
|
OUTDOOR_PVP_HP = 1,
|
2009-05-22 10:29:48 -05:00
|
|
|
OUTDOOR_PVP_NA,
|
|
|
|
|
OUTDOOR_PVP_TF,
|
|
|
|
|
OUTDOOR_PVP_ZM,
|
|
|
|
|
OUTDOOR_PVP_SI,
|
|
|
|
|
OUTDOOR_PVP_EP,
|
|
|
|
|
OPVP_WINTERGRASP,
|
2008-10-14 11:57:03 -05:00
|
|
|
};
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-21 12:31:52 -05:00
|
|
|
const uint8 CapturePointArtKit[3] = {2, 1, 21};
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-20 22:52:49 -05:00
|
|
|
enum ObjectiveStates
|
|
|
|
|
{
|
|
|
|
|
OBJECTIVESTATE_NEUTRAL = 0,
|
|
|
|
|
OBJECTIVESTATE_ALLIANCE,
|
|
|
|
|
OBJECTIVESTATE_HORDE,
|
|
|
|
|
OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE,
|
|
|
|
|
OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE,
|
|
|
|
|
OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE,
|
|
|
|
|
OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE,
|
|
|
|
|
};
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// struct for go spawning
|
|
|
|
|
struct go_type{
|
|
|
|
|
uint32 entry;
|
|
|
|
|
uint32 map;
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float z;
|
|
|
|
|
float o;
|
|
|
|
|
float rot0;
|
|
|
|
|
float rot1;
|
|
|
|
|
float rot2;
|
|
|
|
|
float rot3;
|
|
|
|
|
};
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// struct for creature spawning
|
|
|
|
|
struct creature_type{
|
|
|
|
|
uint32 entry;
|
|
|
|
|
uint32 teamval;
|
|
|
|
|
uint32 map;
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float z;
|
|
|
|
|
float o;
|
|
|
|
|
};
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// some class predefs
|
|
|
|
|
class Player;
|
|
|
|
|
class GameObject;
|
|
|
|
|
class WorldPacket;
|
|
|
|
|
class Creature;
|
|
|
|
|
class Unit;
|
|
|
|
|
struct GossipOption;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-29 00:18:41 -05:00
|
|
|
typedef std::set<Player*> PlayerSet;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
class OutdoorPvP;
|
2009-05-29 00:18:41 -05:00
|
|
|
class OPvPCapturePoint
|
2008-10-14 11:57:03 -05:00
|
|
|
{
|
|
|
|
|
public:
|
2009-05-29 00:18:41 -05:00
|
|
|
OPvPCapturePoint(OutdoorPvP * pvp);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual void FillInitialWorldStates(WorldPacket & data) {}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// send world state update to all players present
|
2009-08-12 08:51:51 -05:00
|
|
|
void SendUpdateWorldState(uint32 field, uint32 value);
|
2008-10-14 11:57:03 -05:00
|
|
|
// send kill notify to players in the controlling faction
|
2009-08-12 08:51:51 -05:00
|
|
|
void SendObjectiveComplete(uint32 id, uint64 guid);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// used when player is activated/inactivated in the area
|
|
|
|
|
virtual bool HandlePlayerEnter(Player * plr);
|
|
|
|
|
virtual void HandlePlayerLeave(Player * plr);
|
2009-05-29 00:18:41 -05:00
|
|
|
//virtual void HandlePlayerActivityChanged(Player * plr);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// checks if player is in range of a capture credit marker
|
2009-05-29 00:18:41 -05:00
|
|
|
bool IsInsideObjective(Player * plr) const;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual bool HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go);
|
|
|
|
|
virtual int32 HandleOpenGo(Player *plr, uint64 guid);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// returns true if the state of the objective has changed, in this case, the OutdoorPvP must send a world state ui update.
|
|
|
|
|
virtual bool Update(uint32 diff);
|
2009-08-10 23:38:51 -05:00
|
|
|
virtual void ChangeState() = 0;
|
2009-08-21 12:31:52 -05:00
|
|
|
virtual void ChangeTeam(TeamId oldTeam) {}
|
2009-08-12 08:51:51 -05:00
|
|
|
virtual void SendChangePhase();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual bool HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual bool CanTalkTo(Player * plr, Creature * c, GossipOption &gso);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual bool HandleDropFlag(Player * plr, uint32 spellId);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual void DeleteSpawns();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-21 12:31:52 -05:00
|
|
|
uint32 m_capturePointGUID;
|
2009-05-29 00:18:41 -05:00
|
|
|
GameObject *m_capturePoint;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-10 23:38:51 -05:00
|
|
|
void AddGO(uint32 type, uint32 guid, uint32 entry = 0);
|
|
|
|
|
void AddCre(uint32 type, uint32 guid, uint32 entry = 0);
|
2009-08-19 18:17:30 -05:00
|
|
|
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);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
protected:
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-10 23:38:51 -05:00
|
|
|
bool AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3);
|
|
|
|
|
bool AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-10 23:38:51 -05:00
|
|
|
bool DelCreature(uint32 type);
|
|
|
|
|
bool DelObject(uint32 type);
|
|
|
|
|
bool DelCapturePoint();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
protected:
|
2008-12-23 10:00:03 +01:00
|
|
|
// active players in the area of the objective, 0 - alliance, 1 - horde
|
2009-05-29 00:18:41 -05:00
|
|
|
PlayerSet m_activePlayers[2];
|
2008-10-14 11:57:03 -05:00
|
|
|
// total shift needed to capture the objective
|
2009-08-12 08:51:51 -05:00
|
|
|
float m_maxValue;
|
|
|
|
|
float m_minValue;
|
2008-10-14 11:57:03 -05:00
|
|
|
// maximum speed of capture
|
2009-08-12 08:51:51 -05:00
|
|
|
float m_maxSpeed;
|
2008-10-14 11:57:03 -05:00
|
|
|
// the status of the objective
|
2009-08-12 08:51:51 -05:00
|
|
|
float m_value;
|
2009-08-21 12:31:52 -05:00
|
|
|
TeamId m_team;
|
2008-10-14 11:57:03 -05:00
|
|
|
// objective states
|
2009-08-20 22:52:49 -05:00
|
|
|
ObjectiveStates m_OldState;
|
|
|
|
|
ObjectiveStates m_State;
|
2008-10-14 11:57:03 -05:00
|
|
|
// neutral value on capture bar
|
2009-08-12 08:51:51 -05:00
|
|
|
uint32 m_neutralValuePct;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// pointer to the OutdoorPvP this objective belongs to
|
|
|
|
|
OutdoorPvP* m_PvP;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// map to store the various gameobjects and creatures spawned by the objective
|
|
|
|
|
// type , guid
|
|
|
|
|
std::map<uint32,uint64> m_Objects;
|
|
|
|
|
std::map<uint32,uint64> m_Creatures;
|
|
|
|
|
std::map<uint64,uint32> m_ObjectTypes;
|
|
|
|
|
std::map<uint64,uint32> m_CreatureTypes;
|
|
|
|
|
};
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// base class for specific outdoor pvp handlers
|
2009-05-30 22:15:05 -05:00
|
|
|
class OutdoorPvP : public ZoneScript
|
2008-10-14 11:57:03 -05:00
|
|
|
{
|
2009-05-24 17:26:44 -05:00
|
|
|
friend class OutdoorPvPMgr;
|
2008-10-14 11:57:03 -05:00
|
|
|
public:
|
|
|
|
|
// ctor
|
|
|
|
|
OutdoorPvP();
|
|
|
|
|
// dtor
|
|
|
|
|
~OutdoorPvP();
|
|
|
|
|
// deletes all gos/creatures spawned by the pvp
|
|
|
|
|
void DeleteSpawns();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-19 18:17:30 -05:00
|
|
|
typedef std::map<uint32/*lowguid*/, OPvPCapturePoint*> OPvPCapturePointMap;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-24 17:26:44 -05:00
|
|
|
virtual void FillInitialWorldStates(WorldPacket & data) {}
|
2008-10-14 11:57:03 -05:00
|
|
|
// called when a player triggers an areatrigger
|
|
|
|
|
virtual bool HandleAreaTrigger(Player * plr, uint32 trigger);
|
|
|
|
|
// called on custom spell
|
|
|
|
|
virtual bool HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go);
|
|
|
|
|
// called on go use
|
|
|
|
|
virtual bool HandleOpenGo(Player *plr, uint64 guid);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// setup stuff
|
|
|
|
|
virtual bool SetupOutdoorPvP() {return true;}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-30 22:15:05 -05:00
|
|
|
void OnGameObjectCreate(GameObject *go, bool add);
|
|
|
|
|
void OnCreatureCreate(Creature *, bool add) {}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// send world state update to all players present
|
2009-08-20 22:52:49 -05:00
|
|
|
void SendUpdateWorldState(uint32 field, uint32 value);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// called by OutdoorPvPMgr, updates the objectives and if needed, sends new worldstateui information
|
|
|
|
|
virtual bool Update(uint32 diff);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// handle npc/player kill
|
|
|
|
|
virtual void HandleKill(Player * killer, Unit * killed);
|
|
|
|
|
virtual void HandleKillImpl(Player * killer, Unit * killed) {}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// checks if player is in range of a capture credit marker
|
2009-05-29 00:18:41 -05:00
|
|
|
bool IsInsideObjective(Player * plr) const;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
// awards rewards for player kill
|
|
|
|
|
virtual void AwardKillBonus(Player * plr) {}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
uint32 GetTypeId() {return m_TypeId;}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual bool HandleDropFlag(Player * plr, uint32 spellId);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual bool HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
virtual bool CanTalkTo(Player * plr, Creature * c, GossipOption &gso);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-24 17:26:44 -05:00
|
|
|
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2 = 0);
|
2008-10-14 11:57:03 -05:00
|
|
|
protected:
|
|
|
|
|
// the map of the objectives belonging to this outdoorpvp
|
2009-05-29 00:18:41 -05:00
|
|
|
OPvPCapturePointMap m_capturePoints;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-24 17:26:44 -05:00
|
|
|
PlayerSet m_players[2];
|
2008-10-14 11:57:03 -05:00
|
|
|
uint32 m_TypeId;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-20 22:52:49 -05:00
|
|
|
bool m_sendUpdate;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-24 17:26:44 -05:00
|
|
|
// world state stuff
|
|
|
|
|
virtual void SendRemoveWorldStates(Player * plr) {}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-20 22:52:49 -05:00
|
|
|
void BroadcastPacket(WorldPacket & data) const;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-24 17:26:44 -05:00
|
|
|
virtual void HandlePlayerEnterZone(Player * plr, uint32 zone);
|
|
|
|
|
virtual void HandlePlayerLeaveZone(Player * plr, uint32 zone);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-19 18:17:30 -05:00
|
|
|
void AddCapturePoint(OPvPCapturePoint* cp)
|
|
|
|
|
{
|
2009-08-21 12:31:52 -05:00
|
|
|
m_capturePoints[cp->m_capturePointGUID] = cp;
|
2009-08-19 18:17:30 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-08-19 23:05:36 -05:00
|
|
|
OPvPCapturePoint * GetCapturePoint(uint32 lowguid) const
|
|
|
|
|
{
|
|
|
|
|
OutdoorPvP::OPvPCapturePointMap::const_iterator itr = m_capturePoints.find(lowguid);
|
|
|
|
|
if(itr != m_capturePoints.end())
|
|
|
|
|
return itr->second;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-05-22 10:29:48 -05:00
|
|
|
void RegisterZone(uint32 zoneid);
|
2009-05-24 17:26:44 -05:00
|
|
|
bool HasPlayer(Player *plr) const;
|
|
|
|
|
void TeamCastSpell(TeamId team, int32 spellId);
|
2008-10-14 11:57:03 -05:00
|
|
|
};
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-14 11:57:03 -05:00
|
|
|
#endif /*OUTDOOR_PVP_H_*/
|
2009-02-17 20:07:49 -06:00
|
|
|
|