AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
OutdoorPvPTF Class Reference

#include "OutdoorPvPTF.h"

Inheritance diagram for OutdoorPvPTF:
OutdoorPvP ZoneScript

Public Member Functions

 OutdoorPvPTF ()
 
bool SetupOutdoorPvP () override
 
void HandlePlayerEnterZone (Player *player, uint32 zone) override
 
void HandlePlayerLeaveZone (Player *player, uint32 zone) override
 
bool Update (uint32 diff) override
 
void FillInitialWorldStates (WorldPacket &data) override
 
void SendRemoveWorldStates (Player *player) override
 
void SaveRequiredWorldStates () const
 
void ResetZoneToTeamControlled (TeamId team)
 
void RecalculateClientUILockTime ()
 
uint32 GetAllianceTowersControlled () const
 
void SetAllianceTowersControlled (uint32 count)
 
uint32 GetHordeTowersControlled () const
 
void SetHordeTowersControlled (uint32 count)
 
bool IsLocked () const
 
- Public Member Functions inherited from OutdoorPvP
 OutdoorPvP ()=default
 
 ~OutdoorPvP () override
 
void DeleteSpawns ()
 
virtual void FillInitialWorldStates (WorldPacket &)
 
virtual bool HandleAreaTrigger (Player *player, uint32 trigger)
 
virtual bool HandleCustomSpell (Player *player, uint32 spellId, GameObject *go)
 
virtual bool HandleOpenGo (Player *player, GameObject *go)
 
virtual bool SetupOutdoorPvP ()
 
void OnGameObjectCreate (GameObject *go) override
 
void OnGameObjectRemove (GameObject *go) override
 
void OnCreatureCreate (Creature *creature) override
 
void OnCreatureRemove (Creature *creature) override
 
void SendUpdateWorldState (uint32 field, uint32 value)
 
virtual bool Update (uint32 diff)
 
virtual void HandleKill (Player *killer, Unit *killed)
 
virtual void HandleKillImpl (Player *, Unit *)
 
bool IsInsideObjective (Player *player) const
 
virtual void AwardKillBonus (Player *)
 
uint32 GetTypeId () const
 
virtual bool HandleDropFlag (Player *player, uint32 spellId)
 
virtual bool HandleGossipOption (Player *player, Creature *creature, uint32 gossipId)
 
virtual bool CanTalkTo (Player *player, Creature *c, GossipMenuItems const &gso)
 
void TeamApplyBuff (TeamId teamId, uint32 spellId, uint32 spellId2=0, Player *sameMapPlr=nullptr)
 
MapGetMap () const
 
- Public Member Functions inherited from ZoneScript
 ZoneScript ()
 
virtual ~ZoneScript ()
 
virtual uint32 GetCreatureEntry (ObjectGuid::LowType, CreatureData const *data)
 
virtual uint32 GetGameObjectEntry (ObjectGuid::LowType, uint32 entry)
 
virtual void OnCreatureCreate (Creature *)
 
virtual void OnCreatureRemove (Creature *)
 
virtual void OnGameObjectCreate (GameObject *)
 
virtual void OnGameObjectRemove (GameObject *)
 
virtual void OnUnitDeath (Unit *)
 
virtual void OnCreatureEvade (Creature *)
 
virtual ObjectGuid GetGuidData (uint32) const
 
virtual void SetGuidData (uint32, ObjectGuid)
 
virtual uint64 GetData64 (uint32) const
 
virtual void SetData64 (uint32, uint64)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void ProcessEvent (WorldObject *, uint32)
 

Private Attributes

bool m_IsLocked
 
bool m_JustLocked
 
uint32 m_LockTimer
 
uint32 m_LockTimerUpdate
 
uint32 m_AllianceTowersControlled
 
uint32 m_HordeTowersControlled
 
uint32 hours_left
 
uint32 second_digit
 
uint32 first_digit
 

Additional Inherited Members

