AzeorthCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
OPvPCapturePoint Class Referenceabstract

#include "OutdoorPvP.h"

Inheritance diagram for OPvPCapturePoint:
OPvPCapturePointEP_CGT OPvPCapturePointEP_EWT OPvPCapturePointEP_NPT OPvPCapturePointEP_PWT OPvPCapturePointGH OPvPCapturePointHP OPvPCapturePointNA OPvPCapturePointTF OPvPCapturePointZM_Beacon OPvPCapturePointZM_GraveYard

Public Member Functions

 OPvPCapturePoint (OutdoorPvP *pvp)
 
virtual ~OPvPCapturePoint ()
 
virtual void FillInitialWorldStates (WorldPacket &)
 
void SendUpdateWorldState (uint32 field, uint32 value)
 
void SendObjectiveComplete (uint32 id, ObjectGuid guid=ObjectGuid::Empty)
 
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 *player, Creature *creature, uint32 gossipid)
 
virtual bool CanTalkTo (Player *player, Creature *c, GossipMenuItems const &gso)
 
virtual bool HandleDropFlag (Player *player, uint32 spellId)
 
virtual void DeleteSpawns ()
 
void AddGO (uint32 type, ObjectGuid::LowType guid, uint32 entry=0)
 
void AddCre (uint32 type, ObjectGuid::LowType guid, uint32 entry=0)
 
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)
 
bool AddCreature (uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay=0)
 
bool DelCreature (uint32 type)
 
bool DelObject (uint32 type)
 
bool DelCapturePoint ()
 

Protected Attributes

PlayerSet 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::LowTypem_Objects
 
std::map< uint32, ObjectGuid::LowTypem_Creatures
 
std::map< ObjectGuid::LowType, uint32m_ObjectTypes
 
std::map< ObjectGuid::LowType, uint32m_CreatureTypes
 

Detailed Description

Constructor & Destructor Documentation

◆ OPvPCapturePoint()

OPvPCapturePoint::OPvPCapturePoint ( OutdoorPvP pvp)
30 :
34{ }
@ OBJECTIVESTATE_NEUTRAL
Definition: OutdoorPvP.h:42
@ TEAM_NEUTRAL
Definition: SharedDefines.h:734
float m_value
Definition: OutdoorPvP.h:163
ObjectiveStates m_OldState
Definition: OutdoorPvP.h:168
OutdoorPvP * m_PvP
Definition: OutdoorPvP.h:175
TeamId m_team
Definition: OutdoorPvP.h:165
ObjectiveStates m_State
Definition: OutdoorPvP.h:169
uint32 m_neutralValuePct
Definition: OutdoorPvP.h:172
float m_minValue
Definition: OutdoorPvP.h:157
GameObject * m_capturePoint
Definition: OutdoorPvP.h:133
ObjectGuid::LowType m_capturePointSpawnId
Definition: OutdoorPvP.h:131
float m_maxValue
Definition: OutdoorPvP.h:156
float m_maxSpeed
Definition: OutdoorPvP.h:160

◆ ~OPvPCapturePoint()

virtual OPvPCapturePoint::~OPvPCapturePoint ( )
inlinevirtual
93{}

Member Function Documentation

◆ AddCre()

void OPvPCapturePoint::AddCre ( uint32  type,
ObjectGuid::LowType  guid,
uint32  entry = 0 
)
81{
82 if (!entry)
83 {
84 const CreatureData* data = sObjectMgr->GetCreatureData(guid);
85 if (!data)
86 return;
87 entry = data->id1;
88 }
89 m_Creatures[type] = guid;
90 m_CreatureTypes[m_Creatures[type]] = type;
91}
#define sObjectMgr
Definition: ObjectMgr.h:1606
Definition: CreatureData.h:359
uint32 id1
Definition: CreatureData.h:361
std::map< uint32, ObjectGuid::LowType > m_Creatures
Definition: OutdoorPvP.h:180
std::map< ObjectGuid::LowType, uint32 > m_CreatureTypes
Definition: OutdoorPvP.h:182

References CreatureData::id1, m_Creatures, m_CreatureTypes, and sObjectMgr.

Referenced by AddCreature().

