AzerothCore 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 ()=default
 
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)
 
void SetSlider (float slider)
 
float GetSlider () const
 

Public Attributes

ObjectGuid::LowType m_capturePointSpawnId {}
 
GameObject_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

std::array< PlayerSet, 2 > _activePlayers
 
float _maxValue {}
 
float _minValue {}
 
float _maxSpeed {}
 
float _value {}
 
TeamId _team { TEAM_NEUTRAL }
 
ObjectiveStates _oldState { OBJECTIVESTATE_NEUTRAL }
 
ObjectiveStates _state { OBJECTIVESTATE_NEUTRAL }
 
uint32 _neutralValuePct {}
 
OutdoorPvP_pvp {}
 
std::unordered_map< uint32, ObjectGuid::LowType_objects
 
std::unordered_map< uint32, ObjectGuid::LowType_creatures
 
std::unordered_map< ObjectGuid::LowType, uint32_objectTypes
 
std::unordered_map< ObjectGuid::LowType, uint32_creatureTypes
 

Detailed Description

Constructor & Destructor Documentation

◆ OPvPCapturePoint()

OPvPCapturePoint::OPvPCapturePoint ( OutdoorPvP pvp)
explicit
29 :
30 _pvp(pvp)
31{
32}
OutdoorPvP * _pvp
Definition: OutdoorPvP.h:173

◆ ~OPvPCapturePoint()

virtual OPvPCapturePoint::~OPvPCapturePoint ( )
virtualdefault

Member Function Documentation

◆ AddCre()

void OPvPCapturePoint::AddCre ( uint32  type,
ObjectGuid::LowType  guid,
uint32  entry = 0 
)
89{
90 if (!entry)
91 {
92 const CreatureData* data = sObjectMgr->GetCreatureData(guid);
93 if (!data)
94 {
95 return;
96 }
97
98 entry = data->id1;
99 }
100
101 _creatures[type] = guid;
102 _creatureTypes[_creatures[type]] = type;
103}
#define sObjectMgr
Definition: ObjectMgr.h:1640
Definition: CreatureData.h:359
uint32 id1
Definition: CreatureData.h:361
std::unordered_map< ObjectGuid::LowType, uint32 > _creatureTypes
Definition: OutdoorPvP.h:181
std::unordered_map< uint32, ObjectGuid::LowType > _creatures
Definition: OutdoorPvP.h:179

References _creatures, _creatureTypes, CreatureData::id1, 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
117{
118 if (ObjectGuid::LowType guid = sObjectMgr->AddCreData(entry, map, x, y, z, o, spawntimeDelay))
119 {
120 AddCre(type, guid, entry);
121 return true;
122 }
123
124 return false;
125}
uint32 LowType
Definition: ObjectGuid.h:124
void AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry=0)
Definition: OutdoorPvP.cpp:88

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 
)
72{
73 if (!entry)
74 {
75 const GameObjectData* data = sObjectMgr->GetGameObjectData(guid);
76 if (!data)
77 {
78 return;
79 }
80
81 entry = data->id;
82 }
83
84 _objects[type] = guid;
85 _objectTypes[_objects[type]] = type;
86}
Definition: GameObjectData.h:697
uint32 id
Definition: GameObjectData.h:699
std::unordered_map< ObjectGuid::LowType, uint32 > _objectTypes
Definition: OutdoorPvP.h:180
std::unordered_map< uint32, ObjectGuid::LowType > _objects
Definition: OutdoorPvP.h:178

References _objects, _objectTypes, GameObjectData::id, 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.

603{
604 return false;
605}

◆ ChangeState()

◆ ChangeTeam()

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

Referenced by Update().

◆ DelCapturePoint()

