TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
OPvPCapturePoint Class Referenceabstract

#include <OutdoorPvP.h>

Public Member Functions

 OPvPCapturePoint (OutdoorPvP *pvp)
 
virtual ~OPvPCapturePoint ()
 
virtual void FillInitialWorldStates (WorldPackets::WorldState::InitWorldStates &)
 
void SendUpdateWorldState (uint32 field, uint32 value)
 
void SendObjectiveComplete (uint32 id, ObjectGuid guid)
 
virtual bool HandlePlayerEnter (Player *player)
 
virtual void HandlePlayerLeave (Player *player)
 
bool IsInsideObjective (Player *player) const
 
virtual bool HandleCustomSpell (Player *player, uint32 spellId, GameObject *go)
 
virtual int32 HandleOpenGo (Player *player, GameObject *go)
 
virtual bool Update (uint32 diff)
 
virtual void ChangeState ()=0
 
virtual void ChangeTeam (TeamId)
 
virtual void SendChangePhase ()
 
virtual bool HandleGossipOption (Player *, Creature *, uint32)
 
virtual bool CanTalkTo (Player *, Creature *, GossipMenuItems const &)
 
virtual bool HandleDropFlag (Player *, uint32)
 
virtual void DeleteSpawns ()
 
void AddGO (uint32 type, ObjectGuid::LowType guid)
 
void AddCre (uint32 type, ObjectGuid::LowType guid)
 
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)
 

Public Attributes

ObjectGuid::LowType m_capturePointSpawnId
 
GameObjectm_capturePoint
 

Protected Member Functions

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 map, float x, float y, float z, float o, TeamId teamId=TEAM_NEUTRAL, uint32 spawntimedelay=0)
 
bool DelCreature (uint32 type)
 
bool DelObject (uint32 type)
 
bool DelCapturePoint ()
 

Protected Attributes

GuidSet m_activePlayers [2]
 
float m_maxValue
 
float m_minValue
 
float m_maxSpeed
 
float m_value
 
TeamId m_team
 
ObjectiveStates m_OldState
 
ObjectiveStates m_State
 
uint32 m_neutralValuePct
 
OutdoorPvPm_PvP
 
std::map< uint32,
ObjectGuid::LowType
m_Objects
 
std::map< uint32,
ObjectGuid::LowType
m_Creatures
 
std::map< ObjectGuid::LowType,
uint32
m_ObjectTypes
 
std::map< ObjectGuid::LowType,
uint32
m_CreatureTypes
 

Constructor & Destructor Documentation

OPvPCapturePoint::OPvPCapturePoint ( OutdoorPvP pvp)
52  :
56 { }
TeamId m_team
Definition: OutdoorPvP.h:167
OutdoorPvP * m_PvP
Definition: OutdoorPvP.h:177
float m_value
Definition: OutdoorPvP.h:165
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:994
ObjectGuid::LowType m_capturePointSpawnId
Definition: OutdoorPvP.h:131
GameObject * m_capturePoint
Definition: OutdoorPvP.h:133
float m_maxValue
Definition: OutdoorPvP.h:158
uint32 m_neutralValuePct
Definition: OutdoorPvP.h:174
float m_minValue
Definition: OutdoorPvP.h:159
ObjectiveStates m_OldState
Definition: OutdoorPvP.h:170
ObjectiveStates m_State
Definition: OutdoorPvP.h:171
float m_maxSpeed
Definition: OutdoorPvP.h:162
Definition: OutdoorPvP.h:41
virtual OPvPCapturePoint::~OPvPCapturePoint ( )
inlinevirtual
93 { }

Member Function Documentation

void OPvPCapturePoint::AddCre ( uint32  type,
ObjectGuid::LowType  guid 
)
100 {
101  CreatureData const* data = sObjectMgr->GetCreatureData(guid);
102  if (!data)
103  return;
104 
105  m_Creatures[type] = guid;
106  m_CreatureTypes[m_Creatures[type]] = type;
107 }
Definition: Creature.h:287
std::map< uint32, ObjectGuid::LowType > m_Creatures
Definition: OutdoorPvP.h:182
#define sObjectMgr
Definition: ObjectMgr.h:1567
std::map< ObjectGuid::LowType, uint32 > m_CreatureTypes
Definition: OutdoorPvP.h:184