- Public Types inherited from OutdoorPvP
typedef std::map< ObjectGuid::LowType, OPvPCapturePoint * > OPvPCapturePointMap
 
typedef std::pair< ObjectGuid::LowType, GameObject * > GoScriptPair
 
typedef std::pair< ObjectGuid::LowType, Creature * > CreatureScriptPair
 
- Protected Member Functions inherited from OutdoorPvP
void BroadcastPacket (WorldPacket &data) const
 
virtual void SendRemoveWorldStates (Player *)
 
virtual void HandlePlayerEnterZone (Player *player, uint32 zone)
 
virtual void HandlePlayerLeaveZone (Player *player, uint32 zone)
 
virtual void HandlePlayerResurrects (Player *player, uint32 zone)
 
void AddCapturePoint (OPvPCapturePoint *cp)
 
OPvPCapturePointGetCapturePoint (ObjectGuid::LowType spawnId) const
 
void RegisterZone (uint32 zoneid)
 
bool HasPlayer (Player const *player) const
 
void TeamCastSpell (TeamId team, int32 spellId, Player *sameMapPlr=nullptr)
 
void SetMapFromZone (uint32 zone)
 
- Protected Attributes inherited from OutdoorPvP
OPvPCapturePointMap _capturePoints
 
std::array< PlayerSet, 2 > _players
 
uint32 _typeId {}
 
bool _sendUpdate { true }
 
Map_map {}
 
std::unordered_map< ObjectGuid::LowType, GameObject * > _goScriptStore
 
std::unordered_map< ObjectGuid::LowType, Creature * > _creatureScriptStore
 

Detailed Description

Constructor & Destructor Documentation

◆ OutdoorPvPTF()

OutdoorPvPTF::OutdoorPvPTF ( )
31{
33
34 m_IsLocked = false;
35 m_JustLocked = false;
38
41
42 hours_left = 6;
43 second_digit = 0;
44 first_digit = 0;
45}
@ OUTDOOR_PVP_TF
Definition: OutdoorPvP.h:32
const uint32 TF_LOCK_TIME
Definition: OutdoorPvPTF.h:35
uint32 _typeId
Definition: OutdoorPvP.h:270
bool m_IsLocked
Definition: OutdoorPvPTF.h:189
uint32 m_HordeTowersControlled
Definition: OutdoorPvPTF.h:195
uint32 m_AllianceTowersControlled
Definition: OutdoorPvPTF.h:194
uint32 second_digit
Definition: OutdoorPvPTF.h:197
uint32 m_LockTimer
Definition: OutdoorPvPTF.h:191
bool m_JustLocked
Definition: OutdoorPvPTF.h:190
uint32 m_LockTimerUpdate
Definition: OutdoorPvPTF.h:192
uint32 hours_left
Definition: OutdoorPvPTF.h:197
uint32 first_digit
Definition: OutdoorPvPTF.h:197

References OutdoorPvP::_typeId, first_digit, hours_left, m_AllianceTowersControlled, m_HordeTowersControlled, m_IsLocked, m_JustLocked, m_LockTimer, m_LockTimerUpdate, OUTDOOR_PVP_TF, second_digit, and TF_LOCK_TIME.

Member Function Documentation

◆ FillInitialWorldStates()

void OutdoorPvPTF::FillInitialWorldStates ( WorldPacket data)
overridevirtual

Reimplemented from OutdoorPvP.