bool OPvPCapturePoint::DelCapturePoint ( )
protected
216{
217 sObjectMgr->DeleteGOData(m_capturePointSpawnId);
219
220 if (_capturePoint)
221 {
222 _capturePoint->SetRespawnTime(0); // not save respawn time
224 }
225
226 return true;
227}
void Delete()
Definition: GameObject.cpp:976
void SetRespawnTime(int32 respawn)
Definition: GameObject.cpp:1301
GameObject * _capturePoint
Definition: OutdoorPvP.h:126
ObjectGuid::LowType m_capturePointSpawnId
Definition: OutdoorPvP.h:125

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

Referenced by DeleteSpawns().

◆ DelCreature()

bool OPvPCapturePoint::DelCreature ( uint32  type)
protected
152{
153 ObjectGuid::LowType spawnId = _creatures[type];
154 if (!spawnId)
155 {
156 LOG_DEBUG("outdoorpvp", "OutdoorPvP: Creature type {} was already deleted", type);
157 return false;
158 }
159
160 auto bounds = _pvp->GetMap()->GetCreatureBySpawnIdStore().equal_range(spawnId);
161 for (auto itr = bounds.first; itr != bounds.second;)
162 {
163 // can happen when closing the core
164 Creature* c = itr->second;
165 ++itr;
166
167 // Don't save respawn time
168 c->SetRespawnTime(0);
169 c->RemoveCorpse();
171 }
172
173 LOG_DEBUG("outdoorpvp", "OutdoorPvP: Deleting creature type {}", type);
174
175 // explicit removal from map
176 // beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
177 // so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
178 //if (Map* map = sMapMgr->FindMap(cr->GetMapId()))
179 // map->Remove(cr, false);
180 // delete respawn time for this creature
182 stmt->SetData(0, spawnId);
183 stmt->SetData(1, _pvp->GetMap()->GetId());
184 stmt->SetData(2, 0); // instance id, always 0 for world maps
185 CharacterDatabase.Execute(stmt);
186
187 sObjectMgr->DeleteCreatureData(spawnId);
188 _creatureTypes[_creatures[type]] = 0;
189 _creatures[type] = 0;
190 return true;
191}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
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:3675
void RemoveCorpse(bool setSpawnTime=true, bool skipVisibility=false)
Definition: Creature.cpp:346
void AddObjectToRemoveList()
Definition: Object.cpp:2140
uint32 GetId() const
Definition: Map.h:379
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:519
Map * GetMap() const
Definition: OutdoorPvP.h:244

References _creatures, _creatureTypes, _pvp, WorldObject::AddObjectToRemoveList(), CHAR_DEL_CREATURE_RESPAWN, CharacterDatabase, Map::GetCreatureBySpawnIdStore(), Map::GetId(), OutdoorPvP::GetMap(), LOG_DEBUG, 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
230{
231 for (auto const& [type, guid] : _objects)
232 {
233 DelObject(type);
234 }
235
236 for (auto const& [type, guid] : _creatures)
237 {
238 DelCreature(type);
239 }
240
242}
bool DelCapturePoint()
Definition: OutdoorPvP.cpp:215
bool DelCreature(uint32 type)
Definition: OutdoorPvP.cpp:151
bool DelObject(uint32 type)
Definition: OutdoorPvP.cpp:193

References _creatures, _objects, DelCapturePoint(), DelCreature(), and DelObject().

◆ DelObject()

bool OPvPCapturePoint::DelObject ( uint32  type)
protected
194{
195 ObjectGuid::LowType spawnId = _objects[type];
196 if (!spawnId)
197 return false;
198
199 auto bounds = _pvp->GetMap()->GetGameObjectBySpawnIdStore().equal_range(spawnId);
200 for (auto itr = bounds.first; itr != bounds.second;)
201 {
202 GameObject* go = itr->second;
203 ++itr;
204 // Don't save respawn time
205 go->SetRespawnTime(0);
206 go->Delete();
207 }
208
209 sObjectMgr->DeleteGOData(spawnId);
210 _objectTypes[_objects[type]] = 0;
211 _objects[type] = 0;
212 return true;
213}
Definition: GameObject.h:122
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:522

