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:172

◆ ~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:1635
Definition: CreatureData.h:370
uint32 id1
Definition: CreatureData.h:372
std::unordered_map< ObjectGuid::LowType, uint32 > _creatureTypes
Definition: OutdoorPvP.h:180
std::unordered_map< uint32, ObjectGuid::LowType > _creatures
Definition: OutdoorPvP.h:178

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:122
void AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entry=0)
Definition: OutdoorPvP.cpp:88

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 
)
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:696
uint32 id
Definition: GameObjectData.h:698
std::unordered_map< ObjectGuid::LowType, uint32 > _objectTypes
Definition: OutdoorPvP.h:179
std::unordered_map< uint32, ObjectGuid::LowType > _objects
Definition: OutdoorPvP.h:177

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.

602{
603 return false;
604}

◆ ChangeState()

◆ ChangeTeam()

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

Referenced by Update(), and OPvPCapturePointNA::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:981
void SetRespawnTime(int32 respawn)
Definition: GameObject.cpp:1305
GameObject * _capturePoint
Definition: OutdoorPvP.h:125
ObjectGuid::LowType m_capturePointSpawnId
Definition: OutdoorPvP.h:124

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
@ CHAR_DEL_CREATURE_RESPAWN
Definition: CharacterDatabase.h:252
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77
Definition: Creature.h:43
void SetRespawnTime(uint32 respawn)
Definition: Creature.cpp:3775
void RemoveCorpse(bool setSpawnTime=true, bool skipVisibility=false)
Definition: Creature.cpp:400
void AddObjectToRemoveList()
Definition: Object.cpp:2160
uint32 GetId() const
Definition: Map.h:377
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:518
Map * GetMap() const
Definition: OutdoorPvP.h:243

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
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:120
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:521

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
136 {
137 return _value;
138 }
float _value
Definition: OutdoorPvP.h:160

References _value.

◆ HandleCustomSpell()

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

Reimplemented in OPvPCapturePointNA.

556{
557 return false;
558}

◆ HandleDropFlag()

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

Reimplemented in OPvPCapturePointZM_GraveYard.

607{
608 return false;
609}

◆ HandleGossipOption()

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

Reimplemented in OPvPCapturePointZM_GraveYard.

597{
598 return false;
599}

◆ HandleOpenGo()

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

Reimplemented in OPvPCapturePointNA, and OPvPCapturePointZM_GraveYard.

612{
613 auto const itr = _objectTypes.find(go->GetSpawnId());
614 if (itr != _objectTypes.end())
615 {
616 return (int32)itr->second;
617 }
618
619 return -1;
620}
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.

35{
36 if (_capturePoint)
37 {
41 }
42
43 return _activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
44}
std::uint32_t uint32
Definition: Define.h:107
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:136
uint32 worldstate3
Definition: GameObjectData.h:315
uint32 worldstate2
Definition: GameObjectData.h:305
struct GameObjectTemplate::@230::@254 capturePoint
uint32 worldState1
Definition: GameObjectData.h:223
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition: PlayerUpdates.cpp:2197
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2108
uint32 _neutralValuePct
Definition: OutdoorPvP.h:169
float _maxValue
Definition: OutdoorPvP.h:153
std::array< PlayerSet, 2 > _activePlayers
Definition: OutdoorPvP.h:150

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
541{
542 PlayerSet const& plSet = _activePlayers[player->GetTeamId()];
543 return plSet.find(player->GetGUID()) != plSet.end();
544}
GuidSet PlayerSet
Definition: OutdoorPvP.h:87

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:465

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 
)
477{
478 uint32 team;
479 switch (_state)
480 {
482 team = 0;
483 break;
485 team = 1;
486 break;
487 default:
488 return;
489 }
490
491 // send to all players present in the area
492 for (auto itr : _activePlayers[team])
493 if (Player* const player = ObjectAccessor::FindPlayer(itr))
494 player->KilledMonsterCredit(id, guid);
495}
@ OBJECTIVESTATE_HORDE
Definition: OutdoorPvP.h:44
@ OBJECTIVESTATE_ALLIANCE
Definition: OutdoorPvP.h:43
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:245
Definition: Player.h:1081
ObjectiveStates _state
Definition: OutdoorPvP.h:166

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: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
float _minValue
Definition: OutdoorPvP.h:154
float _maxSpeed
Definition: OutdoorPvP.h:157

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)
623{
624 _value = std::clamp<float>(slider, -_maxValue, _maxValue);
625}

References _maxValue, and _value.

◆ Update()

bool OPvPCapturePoint::Update ( uint32  diff)
virtual

Reimplemented in OPvPCapturePointNA, OPvPCapturePointTF, and OPvPCapturePointZM_GraveYard.

317{
318 if (!_capturePoint)
319 return false;
320
321 auto radius = (float)_capturePoint->GetGOInfo()->capturePoint.radius;
322
323 for (auto const& activePlayer : _activePlayers)
324 {
325 for (auto itr = activePlayer.begin(); itr != activePlayer.end();)
326 {
327 ObjectGuid playerGuid = *itr;
328 ++itr;
329
330 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
331 if (!_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
332 HandlePlayerLeave(player);
333 }
334 }
335
336 std::list<Player*> players;
339 Cell::VisitWorldObjects(_capturePoint, searcher, radius);
340
341 for (auto& itr : players)
342 {
343 Player* const player = itr;
344 if (player->IsOutdoorPvPActive())
345 {
346 if (_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second)
348 }
349 }
350
351 // get the difference of numbers
352 float factDiff = ((float)_activePlayers[0].size() - (float)_activePlayers[1].size()) * float(diff) / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
353 if (factDiff == 0.f)
354 return false;
355
356 TeamId ChallengerId = TEAM_NEUTRAL;
357 float maxDiff = _maxSpeed * float(diff);
358
359 if (factDiff < 0.f)
360 {
361 // horde is in majority, but it's already horde-controlled -> no change
363 return false;
364
365 if (factDiff < -maxDiff)
366 factDiff = -maxDiff;
367
368 ChallengerId = TEAM_HORDE;
369 }
370 else
371 {
372 // ally is in majority, but it's already ally-controlled -> no change
374 return false;
375
376 if (factDiff > maxDiff)
377 factDiff = maxDiff;
378
379 ChallengerId = TEAM_ALLIANCE;
380 }
381
382 float oldValue = _value;
383 TeamId oldTeam = _team;
384
386 _value += factDiff;
387
388 if (_value < -_minValue) // red
389 {
390 if (_value < -_maxValue)
391 {
392 _value = -_maxValue;
393 }
394
397 }
398 else if (_value > _minValue) // blue
399 {
400 if (_value > _maxValue)
401 {
403 }
404
407 }
408 else if (oldValue * _value <= 0) // grey, go through mid-point
409 {
410 // if challenger is ally, then n->a challenge
411 if (ChallengerId == TEAM_ALLIANCE)
412 {
414 }
415 else if (ChallengerId == TEAM_HORDE) // if challenger is horde, then n->h challenge
416 {
418 }
419
421 }
422 else // grey, did not go through mid-point
423 {
424 // old phase and current are on the same side, so one team challenges the other
426 {
428 }
430 {
432 }
433
435 }
436
437 if (_value != oldValue)
438 {
440 }
441
442 if (_oldState != _state)
443 {
444 if (oldTeam != _team)
445 {
446 ChangeTeam(oldTeam);
447 }
448
449 ChangeState();
450 return true;
451 }
452
453 return false;
454}
TeamId
Definition: SharedDefines.h:759
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
#define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL
Definition: OutdoorPvPMgr.h:21
@ 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
bool IsWithinDistInMap(Player const *player) const
Definition: GameObject.cpp:3005
uint32 radius
Definition: GameObjectData.h:196
Definition: ObjectGuid.h:118
bool IsOutdoorPvPActive()
Definition: Player.cpp:6436
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:192
Definition: GridNotifiers.h:525
Definition: GridNotifiers.h:1354
virtual void ChangeState()=0
ObjectiveStates _oldState
Definition: OutdoorPvP.h:165
virtual void HandlePlayerLeave(Player *player)
Definition: OutdoorPvP.cpp:46
TeamId _team
Definition: OutdoorPvP.h:162
virtual bool HandlePlayerEnter(Player *player)
Definition: OutdoorPvP.cpp:34
virtual void ChangeTeam(TeamId)
Definition: OutdoorPvP.h:117
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 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