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 (WorldPackets::WorldState::InitWorldStates &)
 
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
30 :
31 _pvp(pvp)
32{
33}
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 
)
90{
91 if (!entry)
92 {
93 const CreatureData* data = sObjectMgr->GetCreatureData(guid);
94 if (!data)
95 {
96 return;
97 }
98
99 entry = data->id1;
100 }
101
102 _creatures[type] = guid;
103 _creatureTypes[_creatures[type]] = type;
104}
#define sObjectMgr
Definition ObjectMgr.h:1686
std::unordered_map< ObjectGuid::LowType, uint32 > _creatureTypes
Definition OutdoorPvP.h:181
std::unordered_map< uint32, ObjectGuid::LowType > _creatures
Definition OutdoorPvP.h:179
Definition CreatureData.h:366
uint32 id1
Definition CreatureData.h:368

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

References AddCre(), and sObjectMgr.

Referenced by OPvPCapturePointZM_Graveyard::OPvPCapturePointZM_Graveyard(), OPvPCapturePointEP_PWT::SummonFlightMaster(), and OPvPCapturePointEP_EWT::SummonSupportUnitAtNorthpassTower().

◆ AddGO()

void OPvPCapturePoint::AddGO ( uint32  type,
ObjectGuid::LowType  guid,
uint32  entry = 0 
)
73{
74 if (!entry)
75 {
76 const GameObjectData* data = sObjectMgr->GetGameObjectData(guid);
77 if (!data)
78 {
79 return;
80 }
81
82 entry = data->id;
83 }
84
85 _objects[type] = guid;
86 _objectTypes[_objects[type]] = type;
87}
std::unordered_map< ObjectGuid::LowType, uint32 > _objectTypes
Definition OutdoorPvP.h:180
std::unordered_map< uint32, ObjectGuid::LowType > _objects
Definition OutdoorPvP.h:178
Definition GameObjectData.h:712
uint32 id
Definition GameObjectData.h:714

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(), and OPvPCapturePointNA::Update().

◆ DelCapturePoint()

bool OPvPCapturePoint::DelCapturePoint ( )
protected
217{
218 sObjectMgr->DeleteGOData(m_capturePointSpawnId);
220
221 if (_capturePoint)
222 {
223 _capturePoint->SetRespawnTime(0); // not save respawn time
225 }
226
227 return true;
228}
void Delete()
Definition GameObject.cpp:962
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1268
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
153{
154 ObjectGuid::LowType spawnId = _creatures[type];
155 if (!spawnId)
156 {
157 LOG_DEBUG("outdoorpvp", "OutdoorPvP: Creature type {} was already deleted", type);
158 return false;
159 }
160
161 auto bounds = _pvp->GetMap()->GetCreatureBySpawnIdStore().equal_range(spawnId);
162 for (auto itr = bounds.first; itr != bounds.second;)
163 {
164 // can happen when closing the core
165 Creature* c = itr->second;
166 ++itr;
167
168 // Don't save respawn time
169 c->SetRespawnTime(0);
170 c->RemoveCorpse();
172 }
173
174 LOG_DEBUG("outdoorpvp", "OutdoorPvP: Deleting creature type {}", type);
175
176 // explicit removal from map
177 // beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
178 // so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
179 //if (Map* map = sMapMgr->FindMap(cr->GetMapId()))
180 // map->Remove(cr, false);
181 // delete respawn time for this creature
183 stmt->SetData(0, spawnId);
184 stmt->SetData(1, _pvp->GetMap()->GetId());
185 stmt->SetData(2, 0); // instance id, always 0 for world maps
186 CharacterDatabase.Execute(stmt);
187
188 sObjectMgr->DeleteCreatureData(spawnId);
189 _creatureTypes[_creatures[type]] = 0;
190 _creatures[type] = 0;
191 return true;
192}
@ CHAR_DEL_CREATURE_RESPAWN
Definition CharacterDatabase.h:254
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
Definition Creature.h:47
void SetRespawnTime(uint32 respawn)
Definition Creature.cpp:3649
void RemoveCorpse(bool setSpawnTime=true, bool skipVisibility=false)
Definition Creature.cpp:394
uint32 GetId() const
Definition Map.h:229
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:351
Map * GetMap() const
Definition OutdoorPvP.h:244
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
void AddObjectToRemoveList()
Definition Object.cpp:2144

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(), OPvPCapturePointEP_PWT::SummonFlightMaster(), and OPvPCapturePointEP_EWT::SummonSupportUnitAtNorthpassTower().

◆ DeleteSpawns()

void OPvPCapturePoint::DeleteSpawns ( )
virtual
231{
232 for (auto const& [type, guid] : _objects)
233 {
234 DelObject(type);
235 }
236
237 for (auto const& [type, guid] : _creatures)
238 {
239 DelCreature(type);
240 }
241
243}
bool DelCapturePoint()
Definition OutdoorPvP.cpp:216
bool DelCreature(uint32 type)
Definition OutdoorPvP.cpp:152
bool DelObject(uint32 type)
Definition OutdoorPvP.cpp:194

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

◆ DelObject()

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

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 false;
559}

◆ 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:103
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144

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.

36{
37 if (_capturePoint)
38 {
42 }
43
44 return _activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
45}
std::uint32_t uint32
Definition Define.h:107
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:136
uint32 _neutralValuePct
Definition OutdoorPvP.h:170
float _maxValue
Definition OutdoorPvP.h:154
std::array< PlayerSet, 2 > _activePlayers
Definition OutdoorPvP.h:151
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition PlayerUpdates.cpp:2235
TeamId GetTeamId(bool original=false) const
Definition Player.h:2101
uint32 worldstate3
Definition GameObjectData.h:315
uint32 worldstate2
Definition GameObjectData.h:305
struct GameObjectTemplate::@234::@258 capturePoint
uint32 worldState1
Definition GameObjectData.h:223

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.

58{
59 if (!_capturePoint)
60 return;
61
62 // send this too, sometimes the slider disappears, dunno why :(
64
65 // send these updates to only the ones in this objective
67
68 // send this too, sometimes it resets :S
70}
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
ObjectiveStates _state
Definition OutdoorPvP.h:167
Definition Player.h:1066
Definition ObjectAccessor.h:61
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245

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()

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

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::VisitObjects(_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) * sWorld->getFloatConfig(CONFIG_OUTDOOR_PVP_CAPTURE_RATE);
354 if (factDiff == 0.f)
355 return false;
356
357 TeamId ChallengerId = TEAM_NEUTRAL;
358 float maxDiff = (_maxSpeed * float(diff)) * sWorld->getFloatConfig(CONFIG_OUTDOOR_PVP_CAPTURE_RATE);
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}
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL
Definition OutdoorPvPMgr.h:21
@ 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
TeamId
Definition SharedDefines.h:770
@ TEAM_NEUTRAL
Definition SharedDefines.h:773
@ TEAM_ALLIANCE
Definition SharedDefines.h:771
@ TEAM_HORDE
Definition SharedDefines.h:772
@ CONFIG_OUTDOOR_PVP_CAPTURE_RATE
Definition WorldConfig.h:375
Definition GridNotifiers.h:1348
bool IsWithinDistInMap(Player const *player) const
Definition GameObject.cpp:2977
virtual void ChangeState()=0
ObjectiveStates _oldState
Definition OutdoorPvP.h:166
virtual void HandlePlayerLeave(Player *player)
Definition OutdoorPvP.cpp:47
TeamId _team
Definition OutdoorPvP.h:163
virtual bool HandlePlayerEnter(Player *player)
Definition OutdoorPvP.cpp:35
virtual void ChangeTeam(TeamId)
Definition OutdoorPvP.h:118
virtual void SendChangePhase()
Definition OutdoorPvP.cpp:57
Definition ObjectGuid.h:118
bool IsOutdoorPvPActive()
Definition Player.cpp:6415
#define sWorld
Definition World.h:316
Definition GridNotifiers.h:516
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165
uint32 radius
Definition GameObjectData.h:196

References _activePlayers, _capturePoint, _maxSpeed, _maxValue, _minValue, _oldState, _state, _team, _value, GameObjectTemplate::capturePoint, ChangeState(), ChangeTeam(), CONFIG_OUTDOOR_PVP_CAPTURE_RATE, 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(), sWorld, TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, and Cell::VisitObjects().

Referenced by OPvPCapturePointTF::Update().

Member Data Documentation

◆ _activePlayers

◆ _capturePoint

◆ _creatures

◆ _creatureTypes

◆ _maxSpeed

float OPvPCapturePoint::_maxSpeed {}
protected

◆ _maxValue

◆ _minValue

float OPvPCapturePoint::_minValue {}
protected

◆ _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


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