TrinityCore
Loading...
Searching...
No Matches
OutdoorPvPZM.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 "OutdoorPvPZM.h"
19#include "Creature.h"
20#include "GossipDef.h"
21#include "MapManager.h"
22#include "ObjectAccessor.h"
23#include "ObjectMgr.h"
24#include "OutdoorPvPMgr.h"
25#include "Player.h"
26#include "ScriptMgr.h"
27#include "WorldStatePackets.h"
28
30
31// the buff is cast in these zones
32uint32 const OutdoorPvPZMBuffZones[OutdoorPvPZMBuffZonesNum] = { 3521, 3607, 3717, 3715, 3716 };
33
34// linked when the central tower is controlled
36
37// linked when the central tower is controlled
39
40// banners 182527, 182528, 182529, gotta check them ingame
41go_type const ZM_Banner_A = { 182527, 530, { 253.54f, 7083.81f, 36.7728f, -0.017453f }, { 0.0f, 0.0f, 0.008727f, -0.999962f } };
42go_type const ZM_Banner_H = { 182528, 530, { 253.54f, 7083.81f, 36.7728f, -0.017453f }, { 0.0f, 0.0f, 0.008727f, -0.999962f } };
43go_type const ZM_Banner_N = { 182529, 530, { 253.54f, 7083.81f, 36.7728f, -0.017453f }, { 0.0f, 0.0f, 0.008727f, -0.999962f } };
44
45// horde field scout spawn data
46creature_type const ZM_HordeFieldScout = { 18564, 530, { 296.625f, 7818.4f, 42.6294f, 5.18363f } };
47
48// alliance field scout spawn data
49creature_type const ZM_AllianceFieldScout = { 18581, 530, { 374.395f, 6230.08f, 22.8351f, 0.593412f } };
50
62
64{
65 { 2560, 2559, 2558, 2652, 2651, 2650, 11807, 11806 },
66 { 2557, 2556, 2555, 2646, 2645, 2644, 11805, 11804 }
67};
68
74
80
82{
83 { 182523, 530, { 303.243f, 6841.36f, 40.1245f, -1.58825f }, { 0.0f, 0.0f, 0.71325f, -0.700909f } },
84 { 182522, 530, { 336.466f, 7340.26f, 41.4984f, -1.58825f }, { 0.0f, 0.0f, 0.71325f, -0.700909f } }
85};
86
91
93{
94 packet.Worldstates.emplace_back(ZMBeaconInfo[m_TowerType].ui_tower_n, (m_TowerState & ZM_TOWERSTATE_N) != 0 ? 1 : 0);
95 packet.Worldstates.emplace_back(ZMBeaconInfo[m_TowerType].map_tower_n, (m_TowerState & ZM_TOWERSTATE_N) != 0 ? 1 : 0);
96 packet.Worldstates.emplace_back(ZMBeaconInfo[m_TowerType].ui_tower_a, (m_TowerState & ZM_TOWERSTATE_A) != 0 ? 1 : 0);
97 packet.Worldstates.emplace_back(ZMBeaconInfo[m_TowerType].map_tower_a, (m_TowerState & ZM_TOWERSTATE_A) != 0 ? 1 : 0);
98 packet.Worldstates.emplace_back(ZMBeaconInfo[m_TowerType].ui_tower_h, (m_TowerState & ZM_TOWERSTATE_H) != 0 ? 1 : 0);
99 packet.Worldstates.emplace_back(ZMBeaconInfo[m_TowerType].map_tower_h, (m_TowerState & ZM_TOWERSTATE_H) != 0 ? 1 : 0);
100}
101
111
113{
114 // if changing from controlling alliance to horde
116 {
117 if (uint32 alliance_towers = ((OutdoorPvPZM*)m_PvP)->GetAllianceTowersControlled())
118 ((OutdoorPvPZM*)m_PvP)->SetAllianceTowersControlled(--alliance_towers);
119 }
120 // if changing from controlling horde to alliance
122 {
123 if (uint32 horde_towers = ((OutdoorPvPZM*)m_PvP)->GetHordeTowersControlled())
124 ((OutdoorPvPZM*)m_PvP)->SetHordeTowersControlled(--horde_towers);
125 }
126
127 switch (m_State)
128 {
130 {
132 uint32 alliance_towers = ((OutdoorPvPZM*)m_PvP)->GetAllianceTowersControlled();
133 if (alliance_towers < ZM_NUM_BEACONS)
134 ((OutdoorPvPZM*)m_PvP)->SetAllianceTowersControlled(++alliance_towers);
136 break;
137 }
139 {
141 uint32 horde_towers = ((OutdoorPvPZM*)m_PvP)->GetHordeTowersControlled();
142 if (horde_towers < ZM_NUM_BEACONS)
143 ((OutdoorPvPZM*)m_PvP)->SetHordeTowersControlled(++horde_towers);
145 break;
146 }
153 break;
154 }
155
157}
158
160{
161 bool changed = OutdoorPvP::Update(diff);
162 if (changed)
163 {
168 else
170 }
171 return changed;
172}
173
175{
176 if (player->GetTeam() == ALLIANCE)
177 {
179 player->CastSpell(player, ZM_CAPTURE_BUFF, true);
180 }
181 else
182 {
184 player->CastSpell(player, ZM_CAPTURE_BUFF, true);
185 }
187}
188
190{
191 // remove buffs
193 // remove flag
197}
198
206
208{
211
213
214 // add the zones affected by the pvp buff
215 for (uint8 i = 0; i < OutdoorPvPZMBuffZonesNum; ++i)
217
221 AddCapturePoint(m_Graveyard); // though the update function isn't used, the handleusego is!
222
223 return true;
224}
225
227{
228 if (killed->GetTypeId() != TYPEID_PLAYER)
229 return;
230
231 if (player->GetTeam() == ALLIANCE && killed->ToPlayer()->GetTeam() != ALLIANCE)
232 player->CastSpell(player, ZM_AlliancePlayerKillReward, true);
233 else if (player->GetTeam() == HORDE && killed->ToPlayer()->GetTeam() != HORDE)
234 player->CastSpell(player, ZM_HordePlayerKillReward, true);
235}
236
238{
239 bool retval = m_State != m_OldState;
241 return retval;
242}
243
245{
246 int32 retval = OPvPCapturePoint::HandleOpenGo(player, go);
247 if (retval >= 0)
248 {
250 {
252 DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant
254 sObjectMgr->RemoveGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE); // rem gy
255 sObjectMgr->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE, false); // add gy
259 }
261 {
263 DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant
265 sObjectMgr->RemoveGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE); // rem gy
266 sObjectMgr->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE, false); // add gy
270 }
272 }
273 return retval;
274}
275
287
299
310
312{
313 // nothing to do here
314 if (m_BothControllingFaction == controlling_faction)
315 return;
316 m_BothControllingFaction = controlling_faction;
317
318 switch (controlling_faction)
319 {
320 case ALLIANCE:
321 // if ally already controls the gy and taken back both beacons, return, nothing to do for us
323 return;
324 // ally doesn't control the gy, but controls the side beacons -> add gossip option, add neutral banner
325 break;
326 case HORDE:
327 // if horde already controls the gy and taken back both beacons, return, nothing to do for us
329 return;
330 // horde doesn't control the gy, but controls the side beacons -> add gossip option, add neutral banner
331 break;
332 default:
333 // if the graveyard is not neutral, then leave it that way
334 // if the graveyard is neutral, then we have to dispel the buff from the flag carrier
336 {
337 // gy was neutral, thus neutral banner was spawned, it is possible that someone was taking the flag to the gy
339 {
340 // remove flag from carrier, reset flag carrier guid
342 if (p)
343 {
346 }
348 }
349 }
350 break;
351 }
352 // send worldstateupdate
354}
355
357{
358 std::map<uint32, uint32>::iterator itr = m_CreatureTypes.find(c->GetSpawnId());
359
360 if (itr != m_CreatureTypes.end())
361 {
363 return true;
365 return true;
366 }
367 return false;
368}
369
371{
372 std::map<uint32, uint32>::iterator itr = m_CreatureTypes.find(creature->GetSpawnId());
373
374 if (itr != m_CreatureTypes.end())
375 {
376 // if the flag is already taken, then return
378 return true;
379 if (itr->second == ZM_ALLIANCE_FIELD_SCOUT)
380 {
381 creature->CastSpell(player, ZM_BATTLE_STANDARD_A, true);
382 m_FlagCarrierGUID = player->GetGUID();
383 }
384 else if (itr->second == ZM_HORDE_FIELD_SCOUT)
385 {
386 creature->CastSpell(player, ZM_BATTLE_STANDARD_H, true);
387 m_FlagCarrierGUID = player->GetGUID();
388 }
391 return true;
392 }
393 return false;
394}
395
397{
398 switch (spellId)
399 {
402 return true;
405 return true;
406 }
407 return false;
408}
409
414
419
424
429
434
436{
437 packet.Worldstates.emplace_back(ZM_WORLDSTATE_UNK_1, 1);
438
439 for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
440 itr->second->FillInitialWorldStates(packet);
441}
442
466
468{
469 public:
471
472 OutdoorPvP* GetOutdoorPvP() const override
473 {
474 return new OutdoorPvPZM();
475 }
476};
477
479{
481}
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ TYPEID_PLAYER
Definition ObjectGuid.h:39
#define sObjectMgr
Definition ObjectMgr.h:1721
uint8 const OutdoorPvPZMBuffZonesNum
go_type const ZM_Banner_H
creature_type const ZM_HordeFieldScout
void AddSC_outdoorpvp_zm()
uint32 const OutdoorPvPZMBuffZones[OutdoorPvPZMBuffZonesNum]
uint32 const ZM_GRAVEYARD_ZONE
uint32 const ZM_GRAVEYARD_ID
go_type const ZM_Banner_A
creature_type const ZM_AllianceFieldScout
uint32 const ZMBeaconCaptureH[ZM_NUM_BEACONS]
zm_beacon const ZMBeaconInfo[ZM_NUM_BEACONS]
go_type const ZM_Banner_N
go_type const ZMCapturePoints[ZM_NUM_BEACONS]
uint32 const ZMBeaconCaptureA[ZM_NUM_BEACONS]
@ ZM_TOWERSTATE_N
@ ZM_TOWERSTATE_H
@ ZM_TOWERSTATE_A
ZM_BeaconType
@ ZM_BEACON_EAST
@ ZM_BEACON_WEST
@ ZM_NUM_BEACONS
@ TEXT_EAST_BEACON_TAKEN_ALLIANCE
@ TEXT_TWIN_SPIRE_RUINS_TAKEN_ALLIANCE
@ TEXT_WEST_BEACON_TAKEN_ALLIANCE
@ TEXT_EAST_BEACON_TAKEN_HORDE
@ TEXT_TWIN_SPIRE_RUINS_TAKEN_HORDE
@ TEXT_WEST_BEACON_TAKEN_HORDE
@ ZM_HORDE_FIELD_SCOUT
@ ZM_ALLIANCE_FIELD_SCOUT
@ ZM_GRAVEYARD_H
@ ZM_GRAVEYARD_N
@ ZM_GRAVEYARD_A
@ ZM_BATTLE_STANDARD_H
@ ZM_BATTLE_STANDARD_A
@ ZM_CAPTURE_BUFF
@ ZM_AlliancePlayerKillReward
@ ZM_HordePlayerKillReward
@ ZM_MAP_TOWER_EAST_A
@ ZM_MAP_HORDE_FLAG_NOT_READY
@ ZM_UI_TOWER_WEST_N
@ ZM_UI_TOWER_WEST_A
@ ZM_WORLDSTATE_UNK_1
@ ZM_MAP_ALLIANCE_FLAG_READY
@ ZM_MAP_GRAVEYARD_A
@ ZM_MAP_TOWER_WEST_N
@ ZM_MAP_TOWER_WEST_A
@ ZM_MAP_GRAVEYARD_N
@ ZM_MAP_GRAVEYARD_H
@ ZM_UI_TOWER_EAST_H
@ ZM_MAP_TOWER_EAST_N
@ ZM_UI_TOWER_WEST_H
@ ZM_MAP_TOWER_WEST_H
@ ZM_MAP_HORDE_FLAG_READY
@ ZM_MAP_ALLIANCE_FLAG_NOT_READY
@ ZM_UI_TOWER_EAST_A
@ ZM_UI_TOWER_EAST_N
@ ZM_MAP_TOWER_EAST_H
@ OUTDOOR_PVP_ZM
Definition OutdoorPvP.h:32
@ 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
@ HORDE
ObjectGuid::LowType GetSpawnId() const
Definition Creature.h:83
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
OPvPCapturePointZM_Beacon(OutdoorPvP *pvp, ZM_BeaconType type)
bool HandleGossipOption(Player *player, Creature *creature, uint32 gossipid) override
bool Update(uint32 diff) override
OPvPCapturePointZM_Graveyard(OutdoorPvP *pvp)
bool HandleDropFlag(Player *player, uint32 spellId) override
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
void SetBeaconState(uint32 controlling_team)
int32 HandleOpenGo(Player *player, GameObject *go) override
bool CanTalkTo(Player *player, Creature *creature, GossipMenuItems const &gso) override
ObjectiveStates m_OldState
Definition OutdoorPvP.h:167
OutdoorPvP * m_PvP
Definition OutdoorPvP.h:174
bool AddCreature(uint32 type, uint32 entry, uint32 map, Position const &pos, TeamId teamId=TEAM_NEUTRAL, uint32 spawntimedelay=0)
std::map< ObjectGuid::LowType, uint32 > m_CreatureTypes
Definition OutdoorPvP.h:181
ObjectiveStates m_State
Definition OutdoorPvP.h:168
bool SetCapturePointData(uint32 entry, uint32 map, Position const &pos, QuaternionData const &rot)
virtual int32 HandleOpenGo(Player *player, GameObject *go)
bool AddObject(uint32 type, uint32 entry, uint32 map, Position const &pos, QuaternionData const &rot)
bool DelObject(uint32 type)
bool IsEmpty() const
Definition ObjectGuid.h:172
void Clear()
Definition ObjectGuid.h:150
TypeID GetTypeId() const
Definition Object.h:93
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
static Player * ToPlayer(Object *o)
Definition Object.h:180
void SetHordeTowersControlled(uint32 count)
uint32 GetAllianceTowersControlled() const
void HandleKillImpl(Player *player, Unit *killed) override
bool SetupOutdoorPvP() override
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
void HandlePlayerEnterZone(Player *player, uint32 zone) override
void HandlePlayerLeaveZone(Player *player, uint32 zone) override
OPvPCapturePointZM_Graveyard * m_Graveyard
uint32 GetHordeTowersControlled() const
void SetAllianceTowersControlled(uint32 count)
void SendRemoveWorldStates(Player *player) override
bool Update(uint32 diff) override
uint32 m_HordeTowersControlled
uint32 m_AllianceTowersControlled
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)
void SendUpdateWorldState(uint32 field, uint32 value)
void SetMapFromZone(uint32 zone)
void SendDefenseMessage(uint32 zoneId, uint32 id)
void AddCapturePoint(OPvPCapturePoint *cp)
Definition OutdoorPvP.h:287
void SendCloseGossip()
uint32 GetTeam() const
Definition Player.h:1832
void SendUpdateWorldState(uint32 variable, uint32 value) const
Definition Player.cpp:8493
PlayerMenu * PlayerTalkClass
Definition Player.h:1969
Definition Unit.h:769
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
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 &)
Position pos
Definition OutdoorPvP.h:66
uint32 map
Definition OutdoorPvP.h:56
uint32 entry
Definition OutdoorPvP.h:55
Position pos
Definition OutdoorPvP.h:57
QuaternionData rot
Definition OutdoorPvP.h:58
uint32 ui_tower_a
uint32 map_tower_n
uint32 event_leave
uint32 ui_tower_h
uint32 map_tower_a
uint32 map_tower_h
uint32 event_enter
uint32 ui_tower_n