Files
TCPlayerbotCore/src/game/OutdoorPvP.h
T

225 lines
6.8 KiB
C++
Raw Normal View History

/*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* 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
*/
2008-10-14 11:57:03 -05:00
#ifndef OUTDOOR_PVP_H_
#define OUTDOOR_PVP_H_
#include "Util.h"
2009-05-29 10:54:04 -05:00
#include "SharedDefines.h"
#include "ZoneScript.h"
2008-10-14 11:57:03 -05:00
class GameObject;
2009-05-24 17:26:44 -05:00
enum OutdoorPvPTypes
{
2008-10-14 11:57:03 -05:00
OUTDOOR_PVP_HP = 1,
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
};
// 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;
};
// struct for creature spawning
struct creature_type{
uint32 entry;
uint32 teamval;
uint32 map;
float x;
float y;
float z;
float o;
};
// some class predefs
class Player;
class GameObject;
class WorldPacket;
class Creature;
class Unit;
struct GossipOption;
typedef std::set<Player*> PlayerSet;
2008-10-14 11:57:03 -05:00
class OutdoorPvP;
class OPvPCapturePoint
2008-10-14 11:57:03 -05:00
{
public:
OPvPCapturePoint(OutdoorPvP * pvp);
2008-10-14 11:57:03 -05:00
virtual void FillInitialWorldStates(WorldPacket & data) {}
// send world state update to all players present
virtual void SendUpdateWorldState(uint32 field, uint32 value);
// send kill notify to players in the controlling faction
virtual void SendObjectiveComplete(uint32 id, uint64 guid);
// used when player is activated/inactivated in the area
virtual bool HandlePlayerEnter(Player * plr);
virtual void HandlePlayerLeave(Player * plr);
//virtual void HandlePlayerActivityChanged(Player * plr);
2008-10-14 11:57:03 -05:00
// checks if player is in range of a capture credit marker
bool IsInsideObjective(Player * plr) const;
2008-10-14 11:57:03 -05:00
virtual bool HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go);
virtual int32 HandleOpenGo(Player *plr, uint64 guid);
// 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);
virtual bool HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid);
virtual bool CanTalkTo(Player * plr, Creature * c, GossipOption &gso);
virtual bool HandleDropFlag(Player * plr, uint32 spellId);
virtual void DeleteSpawns();
uint32 m_CapturePointGUID;
GameObject *m_capturePoint;
2008-10-14 11:57:03 -05:00
protected:
virtual bool AddCapturePoint(uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3);
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);
virtual bool AddCreature(uint32 type, uint32 entry, uint32 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay = 0);
virtual bool DelCreature(uint32 type);
virtual bool DelObject(uint32 type);
virtual bool DelCapturePoint();
protected:
// active players in the area of the objective, 0 - alliance, 1 - horde
PlayerSet m_activePlayers[2];
2008-10-14 11:57:03 -05:00
// total shift needed to capture the objective
float m_ShiftMaxPhase;
// maximum speed of capture
float m_ShiftMaxCaptureSpeed;
// the status of the objective
float m_ShiftPhase;
// phase before update, used to check which faction is in conquer / control
float m_OldPhase;
// objective states
uint32 m_OldState;
uint32 m_State;
// neutral value on capture bar
uint32 m_NeutralValue;
// pointer to the OutdoorPvP this objective belongs to
OutdoorPvP* m_PvP;
// 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;
};
// base class for specific outdoor pvp handlers
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();
typedef std::vector<OPvPCapturePoint*> OPvPCapturePointMap;
2008-10-14 11:57:03 -05: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);
// setup stuff
virtual bool SetupOutdoorPvP() {return true;}
void OnGameObjectCreate(GameObject *go, bool add);
void OnCreatureCreate(Creature *, bool add) {}
2008-10-14 11:57:03 -05:00
// send world state update to all players present
virtual void SendUpdateWorldState(uint32 field, uint32 value);
// called by OutdoorPvPMgr, updates the objectives and if needed, sends new worldstateui information
virtual bool Update(uint32 diff);
// handle npc/player kill
virtual void HandleKill(Player * killer, Unit * killed);
virtual void HandleKillImpl(Player * killer, Unit * killed) {}
// checks if player is in range of a capture credit marker
bool IsInsideObjective(Player * plr) const;
2008-10-14 11:57:03 -05:00
// awards rewards for player kill
virtual void AwardKillBonus(Player * plr) {}
uint32 GetTypeId() {return m_TypeId;}
virtual bool HandleDropFlag(Player * plr, uint32 spellId);
virtual bool HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid);
virtual bool CanTalkTo(Player * plr, Creature * c, GossipOption &gso);
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
OPvPCapturePointMap m_capturePoints;
2009-05-24 17:26:44 -05:00
PlayerSet m_players[2];
2008-10-14 11:57:03 -05:00
uint32 m_TypeId;
2009-05-24 17:26:44 -05:00
// world state stuff
virtual void SendRemoveWorldStates(Player * plr) {}
void BroadcastPacket(WorldPacket & data);
2009-05-24 17:26:44 -05:00
virtual void HandlePlayerEnterZone(Player * plr, uint32 zone);
virtual void HandlePlayerLeaveZone(Player * plr, uint32 zone);
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
};
#endif /*OUTDOOR_PVP_H_*/
2009-02-17 20:07:49 -06:00