+ Here is the caller graph for this function:

bool OPvPCapturePoint::AddCreature ( uint32  type,
uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
TeamId  teamId = TEAM_NEUTRAL,
uint32  spawntimedelay = 0 
)
protectedvirtual
121 {
122  if (ObjectGuid::LowType guid = sObjectMgr->AddCreatureData(entry, map, x, y, z, o, spawntimedelay))
123  {
124  AddCre(type, guid);
125  return true;
126  }
127 
128  return false;
129 }
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
void AddCre(uint32 type, ObjectGuid::LowType guid)
Definition: OutdoorPvP.cpp:99
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OPvPCapturePoint::AddGO ( uint32  type,
ObjectGuid::LowType  guid 
)
90 {
91  GameObjectData const* data = sObjectMgr->GetGOData(guid);
92  if (!data)
93  return;
94 
95  m_Objects[type] = guid;
96  m_ObjectTypes[m_Objects[type]] = type;
97 }
#define sObjectMgr
Definition: ObjectMgr.h:1567
std::map< uint32, ObjectGuid::LowType > m_Objects
Definition: OutdoorPvP.h:181
Definition: GameObject.h:833
std::map< ObjectGuid::LowType, uint32 > m_ObjectTypes
Definition: OutdoorPvP.h:183

+ Here is the caller graph for this function:

bool OPvPCapturePoint::AddObject ( uint32  type,
uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
float  rotation0,
float  rotation1,
float  rotation2,
float  rotation3 
)
protected
110 {
111  if (ObjectGuid::LowType guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3))
112  {
113  AddGO(type, guid);
114  return true;
115  }
116 
117  return false;
118 }
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
void AddGO(uint32 type, ObjectGuid::LowType guid)
Definition: OutdoorPvP.cpp:89
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual bool OPvPCapturePoint::CanTalkTo ( Player ,
Creature ,
GossipMenuItems const  
)
inlinevirtual

Reimplemented in OPvPCapturePointZM_GraveYard.

125 { return false; }
virtual void OPvPCapturePoint::ChangeState ( )
pure virtual

Implemented in OPvPCapturePointNA, OPvPCapturePointZM_GraveYard, OPvPCapturePointZM_Beacon, OPvPCapturePointTF, and OPvPCapturePointHP.

+ Here is the caller graph for this function:

virtual void OPvPCapturePoint::ChangeTeam ( TeamId  )
inlinevirtual
119 { }

+ Here is the caller graph for this function:

bool OPvPCapturePoint::DelCapturePoint ( )
protected
218 {
219  sObjectMgr->DeleteGOData(m_capturePointSpawnId);
221 
222  if (m_capturePoint)
223  {
224  m_capturePoint->SetRespawnTime(0); // not save respawn time
226  }
227 
228  return true;
229 }
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
#define sObjectMgr
Definition: ObjectMgr.h:1567
ObjectGuid::LowType m_capturePointSpawnId
Definition: OutdoorPvP.h:131
GameObject * m_capturePoint
Definition: OutdoorPvP.h:133
void Delete()
Definition: GameObject.cpp:726

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool OPvPCapturePoint::DelCreature ( uint32  type)
protected
157 {
158  ObjectGuid::LowType spawnId = m_Creatures[type];
159  if (!spawnId)
160  {
161  TC_LOG_DEBUG("outdoorpvp", "opvp creature type %u was already deleted", type);
162  return false;
163  }
164 
165  auto bounds = m_PvP->GetMap()->GetCreatureBySpawnIdStore().equal_range(spawnId);
166  for (auto itr = bounds.first; itr != bounds.second;)
167  {
168  Creature* c = itr->second;
169  ++itr;
170  // Don't save respawn time
171  c->SetRespawnTime(0);
172  c->RemoveCorpse();
174  }
175 
176  TC_LOG_DEBUG("outdoorpvp", "deleting opvp creature type %u", type);
177  // explicit removal from map
178  // beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
179  // so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
180  //if (Map* map = sMapMgr->FindMap(cr->GetMapId()))
181  // map->Remove(cr, false);
182  // delete respawn time for this creature
184  stmt->setUInt64(0, spawnId);
185  stmt->setUInt16(1, m_PvP->GetMap()->GetId());
186  stmt->setUInt32(2, 0); // instance id, always 0 for world maps
188 
189  sObjectMgr->DeleteCreatureData(spawnId);
190  m_CreatureTypes[m_Creatures[type]] = 0;
191  m_Creatures[type] = 0;
192  return true;
193 }
void SetRespawnTime(uint32 respawn)
Definition: Creature.h:633
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
OutdoorPvP * m_PvP
Definition: OutdoorPvP.h:177
std::map< uint32, ObjectGuid::LowType > m_Creatures
Definition: OutdoorPvP.h:182
Map * GetMap() const
Definition: OutdoorPvP.h:264
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: CharacterDatabase.h:291
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
std::map< ObjectGuid::LowType, uint32 > m_CreatureTypes
Definition: OutdoorPvP.h:184
uint32 GetId(void) const
Definition: Map.h:325
void AddObjectToRemoveList()
Definition: Object.cpp:2205
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:469
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
void RemoveCorpse(bool setSpawnTime=true)
Definition: Creature.cpp:280
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OPvPCapturePoint::DeleteSpawns ( )
virtual
232 {
233  for (std::map<uint32, ObjectGuid::LowType>::iterator i = m_Objects.begin(); i != m_Objects.end(); ++i)
234  DelObject(i->first);
235  for (std::map<uint32, ObjectGuid::LowType>::iterator i = m_Creatures.begin(); i != m_Creatures.end(); ++i)
236  DelCreature(i->first);
237  DelCapturePoint();
238 }
std::map< uint32, ObjectGuid::LowType > m_Creatures
Definition: OutdoorPvP.h:182
bool DelObject(uint32 type)
Definition: OutdoorPvP.cpp:195
std::map< uint32, ObjectGuid::LowType > m_Objects
Definition: OutdoorPvP.h:181
bool DelCreature(uint32 type)
Definition: OutdoorPvP.cpp:156
bool DelCapturePoint()
Definition: OutdoorPvP.cpp:217

+ Here is the call graph for this function:

bool OPvPCapturePoint::DelObject ( uint32  type)
protected
196 {
197  if (!m_Objects[type])
198  return false;
199 
200  ObjectGuid::LowType spawnId = m_Objects[type];
201  auto bounds = m_PvP->GetMap()->GetGameObjectBySpawnIdStore().equal_range(spawnId);
202  for (auto itr = bounds.first; itr != bounds.second;)
203  {
204  GameObject* go = itr->second;
205  ++itr;
206  // Don't save respawn time
207  go->SetRespawnTime(0);
208  go->Delete();
209  }
210 
211  sObjectMgr->DeleteGOData(spawnId);
212  m_ObjectTypes[m_Objects[type]] = 0;
213  m_Objects[type] = 0;
214  return true;
215 }
OutdoorPvP * m_PvP
Definition: OutdoorPvP.h:177
Map * GetMap() const
Definition: OutdoorPvP.h:264
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: GameObject.h:880
std::map< uint32, ObjectGuid::LowType > m_Objects
Definition: OutdoorPvP.h:181
std::map< ObjectGuid::LowType, uint32 > m_ObjectTypes
Definition: OutdoorPvP.h:183
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:472
void Delete()
Definition: GameObject.cpp:726

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void OPvPCapturePoint::FillInitialWorldStates ( WorldPackets::WorldState::InitWorldStates )
inlinevirtual
bool OPvPCapturePoint::HandleCustomSpell ( Player player,
uint32  spellId,
GameObject go 
)
virtual

Reimplemented in OPvPCapturePointNA.

504 {
505  if (!player->IsOutdoorPvPActive())
506  return false;
507  return true;
508 }
virtual bool OPvPCapturePoint::HandleDropFlag ( Player ,
uint32   
)
inlinevirtual

Reimplemented in OPvPCapturePointZM_GraveYard.