References _objects, _objectTypes, _pvp, GameObject::Delete(), Map::GetGameObjectBySpawnIdStore(), OutdoorPvP::GetMap(), GameObject::SetRespawnTime(), and sObjectMgr.

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

◆ FillInitialWorldStates()

◆ GetSlider()

float OPvPCapturePoint::GetSlider ( ) const
inline
137 {
138 return _value;
139 }
float _value
Definition: OutdoorPvP.h:161

References _value.

◆ HandleCustomSpell()

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

Reimplemented in OPvPCapturePointNA.

557{
558 return player->IsOutdoorPvPActive();
559}
bool IsOutdoorPvPActive()
Definition: Player.cpp:6320

References Player::IsOutdoorPvPActive().

◆ HandleDropFlag()

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

Reimplemented in OPvPCapturePointZM_GraveYard.

608{
609 return false;
610}

◆ HandleGossipOption()

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

Reimplemented in OPvPCapturePointZM_GraveYard.

598{
599 return false;
600}

◆ HandleOpenGo()

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

Reimplemented in OPvPCapturePointNA, and OPvPCapturePointZM_GraveYard.

613{
614 auto const itr = _objectTypes.find(go->GetSpawnId());
615 if (itr != _objectTypes.end())
616 {
617 return (int32)itr->second;
618 }
619
620 return -1;
621}
std::int32_t int32
Definition: Define.h:104
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:146

References _objectTypes, and GameObject::GetSpawnId().

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.

35{
36 if (_capturePoint)
37 {
41 }
42
43 return _activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
44}
std::uint32_t uint32
Definition: Define.h:108
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:138
uint32 worldstate3
Definition: GameObjectData.h:316
uint32 worldstate2
Definition: GameObjectData.h:306
struct GameObjectTemplate::@223::@247 capturePoint
uint32 worldState1
Definition: GameObjectData.h:224
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition: PlayerUpdates.cpp:2197
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2072
uint32 _neutralValuePct
Definition: OutdoorPvP.h:170
float _maxValue
Definition: OutdoorPvP.h:154
std::array< PlayerSet, 2 > _activePlayers
Definition: OutdoorPvP.h:151

References _activePlayers, _capturePoint, _maxValue, _neutralValuePct, _value, GameObjectTemplate::capturePoint, GameObject::GetGOInfo(), Object::GetGUID(), Player::GetTeamId(), 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
542{
543 PlayerSet const& plSet = _activePlayers[player->GetTeamId()];
544 return plSet.find(player->GetGUID()) != plSet.end();
545}
GuidSet PlayerSet
Definition: OutdoorPvP.h:88

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

◆ SendChangePhase()

void OPvPCapturePoint::SendChangePhase ( )
virtual

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

57{
58 if (!_capturePoint)
59 return;
60
61 // send this too, sometimes the slider disappears, dunno why :(
63
64 // send these updates to only the ones in this objective
66
67 // send this too, sometimes it resets :S
69}
void SendUpdateWorldState(uint32 field, uint32 value)
Definition: OutdoorPvP.cpp:466

References _capturePoint, _maxValue, _neutralValuePct, _value, GameObjectTemplate::capturePoint, GameObject::GetGOInfo(), SendUpdateWorldState(), GameObjectTemplate::worldState1, GameObjectTemplate::worldstate2, and GameObjectTemplate::worldstate3.

Referenced by Update().

◆ SendObjectiveComplete()

void OPvPCapturePoint::SendObjectiveComplete ( uint32  id,
ObjectGuid  guid = ObjectGuid::Empty 
)
478{
479 uint32 team;
480 switch (_state)
481 {
483 team = 0;
484 break;
486 team = 1;
487 break;
488 default:
489 return;
490 }
491
492 // send to all players present in the area
493 for (auto itr : _activePlayers[team])
494 if (Player* const player = ObjectAccessor::FindPlayer(itr))
495 player->KilledMonsterCredit(id, guid);
496}
@ OBJECTIVESTATE_HORDE
Definition: OutdoorPvP.h:45
@ OBJECTIVESTATE_ALLIANCE
Definition: OutdoorPvP.h:44
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
Definition: Player.h:1056
ObjectiveStates _state
Definition: OutdoorPvP.h:167