◆ AddCreature()

bool OPvPCapturePoint::AddCreature ( uint32  type,
uint32  entry,
uint32  map,
float  x,
float  y,
float  z,
float  o,
uint32  spawntimedelay = 0 
)
protected
105{
106 if (ObjectGuid::LowType guid = sObjectMgr->AddCreData(entry, map, x, y, z, o, spawntimedelay))
107 {
108 AddCre(type, guid, entry);
109 return true;
110 }
111
112 return false;
113}
uint32 LowType
Definition: ObjectGuid.h:124
void AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry=0)
Definition: OutdoorPvP.cpp:80

References AddCre(), and sObjectMgr.

Referenced by OPvPCapturePointZM_GraveYard::OPvPCapturePointZM_GraveYard(), OPvPCapturePointNA::SpawnNPCsForTeam(), OPvPCapturePointEP_PWT::SummonFlightMaster(), and OPvPCapturePointEP_EWT::SummonSupportUnitAtNorthpassTower().

◆ AddGO()

void OPvPCapturePoint::AddGO ( uint32  type,
ObjectGuid::LowType  guid,
uint32  entry = 0 
)
68{
69 if (!entry)
70 {
71 const GameObjectData* data = sObjectMgr->GetGOData(guid);
72 if (!data)
73 return;
74 entry = data->id;
75 }
76 m_Objects[type] = guid;
77 m_ObjectTypes[m_Objects[type]] = type;
78}
Definition: GameObject.h:772
uint32 id
Definition: GameObject.h:774
std::map< ObjectGuid::LowType, uint32 > m_ObjectTypes
Definition: OutdoorPvP.h:181
std::map< uint32, ObjectGuid::LowType > m_Objects
Definition: OutdoorPvP.h:179

References GameObjectData::id, m_Objects, m_ObjectTypes, and sObjectMgr.

Referenced by AddObject().

◆ AddObject()

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

◆ CanTalkTo()

bool OPvPCapturePoint::CanTalkTo ( Player player,
Creature c,
GossipMenuItems const &  gso 
)
virtual

Reimplemented in OPvPCapturePointZM_GraveYard.

558{
559 return false;
560}

◆ ChangeState()

◆ ChangeTeam()

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

Referenced by Update().

◆ DelCapturePoint()

bool OPvPCapturePoint::DelCapturePoint ( )
protected
201{
202 sObjectMgr->DeleteGOData(m_capturePointSpawnId);
204
205 if (m_capturePoint)
206 {
207 m_capturePoint->SetRespawnTime(0); // not save respawn time
209 }
210
211 return true;
212}
void Delete()
Definition: GameObject.cpp:976
void SetRespawnTime(int32 respawn)
Definition: GameObject.cpp:1301

References GameObject::Delete(), m_capturePoint, m_capturePointSpawnId, GameObject::SetRespawnTime(), and sObjectMgr.

Referenced by DeleteSpawns().

◆ DelCreature()

bool OPvPCapturePoint::DelCreature ( uint32  type)
protected
140{
141 ObjectGuid::LowType spawnId = m_Creatures[type];
142 if (!spawnId)
143 {
144 LOG_DEBUG("outdoorpvp", "opvp creature type {} was already deleted", type);
145 return false;
146 }
147
148 auto bounds = m_PvP->GetMap()->GetCreatureBySpawnIdStore().equal_range(spawnId);
149 for (auto itr = bounds.first; itr != bounds.second;)
150 {
151 // can happen when closing the core
152 Creature* c = itr->second;
153 ++itr;
154 // Don't save respawn time
155 c->SetRespawnTime(0);
156 c->RemoveCorpse();
158 }
159 LOG_DEBUG("outdoorpvp", "deleting opvp creature type {}", type);
160 // explicit removal from map
161 // beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
162 // so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
163 //if (Map* map = sMapMgr->FindMap(cr->GetMapId()))
164 // map->Remove(cr, false);
165 // delete respawn time for this creature
167 stmt->SetData(0, spawnId);
168 stmt->SetData(1, m_PvP->GetMap()->GetId());
169 stmt->SetData(2, 0); // instance id, always 0 for world maps
170 CharacterDatabase.Execute(stmt);
171
172 sObjectMgr->DeleteCreatureData(spawnId);
173 m_CreatureTypes[m_Creatures[type]] = 0;
174 m_Creatures[type] = 0;
175 return true;
176}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ CHAR_DEL_CREATURE_RESPAWN
Definition: CharacterDatabase.h:252
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
Definition: Creature.h:46
void SetRespawnTime(uint32 respawn)
Definition: Creature.cpp:3625
void RemoveCorpse(bool setSpawnTime=true, bool skipVisibility=false)
Definition: Creature.cpp:347
void AddObjectToRemoveList()
Definition: Object.cpp:2104
uint32 GetId() const
Definition: Map.h:378
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:518
Map * GetMap() const
Definition: OutdoorPvP.h:249