127 { return false; }
virtual bool OPvPCapturePoint::HandleGossipOption ( Player ,
Creature ,
uint32   
)
inlinevirtual

Reimplemented in OPvPCapturePointZM_GraveYard.

123 { return false; }
int32 OPvPCapturePoint::HandleOpenGo ( Player player,
GameObject go 
)
virtual

Reimplemented in OPvPCapturePointNA, and OPvPCapturePointZM_GraveYard.

547 {
548  std::map<ObjectGuid::LowType, uint32>::iterator itr = m_ObjectTypes.find(go->GetSpawnId());
549  if (itr != m_ObjectTypes.end())
550  return itr->second;
551 
552  return -1;
553 }
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
std::map< ObjectGuid::LowType, uint32 > m_ObjectTypes
Definition: OutdoorPvP.h:183

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool OPvPCapturePoint::HandlePlayerEnter ( Player player)
virtual
59 {
60  if (m_capturePoint)
61  {
62  player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->controlZone.worldState1, 1);
63  player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->controlZone.worldstate2, (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
64  player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->controlZone.worldstate3, m_neutralValuePct);
65  }
66  return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
67 }
GuidSet m_activePlayers[2]
Definition: OutdoorPvP.h:155
float m_value
Definition: OutdoorPvP.h:165
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
GameObject * m_capturePoint
Definition: OutdoorPvP.h:133
float m_maxValue
Definition: OutdoorPvP.h:158
uint32 m_neutralValuePct
Definition: OutdoorPvP.h:174
struct GameObjectTemplate::@221::@252 controlZone
uint32_t uint32
Definition: g3dmath.h:168
static Vector3int16 ceil(const Vector3 &v)
Definition: Vector3int16.cpp:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OPvPCapturePoint::HandlePlayerLeave ( Player player)
virtual
70 {
71  if (m_capturePoint)
72  player->SendUpdateWorldState(m_capturePoint->GetGOInfo()->controlZone.worldState1, 0);
73  m_activePlayers[player->GetTeamId()].erase(player->GetGUID());
74 }
GuidSet m_activePlayers[2]
Definition: OutdoorPvP.h:155
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
GameObject * m_capturePoint
Definition: OutdoorPvP.h:133
struct GameObjectTemplate::@221::@252 controlZone

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool OPvPCapturePoint::IsInsideObjective ( Player player) const
489 {
490  GuidSet const &plSet = m_activePlayers[player->GetTeamId()];
491  return plSet.find(player->GetGUID()) != plSet.end();
492 }
GuidSet m_activePlayers[2]
Definition: OutdoorPvP.h:155
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
void OPvPCapturePoint::SendChangePhase ( )
virtual
77 {
78  if (!m_capturePoint)
79  return;
80 
81  // send this too, sometimes the slider disappears, dunno why :(
83  // send these updates to only the ones in this objective
85  // send this too, sometimes it resets :S
87 }
float m_value
Definition: OutdoorPvP.h:165
void SendUpdateWorldState(uint32 field, uint32 value)
Definition: OutdoorPvP.cpp:418
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
GameObject * m_capturePoint
Definition: OutdoorPvP.h:133
float m_maxValue
Definition: OutdoorPvP.h:158
uint32 m_neutralValuePct
Definition: OutdoorPvP.h:174
struct GameObjectTemplate::@221::@252 controlZone
uint32_t uint32
Definition: g3dmath.h:168
static Vector3int16 ceil(const Vector3 &v)
Definition: Vector3int16.cpp:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OPvPCapturePoint::SendObjectiveComplete ( uint32  id,
ObjectGuid  guid 
)
430 {
431  uint32 team;
432  switch (m_State)
433  {
435  team = 0;
436  break;
438  team = 1;
439  break;
440  default:
441  return;
442  }
443 
444  // send to all players present in the area
445  for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
446  if (Player* const player = ObjectAccessor::FindPlayer(*itr))
447  player->KilledMonsterCredit(id, guid);
448 }
GuidSet m_activePlayers[2]
Definition: OutdoorPvP.h:155
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: OutdoorPvP.h:43
uint32_t uint32
Definition: Define.h:150
Definition: OutdoorPvP.h:42
ObjectiveStates m_State
Definition: OutdoorPvP.h:171

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void OPvPCapturePoint::SendUpdateWorldState ( uint32  field,
uint32  value 
)
419 {
420  for (uint32 team = 0; team < 2; ++team)
421  {
422  // send to all players present in the area
423  for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
424  if (Player* const player = ObjectAccessor::FindPlayer(*itr))
425  player->SendUpdateWorldState(field, value);
426  }
427 }
GuidSet m_activePlayers[2]
Definition: OutdoorPvP.h:155
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
uint32_t uint32
Definition: Define.h:150
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool OPvPCapturePoint::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 
)
132 {
133  TC_LOG_DEBUG("outdoorpvp", "Creating capture point %u", entry);
134 
135  // check info existence
136  GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
137  if (!goinfo || goinfo->type != GAMEOBJECT_TYPE_CONTROL_ZONE)
138  {
139  TC_LOG_ERROR("outdoorpvp", "OutdoorPvP: GO %u is not capture point!", entry);
140  return false;
141  }
142 
143  m_capturePointSpawnId = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
145  return false;
146 
147  // get the needed values from goinfo
148  m_maxValue = (float)goinfo->controlZone.maxTime;
149  m_maxSpeed = m_maxValue / (goinfo->controlZone.minTime ? goinfo->controlZone.minTime : 60);
150  m_neutralValuePct = goinfo->controlZone.neutralPercent;
152 
153  return true;
154 }
Definition: SharedDefines.h:2094
Definition: GameObject.h:34
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
ObjectGuid::LowType m_capturePointSpawnId
Definition: OutdoorPvP.h:131
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
T CalculatePct(T base, U pct)
Definition: Util.h:92
float m_maxValue
Definition: OutdoorPvP.h:158
uint32 m_neutralValuePct
Definition: OutdoorPvP.h:174
float m_minValue
Definition: OutdoorPvP.h:159
struct GameObjectTemplate::@221::@252 controlZone
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
uint32 type
Definition: GameObject.h:37
float m_maxSpeed
Definition: OutdoorPvP.h:162

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool OPvPCapturePoint::Update ( uint32  diff)
virtual