References _activePlayers, _state, ObjectAccessor::FindPlayer(), 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 
)

◆ 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 
)
128{
129 LOG_DEBUG("outdoorpvp", "Creating capture point {}", entry);
130
131 // check info existence
132 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
133 if (!goinfo || goinfo->type != GAMEOBJECT_TYPE_CAPTURE_POINT)
134 {
135 LOG_ERROR("outdoorpvp", "OutdoorPvP: GO {} is not capture point!", entry);
136 return false;
137 }
138
139 m_capturePointSpawnId = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3);
141 return false;
142
143 // get the needed values from goinfo
144 _maxValue = (float)goinfo->capturePoint.maxTime;
145 _maxSpeed = _maxValue / float(goinfo->capturePoint.minTime ? goinfo->capturePoint.minTime : 60);
148 return true;
149}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
T CalculatePct(T base, U pct)
Definition: Util.h:61
@ GAMEOBJECT_TYPE_CAPTURE_POINT
Definition: SharedDefines.h:1589
Definition: GameObjectData.h:32
uint32 type
Definition: GameObjectData.h:34
uint32 minTime
Definition: GameObjectData.h:319
uint32 neutralPercent
Definition: GameObjectData.h:315
uint32 maxTime
Definition: GameObjectData.h:320
float _minValue
Definition: OutdoorPvP.h:155
float _maxSpeed
Definition: OutdoorPvP.h:158

References _maxSpeed, _maxValue, _minValue, _neutralValuePct, CalculatePct(), GameObjectTemplate::capturePoint, GAMEOBJECT_TYPE_CAPTURE_POINT, LOG_DEBUG, LOG_ERROR, m_capturePointSpawnId, 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().

◆ SetSlider()

void OPvPCapturePoint::SetSlider ( float  slider)
624{
625 _value = std::clamp<float>(slider, -_maxValue, _maxValue);
626}

References _maxValue, and _value.

◆ Update()

bool OPvPCapturePoint::Update ( uint32  diff)
virtual

Reimplemented in OPvPCapturePointNA, OPvPCapturePointTF, and OPvPCapturePointZM_GraveYard.