61{
62 data << TF_UI_TOWER_SLIDER_POS << uint32(50);
63 data << TF_UI_TOWER_SLIDER_N << uint32(100);
65
69
73
77
78 for (OPvPCapturePointMap::iterator itr = _capturePoints.begin(); itr != _capturePoints.end(); ++itr)
79 {
80 itr->second->FillInitialWorldStates(data);
81 }
82}
std::uint32_t uint32
Definition: Define.h:107
@ TF_UI_TOWER_SLIDER_DISPLAY
Definition: OutdoorPvPTF.h:103
@ TF_UI_TOWER_SLIDER_POS
Definition: OutdoorPvPTF.h:101
@ TF_UI_LOCKED_TIME_MINUTES_FIRST_DIGIT
Definition: OutdoorPvPTF.h:109
@ TF_UI_LOCKED_DISPLAY_ALLIANCE
Definition: OutdoorPvPTF.h:114
@ TF_UI_LOCKED_TIME_MINUTES_SECOND_DIGIT
Definition: OutdoorPvPTF.h:110
@ TF_UI_LOCKED_DISPLAY_NEUTRAL
Definition: OutdoorPvPTF.h:112
@ TF_UI_TOWER_SLIDER_N
Definition: OutdoorPvPTF.h:102
@ TF_UI_LOCKED_DISPLAY_HORDE
Definition: OutdoorPvPTF.h:113
@ TF_UI_TOWER_COUNT_H
Definition: OutdoorPvPTF.h:105
@ TF_UI_TOWERS_CONTROLLED_DISPLAY
Definition: OutdoorPvPTF.h:107
@ TF_UI_TOWER_COUNT_A
Definition: OutdoorPvPTF.h:106
@ TF_UI_LOCKED_TIME_HOURS
Definition: OutdoorPvPTF.h:111
OPvPCapturePointMap _capturePoints
Definition: OutdoorPvP.h:268

References OutdoorPvP::_capturePoints, first_digit, hours_left, m_AllianceTowersControlled, m_HordeTowersControlled, m_IsLocked, second_digit, TF_UI_LOCKED_DISPLAY_ALLIANCE, TF_UI_LOCKED_DISPLAY_HORDE, TF_UI_LOCKED_DISPLAY_NEUTRAL, TF_UI_LOCKED_TIME_HOURS, TF_UI_LOCKED_TIME_MINUTES_FIRST_DIGIT, TF_UI_LOCKED_TIME_MINUTES_SECOND_DIGIT, TF_UI_TOWER_COUNT_A, TF_UI_TOWER_COUNT_H, TF_UI_TOWER_SLIDER_DISPLAY, TF_UI_TOWER_SLIDER_N, TF_UI_TOWER_SLIDER_POS, and TF_UI_TOWERS_CONTROLLED_DISPLAY.

◆ GetAllianceTowersControlled()

uint32 OutdoorPvPTF::GetAllianceTowersControlled ( ) const
307{
309}

References m_AllianceTowersControlled.

◆ GetHordeTowersControlled()

uint32 OutdoorPvPTF::GetHordeTowersControlled ( ) const
317{
319}

References m_HordeTowersControlled.

◆ HandlePlayerEnterZone()

void OutdoorPvPTF::HandlePlayerEnterZone ( Player player,
uint32  zone 
)
overridevirtual

Reimplemented from OutdoorPvP.

285{
286 if (player->GetTeamId() == TEAM_ALLIANCE)
287 {
289 player->CastSpell(player, TF_CAPTURE_BUFF, true);
290 }
291 else
292 {
294 player->CastSpell(player, TF_CAPTURE_BUFF, true);
295 }
297}
@ TF_TOWER_NUM
Definition: OutdoorPvPTF.h:53
#define TF_CAPTURE_BUFF
Definition: OutdoorPvPTF.h:41
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2088
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1168
virtual void HandlePlayerEnterZone(Player *player, uint32 zone)
Definition: OutdoorPvP.cpp:277

References Unit::CastSpell(), Player::GetTeamId(), OutdoorPvP::HandlePlayerEnterZone(), m_AllianceTowersControlled, m_HordeTowersControlled, TEAM_ALLIANCE, TF_CAPTURE_BUFF, and TF_TOWER_NUM.

◆ HandlePlayerLeaveZone()

void OutdoorPvPTF::HandlePlayerLeaveZone ( Player player,
uint32  zone 
)
overridevirtual

Reimplemented from OutdoorPvP.

300{
301 // remove buffs
304}
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4891
virtual void HandlePlayerLeaveZone(Player *player, uint32 zone)
Definition: OutdoorPvP.cpp:282

References OutdoorPvP::HandlePlayerLeaveZone(), Unit::RemoveAurasDueToSpell(), and TF_CAPTURE_BUFF.

◆ IsLocked()

bool OutdoorPvPTF::IsLocked ( ) const
327{
328 return m_IsLocked;
329}

References m_IsLocked.

◆ RecalculateClientUILockTime()

void OutdoorPvPTF::RecalculateClientUILockTime ( )
inline
172 {
173 uint32 minutes_left = m_LockTimer / 60000;
174 hours_left = minutes_left / 60;
175 minutes_left -= hours_left * 60;
176 second_digit = minutes_left % 10;
177 first_digit = minutes_left / 10;
178 }

References first_digit, hours_left, m_LockTimer, and second_digit.

Referenced by SetupOutdoorPvP(), and Update().

◆ ResetZoneToTeamControlled()

void OutdoorPvPTF::ResetZoneToTeamControlled ( TeamId  team)
123{
124 switch (team)
125 {
126 case TEAM_HORDE:
129 break;
130 case TEAM_ALLIANCE:
133 break;
134 case TEAM_NEUTRAL:
137 break;
138 }
139
140 for (auto& [guid, tower] : _capturePoints)
141 {
142 dynamic_cast<OPvPCapturePointTF*>(tower)->ResetToTeamControlled(team);
143 }
144
147}
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
@ TEAM_HORDE
Definition: SharedDefines.h:761
void SendUpdateWorldState(uint32 field, uint32 value)
Definition: OutdoorPvP.cpp:456
Definition: OutdoorPvPTF.h:125

References OutdoorPvP::_capturePoints, m_AllianceTowersControlled, m_HordeTowersControlled, OutdoorPvP::SendUpdateWorldState(), TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, TF_TOWER_NUM, TF_UI_TOWER_COUNT_A, and TF_UI_TOWER_COUNT_H.

Referenced by SetupOutdoorPvP(), and Update().

◆ SaveRequiredWorldStates()

void OutdoorPvPTF::SaveRequiredWorldStates ( ) const
111{
114
116
117 // Save expiry as unix
118 uint32 const lockExpireTime = GameTime::GetGameTime().count() + (m_LockTimer / IN_MILLISECONDS);
119 sWorld->setWorldState(TF_UI_LOCKED_TIME_HOURS, lockExpireTime);
120}
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
#define sWorld
Definition: World.h:444
Seconds GetGameTime()
Definition: GameTime.cpp:38

References GameTime::GetGameTime(), IN_MILLISECONDS, m_AllianceTowersControlled, m_HordeTowersControlled, m_IsLocked, m_LockTimer, sWorld, TF_UI_LOCKED_TIME_HOURS, TF_UI_TOWER_COUNT_A, TF_UI_TOWER_COUNT_H, and TF_UI_TOWERS_CONTROLLED_DISPLAY.

Referenced by SetupOutdoorPvP(), and Update().

◆ SendRemoveWorldStates()

void OutdoorPvPTF::SendRemoveWorldStates ( Player player)
overridevirtual

Reimplemented from OutdoorPvP.

85{
89
93
97
101
102 for (int i = 0; i < TF_TOWER_NUM; ++i)
103 {
107 }
108}
const tf_tower_world_state TFTowerWorldStates[TF_TOWER_NUM]
Definition: OutdoorPvPTF.h:72
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition: PlayerUpdates.cpp:2193

References Player::SendUpdateWorldState(), TF_TOWER_NUM, TF_UI_LOCKED_DISPLAY_ALLIANCE, TF_UI_LOCKED_DISPLAY_HORDE, TF_UI_LOCKED_DISPLAY_NEUTRAL, TF_UI_LOCKED_TIME_HOURS, TF_UI_LOCKED_TIME_MINUTES_FIRST_DIGIT, TF_UI_LOCKED_TIME_MINUTES_SECOND_DIGIT, TF_UI_TOWER_COUNT_A, TF_UI_TOWER_COUNT_H, TF_UI_TOWER_SLIDER_DISPLAY, TF_UI_TOWER_SLIDER_N, TF_UI_TOWER_SLIDER_POS, TF_UI_TOWERS_CONTROLLED_DISPLAY, and TFTowerWorldStates.