References WorldObject::AddObjectToRemoveList(), CHAR_DEL_CREATURE_RESPAWN, CharacterDatabase, Map::GetCreatureBySpawnIdStore(), Map::GetId(), OutdoorPvP::GetMap(), LOG_DEBUG, m_Creatures, m_CreatureTypes, m_PvP, Creature::RemoveCorpse(), PreparedStatementBase::SetData(), Creature::SetRespawnTime(), and sObjectMgr.

Referenced by OPvPCapturePointEP_PWT::ChangeState(), DeleteSpawns(), OPvPCapturePointNA::DeSpawnNPCs(), OPvPCapturePointEP_PWT::SummonFlightMaster(), and OPvPCapturePointEP_EWT::SummonSupportUnitAtNorthpassTower().

◆ DeleteSpawns()

void OPvPCapturePoint::DeleteSpawns ( )
virtual
215{
216 for (std::map<uint32, ObjectGuid::LowType>::iterator i = m_Objects.begin(); i != m_Objects.end(); ++i)
217 DelObject(i->first);
218 for (std::map<uint32, ObjectGuid::LowType>::iterator i = m_Creatures.begin(); i != m_Creatures.end(); ++i)
219 DelCreature(i->first);
221}
bool DelCapturePoint()
Definition: OutdoorPvP.cpp:200
bool DelCreature(uint32 type)
Definition: OutdoorPvP.cpp:139
bool DelObject(uint32 type)
Definition: OutdoorPvP.cpp:178

References DelCapturePoint(), DelCreature(), DelObject(), m_Creatures, and m_Objects.

◆ DelObject()

bool OPvPCapturePoint::DelObject ( uint32  type)
protected
179{
180 ObjectGuid::LowType spawnId = m_Objects[type];
181 if (!spawnId)
182 return false;
183
184 auto bounds = m_PvP->GetMap()->GetGameObjectBySpawnIdStore().equal_range(spawnId);
185 for (auto itr = bounds.first; itr != bounds.second;)
186 {
187 GameObject* go = itr->second;
188 ++itr;
189 // Don't save respawn time
190 go->SetRespawnTime(0);
191 go->Delete();
192 }
193
194 sObjectMgr->DeleteGOData(spawnId);
195 m_ObjectTypes[m_Objects[type]] = 0;
196 m_Objects[type] = 0;
197 return true;
198}
Definition: GameObject.h:813
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:521

References GameObject::Delete(), Map::GetGameObjectBySpawnIdStore(), OutdoorPvP::GetMap(), m_Objects, m_ObjectTypes, m_PvP, GameObject::SetRespawnTime(), and sObjectMgr.

Referenced by OPvPCapturePointEP_NPT::ChangeState(), DeleteSpawns(), OPvPCapturePointNA::DeSpawnGOs(), OPvPCapturePointNA::HandleOpenGo(), OPvPCapturePointZM_GraveYard::HandleOpenGo(), and OPvPCapturePointEP_NPT::SummonGO().

◆ FillInitialWorldStates()

◆ HandleCustomSpell()

bool OPvPCapturePoint::HandleCustomSpell ( Player player,
uint32  spellId,
GameObject go 
)
virtual

Reimplemented in OPvPCapturePointNA.

510{
511 if (!player->IsOutdoorPvPActive())
512 return false;
513 return false;
514}
bool IsOutdoorPvPActive()
Definition: Player.cpp:6288

References Player::IsOutdoorPvPActive().

◆ HandleDropFlag()

bool OPvPCapturePoint::HandleDropFlag ( Player player,
uint32  spellId 
)
virtual

Reimplemented in OPvPCapturePointZM_GraveYard.

563{
564 return false;
565}

◆ HandleGossipOption()

bool OPvPCapturePoint::HandleGossipOption ( Player player,
Creature creature,
uint32  gossipid 
)
virtual

Reimplemented in OPvPCapturePointZM_GraveYard.

553{
554 return false;
555}

◆ HandleOpenGo()

int32 OPvPCapturePoint::HandleOpenGo ( Player player,
GameObject go 
)
virtual

Reimplemented in OPvPCapturePointNA, and OPvPCapturePointZM_GraveYard.

568{
569 std::map<ObjectGuid::LowType, uint32>::iterator itr = m_ObjectTypes.find(go->GetSpawnId());
570 if (itr != m_ObjectTypes.end())
571 {
572 return itr->second;
573 }
574 return -1;
575}
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:837

References GameObject::GetSpawnId(), and m_ObjectTypes.

Referenced by OPvPCapturePointNA::HandleOpenGo(), and OPvPCapturePointZM_GraveYard::HandleOpenGo().

◆ HandlePlayerEnter()

bool OPvPCapturePoint::HandlePlayerEnter ( Player player)
virtual

Reimplemented in OPvPCapturePointEP_EWT, OPvPCapturePointEP_NPT, OPvPCapturePointEP_CGT, OPvPCapturePointEP_PWT, OPvPCapturePointGH, OPvPCapturePointHP, OPvPCapturePointNA, OPvPCapturePointTF, and OPvPCapturePointZM_Beacon.

37{
39 {
43 }
44 return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
45}
std::uint32_t uint32
Definition: Define.h:108
uint32 worldstate3
Definition: GameObject.h:325
uint32 worldstate2
Definition: GameObject.h:315
struct GameObjectTemplate::@210::@234 capturePoint
uint32 worldState1
Definition: GameObject.h:233
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:829
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition: PlayerUpdates.cpp:2194
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2058
PlayerSet m_activePlayers[2]
Definition: OutdoorPvP.h:153

References GameObjectTemplate::capturePoint, GameObject::GetGOInfo(), Object::GetGUID(), Player::GetTeamId(), m_activePlayers, m_capturePoint, m_maxValue, m_neutralValuePct, m_value, Player::SendUpdateWorldState(), GameObjectTemplate::worldState1, GameObjectTemplate::worldstate2, and GameObjectTemplate::worldstate3.

Referenced by OPvPCapturePointEP_EWT::HandlePlayerEnter(), OPvPCapturePointEP_NPT::HandlePlayerEnter(), OPvPCapturePointEP_CGT::HandlePlayerEnter(), OPvPCapturePointEP_PWT::HandlePlayerEnter(), OPvPCapturePointGH::HandlePlayerEnter(), OPvPCapturePointHP::HandlePlayerEnter(), OPvPCapturePointNA::HandlePlayerEnter(), OPvPCapturePointTF::HandlePlayerEnter(), OPvPCapturePointZM_Beacon::HandlePlayerEnter(), and Update().

◆ HandlePlayerLeave()

◆ IsInsideObjective()

bool OPvPCapturePoint::IsInsideObjective ( Player player) const
495{
496 PlayerSet const& plSet = m_activePlayers[player->GetTeamId()];
497 return plSet.find(player->GetGUID()) != plSet.end();
498}
GuidSet PlayerSet
Definition: OutdoorPvP.h:86

References Object::GetGUID(), Player::GetTeamId(), and m_activePlayers.

◆ SendChangePhase()

void OPvPCapturePoint::SendChangePhase ( )
virtual

◆ SendObjectiveComplete()