Reimplemented in OPvPCapturePointNA, OPvPCapturePointZM_GraveYard, and OPvPCapturePointTF.

288 {
289  if (!m_capturePoint)
290  return false;
291 
292  float radius = (float)m_capturePoint->GetGOInfo()->controlZone.radius;
293 
294  for (uint32 team = 0; team < 2; ++team)
295  {
296  for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
297  {
298  ObjectGuid playerGuid = *itr;
299  ++itr;
300 
301  if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
302  if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
303  HandlePlayerLeave(player);
304  }
305  }
306 
307  std::list<Player*> players;
310  m_capturePoint->VisitNearbyWorldObject(radius, searcher);
311 
312  for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
313  {
314  Player* const player = *itr;
315  if (player->IsOutdoorPvPActive())
316  {
317  if (m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second)
318  HandlePlayerEnter(*itr);
319  }
320  }
321 
322  // get the difference of numbers
323  float fact_diff = ((float)m_activePlayers[0].size() - (float)m_activePlayers[1].size()) * diff / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
324  if (!fact_diff)
325  return false;
326 
327  uint32 Challenger = 0;
328  float maxDiff = m_maxSpeed * diff;
329 
330  if (fact_diff < 0)
331  {
332  // horde is in majority, but it's already horde-controlled -> no change
334  return false;
335 
336  if (fact_diff < -maxDiff)
337  fact_diff = -maxDiff;
338 
339  Challenger = HORDE;
340  }
341  else
342  {
343  // ally is in majority, but it's already ally-controlled -> no change
345  return false;
346 
347  if (fact_diff > maxDiff)
348  fact_diff = maxDiff;
349 
350  Challenger = ALLIANCE;
351  }
352 
353  float oldValue = m_value;
354  TeamId oldTeam = m_team;
355 
357 
358  m_value += fact_diff;
359 
360  if (m_value < -m_minValue) // red
361  {
362  if (m_value < -m_maxValue)
363  m_value = -m_maxValue;
365  m_team = TEAM_HORDE;
366  }
367  else if (m_value > m_minValue) // blue
368  {
369  if (m_value > m_maxValue)
373  }
374  else if (oldValue * m_value <= 0) // grey, go through mid point
375  {
376  // if challenger is ally, then n->a challenge
377  if (Challenger == ALLIANCE)
379  // if challenger is horde, then n->h challenge
380  else if (Challenger == HORDE)
383  }
384  else // grey, did not go through mid point
385  {
386  // old phase and current are on the same side, so one team challenges the other
392  }
393 
394  if (m_value != oldValue)
395  SendChangePhase();
396 
397  if (m_OldState != m_State)
398  {
399  //TC_LOG_ERROR("outdoorpvp", "%u->%u", m_OldState, m_State);
400  if (oldTeam != m_team)
401  ChangeTeam(oldTeam);
402  ChangeState();
403  return true;
404  }
405 
406  return false;
407 }
TeamId m_team
Definition: OutdoorPvP.h:167
GuidSet m_activePlayers[2]
Definition: OutdoorPvP.h:155
Definition: OutdoorPvP.h:46
virtual void ChangeTeam(TeamId)
Definition: OutdoorPvP.h:119
Definition: GridNotifiers.h:1188
virtual void HandlePlayerLeave(Player *player)
Definition: OutdoorPvP.cpp:69
void VisitNearbyWorldObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:589
float m_value
Definition: OutdoorPvP.h:165
Definition: GridNotifiers.h:510
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
Definition: SharedDefines.h:994
Definition: SharedDefines.h:1000
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
virtual void SendChangePhase()
Definition: OutdoorPvP.cpp:76
Definition: OutdoorPvP.h:43
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL
Definition: OutdoorPvPMgr.h:21
uint32_t uint32
Definition: Define.h:150
virtual bool HandlePlayerEnter(Player *player)
Definition: OutdoorPvP.cpp:58
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Definition: SharedDefines.h:992
Definition: OutdoorPvP.h:45
GameObject * m_capturePoint
Definition: OutdoorPvP.h:133
TeamId
Definition: SharedDefines.h:990
Definition: SharedDefines.h:999
float m_maxValue
Definition: OutdoorPvP.h:158
Definition: OutdoorPvP.h:42
float m_minValue
Definition: OutdoorPvP.h:159
struct GameObjectTemplate::@221::@252 controlZone
virtual void ChangeState()=0
Definition: ObjectGuid.h:189
Definition: OutdoorPvP.h:47
Definition: SharedDefines.h:993
ObjectiveStates m_OldState
Definition: OutdoorPvP.h:170
ObjectiveStates m_State
Definition: OutdoorPvP.h:171
float m_maxSpeed
Definition: OutdoorPvP.h:162

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

GuidSet OPvPCapturePoint::m_activePlayers[2]
protected
GameObject* OPvPCapturePoint::m_capturePoint
ObjectGuid::LowType OPvPCapturePoint::m_capturePointSpawnId
std::map<uint32, ObjectGuid::LowType> OPvPCapturePoint::m_Creatures
protected
std::map<ObjectGuid::LowType, uint32> OPvPCapturePoint::m_CreatureTypes
protected
float OPvPCapturePoint::m_maxSpeed
protected
float OPvPCapturePoint::m_maxValue
protected
float OPvPCapturePoint::m_minValue
protected
uint32 OPvPCapturePoint::m_neutralValuePct
protected
std::map<uint32, ObjectGuid::LowType> OPvPCapturePoint::m_Objects
protected
std::map<ObjectGuid::LowType, uint32> OPvPCapturePoint::m_ObjectTypes
protected
ObjectiveStates OPvPCapturePoint::m_OldState
protected
OutdoorPvP* OPvPCapturePoint::m_PvP
protected
ObjectiveStates OPvPCapturePoint::m_State
protected
TeamId OPvPCapturePoint::m_team
protected
float OPvPCapturePoint::m_value
protected

The documentation for this class was generated from the following files: