Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
OutdoorPvPZM.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "ScriptMgr.h"
7#include "OutdoorPvPZM.h"
8#include "ObjectMgr.h"
9#include "OutdoorPvPMgr.h"
10#include "Player.h"
11#include "Creature.h"
12#include "ObjectAccessor.h"
13#include "WorldPacket.h"
14#include "GossipDef.h"
15#include "World.h"
16
22
32
34{
35 m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].ui_tower_n), uint32(bool(m_TowerState & ZM_TOWERSTATE_N)));
36 m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].map_tower_n), uint32(bool(m_TowerState & ZM_TOWERSTATE_N)));
37 m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].ui_tower_a), uint32(bool(m_TowerState & ZM_TOWERSTATE_A)));
38 m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].map_tower_a), uint32(bool(m_TowerState & ZM_TOWERSTATE_A)));
39 m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].ui_tower_h), uint32(bool(m_TowerState & ZM_TOWERSTATE_H)));
40 m_PvP->SendUpdateWorldState(uint32(ZMBeaconInfo[m_TowerType].map_tower_h), uint32(bool(m_TowerState & ZM_TOWERSTATE_H)));
41}
42
44{
46 {
47 player->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_disp, 1);
48 uint32 phase = (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f);
49 player->SendUpdateWorldState(ZMBeaconInfo[m_TowerType].slider_pos, phase);
51 return true;
52 }
53 return false;
54}
55
61
63{
64 // if changing from controlling alliance to horde
66 {
67 if (uint32 alliance_towers = ((OutdoorPvPZM*)m_PvP)->GetAllianceTowersControlled())
68 ((OutdoorPvPZM*)m_PvP)->SetAllianceTowersControlled(--alliance_towers);
69 sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetSkyFireStringForDBCLocale(ZMBeaconLoseA[m_TowerType]));
70 }
71 // if changing from controlling horde to alliance
73 {
74 if (uint32 horde_towers = ((OutdoorPvPZM*)m_PvP)->GetHordeTowersControlled())
75 ((OutdoorPvPZM*)m_PvP)->SetHordeTowersControlled(--horde_towers);
76 sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetSkyFireStringForDBCLocale(ZMBeaconLoseH[m_TowerType]));
77 }
78
79 switch (m_State)
80 {
82 {
84 uint32 alliance_towers = ((OutdoorPvPZM*)m_PvP)->GetAllianceTowersControlled();
85 if (alliance_towers < ZM_NUM_BEACONS)
86 ((OutdoorPvPZM*)m_PvP)->SetAllianceTowersControlled(++alliance_towers);
87 sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetSkyFireStringForDBCLocale(ZMBeaconCaptureA[m_TowerType]));
88 break;
89 }
91 {
93 uint32 horde_towers = ((OutdoorPvPZM*)m_PvP)->GetHordeTowersControlled();
94 if (horde_towers < ZM_NUM_BEACONS)
95 ((OutdoorPvPZM*)m_PvP)->SetHordeTowersControlled(++horde_towers);
96 sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetSkyFireStringForDBCLocale(ZMBeaconCaptureH[m_TowerType]));
97 break;
98 }
105 break;
106 }
107
109}
110
112{
113 // send this too, sometimes the slider disappears, dunno why :(
115 // send these updates to only the ones in this objective
116 uint32 phase = (uint32)ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f);
119}
120
122{
123 bool changed = OutdoorPvP::Update(diff);
124 if (changed)
125 {
127 m_GraveYard->SetBeaconState(ALLIANCE);
129 m_GraveYard->SetBeaconState(HORDE);
130 else
131 m_GraveYard->SetBeaconState(0);
132 }
133 return changed;
134}
135
137{
138 if (player->GetTeam() == ALLIANCE)
139 {
140 if (m_GraveYard->GetGraveYardState() & ZM_GRAVEYARD_A)
141 player->CastSpell(player, ZM_CAPTURE_BUFF, true);
142 }
143 else
144 {
145 if (m_GraveYard->GetGraveYardState() & ZM_GRAVEYARD_H)
146 player->CastSpell(player, ZM_CAPTURE_BUFF, true);
147 }
149}
150
152{
153 // remove buffs
155 // remove flag
159}
160
168
170{
173
174 // add the zones affected by the pvp buff
175 for (uint8 i = 0; i < OutdoorPvPZMBuffZonesNum; ++i)
177
181 AddCapturePoint(m_GraveYard); // though the update function isn't used, the handleusego is!
182
183 return true;
184}
185
187{
188 if (killed->GetTypeId() != TypeID::TYPEID_PLAYER)
189 return;
190
191 if (player->GetTeam() == ALLIANCE && killed->ToPlayer()->GetTeam() != ALLIANCE)
192 player->CastSpell(player, ZM_AlliancePlayerKillReward, true);
193 else if (player->GetTeam() == HORDE && killed->ToPlayer()->GetTeam() != HORDE)
194 player->CastSpell(player, ZM_HordePlayerKillReward, true);
195}
196
198{
199 bool retval = m_State != m_OldState;
201 return retval;
202}
203
205{
206 int32 retval = OPvPCapturePoint::HandleOpenGo(player, guid);
207 if (retval >= 0)
208 {
210 {
212 sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetSkyFireStringForDBCLocale(LANG_OPVP_ZM_LOSE_GY_H));
214 DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant
216 sObjectMgr->RemoveGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE); // rem gy
217 sObjectMgr->AddGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE, false); // add gy
218 m_PvP->TeamApplyBuff(TEAM_ALLIANCE, ZM_CAPTURE_BUFF);
220 sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetSkyFireStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_A));
221 }
223 {
225 sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetSkyFireStringForDBCLocale(LANG_OPVP_ZM_LOSE_GY_A));
227 DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant
229 sObjectMgr->RemoveGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE); // rem gy
230 sObjectMgr->AddGraveYardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE, false); // add gy
231 m_PvP->TeamApplyBuff(TEAM_HORDE, ZM_CAPTURE_BUFF);
233 sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetSkyFireStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_H));
234 }
236 }
237 return retval;
238}
239
252
264
276
278{
279 // nothing to do here
280 if (m_BothControllingFaction == controlling_faction)
281 return;
282 m_BothControllingFaction = controlling_faction;
283
284 switch (controlling_faction)
285 {
286 case ALLIANCE:
287 // if ally already controls the gy and taken back both beacons, return, nothing to do for us
289 return;
290 // ally doesn't control the gy, but controls the side beacons -> add gossip option, add neutral banner
291 break;
292 case HORDE:
293 // if horde already controls the gy and taken back both beacons, return, nothing to do for us
295 return;
296 // horde doesn't control the gy, but controls the side beacons -> add gossip option, add neutral banner
297 break;
298 default:
299 // if the graveyard is not neutral, then leave it that way
300 // if the graveyard is neutral, then we have to dispel the buff from the flag carrier
302 {
303 // gy was neutral, thus neutral banner was spawned, it is possible that someone was taking the flag to the gy
305 {
306 // remove flag from carrier, reset flag carrier guid
308 if (p)
309 {
312 }
314 }
315 }
316 break;
317 }
318 // send worldstateupdate
320}
321
323{
324 uint64 guid = c->GetGUID();
325 std::map<uint64, uint32>::iterator itr = m_CreatureTypes.find(guid);
326 if (itr != m_CreatureTypes.end())
327 {
329 return true;
331 return true;
332 }
333 return false;
334}
335
337{
338 std::map<uint64, uint32>::iterator itr = m_CreatureTypes.find(guid);
339 if (itr != m_CreatureTypes.end())
340 {
342 if (!cr)
343 return true;
344 // if the flag is already taken, then return
346 return true;
347 if (itr->second == ZM_ALLIANCE_FIELD_SCOUT)
348 {
349 cr->CastSpell(player, ZM_BATTLE_STANDARD_A, true);
350 m_FlagCarrierGUID = player->GetGUID();
351 }
352 else if (itr->second == ZM_HORDE_FIELD_SCOUT)
353 {
354 cr->CastSpell(player, ZM_BATTLE_STANDARD_H, true);
355 m_FlagCarrierGUID = player->GetGUID();
356 }
359 return true;
360 }
361 return false;
362}
363
365{
366 switch (spellId)
367 {
370 return true;
373 return true;
374 }
375 return false;
376}
377
382
387
392
397
402
404{
406
407 for (OPvPCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
408 {
409 itr->second->FillInitialWorldStates(builder);
410 }
411}
412
414{
441}
442
444{
445 public:
447
449 {
450 return new OutdoorPvPZM();
451 }
452};
453
455{
457}
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
@ LANG_OPVP_ZM_CAPTURE_GY_A
Definition Language.h:1172
@ LANG_OPVP_ZM_LOSE_GY_A
Definition Language.h:1178
@ LANG_OPVP_ZM_LOSE_GY_H
Definition Language.h:1177
@ LANG_OPVP_ZM_CAPTURE_GY_H
Definition Language.h:1171
@ TYPEID_PLAYER
Definition Object.h:55
#define sObjectMgr
Definition ObjectMgr.h:1617
@ OUTDOOR_PVP_ZM
Definition OutdoorPvP.h:21
@ OBJECTIVESTATE_HORDE
Definition OutdoorPvP.h:31
@ OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE
Definition OutdoorPvP.h:33
@ OBJECTIVESTATE_ALLIANCE
Definition OutdoorPvP.h:30
@ OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE
Definition OutdoorPvP.h:32
@ OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE
Definition OutdoorPvP.h:35
@ OBJECTIVESTATE_NEUTRAL
Definition OutdoorPvP.h:29
@ OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE
Definition OutdoorPvP.h:34
void AddSC_outdoorpvp_zm()
const creature_type ZM_AllianceFieldScout
const uint32 ZM_GRAVEYARD_ZONE
const uint32 ZMBeaconLoseH[ZM_NUM_BEACONS]
const go_type ZMCapturePoints[ZM_NUM_BEACONS]
const uint32 ZMBeaconCaptureH[ZM_NUM_BEACONS]
const uint32 OutdoorPvPZMBuffZones[OutdoorPvPZMBuffZonesNum]
@ ZM_TOWERSTATE_N
@ ZM_TOWERSTATE_H
@ ZM_TOWERSTATE_A
const go_type ZM_Banner_H
@ ZM_GRAVEYARD_H
@ ZM_GRAVEYARD_N
@ ZM_GRAVEYARD_A
ZM_BeaconType
@ ZM_BEACON_EAST
@ ZM_BEACON_WEST
@ ZM_NUM_BEACONS
const go_type ZM_Banner_A
const go_type ZM_Banner_N
const creature_type ZM_HordeFieldScout
@ ZM_HORDE_FIELD_SCOUT
@ ZM_ALLIANCE_FIELD_SCOUT
@ ZM_BATTLE_STANDARD_H
@ ZM_BATTLE_STANDARD_A
@ ZM_CAPTURE_BUFF
@ ZM_AlliancePlayerKillReward
@ ZM_HordePlayerKillReward
const uint32 ZMBeaconLoseA[ZM_NUM_BEACONS]
const uint32 ZM_GRAVEYARD_ID
const uint32 ZMBeaconCaptureA[ZM_NUM_BEACONS]
const zm_beacon ZMBeaconInfo[ZM_NUM_BEACONS]
@ ZM_MAP_TOWER_EAST_A
@ ZM_MAP_HORDE_FLAG_NOT_READY
@ ZM_UI_TOWER_WEST_N
@ ZM_UI_TOWER_WEST_A
@ ZM_UI_TOWER_SLIDER_N_W
@ ZM_UI_TOWER_SLIDER_POS_W
@ ZM_WORLDSTATE_UNK_1
@ ZM_MAP_ALLIANCE_FLAG_READY
@ ZM_MAP_GRAVEYARD_A
@ ZM_MAP_TOWER_WEST_N
@ ZM_MAP_TOWER_WEST_A
@ ZM_UI_TOWER_SLIDER_DISPLAY_W
@ ZM_MAP_GRAVEYARD_N
@ ZM_MAP_GRAVEYARD_H
@ ZM_UI_TOWER_EAST_H
@ ZM_MAP_TOWER_EAST_N
@ ZM_UI_TOWER_SLIDER_POS_E
@ ZM_UI_TOWER_SLIDER_DISPLAY_E
@ ZM_UI_TOWER_WEST_H
@ ZM_MAP_TOWER_WEST_H
@ ZM_MAP_HORDE_FLAG_READY
@ ZM_UI_TOWER_SLIDER_N_E
@ ZM_MAP_ALLIANCE_FLAG_NOT_READY
@ ZM_UI_TOWER_EAST_A
@ ZM_UI_TOWER_EAST_N
@ ZM_MAP_TOWER_EAST_H
const uint8 OutdoorPvPZMBuffZonesNum
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ ALLIANCE
@ HORDE
static T * Find(uint64 guid)
OPvPCapturePoint(OutdoorPvP *pvp)
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 teamval, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay=0)
virtual int32 HandleOpenGo(Player *player, uint64 guid)
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)
ObjectiveStates m_OldState
Definition OutdoorPvP.h:158
OutdoorPvP * m_PvP
Definition OutdoorPvP.h:165
ObjectiveStates m_State
Definition OutdoorPvP.h:159
uint32 m_neutralValuePct
Definition OutdoorPvP.h:162
void SendUpdateWorldState(uint32 field, uint32 value)
virtual void HandlePlayerLeave(Player *player)
virtual bool HandlePlayerEnter(Player *player)
std::map< uint64, uint32 > m_CreatureTypes
Definition OutdoorPvP.h:172
bool DelObject(uint32 type)
void HandlePlayerLeave(Player *player) OVERRIDE
void ChangeState() OVERRIDE
OPvPCapturePointZM_Beacon(OutdoorPvP *pvp, ZM_BeaconType type)
bool HandlePlayerEnter(Player *player) OVERRIDE
void SendChangePhase() OVERRIDE
void FillInitialWorldStates(WorldStateBuilder &builder) OVERRIDE
bool HandleDropFlag(Player *player, uint32 spellId) OVERRIDE
bool HandleGossipOption(Player *player, uint64 guid, uint32 gossipid) OVERRIDE
int32 HandleOpenGo(Player *player, uint64 guid) OVERRIDE
bool Update(uint32 diff) OVERRIDE
OPvPCapturePointZM_GraveYard(OutdoorPvP *pvp)
void FillInitialWorldStates(WorldStateBuilder &builder) OVERRIDE
void SetBeaconState(uint32 controlling_team)
bool CanTalkTo(Player *player, Creature *creature, GossipMenuItems const &gso) OVERRIDE
static Player * FindPlayer(uint64)
uint64 GetGUID() const
Definition Object.h:119
Player * ToPlayer()
Definition Object.h:204
TypeID GetTypeId() const
Definition Object.h:131
OutdoorPvP * GetOutdoorPvP() const OVERRIDE
virtual void HandlePlayerEnterZone(Player *player, uint32 zone)
OPvPCapturePointMap m_capturePoints
Definition OutdoorPvP.h:238
uint32 m_TypeId
Definition OutdoorPvP.h:242
virtual bool Update(uint32 diff)
void RegisterZone(uint32 zoneid)
virtual void HandlePlayerLeaveZone(Player *player, uint32 zone)
void AddCapturePoint(OPvPCapturePoint *cp)
Definition OutdoorPvP.h:256
OutdoorPvPScript(const char *name)
bool SetupOutdoorPvP() OVERRIDE
void SetHordeTowersControlled(uint32 count)
void SendRemoveWorldStates(Player *player) OVERRIDE
void HandleKillImpl(Player *player, Unit *killed) OVERRIDE
void FillInitialWorldStates(WorldStateBuilder &builder) OVERRIDE
uint32 GetAllianceTowersControlled() const
bool Update(uint32 diff) OVERRIDE
uint32 GetHordeTowersControlled() const
void HandlePlayerEnterZone(Player *player, uint32 zone) OVERRIDE
void SetAllianceTowersControlled(uint32 count)
uint32 m_HordeTowersControlled
void HandlePlayerLeaveZone(Player *player, uint32 zone) OVERRIDE
OPvPCapturePointZM_GraveYard * m_GraveYard
uint32 m_AllianceTowersControlled
uint32 GetTeam() const
Definition Player.h:2527
void SendUpdateWorldState(uint32 Field, uint32 Value)
Definition Player.cpp:9734
PlayerMenu * PlayerTalkClass
Definition Player.h:2680
void SendCloseGossip() const
Definition Unit.h:1367
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID=0, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
void AppendState(uint32 worldstate, uint32 value)
#define sWorld
Definition World.h:910