TrinityCore
Loading...
Searching...
No Matches
OutdoorPvPTF.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "GameObject.h"
19#include "Map.h"
20#include "ObjectAccessor.h"
21#include "OutdoorPvPMgr.h"
22#include "OutdoorPvPTF.h"
23#include "Player.h"
24#include "ScriptMgr.h"
25#include "WorldStatePackets.h"
26
29{
30 3519 /*Terokkar Forest*/,
31 3791 /*Sethekk Halls*/,
32 3789 /*Shadow Labyrinth*/,
33 3792 /*Mana-Tombs*/,
34 3790 /*Auchenai Crypts*/
35};
36
37// locked for 6 hours after capture
38uint32 const TF_LOCK_TIME = 3600 * 6 * 1000;
39
40// update lock timer every 1/4 minute (overkill, but this way it's sure the timer won't "jump" 2 minutes at once.)
42
43// blessing of auchindoun, used in TeamCastSpell which uses signed int, so signed
44int32 const TF_CAPTURE_BUFF = 33377;
45
46uint32 const TF_ALLY_QUEST = 11505;
47uint32 const TF_HORDE_QUEST = 11506;
48
50{
51 { 183104, 530, { -3081.65f, 5335.03f, 17.1853f, -2.146750f }, { 0.0f, 0.0f, 0.878817f, -0.477159f } },
52 { 183411, 530, { -2939.90f, 4788.73f, 18.9870f, 2.775070f }, { 0.0f, 0.0f, 0.983255f, 0.182236f } },
53 { 183412, 530, { -3174.94f, 4440.97f, 16.2281f, 1.867500f }, { 0.0f, 0.0f, 0.803857f, 0.594823f } },
54 { 183413, 530, { -3603.31f, 4529.15f, 20.9077f, 0.994838f }, { 0.0f, 0.0f, 0.477159f, 0.878817f } },
55 { 183414, 530, { -3812.37f, 4899.30f, 17.7249f, 0.087266f }, { 0.0f, 0.0f, 0.043619f, 0.999048f } }
56};
57
64
66{
67 { 0xa79, 0xa7a, 0xa7b },
68 { 0xa7e, 0xa7d, 0xa7c },
69 { 0xa82, 0xa81, 0xa80 },
70 { 0xa88, 0xa87, 0xa86 },
71 { 0xa85, 0xa84, 0xa83 }
72};
73
74/*
75uint32 const TFTowerPlayerEnterEvents[TF_TOWER_NUM] =
76{
77 12226,
78 12497,
79 12486,
80 12499,
81 12501
82};
83
84uint32 const TFTowerPlayerLeaveEvents[TF_TOWER_NUM] =
85{
86 12225,
87 12496,
88 12487,
89 12498,
90 12500
91};
92*/
93
106
108{
109 SetCapturePointData(TFCapturePoints[type].entry, TFCapturePoints[type].map, TFCapturePoints[type].pos, TFCapturePoints[type].rot);
110}
111
118
134
156
163
165{
166 bool changed = OutdoorPvP::Update(diff);
167
168 if (changed)
169 {
171 {
173 m_IsLocked = true;
178 }
180 {
182 m_IsLocked = true;
187 }
188 else
189 {
192 }
195 }
196 if (m_IsLocked)
197 {
198 // lock timer is down, release lock
199 if (m_LockTimer < diff)
200 {
203 m_IsLocked = false;
208 }
209 else
210 {
211 // worldstateui update timer is down, update ui with new time data
212 if (m_LockTimerUpdate < diff)
213 {
215 uint32 minutes_left = m_LockTimer / 60000;
216 hours_left = minutes_left / 60;
217 minutes_left -= hours_left * 60;
218 second_digit = minutes_left % 10;
219 first_digit = minutes_left / 10;
220
224 } else m_LockTimerUpdate -= diff;
225 m_LockTimer -= diff;
226 }
227 }
228 return changed;
229}
230
232{
233 if (player->GetTeam() == ALLIANCE)
234 {
236 player->CastSpell(player, TF_CAPTURE_BUFF, true);
237 }
238 else
239 {
241 player->CastSpell(player, TF_CAPTURE_BUFF, true);
242 }
244}
245
247{
248 // remove buffs
251}
252
257
262
267
272
274{
275 return m_IsLocked;
276}
277
279{
282
283 m_IsLocked = false;
286 hours_left = 6;
287 second_digit = 0;
288 first_digit = 0;
289
291
292 // add the zones affected by the pvp buff
293 for (uint8 i = 0; i < OutdoorPvPTFBuffZonesNum; ++i)
295
301
302 return true;
303}
304
306{
307 // can update even in locked state if gathers the controlling faction
308 bool canupdate = ((((OutdoorPvPTF*)m_PvP)->GetAllianceTowersControlled() > 0) && m_activePlayers[0].size() > m_activePlayers[1].size()) ||
309 ((((OutdoorPvPTF*)m_PvP)->GetHordeTowersControlled() > 0) && m_activePlayers[0].size() < m_activePlayers[1].size());
310 // if gathers the other faction, then only update if the pvp is unlocked
311 canupdate = canupdate || !((OutdoorPvPTF*)m_PvP)->IsLocked();
312 return canupdate && OPvPCapturePoint::Update(diff);
313}
314
316{
317 // if changing from controlling alliance to horde
319 {
320 if (uint32 alliance_towers = ((OutdoorPvPTF*)m_PvP)->GetAllianceTowersControlled())
321 ((OutdoorPvPTF*)m_PvP)->SetAllianceTowersControlled(--alliance_towers);
323 }
324 // if changing from controlling horde to alliance
326 {
327 if (uint32 horde_towers = ((OutdoorPvPTF*)m_PvP)->GetHordeTowersControlled())
328 ((OutdoorPvPTF*)m_PvP)->SetHordeTowersControlled(--horde_towers);
330 }
331
332 uint32 artkit = 21;
333
334 switch (m_State)
335 {
337 {
339 artkit = 2;
340 uint32 alliance_towers = ((OutdoorPvPTF*)m_PvP)->GetAllianceTowersControlled();
341 if (alliance_towers < TF_TOWER_NUM)
342 ((OutdoorPvPTF*)m_PvP)->SetAllianceTowersControlled(++alliance_towers);
343
345
346 for (GuidSet::iterator itr = m_activePlayers[0].begin(); itr != m_activePlayers[0].end(); ++itr)
347 if (Player* player = ObjectAccessor::FindPlayer(*itr))
348 player->AreaExploredOrEventHappens(TF_ALLY_QUEST);
349 break;
350 }
352 {
354 artkit = 1;
355 uint32 horde_towers = ((OutdoorPvPTF*)m_PvP)->GetHordeTowersControlled();
356 if (horde_towers < TF_TOWER_NUM)
357 ((OutdoorPvPTF*)m_PvP)->SetHordeTowersControlled(++horde_towers);
358
360
361 for (GuidSet::iterator itr = m_activePlayers[1].begin(); itr != m_activePlayers[1].end(); ++itr)
362 if (Player* player = ObjectAccessor::FindPlayer(*itr))
363 player->AreaExploredOrEventHappens(TF_HORDE_QUEST);
364 break;
365 }
372 break;
373 }
374
375 auto bounds = m_PvP->GetMap()->GetGameObjectBySpawnIdStore().equal_range(m_capturePointSpawnId);
376 for (auto itr = bounds.first; itr != bounds.second; ++itr)
377 itr->second->SetGoArtKit(artkit);
378
380}
381
383{
384 public:
386
387 OutdoorPvP* GetOutdoorPvP() const override
388 {
389 return new OutdoorPvPTF();
390 }
391};
392
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
uint32 const OutdoorPvPTFBuffZones[OutdoorPvPTFBuffZonesNum]
go_type const TFCapturePoints[TF_TOWER_NUM]
tf_tower_world_state const TFTowerWorldStates[TF_TOWER_NUM]
uint32 const TF_HORDE_QUEST
uint32 const TF_ALLY_QUEST
uint32 const TF_LOCK_TIME_UPDATE
int32 const TF_CAPTURE_BUFF
void AddSC_outdoorpvp_tf()
uint8 const OutdoorPvPTFBuffZonesNum
uint32 const TF_LOCK_TIME
@ TF_UI_LOCKED_TIME_MINUTES_FIRST_DIGIT
@ TF_UI_LOCKED_DISPLAY_ALLIANCE
@ TF_UI_LOCKED_TIME_MINUTES_SECOND_DIGIT
@ TF_UI_LOCKED_DISPLAY_NEUTRAL
@ TF_UI_LOCKED_DISPLAY_HORDE
@ TF_UI_TOWER_COUNT_H
@ TF_UI_TOWERS_CONTROLLED_DISPLAY
@ TF_UI_TOWER_COUNT_A
@ TF_UI_LOCKED_TIME_HOURS
@ TF_TOWERSTATE_H
@ TF_TOWERSTATE_N
@ TF_TOWERSTATE_A
OutdoorPvPTF_TowerType
@ TF_TOWER_SE
@ TF_TOWER_N
@ TF_TOWER_NE
@ TF_TOWER_NW
@ TF_TOWER_NUM
@ TF_TOWER_S
@ TEXT_SPIRIT_TOWER_LOSE_HORDE
@ TEXT_SPIRIT_TOWER_TAKEN_ALLIANCE
@ TEXT_SPIRIT_TOWER_TAKEN_HORDE
@ TEXT_SPIRIT_TOWER_LOSE_ALLIANCE
@ OUTDOOR_PVP_TF
Definition OutdoorPvP.h:31
@ OBJECTIVESTATE_HORDE
Definition OutdoorPvP.h:43
@ OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE
Definition OutdoorPvP.h:45
@ OBJECTIVESTATE_ALLIANCE
Definition OutdoorPvP.h:42
@ OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE
Definition OutdoorPvP.h:44
@ OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE
Definition OutdoorPvP.h:47
@ OBJECTIVESTATE_NEUTRAL
Definition OutdoorPvP.h:41
@ OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE
Definition OutdoorPvP.h:46
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ ALLIANCE
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:496
bool Update(uint32 diff) override
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
void ChangeState() override
OutdoorPvPTF_TowerType m_TowerType
OPvPCapturePointTF(OutdoorPvP *pvp, OutdoorPvPTF_TowerType type)
ObjectiveStates m_OldState
Definition OutdoorPvP.h:167
OutdoorPvP * m_PvP
Definition OutdoorPvP.h:174
virtual bool Update(uint32 diff)
ObjectiveStates m_State
Definition OutdoorPvP.h:168
GuidSet m_activePlayers[2]
Definition OutdoorPvP.h:152
ObjectGuid::LowType m_capturePointSpawnId
Definition OutdoorPvP.h:130
bool SetCapturePointData(uint32 entry, uint32 map, Position const &pos, QuaternionData const &rot)
void HandlePlayerEnterZone(Player *player, uint32 zone) override
void SendRemoveWorldStates(Player *player) override
void SetHordeTowersControlled(uint32 count)
uint32 GetHordeTowersControlled() const
uint32 GetAllianceTowersControlled() const
uint32 m_HordeTowersControlled
bool IsLocked() const
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
uint32 m_AllianceTowersControlled
uint32 second_digit
uint32 m_LockTimer
void HandlePlayerLeaveZone(Player *player, uint32 zone) override
bool SetupOutdoorPvP() override
uint32 m_LockTimerUpdate
bool Update(uint32 diff) override
uint32 hours_left
uint32 first_digit
void SetAllianceTowersControlled(uint32 count)
OutdoorPvP * GetOutdoorPvP() const override
virtual void HandlePlayerEnterZone(Player *player, uint32 zone)
OPvPCapturePointMap m_capturePoints
Definition OutdoorPvP.h:269
uint32 m_TypeId
Definition OutdoorPvP.h:273
virtual bool Update(uint32 diff)
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2=0)
void RegisterZone(uint32 zoneid)
virtual void HandlePlayerLeaveZone(Player *player, uint32 zone)
Map * GetMap() const
Definition OutdoorPvP.h:264
void TeamCastSpell(TeamId team, int32 spellId)
void SendUpdateWorldState(uint32 field, uint32 value)
void SetMapFromZone(uint32 zone)
void SendDefenseMessage(uint32 zoneId, uint32 id)
void AddCapturePoint(OPvPCapturePoint *cp)
Definition OutdoorPvP.h:287
uint32 GetTeam() const
Definition Player.h:1832
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition Player.cpp:8493
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
std::vector< WorldStateInfo > Worldstates
TC_GAME_API Player * FindPlayer(ObjectGuid const &)