◆ SetAllianceTowersControlled()

void OutdoorPvPTF::SetAllianceTowersControlled ( uint32  count)
312{
314}

References m_AllianceTowersControlled.

◆ SetHordeTowersControlled()

void OutdoorPvPTF::SetHordeTowersControlled ( uint32  count)
322{
324}

References m_HordeTowersControlled.

◆ SetupOutdoorPvP()

bool OutdoorPvPTF::SetupOutdoorPvP ( )
overridevirtual

Reimplemented from OutdoorPvP.

332{
335
336 m_IsLocked = bool(sWorld->getWorldState(TF_UI_TOWERS_CONTROLLED_DISPLAY));
337 m_JustLocked = false;
340 hours_left = 6;
341 second_digit = 0;
342 first_digit = 0;
343
344 // add the zones affected by the pvp buff
345 for (uint8 i = 0; i < OutdoorPvPTFBuffZonesNum; ++i)
347
349
355
356 if (m_IsLocked)
357 {
358 // Core shutdown while locked -- init from latest known data in WorldState
359 // Convert from unix
360 int32 const lockRemainingTime = int32((sWorld->getWorldState(TF_UI_LOCKED_TIME_HOURS) - GameTime::GetGameTime().count()) * IN_MILLISECONDS);
361 if (lockRemainingTime > 0)
362 {
363 m_LockTimer = lockRemainingTime;
365
366 uint32 const hordeTowers = uint32(sWorld->getWorldState(TF_UI_TOWER_COUNT_H));
367 uint32 const allianceTowers = uint32(sWorld->getWorldState(TF_UI_TOWER_COUNT_A));
368 TeamId const controllingTeam = hordeTowers > allianceTowers ? TEAM_HORDE : TEAM_ALLIANCE;
369
370 ResetZoneToTeamControlled(controllingTeam);
371 }
372 else
373 {
374 // Lock expired while core was offline
375 m_IsLocked = false;
377 }
378 }
379
380 return true;
381}
std::int32_t int32
Definition: Define.h:103
std::uint8_t uint8
Definition: Define.h:109
const uint32 OutdoorPvPTFBuffZones[OutdoorPvPTFBuffZonesNum]
Definition: OutdoorPvPTF.h:25
@ TF_TOWER_SE
Definition: OutdoorPvPTF.h:51
@ TF_TOWER_N
Definition: OutdoorPvPTF.h:49
@ TF_TOWER_NE
Definition: OutdoorPvPTF.h:50
@ TF_TOWER_NW
Definition: OutdoorPvPTF.h:48
@ TF_TOWER_S
Definition: OutdoorPvPTF.h:52
const uint8 OutdoorPvPTFBuffZonesNum
Definition: OutdoorPvPTF.h:23
TeamId
Definition: SharedDefines.h:759
void RegisterZone(uint32 zoneid)
Definition: OutdoorPvP.cpp:641
void SetMapFromZone(uint32 zone)
Definition: OutdoorPvP.cpp:718
void AddCapturePoint(OPvPCapturePoint *cp)
Definition: OutdoorPvP.h:254
void RecalculateClientUILockTime()
Definition: OutdoorPvPTF.h:171
void SaveRequiredWorldStates() const
Definition: OutdoorPvPTF.cpp:110
void ResetZoneToTeamControlled(TeamId team)
Definition: OutdoorPvPTF.cpp:122