318{
319 if (!_capturePoint)
320 return false;
321
322 auto radius = (float)_capturePoint->GetGOInfo()->capturePoint.radius;
323
324 for (auto const& activePlayer : _activePlayers)
325 {
326 for (auto itr = activePlayer.begin(); itr != activePlayer.end();)
327 {
328 ObjectGuid playerGuid = *itr;
329 ++itr;
330
331 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
332 if (!_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
333 HandlePlayerLeave(player);
334 }
335 }
336
337 std::list<Player*> players;
340 Cell::VisitWorldObjects(_capturePoint, searcher, radius);
341
342 for (auto& itr : players)
343 {
344 Player* const player = itr;
345 if (player->IsOutdoorPvPActive())
346 {
347 if (_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second)
349 }
350 }
351
352 // get the difference of numbers
353 float factDiff = ((float)_activePlayers[0].size() - (float)_activePlayers[1].size()) * float(diff) / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
354 if (factDiff == 0.f)
355 return false;
356
357 TeamId ChallengerId = TEAM_NEUTRAL;
358 float maxDiff = _maxSpeed * float(diff);
359
360 if (factDiff < 0.f)
361 {
362 // horde is in majority, but it's already horde-controlled -> no change
364 return false;
365
366 if (factDiff < -maxDiff)
367 factDiff = -maxDiff;
368
369 ChallengerId = TEAM_HORDE;
370 }
371 else
372 {
373 // ally is in majority, but it's already ally-controlled -> no change
375 return false;
376
377 if (factDiff > maxDiff)
378 factDiff = maxDiff;
379
380 ChallengerId = TEAM_ALLIANCE;
381 }
382
383 float oldValue = _value;
384 TeamId oldTeam = _team;
385
387 _value += factDiff;
388
389 if (_value < -_minValue) // red
390 {
391 if (_value < -_maxValue)
392 {
393 _value = -_maxValue;
394 }
395
398 }
399 else if (_value > _minValue) // blue
400 {
401 if (_value > _maxValue)
402 {
404 }
405
408 }
409 else if (oldValue * _value <= 0) // grey, go through mid-point
410 {
411 // if challenger is ally, then n->a challenge
412 if (ChallengerId == TEAM_ALLIANCE)
413 {
415 }
416 else if (ChallengerId == TEAM_HORDE) // if challenger is horde, then n->h challenge
417 {
419 }
420
422 }
423 else // grey, did not go through mid-point
424 {
425 // old phase and current are on the same side, so one team challenges the other
427 {
429 }
431 {
433 }
434
436 }
437
438 if (_value != oldValue)
439 {
441 }
442
443 if (_oldState != _state)
444 {
445 if (oldTeam != _team)
446 {
447 ChangeTeam(oldTeam);
448 }
449
450 ChangeState();
451 return true;
452 }
453
454 return false;
455}
@ OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE
Definition: OutdoorPvP.h:47
@ OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE
Definition: OutdoorPvP.h:46
@ OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE
Definition: OutdoorPvP.h:49
@ OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE
Definition: OutdoorPvP.h:48
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL
Definition: OutdoorPvPMgr.h:21
TeamId
Definition: SharedDefines.h:759
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
bool IsWithinDistInMap(Player const *player) const
Definition: GameObject.cpp:3058
uint32 radius
Definition: GameObjectData.h:197
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:1350
virtual void ChangeState()=0
ObjectiveStates _oldState
Definition: OutdoorPvP.h:166
virtual void HandlePlayerLeave(Player *player)
Definition: OutdoorPvP.cpp:46
TeamId _team
Definition: OutdoorPvP.h:163
virtual bool HandlePlayerEnter(Player *player)
Definition: OutdoorPvP.cpp:34
virtual void ChangeTeam(TeamId)
Definition: OutdoorPvP.h:118
virtual void SendChangePhase()
Definition: OutdoorPvP.cpp:56

References _activePlayers, _capturePoint, _maxSpeed, _maxValue, _minValue, _oldState, _state, _team, _value, GameObjectTemplate::capturePoint, ChangeState(), ChangeTeam(), ObjectAccessor::FindPlayer(), GameObject::GetGOInfo(), Object::GetGUID(), Player::GetTeamId(), HandlePlayerEnter(), HandlePlayerLeave(), Player::IsOutdoorPvPActive(), GameObject::IsWithinDistInMap(), 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

◆ _activePlayers

◆ _capturePoint

GameObject* OPvPCapturePoint::_capturePoint {}

◆ _creatures

std::unordered_map<uint32, ObjectGuid::LowType> OPvPCapturePoint::_creatures
protected

◆ _creatureTypes

std::unordered_map<ObjectGuid::LowType, uint32> OPvPCapturePoint::_creatureTypes
protected

◆ _maxSpeed

float OPvPCapturePoint::_maxSpeed {}
protected

Referenced by SetCapturePointData(), and Update().

◆ _maxValue

◆ _minValue

float OPvPCapturePoint::_minValue {}
protected

Referenced by SetCapturePointData(), and Update().

◆ _neutralValuePct

◆ _objects

◆ _objectTypes

std::unordered_map<ObjectGuid::LowType, uint32> OPvPCapturePoint::_objectTypes
protected

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

◆ _oldState

◆ _pvp

◆ _state

◆ _team

TeamId OPvPCapturePoint::_team { TEAM_NEUTRAL }
protected

◆ _value

◆ m_capturePointSpawnId