void OPvPCapturePoint::SendObjectiveComplete ( uint32  id,
ObjectGuid  guid = ObjectGuid::Empty 
)
432{
433 uint32 team;
434 switch (m_State)
435 {
437 team = 0;
438 break;
440 team = 1;
441 break;
442 default:
443 return;
444 }
445
446 // send to all players present in the area
447 for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
448 if (Player* const player = ObjectAccessor::FindPlayer(*itr))
449 player->KilledMonsterCredit(id, guid);
450}
@ OBJECTIVESTATE_HORDE
Definition: OutdoorPvP.h:44
@ OBJECTIVESTATE_ALLIANCE
Definition: OutdoorPvP.h:43
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:250
Definition: Player.h:1046

References ObjectAccessor::FindPlayer(), m_activePlayers, m_State, OBJECTIVESTATE_ALLIANCE, and OBJECTIVESTATE_HORDE.

Referenced by OPvPCapturePointEP_EWT::ChangeState(), OPvPCapturePointEP_NPT::ChangeState(), OPvPCapturePointEP_CGT::ChangeState(), OPvPCapturePointEP_PWT::ChangeState(), and OPvPCapturePointHP::ChangeState().

◆ SendUpdateWorldState()

void OPvPCapturePoint::SendUpdateWorldState ( uint32  field,
uint32  value 
)
421{
422 for (uint32 team = 0; team < 2; ++team)
423 {
424 // send to all players present in the area
425 for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ++itr)
426 if (Player* const player = ObjectAccessor::FindPlayer(*itr))
427 player->SendUpdateWorldState(field, value);
428 }
429}

References ObjectAccessor::FindPlayer(), and m_activePlayers.

Referenced by SendChangePhase(), OPvPCapturePointEP_EWT::SendChangePhase(), OPvPCapturePointEP_NPT::SendChangePhase(), OPvPCapturePointEP_CGT::SendChangePhase(), OPvPCapturePointEP_PWT::SendChangePhase(), OPvPCapturePointGH::SendChangePhase(), OPvPCapturePointHP::SendChangePhase(), OPvPCapturePointNA::SendChangePhase(), OPvPCapturePointTF::SendChangePhase(), and OPvPCapturePointZM_Beacon::SendChangePhase().

◆ SetCapturePointData()

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 
)
116{
117 LOG_DEBUG("outdoorpvp", "Creating capture point {}", entry);
118
119 // check info existence
120 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
121 if (!goinfo || goinfo->type != GAMEOBJECT_TYPE_CAPTURE_POINT)
122 {
123 LOG_ERROR("outdoorpvp", "OutdoorPvP: GO {} is not capture point!", entry);
124 return false;
125 }
126
127 m_capturePointSpawnId = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
129 return false;
130
131 // get the needed values from goinfo
132 m_maxValue = (float)goinfo->capturePoint.maxTime;
133 m_maxSpeed = m_maxValue / (goinfo->capturePoint.minTime ? goinfo->capturePoint.minTime : 60);
136 return true;
137}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
T CalculatePct(T base, U pct)
Definition: Util.h:61
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition: SharedDefines.h:1561
Definition: GameObject.h:41
uint32 type
Definition: GameObject.h:43
uint32 minTime
Definition: GameObject.h:328
uint32 neutralPercent
Definition: GameObject.h:324
uint32 maxTime
Definition: GameObject.h:329

References CalculatePct(), GameObjectTemplate::capturePoint, GAMEOBJECT_TYPE_CAPTURE_POINT, LOG_DEBUG, LOG_ERROR, m_capturePointSpawnId, m_maxSpeed, m_maxValue, m_minValue, m_neutralValuePct, GameObjectTemplate::maxTime, GameObjectTemplate::minTime, GameObjectTemplate::neutralPercent, sObjectMgr, and GameObjectTemplate::type.

Referenced by OPvPCapturePointEP_CGT::OPvPCapturePointEP_CGT(), OPvPCapturePointEP_EWT::OPvPCapturePointEP_EWT(), OPvPCapturePointEP_NPT::OPvPCapturePointEP_NPT(), OPvPCapturePointEP_PWT::OPvPCapturePointEP_PWT(), OPvPCapturePointGH::OPvPCapturePointGH(), OPvPCapturePointHP::OPvPCapturePointHP(), OPvPCapturePointNA::OPvPCapturePointNA(), OPvPCapturePointTF::OPvPCapturePointTF(), and OPvPCapturePointZM_Beacon::OPvPCapturePointZM_Beacon().

