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 "GameObject.h"
21#include "GossipDef.h"
22#include "ObjectAccessor.h"
23#include "ObjectMgr.h"
24#include "Player.h"
25#include "ScriptedCreature.h"
26#include "ScriptedGossip.h"
27#include "ScriptMgr.h"
28#include "WorldSession.h"
29#include "WorldStatePackets.h"
30
32
33// the buff is cast in these zones
34uint32 const OutdoorPvPZMBuffZones[OutdoorPvPZMBuffZonesNum] = { 3521, 3607, 3717, 3715, 3716 };
35
36// linked when the central tower is controlled
38
39ZMControlZoneHandler::ZMControlZoneHandler(OutdoorPvPZM* pvp, uint32 textBeaconTakenHorde, uint32 textBeaconTakenAlliance, uint32 worldstateNeutralUi, uint32 worldstateNeutralMap, uint32 worldstateHordeUi, uint32 worldstateHordeMap, uint32 worldstateAllianceUi, uint32 worldstateAllianceMap)
40 : OutdoorPvPControlZoneHandler(pvp), _textBeaconTakenHorde(textBeaconTakenHorde), _textBeaconTakenAlliance(textBeaconTakenAlliance), _worldstateNeutralUi(worldstateNeutralUi), _worldstateNeutralMap(worldstateNeutralMap),
41 _worldstateHordeUi(worldstateHordeUi), _worldstateHordeMap(worldstateHordeMap), _worldstateAllianceUi(worldstateAllianceUi), _worldstateAllianceMap(worldstateAllianceMap)
42{
43}
44
58
72
79
86
98
103
105{
106 OutdoorPvP::Update(diff);
108 m_Graveyard->SetBeaconState(ALLIANCE);
110 m_Graveyard->SetBeaconState(HORDE);
111 else
112 m_Graveyard->SetBeaconState(0);
113}
114
116{
117 if (player->GetTeam() == ALLIANCE)
118 {
119 if (m_Graveyard->GetGraveyardState() & ZM_GRAVEYARD_A)
120 player->CastSpell(player, ZM_CAPTURE_BUFF, true);
121 }
122 else if (player->GetTeam() == HORDE)
123 {
124 if (m_Graveyard->GetGraveyardState() & ZM_GRAVEYARD_H)
125 player->CastSpell(player, ZM_CAPTURE_BUFF, true);
126 }
128}
129
131{
132 // remove buffs
134 // remove flag
138}
139
170
172{
175
176 // add the zones affected by the pvp buff
177 for (uint8 i = 0; i < OutdoorPvPZMBuffZonesNum; ++i)
179
180 m_Graveyard = std::make_unique<OPvPCapturePointZM_Graveyard>(this);
181
182 return true;
183}
184
186{
187 if (killed->GetTypeId() != TYPEID_PLAYER)
188 return;
189
190 if (player->GetTeam() == ALLIANCE && killed->ToPlayer()->GetTeam() != ALLIANCE)
191 player->CastSpell(player, ZM_AlliancePlayerKillReward, true);
192 else if (player->GetTeam() == HORDE && killed->ToPlayer()->GetTeam() != HORDE)
193 player->CastSpell(player, ZM_HordePlayerKillReward, true);
194}
195
200
228
235
250
252{
253 // nothing to do here
254 if (m_BothControllingFaction == controlling_faction)
255 return;
256 m_BothControllingFaction = controlling_faction;
257
258 switch (controlling_faction)
259 {
260 case ALLIANCE:
261 // if ally already controls the gy and taken back both beacons, return, nothing to do for us
263 return;
264 // ally doesn't control the gy, but controls the side beacons -> add gossip option, add neutral banner
265 break;
266 case HORDE:
267 // if horde already controls the gy and taken back both beacons, return, nothing to do for us
269 return;
270 // horde doesn't control the gy, but controls the side beacons -> add gossip option, add neutral banner
271 break;
272 default:
273 // if the graveyard is not neutral, then leave it that way
274 // if the graveyard is neutral, then we have to dispel the buff from the flag carrier
276 {
277 // gy was neutral, thus neutral banner was spawned, it is possible that someone was taking the flag to the gy
279 {
280 // remove flag from carrier, reset flag carrier guid
282 if (p)
283 {
286 }
288 }
289 }
290 break;
291 }
292 // send worldstateupdate
294}
295
297{
298 switch (spellId)
299 {
303 return true;
304 default:
305 break;
306 }
307 return false;
308}
309
314
319
324
329
334
336{
338 initWorldStates.MapID = player->GetMapId();
339 initWorldStates.AreaID = player->GetZoneId();
340 initWorldStates.SubareaID = player->GetAreaId();
341
342 for (auto& itr : ControlZoneHandlers)
343 {
344 ZMControlZoneHandler* handler = static_cast<ZMControlZoneHandler*>(itr.second.get());
345 initWorldStates.Worldstates.emplace_back(handler->GetWorldStateNeutralUI(), 0);
346 initWorldStates.Worldstates.emplace_back(handler->GetWorldStateNeutralMap(), 0);
347 initWorldStates.Worldstates.emplace_back(handler->GetWorldStateHordeUI(), 0);
348 initWorldStates.Worldstates.emplace_back(handler->GetWorldStateHordeMap(), 0);
349 initWorldStates.Worldstates.emplace_back(handler->GetWorldStateAllianceUI(), 0);
350 initWorldStates.Worldstates.emplace_back(handler->GetWorldStateAllianceMap(), 0);
351 }
352 initWorldStates.Worldstates.emplace_back(ZM_MAP_GRAVEYARD_H, 0);
353 initWorldStates.Worldstates.emplace_back(ZM_MAP_GRAVEYARD_A, 0);
354 initWorldStates.Worldstates.emplace_back(ZM_MAP_GRAVEYARD_N, 0);
355 initWorldStates.Worldstates.emplace_back(ZM_MAP_HORDE_FLAG_READY, 0);
356 initWorldStates.Worldstates.emplace_back(ZM_MAP_HORDE_FLAG_NOT_READY, 0);
357 initWorldStates.Worldstates.emplace_back(ZM_MAP_ALLIANCE_FLAG_NOT_READY, 0);
358 initWorldStates.Worldstates.emplace_back(ZM_MAP_ALLIANCE_FLAG_READY, 0);
359 player->SendDirectMessage(initWorldStates.Write());
360}
361
363{
364 public:
366
367 OutdoorPvP* GetOutdoorPvP(Map* map) const override
368 {
369 return new OutdoorPvPZM(map);
370 }
371};
372
381
382// 18581 - Alliance Field Scout
383// 18564 - Horde Field Scout
385{
386 npc_zm_field_scout(Creature* creature) : ScriptedAI(creature) { }
387
389 {
390 OutdoorPvP* pvp = player->GetOutdoorPvP();
391 if (!pvp)
392 return false;
393
394 OutdoorPvPZM* zmPvp = reinterpret_cast<OutdoorPvPZM*>(pvp);
395 if (!zmPvp)
396 return false;
397
399 if (!gy)
400 return false;
401
402 if (!gy->GetFlagCarrierGUID().IsEmpty())
403 return false;
404
405 switch (me->GetEntry())
406 {
408 return player->GetTeam() == ALLIANCE && pvp->GetWorldState(ZM_MAP_ALLIANCE_FLAG_READY);
410 return player->GetTeam() == HORDE && pvp->GetWorldState(ZM_MAP_HORDE_FLAG_READY);
411 default:
412 break;
413 }
414 return true;
415 }
416
417 bool OnGossipHello(Player* player) override
418 {
422
423 InitGossipMenuFor(player, gossipMenuId);
424 if (CanObtainBanner(player))
426
428 SendGossipMenuFor(player, player->GetGossipTextId(me), me->GetGUID());
429 return true;
430 }
431
432 bool OnGossipSelect(Player* player, uint32 /*menuId*/, uint32 gossipListId) override
433 {
434 uint32 const action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
435 switch (action)
436 {
438 {
439 player->PlayerTalkClass->SendCloseGossip();
440
441 OutdoorPvP* pvp = player->GetOutdoorPvP();
442 if (!pvp)
443 return true;
444
445 OutdoorPvPZM* zmPvp = reinterpret_cast<OutdoorPvPZM*>(pvp);
446 if (!zmPvp)
447 return true;
448
450 if (!gy)
451 return true;
452
453 // if the flag is already taken, then return
454 if (!gy->GetFlagCarrierGUID().IsEmpty())
455 return true;
456
457 uint32 battleStandardSpell = ZM_BATTLE_STANDARD_H;
459 battleStandardSpell = ZM_BATTLE_STANDARD_A;
460
461 me->CastSpell(player, battleStandardSpell, true);
462 gy->SetFlagCarrierGUID(player->GetGUID());
463 gy->UpdateTowerState();
464 break;
465 }
467 player->GetSession()->SendListInventory(me->GetGUID());
468 break;
469 default:
470 break;
471 }
472 return true;
473 }
474};
475
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ TYPEID_PLAYER
Definition ObjectGuid.h:44
uint8 const OutdoorPvPZMBuffZonesNum
void AddSC_outdoorpvp_zm()
uint32 const OutdoorPvPZMBuffZones[OutdoorPvPZMBuffZonesNum]
uint32 const ZM_GRAVEYARD_ZONE
ZMFieldScoutMisc
@ GOSSIP_OPTION_FIELD_SCOUT_VENDOR
@ GOSSIP_MENU_FIELD_SCOUT_HORDE
@ GOSSIP_OPTION_FIELD_SCOUT_BATTLE_STANDARD
@ GOSSIP_MENU_FIELD_SCOUT_ALLIANCE
@ ZM_GO_ENTRY_BEACON_WEST
@ ZM_GO_ENTRY_BEACON_EAST
@ 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_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:33
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
void AddGossipItemFor(Player *player, GossipOptionNpc optionNpc, std::string text, uint32 sender, uint32 action)
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
void InitGossipMenuFor(Player *player, uint32 menuId)
@ GOSSIP_SENDER_MAIN
@ GOSSIP_ACTION_TRADE
@ GOSSIP_ACTION_INFO_DEF
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ ALLIANCE
@ HORDE
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
TypeID GetTypeId() const
Definition BaseEntity.h:166
virtual void HandleNeutralEventHorde(GameObject *controlZone)
Definition ZoneScript.h:58
virtual void HandleProgressEventAlliance(GameObject *controlZone)
Definition ZoneScript.h:57
virtual void HandleNeutralEventAlliance(GameObject *controlZone)
Definition ZoneScript.h:59
virtual void HandleProgressEventHorde(GameObject *controlZone)
Definition ZoneScript.h:56
virtual void HandleNeutralEvent(GameObject *controlZone)
Definition ZoneScript.h:60
Creature *const me
Definition CreatureAI.h:63
Definition Map.h:225
void Update(uint32 diff) override
void SetFlagCarrierGUID(ObjectGuid guid)
OPvPCapturePointZM_Graveyard(OutdoorPvP *pvp)
bool HandleDropFlag(Player *player, uint32 spellId) override
void SetBeaconState(uint32 controlling_team)
int32 HandleOpenGo(Player *player, GameObject *go) override
ObjectGuid GetFlagCarrierGUID() const
ObjectiveStates m_OldState
Definition OutdoorPvP.h:108
OutdoorPvP * m_PvP
Definition OutdoorPvP.h:112
ObjectiveStates m_State
Definition OutdoorPvP.h:109
virtual int32 HandleOpenGo(Player *player, GameObject *go)
bool IsEmpty() const
Definition ObjectGuid.h:362
void Clear()
Definition ObjectGuid.h:329
Player * ToPlayer()
Definition Object.h:126
uint32 GetEntry() const
Definition Object.h:89
OutdoorPvP * GetOutdoorPvP() const
Definition OutdoorPvP.h:121
void Update(uint32 diff) override
OPvPCapturePointZM_Graveyard * GetGraveyard()
void SetHordeTowersControlled(uint32 count)
uint32 GetAllianceTowersControlled() const
void HandleKillImpl(Player *player, Unit *killed) override
bool SetupOutdoorPvP() override
void HandlePlayerEnterZone(Player *player, uint32 zone) override
void HandlePlayerLeaveZone(Player *player, uint32 zone) override
uint32 GetHordeTowersControlled() const
void SetAllianceTowersControlled(uint32 count)
void SendRemoveWorldStates(Player *player) override
std::unique_ptr< OPvPCapturePointZM_Graveyard > m_Graveyard
uint32 m_HordeTowersControlled
OutdoorPvPZM(Map *map)
uint32 m_AllianceTowersControlled
OutdoorPvP * GetOutdoorPvP(Map *map) const override
virtual void HandlePlayerEnterZone(Player *player, uint32 zone)
uint32 m_TypeId
Definition OutdoorPvP.h:208
virtual void Update(uint32 diff)
int32 GetWorldState(int32 worldStateId) const
void TeamApplyBuff(TeamId team, uint32 spellId, uint32 spellId2=0)
void RegisterZone(uint32 zoneid)
void SetWorldState(int32 worldStateId, int32 value)
virtual void HandlePlayerLeaveZone(Player *player, uint32 zone)
ControlZoneHandlerMap ControlZoneHandlers
Definition OutdoorPvP.h:204
void SendDefenseMessage(uint32 zoneId, uint32 id)
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:6283
WorldSession * GetSession() const
Definition Player.h:2272
OutdoorPvP * GetOutdoorPvP() const
Definition Player.cpp:26206
uint32 GetGossipTextId(uint32 menuId, WorldObject *source)
Definition Player.cpp:14269
std::unique_ptr< PlayerMenu > PlayerTalkClass
Definition Player.h:2570
Team GetTeam() const
Definition Player.h:2423
Definition Unit.h:635
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
constexpr uint32 GetMapId() const
Definition Position.h:216
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
uint32 GetAreaId() const
Definition Object.h:333
uint32 GetZoneId() const
Definition Object.h:332
std::vector< WorldStateInfo > Worldstates
void SendListInventory(ObjectGuid guid)
void HandleProgressEventAlliance(GameObject *controlZone) override
uint32 GetWorldStateNeutralUI()
OutdoorPvPZM * GetOutdoorPvpZM()
uint32 GetWorldStateHordeMap()
void HandleNeutralEventAlliance(GameObject *controlZone) override
void HandleNeutralEvent(GameObject *controlZone) override
uint32 GetWorldStateAllianceUI()
uint32 GetWorldStateAllianceMap()
ZMControlZoneHandler(OutdoorPvPZM *pvp, uint32 textBeaconTakenHorde, uint32 textBeaconTakenAlliance, uint32 worldstateNeutralUi, uint32 worldstateNeutralMap, uint32 worldstateHordeUi, uint32 worldstateHordeMap, uint32 worldstateAllianceUi, uint32 worldstateAllianceMap)
uint32 GetWorldStateHordeUI()
void HandleNeutralEventHorde(GameObject *controlZone) override
uint32 GetWorldStateNeutralMap()
void HandleProgressEventHorde(GameObject *controlZone) override
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
npc_zm_field_scout(Creature *creature)
bool OnGossipSelect(Player *player, uint32, uint32 gossipListId) override
bool CanObtainBanner(Player *player)
bool OnGossipHello(Player *player) override