References OutdoorPvP::AddCapturePoint(), first_digit, GameTime::GetGameTime(), hours_left, IN_MILLISECONDS, m_AllianceTowersControlled, m_HordeTowersControlled, m_IsLocked, m_JustLocked, m_LockTimer, m_LockTimerUpdate, OutdoorPvPTFBuffZones, OutdoorPvPTFBuffZonesNum, RecalculateClientUILockTime(), OutdoorPvP::RegisterZone(), ResetZoneToTeamControlled(), SaveRequiredWorldStates(), second_digit, OutdoorPvP::SetMapFromZone(), sWorld, TEAM_ALLIANCE, TEAM_HORDE, TF_LOCK_TIME, TF_TOWER_N, TF_TOWER_NE, TF_TOWER_NW, TF_TOWER_S, TF_TOWER_SE, TF_UI_LOCKED_TIME_HOURS, TF_UI_TOWER_COUNT_A, TF_UI_TOWER_COUNT_H, and TF_UI_TOWERS_CONTROLLED_DISPLAY.

◆ Update()

bool OutdoorPvPTF::Update ( uint32  diff)
overridevirtual

Reimplemented from OutdoorPvP.

202{
203 bool changed = OutdoorPvP::Update(diff);
204
205 if (changed)
206 {
208 {
210 m_IsLocked = true;
211 m_JustLocked = true;
216 }
218 {
220 m_IsLocked = true;
221 m_JustLocked = true;
226 }
227 else
228 {
231 }
232
235 }
236
237 if (m_IsLocked)
238 {
239 if (m_JustLocked)
240 {
241 m_JustLocked = false;
243 }
244
245 // lock timer is down, release lock
246 if (m_LockTimer < diff)
247 {
250 m_IsLocked = false;
251
254
259 }
260 else
261 {
262 // worldstateui update timer is down, update ui with new time data
263 if (m_LockTimerUpdate < diff)
264 {
267
271 }
272 else
273 {
274 m_LockTimerUpdate -= diff;
275 }
276
277 m_LockTimer -= diff;
278 }
279 }
280
281 return changed;
282}
const uint32 TF_LOCK_TIME_UPDATE
Definition: OutdoorPvPTF.h:38
void TeamApplyBuff(TeamId teamId, uint32 spellId, uint32 spellId2=0, Player *sameMapPlr=nullptr)
Definition: OutdoorPvP.cpp:670
virtual bool Update(uint32 diff)
Definition: OutdoorPvP.cpp:304
void TeamCastSpell(TeamId team, int32 spellId, Player *sameMapPlr=nullptr)
Definition: OutdoorPvP.cpp:652

References first_digit, hours_left, m_AllianceTowersControlled, m_HordeTowersControlled, m_IsLocked, m_JustLocked, m_LockTimer, m_LockTimerUpdate, RecalculateClientUILockTime(), ResetZoneToTeamControlled(), SaveRequiredWorldStates(), second_digit, OutdoorPvP::SendUpdateWorldState(), TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, OutdoorPvP::TeamApplyBuff(), OutdoorPvP::TeamCastSpell(), TF_CAPTURE_BUFF, TF_LOCK_TIME, TF_LOCK_TIME_UPDATE, TF_TOWER_NUM, TF_UI_LOCKED_DISPLAY_ALLIANCE, TF_UI_LOCKED_DISPLAY_HORDE, TF_UI_LOCKED_DISPLAY_NEUTRAL, TF_UI_LOCKED_TIME_HOURS, TF_UI_LOCKED_TIME_MINUTES_FIRST_DIGIT, TF_UI_LOCKED_TIME_MINUTES_SECOND_DIGIT, TF_UI_TOWER_COUNT_A, TF_UI_TOWER_COUNT_H, TF_UI_TOWERS_CONTROLLED_DISPLAY, and OutdoorPvP::Update().

Member Data Documentation

◆ first_digit

◆ hours_left

◆ m_AllianceTowersControlled

◆ m_HordeTowersControlled

◆ m_IsLocked

bool OutdoorPvPTF::m_IsLocked
private

◆ m_JustLocked

bool OutdoorPvPTF::m_JustLocked
private

◆ m_LockTimer

◆ m_LockTimerUpdate

uint32 OutdoorPvPTF::m_LockTimerUpdate
private

◆ second_digit