◆ Update()

bool OPvPCapturePoint::Update ( uint32  diff)
virtual

Reimplemented in OPvPCapturePointNA, OPvPCapturePointTF, and OPvPCapturePointZM_GraveYard.

288{
289 if (!m_capturePoint)
290 return false;
291
292 float radius = (float)m_capturePoint->GetGOInfo()->capturePoint.radius;
293
294 for (uint32 team = 0; team < 2; ++team)
295 {
296 for (PlayerSet::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 Cell::VisitWorldObjects(m_capturePoint, searcher, radius);
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 TeamId ChallengerId = TEAM_NEUTRAL;
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 ChallengerId = TEAM_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 ChallengerId = TEAM_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)
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 (ChallengerId == TEAM_ALLIANCE)
379 // if challenger is horde, then n->h challenge
380 else if (ChallengerId == TEAM_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)
396
397 if (m_OldState != m_State)
398 {
399 if (oldTeam != m_team)
400 {
401 ChangeTeam(oldTeam);
402 }
403
404 ChangeState();
405 return true;
406 }
407
408 return false;
409}
@ OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE
Definition: OutdoorPvP.h:46
@ OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE
Definition: OutdoorPvP.h:45
@ OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE
Definition: OutdoorPvP.h:48
@ OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE
Definition: OutdoorPvP.h:47
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL
Definition: OutdoorPvPMgr.h:21
TeamId
Definition: SharedDefines.h:731
@ TEAM_ALLIANCE
Definition: SharedDefines.h:732
@ TEAM_HORDE
Definition: SharedDefines.h:733
uint32 radius
Definition: GameObject.h:206
bool IsWithinDistInMap(Player const *player) const
Definition: GameObject.cpp:3056
Definition: ObjectGuid.h:120
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:193
Definition: GridNotifiers.h:522
Definition: GridNotifiers.h:1353
virtual void ChangeState()=0
virtual void HandlePlayerLeave(Player *player)
Definition: OutdoorPvP.cpp:47
virtual bool HandlePlayerEnter(Player *player)
Definition: OutdoorPvP.cpp:36
virtual void ChangeTeam(TeamId)
Definition: OutdoorPvP.h:119
virtual void SendChangePhase()
Definition: OutdoorPvP.cpp:54

References GameObjectTemplate::capturePoint, ChangeState(), ChangeTeam(), ObjectAccessor::FindPlayer(), GameObject::GetGOInfo(), Object::GetGUID(), Player::GetTeamId(), HandlePlayerEnter(), HandlePlayerLeave(), Player::IsOutdoorPvPActive(), GameObject::IsWithinDistInMap(), m_activePlayers, m_capturePoint, m_maxSpeed, m_maxValue, m_minValue, m_OldState, m_State, m_team, m_value, OBJECTIVESTATE_ALLIANCE, OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE, OBJECTIVESTATE_HORDE, OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE, OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE, OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE, OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL, GameObjectTemplate::radius, SendChangePhase(), TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, and Cell::VisitWorldObjects().

Referenced by OPvPCapturePointNA::Update(), and OPvPCapturePointTF::Update().

Member Data Documentation

◆ m_activePlayers

◆ m_capturePoint

GameObject* OPvPCapturePoint::m_capturePoint

◆ m_capturePointSpawnId

◆ m_Creatures

std::map<uint32, ObjectGuid::LowType> OPvPCapturePoint::m_Creatures
protected

◆ m_CreatureTypes

◆ m_maxSpeed

float OPvPCapturePoint::m_maxSpeed
protected

Referenced by SetCapturePointData(), and Update().

◆ m_maxValue

◆ m_minValue

float OPvPCapturePoint::m_minValue
protected

Referenced by SetCapturePointData(), and Update().

◆ m_neutralValuePct

◆ m_Objects

◆ m_ObjectTypes

std::map<ObjectGuid::LowType, uint32> OPvPCapturePoint::m_ObjectTypes
protected

Referenced by AddGO(), DelObject(), and HandleOpenGo().

◆ m_OldState

◆ m_PvP

◆ m_State

◆ m_team

TeamId OPvPCapturePoint::m_team
protected

◆ m_value