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

#include "BattlefieldWG.h"

Inheritance diagram for BattlefieldWG:
Battlefield ZoneScript

Public Member Functions

 ~BattlefieldWG () override
 
void OnBattleStart () override
 Called when the battle start. More...
 
void OnBattleEnd (bool endByTimer) override
 Called when battle end. More...
 
void OnStartGrouping () override
 Called when grouping starts (15 minutes before battlestart) More...
 
void OnPlayerJoinWar (Player *player) override
 Called when player accept invite to join battle. More...
 
void OnPlayerLeaveWar (Player *player) override
 Called when player left the battle. More...
 
void OnPlayerLeaveZone (Player *player) override
 Called when player left the WG zone. More...
 
void OnPlayerEnterZone (Player *player) override
 Called when player enters in WG zone. More...
 
bool Update (uint32 diff) override
 Called for update battlefield data. More...
 
void OnCreatureCreate (Creature *creature) override
 Called when a creature is created. More...
 
void OnCreatureRemove (Creature *creature) override
 Called when a creature is removed. More...
 
void OnGameObjectCreate (GameObject *go) override
 Called when a gameobject is created. More...
 
void BrokenWallOrTower (TeamId team)
 Called when a wall/tower is broken. More...
 
void UpdateDamagedTowerCount (TeamId team)
 Called when a tower is damaged. More...
 
void UpdatedDestroyedTowerCount (TeamId team, GameObject *go)
 Called when tower is broken. More...
 
void RemoveAurasFromPlayer (Player *player)
 
bool SetupBattlefield () override
 Called when battlefield is setup, at server start. More...
 
GameObjectGetRelic ()
 Return pointer to relic object. More...
 
bool CanInteractWithRelic ()
 Define relic object. More...
 
void SetRelicInteractible (bool allow)
 Define if player can interact with the relic. More...
 
void UpdateCounterVehicle (bool init)
 Vehicle world states update. More...
 
void UpdateVehicleCountWG ()
 
void CapturePointTaken (uint32 areaId)
 
void SendInitWorldStatesTo (Player *player)
 
void SendInitWorldStatesToAll () override
 Send all worldstate data to all player in zone. More...
 
void FillInitialWorldStates (WorldPacket &data) override
 
void HandleKill (Player *killer, Unit *victim) override
 Called when a Unit is kill in battlefield zone. More...
 
void OnUnitDeath (Unit *unit) override
 
void PromotePlayer (Player *killer)
 
uint32 GetHonorBuff (int32 stack) const
 
void UpdateTenacity ()
 
void AddUpdateTenacity (Player *player)
 
void RemoveUpdateTenacity (Player *player)
 
void ProcessEvent (WorldObject *obj, uint32 eventId) override
 
bool FindAndRemoveVehicleFromList (Unit *vehicle)
 
uint8 GetSpiritGraveyardId (uint32 areaId) const
 
uint32 GetAreaByGraveyardId (uint8 gId) const
 
uint32 GetData (uint32 data) const override
 
bool IsKeepNpc (uint32 entry)
 
- Public Member Functions inherited from Battlefield
 Battlefield ()
 Constructor. More...
 
 ~Battlefield () override
 Destructor. More...
 
virtual bool SetupBattlefield ()
 Call this to init the Battlefield. More...
 
void SendUpdateWorldState (uint32 field, uint32 value)
 Update data of a worldstate to all players present in zone. More...
 
virtual bool Update (uint32 diff)
 Called every time for update bf data and time. More...
 
void InvitePlayersInZoneToQueue ()
 Invite all players in zone to join the queue, called x minutes before battle start in Update() More...
 
void InvitePlayersInQueueToWar ()
 Invite all players in queue to join battle on battle start. More...
 
void InvitePlayersInZoneToWar ()
 Invite all players in zone to join battle on battle start. More...
 
virtual void HandleKill (Player *, Unit *)
 Called when a Unit is kill in battlefield zone. More...
 
uint32 GetTypeId ()
 
uint32 GetZoneId ()
 
void TeamApplyBuff (TeamId team, uint32 spellId, uint32 spellId2=0)
 
bool IsWarTime ()
 Return true if battle is start, false if battle is not started. More...
 
void ToggleBattlefield (bool enable)
 Enable or Disable battlefield. More...
 
bool IsEnabled ()
 Return if battlefield is enable. More...
 
void KickPlayerFromBattlefield (ObjectGuid guid)
 Kick player from battlefield and teleport him to kick-point location. More...
 
void HandlePlayerEnterZone (Player *player, uint32 zone)
 Called when player (player) enter in zone. More...
 
void HandlePlayerLeaveZone (Player *player, uint32 zone)
 Called when player (player) leave the zone. More...
 
uint64 GetData64 (uint32 dataId) const override
 
void SetData64 (uint32 dataId, uint64 value) override
 
uint32 GetData (uint32 dataId) const override
 
void SetData (uint32 dataId, uint32 value) override
 
virtual void UpdateData (uint32 index, int32 pad)
 
TeamId GetDefenderTeam ()
 
TeamId GetAttackerTeam ()
 
TeamId GetOtherTeam (TeamId team)
 
void SetDefenderTeam (TeamId team)
 
GroupGetFreeBfRaid (TeamId TeamId)
 Find a not full battlefield group, if there is no, create one. More...
 
GroupGetGroupPlayer (ObjectGuid guid, TeamId TeamId)
 Return battlefield group where player is. More...
 
bool AddOrSetPlayerToCorrectBfGroup (Player *player)
 Force player to join a battlefield group. More...
 
GraveyardStruct const * GetClosestGraveyard (Player *player)
 
virtual void AddPlayerToResurrectQueue (ObjectGuid npc_guid, ObjectGuid player_guid)
 
void RemovePlayerFromResurrectQueue (ObjectGuid player_guid)
 
void SetGraveyardNumber (uint32 number)
 
BfGraveyardGetGraveyardById (uint32 id) const
 
CreatureSpawnCreature (uint32 entry, float x, float y, float z, float o, TeamId teamId)
 
CreatureSpawnCreature (uint32 entry, Position pos, TeamId teamId)
 
GameObjectSpawnGameObject (uint32 entry, float x, float y, float z, float o)
 
CreatureGetCreature (ObjectGuid const guid)
 
GameObjectGetGameObject (ObjectGuid const guid)
 
virtual void OnBattleStart ()
 Called on start. More...
 
virtual void OnBattleEnd (bool)
 Called at the end of battle. More...
 
virtual void OnStartGrouping ()
 Called x minutes before battle start when player in zone are invite to join queue. More...
 
virtual void OnPlayerJoinWar (Player *)
 Called when a player accept to join the battle. More...
 
virtual void OnPlayerLeaveWar (Player *)
 Called when a player leave the battle. More...
 
virtual void OnPlayerLeaveZone (Player *)
 Called when a player leave battlefield zone. More...
 
virtual void OnPlayerEnterZone (Player *)
 Called when a player enter in battlefield zone. More...
 
void SendWarning (uint8 id, WorldObject const *target=nullptr)
 
void PlayerAcceptInviteToQueue (Player *player)
 
void PlayerAcceptInviteToWar (Player *player)
 
uint32 GetBattleId ()
 
void AskToLeaveQueue (Player *player)
 
void PlayerAskToLeave (Player *player)
 
virtual void SendInitWorldStatesToAll ()=0
 Send all worldstate data to all player in zone. More...
 
virtual void FillInitialWorldStates (WorldPacket &)=0
 
bool CanFlyIn ()
 Return if we can use mount in battlefield. More...
 
void SendAreaSpiritHealerQueryOpcode (Player *player, const ObjectGuid &guid)
 
void StartBattle ()
 
void EndBattle (bool endByTimer)
 
void HideNpc (Creature *creature)
 
void ShowNpc (Creature *creature, bool aggressive)
 
GraveyardVect GetGraveyardVector ()
 
uint32 GetTimer ()
 
void SetTimer (uint32 timer)
 
void DoPlaySoundToAll (uint32 SoundID)
 
void InvitePlayerToQueue (Player *player)
 
void InvitePlayerToWar (Player *player)
 
void InitStalker (uint32 entry, float x, float y, float z, float o)
 
- 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)
 

Protected Attributes

bool m_isRelicInteractible
 
Workshop WorkshopsList
 
GameObjectSet DefenderPortalList
 
GameObjectSet m_KeepGameObject [2]
 
GameObjectBuilding BuildingsInZone
 
GuidUnorderedSet m_vehicles [2]
 
GuidUnorderedSet CanonList
 
GuidUnorderedSet KeepCreature [2]
 
GuidUnorderedSet OutsideCreature [2]
 
GuidUnorderedSet m_updateTenacityList
 
int32 m_tenacityStack
 
uint32 m_tenacityUpdateTimer
 
uint32 m_saveTimer
 
ObjectGuid m_titansRelic
 
- Protected Attributes inherited from Battlefield
ObjectGuid StalkerGuid
 
uint32 m_Timer
 
bool m_IsEnabled
 
bool m_isActive
 
TeamId m_DefenderTeam
 
BfCapturePointVector m_capturePoints
 
GuidUnorderedSet m_players [PVP_TEAMS_COUNT]
 
GuidUnorderedSet m_PlayersInQueue [PVP_TEAMS_COUNT]
 
GuidUnorderedSet m_PlayersInWar [PVP_TEAMS_COUNT]
 
PlayerTimerMap m_InvitedPlayers [PVP_TEAMS_COUNT]
 
PlayerTimerMap m_PlayersWillBeKick [PVP_TEAMS_COUNT]
 
uint32 m_TypeId
 
uint32 m_BattleId
 
uint32 m_ZoneId
 
uint32 m_MapId
 
Mapm_Map
 
uint32 m_MaxPlayer
 
uint32 m_MinPlayer
 
uint32 m_MinLevel
 
uint32 m_BattleTime
 
uint32 m_NoWarBattleTime
 
uint32 m_RestartAfterCrash
 
uint32 m_TimeForAcceptInvite
 
uint32 m_uiKickDontAcceptTimer
 
WorldLocation KickPosition
 
uint32 m_uiKickAfkPlayersTimer
 
GraveyardVect m_GraveyardList
 
uint32 m_LastResurectTimer
 
uint32 m_StartGroupingTimer
 
bool m_StartGrouping
 
GuidUnorderedSet m_Groups [PVP_TEAMS_COUNT]
 
std::vector< uint64m_Data64
 
std::vector< uint32m_Data32
 

Additional Inherited Members

- Public Types inherited from Battlefield
typedef std::vector< BfCapturePoint * > BfCapturePointVector
 typedef of map witch store capturepoint and the associate gameobject entry More...
 
- Protected Member Functions inherited from Battlefield
void KickAfkPlayers ()
 
virtual void SendRemoveWorldStates (Player *)
 
void BroadcastPacketToZone (WorldPacket const *data) const
 
void BroadcastPacketToQueue (WorldPacket const *data) const
 
void BroadcastPacketToWar (WorldPacket const *data) const
 
void AddCapturePoint (BfCapturePoint *cp)
 
void RegisterZone (uint32 zoneid)
 
bool HasPlayer (Player *player) const
 
void TeamCastSpell (TeamId team, int32 spellId)
 

Detailed Description

Constructor & Destructor Documentation

◆ ~BattlefieldWG()

BattlefieldWG::~BattlefieldWG ( )
override
Todo:

: Implement proper support for vehicle+player teleportation

: Use spell victory/defeat in wg instead of RewardMarkOfHonor() && RewardHonor

: Add proper implement of achievement

34{
35 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
36 delete *itr;
37
38 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
39 delete *itr;
40}
Workshop WorkshopsList
Definition: BattlefieldWG.h:461
GameObjectBuilding BuildingsInZone
Definition: BattlefieldWG.h:465

References BuildingsInZone, and WorkshopsList.

Member Function Documentation

◆ AddUpdateTenacity()

void BattlefieldWG::AddUpdateTenacity ( Player player)
1113{
1114 m_updateTenacityList.insert(player->GetGUID());
1115}
GuidUnorderedSet m_updateTenacityList
Definition: BattlefieldWG.h:471
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109

References Object::GetGUID(), and m_updateTenacityList.

Referenced by OnPlayerJoinWar().

◆ BrokenWallOrTower()

void BattlefieldWG::BrokenWallOrTower ( TeamId  team)

Called when a wall/tower is broken.

  • Update quest
987{
988 // might be some use for this in the future. old code commented out below. KL
989 /* if (team == GetDefenderTeam())
990 {
991 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
992 {
993 if (Player* player = ObjectAccessor::FindPlayer(*itr))
994 IncrementQuest(player, WGQuest[player->GetTeamId()][2], true);
995 }
996 }*/
997}

Referenced by BfWGGameObjectBuilding::Destroyed().

◆ CanInteractWithRelic()

bool BattlefieldWG::CanInteractWithRelic ( )
inline

Define relic object.

Check if players can interact with the relic (Only if the last door has been broken)

396{ return m_isRelicInteractible; }
bool m_isRelicInteractible
Definition: BattlefieldWG.h:459

References m_isRelicInteractible.

Referenced by ProcessEvent().

◆ CapturePointTaken()

void BattlefieldWG::CapturePointTaken ( uint32  areaId)
336{
337 for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
338 for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
339 if (Player* player = ObjectAccessor::FindPlayer(*itr))
340 if (player->GetAreaId() == areaId)
341 player->UpdateAreaDependentAuras(areaId);
342}
std::uint8_t uint8
Definition: Define.h:109
uint8 constexpr PVP_TEAMS_COUNT
Definition: SharedDefines.h:3445
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
GuidUnorderedSet m_players[PVP_TEAMS_COUNT]
Definition: Battlefield.h:375
Definition: Player.h:1064

References ObjectAccessor::FindPlayer(), Battlefield::m_players, and PVP_TEAMS_COUNT.

Referenced by WGWorkshop::GiveControlTo().

◆ FillInitialWorldStates()

void BattlefieldWG::FillInitialWorldStates ( WorldPacket data)
overridevirtual

Implements Battlefield.

937{
940 data << uint32(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) << uint32(IsWarTime() ? 0 : 1); // Note: cleanup these two, their names look awkward
942
943 for (uint32 i = 0; i < 2; ++i)
944 data << ClockWorldState[i] << uint32(GameTime::GetGameTime().count() + (m_Timer / 1000));
945
950
955
956 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
957 data << (*itr)->m_WorldState << (*itr)->m_State;
958
959 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
960 if (*itr)
961 data << WorkshopsData[(*itr)->workshopId].worldstate << (*itr)->state;
962}
std::uint32_t uint32
Definition: Define.h:107
const WGWorkshopData WorkshopsData[WG_MAX_WORKSHOP]
Definition: BattlefieldWG.h:1074
@ WORLDSTATE_HORDE_KEEP_DEFENDED
Definition: BattlefieldWG.h:530
@ WORLDSTATE_ALLIANCE_KEEP_DEFENDED
Definition: BattlefieldWG.h:532
@ WORLDSTATE_ALLIANCE_KEEP_CAPTURED
Definition: BattlefieldWG.h:531
@ WORLDSTATE_HORDE_KEEP_CAPTURED
Definition: BattlefieldWG.h:529
const uint32 ClockWorldState[2]
Definition: BattlefieldWG.h:42
@ BATTLEFIELD_WG_DATA_VEHICLE_A
Definition: BattlefieldWG.h:98
@ BATTLEFIELD_WG_DATA_MAX_VEHICLE_A
Definition: BattlefieldWG.h:96
@ BATTLEFIELD_WG_DATA_VEHICLE_H
Definition: BattlefieldWG.h:99
@ BATTLEFIELD_WG_DATA_MAX_VEHICLE_H
Definition: BattlefieldWG.h:97
@ BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H
Definition: BattlefieldWG.h:105
@ BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE
Definition: BattlefieldWG.h:112
@ BATTLEFIELD_WG_WORLD_STATE_ACTIVE
Definition: BattlefieldWG.h:109
@ BATTLEFIELD_WG_WORLD_STATE_VEHICLE_A
Definition: BattlefieldWG.h:107
@ BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_H
Definition: BattlefieldWG.h:106
@ BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_A
Definition: BattlefieldWG.h:108
@ BATTLEFIELD_WG_WORLD_STATE_DEFENDER
Definition: BattlefieldWG.h:110
@ BATTLEFIELD_WG_WORLD_STATE_ATTACKER
Definition: BattlefieldWG.h:111
#define sWorld
Definition: World.h:444
Seconds GetGameTime()
Definition: GameTime.cpp:38
uint32 m_Timer
Definition: Battlefield.h:366
TeamId GetDefenderTeam()
Definition: Battlefield.h:277
bool IsWarTime()
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:249
TeamId GetAttackerTeam()
Definition: Battlefield.h:278
uint32 GetData(uint32 data) const override
Definition: BattlefieldWG.cpp:913
uint32 worldstate
Definition: BattlefieldWG.h:1069

References BATTLEFIELD_WG_DATA_MAX_VEHICLE_A, BATTLEFIELD_WG_DATA_MAX_VEHICLE_H, BATTLEFIELD_WG_DATA_VEHICLE_A, BATTLEFIELD_WG_DATA_VEHICLE_H, BATTLEFIELD_WG_WORLD_STATE_ACTIVE, BATTLEFIELD_WG_WORLD_STATE_ATTACKER, BATTLEFIELD_WG_WORLD_STATE_DEFENDER, BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_A, BATTLEFIELD_WG_WORLD_STATE_MAX_VEHICLE_H, BATTLEFIELD_WG_WORLD_STATE_SHOW_WORLDSTATE, BATTLEFIELD_WG_WORLD_STATE_VEHICLE_A, BATTLEFIELD_WG_WORLD_STATE_VEHICLE_H, BuildingsInZone, ClockWorldState, Battlefield::GetAttackerTeam(), GetData(), Battlefield::GetDefenderTeam(), GameTime::GetGameTime(), Battlefield::IsWarTime(), Battlefield::m_Timer, sWorld, WorkshopsData, WorkshopsList, WGWorkshopData::worldstate, WORLDSTATE_ALLIANCE_KEEP_CAPTURED, WORLDSTATE_ALLIANCE_KEEP_DEFENDED, WORLDSTATE_HORDE_KEEP_CAPTURED, and WORLDSTATE_HORDE_KEEP_DEFENDED.

Referenced by SendInitWorldStatesTo().

◆ FindAndRemoveVehicleFromList()

bool BattlefieldWG::FindAndRemoveVehicleFromList ( Unit vehicle)
774{
775 for (uint32 itr = 0; itr < 2; ++itr)
776 {
777 if (m_vehicles[itr].find(vehicle->GetGUID()) != m_vehicles[itr].end())
778 {
779 //m_vehicles[itr].erase(vehicle->GetGUID());
780 if (itr == TEAM_HORDE)
782 else
784 return true;
785 }
786 }
787 return false;
788}
@ TEAM_HORDE
Definition: SharedDefines.h:761
GuidUnorderedSet m_vehicles[2]
Definition: BattlefieldWG.h:467
Definition: UpdateData.h:52

References BATTLEFIELD_WG_DATA_VEHICLE_A, BATTLEFIELD_WG_DATA_VEHICLE_H, Object::GetGUID(), m_vehicles, and TEAM_HORDE.

Referenced by OnUnitDeath().

◆ GetAreaByGraveyardId()

uint32 BattlefieldWG::GetAreaByGraveyardId ( uint8  gId) const
540{
541 switch (gId)
542 {
551 }
552
553 return 0;
554}
@ AREA_THE_SUNKEN_RING
Definition: BattlefieldWG.h:121
@ AREA_EASTPARK_WORKSHOP
Definition: BattlefieldWG.h:124
@ AREA_THE_BROKEN_TEMPLE
Definition: BattlefieldWG.h:122
@ AREA_WESTPARK_WORKSHOP
Definition: BattlefieldWG.h:123
@ BATTLEFIELD_WG_GY_WORKSHOP_NE
Definition: BattlefieldWG.h:146
@ BATTLEFIELD_WG_GY_WORKSHOP_SW
Definition: BattlefieldWG.h:149
@ BATTLEFIELD_WG_GY_WORKSHOP_SE
Definition: BattlefieldWG.h:148
@ BATTLEFIELD_WG_GY_WORKSHOP_NW
Definition: BattlefieldWG.h:147

References AREA_EASTPARK_WORKSHOP, AREA_THE_BROKEN_TEMPLE, AREA_THE_SUNKEN_RING, AREA_WESTPARK_WORKSHOP, BATTLEFIELD_WG_GY_WORKSHOP_NE, BATTLEFIELD_WG_GY_WORKSHOP_NW, BATTLEFIELD_WG_GY_WORKSHOP_SE, and BATTLEFIELD_WG_GY_WORKSHOP_SW.

Referenced by WGWorkshop::GiveControlTo().

◆ GetData()

uint32 BattlefieldWG::GetData ( uint32  data) const
overridevirtual

Reimplemented from Battlefield.

914{
915 // xinef: little hack, same area for default horde graveyard
916 // this graveyard is the one of broken temple!
917 if (data == AREA_THE_CHILLED_QUAGMIRE)
919
920 switch (data)
921 {
922 // Used to determine when the phasing spells must be casted
923 // See: SpellArea::IsFitToRequirements
928 // Graveyards and Workshops are controlled by the same team.
929 if (BfGraveyard const* graveyard = GetGraveyardById(GetSpiritGraveyardId(data)))
930 return graveyard->GetControlTeamId();
931 }
932
933 return Battlefield::GetData(data);
934}
@ AREA_THE_CHILLED_QUAGMIRE
Definition: BattlefieldWG.h:126
Definition: Battlefield.h:148
uint32 GetData(uint32 dataId) const override
Definition: Battlefield.h:272
BfGraveyard * GetGraveyardById(uint32 id) const
Definition: Battlefield.cpp:581
uint8 GetSpiritGraveyardId(uint32 areaId) const
Definition: BattlefieldWG.cpp:513

References AREA_EASTPARK_WORKSHOP, AREA_THE_BROKEN_TEMPLE, AREA_THE_CHILLED_QUAGMIRE, AREA_THE_SUNKEN_RING, AREA_WESTPARK_WORKSHOP, Battlefield::GetData(), Battlefield::GetGraveyardById(), and GetSpiritGraveyardId().

Referenced by FillInitialWorldStates(), OnBattleEnd(), OnCreatureCreate(), OnPlayerJoinWar(), UpdatedDestroyedTowerCount(), and UpdateVehicleCountWG().

◆ GetHonorBuff()

uint32 BattlefieldWG::GetHonorBuff ( int32  stack) const
1102{
1103 if (stack < 5)
1104 return 0;
1105 if (stack < 10)
1106 return SPELL_GREAT_HONOR;
1107 if (stack < 15)
1108 return SPELL_GREATER_HONOR;
1109 return SPELL_GREATEST_HONOR;
1110}
@ SPELL_GREATEST_HONOR
Definition: BattlefieldWG.h:58
@ SPELL_GREATER_HONOR
Definition: BattlefieldWG.h:57
@ SPELL_GREAT_HONOR
Definition: BattlefieldWG.h:56

References SPELL_GREAT_HONOR, SPELL_GREATER_HONOR, and SPELL_GREATEST_HONOR.

Referenced by UpdateTenacity().

◆ GetRelic()

GameObject * BattlefieldWG::GetRelic ( )
inline

Return pointer to relic object.

390{ return GetGameObject(m_titansRelic); }
GameObject * GetGameObject(ObjectGuid const guid)
Definition: Battlefield.cpp:856
ObjectGuid m_titansRelic
Definition: BattlefieldWG.h:477

References Battlefield::GetGameObject(), and m_titansRelic.

Referenced by BfWGGameObjectBuilding::Destroyed(), OnBattleEnd(), and ProcessEvent().

◆ GetSpiritGraveyardId()

uint8 BattlefieldWG::GetSpiritGraveyardId ( uint32  areaId) const
514{
515 switch (areaId)
516 {
527 case AREA_WINTERGRASP:
531 default:
532 LOG_ERROR("bg.battlefield", "BattlefieldWG::GetSpiritGraveyardId: Unexpected Area Id {}", areaId);
533 break;
534 }
535
536 return 0;
537}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
@ AREA_WINTERGRASP_FORTRESS
Definition: BattlefieldWG.h:120
@ AREA_WINTERGRASP
Definition: BattlefieldWG.h:125
@ BATTLEFIELD_WG_GY_KEEP
Definition: BattlefieldWG.h:150
@ BATTLEFIELD_WG_GY_HORDE
Definition: BattlefieldWG.h:151
@ BATTLEFIELD_WG_GY_ALLIANCE
Definition: BattlefieldWG.h:152

References AREA_EASTPARK_WORKSHOP, AREA_THE_BROKEN_TEMPLE, AREA_THE_CHILLED_QUAGMIRE, AREA_THE_SUNKEN_RING, AREA_WESTPARK_WORKSHOP, AREA_WINTERGRASP, AREA_WINTERGRASP_FORTRESS, BATTLEFIELD_WG_GY_ALLIANCE, BATTLEFIELD_WG_GY_HORDE, BATTLEFIELD_WG_GY_KEEP, BATTLEFIELD_WG_GY_WORKSHOP_NE, BATTLEFIELD_WG_GY_WORKSHOP_NW, BATTLEFIELD_WG_GY_WORKSHOP_SE, BATTLEFIELD_WG_GY_WORKSHOP_SW, and LOG_ERROR.

Referenced by GetData(), and OnCreatureCreate().

◆ HandleKill()

void BattlefieldWG::HandleKill ( Player ,
Unit  
)
overridevirtual

Called when a Unit is kill in battlefield zone.

Reimplemented from Battlefield.

714{
715 if (killer == victim)
716 {
717 return;
718 }
719
720 TeamId killerTeam = killer->GetTeamId();
721
722 // xinef: tower cannons also grant rank
723 if (victim->IsPlayer() || IsKeepNpc(victim->GetEntry()) || victim->GetEntry() == NPC_WINTERGRASP_TOWER_CANNON)
724 {
725 if (victim->IsPlayer() && victim->HasAura(SPELL_LIEUTENANT))
726 {
727 // Quest - Wintergrasp - PvP Kill - Horde/Alliance
728 for (auto& playerGuid : m_PlayersInWar[killerTeam])
729 {
730 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
731 {
732 if (player->GetDistance2d(killer) < 40)
733 {
734 player->KilledMonsterCredit(killerTeam == TEAM_HORDE ? NPC_QUEST_PVP_KILL_ALLIANCE : NPC_QUEST_PVP_KILL_HORDE);
735 }
736 }
737 }
738 }
739
740 for (auto& playerGuid : m_PlayersInWar[killerTeam])
741 {
742 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
743 {
744 if (player->GetDistance2d(killer) < 40)
745 {
746 PromotePlayer(player);
747 }
748 }
749 }
750
751 // Xinef: Allow to Skin non-released corpse
752 if (victim->IsPlayer())
753 {
754 victim->SetUnitFlag(UNIT_FLAG_SKINNABLE);
755 }
756 }
757 else if (victim->IsVehicle() && !killer->IsFriendlyTo(victim))
758 {
759 // Quest - Wintergrasp - PvP Kill - Vehicle
760 for (auto& playerGuid : m_PlayersInWar[killerTeam])
761 {
762 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
763 {
764 if (player->GetDistance2d(killer) < 40)
765 {
766 player->KilledMonsterCredit(NPC_QUEST_PVP_KILL_VEHICLE);
767 }
768 }
769 }
770 }
771}
@ NPC_QUEST_PVP_KILL_VEHICLE
Definition: BattlefieldWG.h:220
@ NPC_QUEST_PVP_KILL_ALLIANCE
Definition: BattlefieldWG.h:222
@ NPC_WINTERGRASP_TOWER_CANNON
Definition: BattlefieldWG.h:216
@ NPC_QUEST_PVP_KILL_HORDE
Definition: BattlefieldWG.h:221
@ SPELL_LIEUTENANT
Definition: BattlefieldWG.h:51
@ UNIT_FLAG_SKINNABLE
Definition: UnitDefines.h:255
TeamId
Definition: SharedDefines.h:759
GuidUnorderedSet m_PlayersInWar[PVP_TEAMS_COUNT]
Definition: Battlefield.h:377
void PromotePlayer(Player *killer)
Definition: BattlefieldWG.cpp:799
bool IsKeepNpc(uint32 entry)
Definition: BattlefieldWG.h:428

References ObjectAccessor::FindPlayer(), Object::GetEntry(), Player::GetTeamId(), Unit::HasAura(), Unit::IsFriendlyTo(), IsKeepNpc(), Object::IsPlayer(), Unit::IsVehicle(), Battlefield::m_PlayersInWar, NPC_QUEST_PVP_KILL_ALLIANCE, NPC_QUEST_PVP_KILL_HORDE, NPC_QUEST_PVP_KILL_VEHICLE, NPC_WINTERGRASP_TOWER_CANNON, PromotePlayer(), Unit::SetUnitFlag(), SPELL_LIEUTENANT, TEAM_HORDE, and UNIT_FLAG_SKINNABLE.

◆ IsKeepNpc()

bool BattlefieldWG::IsKeepNpc ( uint32  entry)
inline
429 {
430 switch (entry)
431 {
454 return true;
455 }
456 return false;
457 }
@ BATTLEFIELD_WG_NPC_BRIGADIER_GENERAL
Definition: BattlefieldWG.h:184
@ BATTLEFIELD_WG_NPC_SIEGE_MASTER_STOUTHANDLE
Definition: BattlefieldWG.h:203
@ BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_KILRATH
Definition: BattlefieldWG.h:179
@ BATTLEFIELD_WG_NPC_HORDE_WARBRINGER
Definition: BattlefieldWG.h:183
@ BATTLEFIELD_WG_NPC_COMMANDER_DARDOSH
Definition: BattlefieldWG.h:178
@ BATTLEFIELD_WG_NPC_LIEUTENANT_MURP
Definition: BattlefieldWG.h:182
@ BATTLEFIELD_WG_NPC_COMMANDER_ZANNETH
Definition: BattlefieldWG.h:201
@ BATTLEFIELD_WG_NPC_ANCHORITE_TESSA
Definition: BattlefieldWG.h:204
@ BATTLEFIELD_WG_NPC_BOWYER_RANDOLPH
Definition: BattlefieldWG.h:197
@ BATTLEFIELD_WG_NPC_SIEGESMITH_STRONGHOOF
Definition: BattlefieldWG.h:180
@ BATTLEFIELD_WG_NPC_KNIGHT_DAMERON
Definition: BattlefieldWG.h:198
@ BATTLEFIELD_WG_NPC_GUARD_H
Definition: BattlefieldWG.h:170
@ BATTLEFIELD_WG_NPC_VIERON_BLAZEFEATHER
Definition: BattlefieldWG.h:174
@ BATTLEFIELD_WG_NPC_PRIMALIST_MULFORT
Definition: BattlefieldWG.h:181
@ BATTLEFIELD_WG_NPC_STONE_GUARD_MUKAR
Definition: BattlefieldWG.h:175
@ BATTLEFIELD_WG_NPC_GUARD_A
Definition: BattlefieldWG.h:171
@ BATTLEFIELD_WG_NPC_CHAMPION_ROS_SLAI
Definition: BattlefieldWG.h:177
@ BATTLEFIELD_WG_NPC_SORCERESS_KAYLANA
Definition: BattlefieldWG.h:199
@ BATTLEFIELD_WG_NPC_SENIOR_DEMOLITIONIST_LEGOSO
Definition: BattlefieldWG.h:205
@ BATTLEFIELD_WG_NPC_HOODOO_MASTER_FU_JIN
Definition: BattlefieldWG.h:176
@ BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_AHBRAMIS
Definition: BattlefieldWG.h:202
@ BATTLEFIELD_WG_NPC_MARSHAL_MAGRUDER
Definition: BattlefieldWG.h:200

References BATTLEFIELD_WG_NPC_ANCHORITE_TESSA, BATTLEFIELD_WG_NPC_BOWYER_RANDOLPH, BATTLEFIELD_WG_NPC_BRIGADIER_GENERAL, BATTLEFIELD_WG_NPC_CHAMPION_ROS_SLAI, BATTLEFIELD_WG_NPC_COMMANDER_DARDOSH, BATTLEFIELD_WG_NPC_COMMANDER_ZANNETH, BATTLEFIELD_WG_NPC_GUARD_A, BATTLEFIELD_WG_NPC_GUARD_H, BATTLEFIELD_WG_NPC_HOODOO_MASTER_FU_JIN, BATTLEFIELD_WG_NPC_HORDE_WARBRINGER, BATTLEFIELD_WG_NPC_KNIGHT_DAMERON, BATTLEFIELD_WG_NPC_LIEUTENANT_MURP, BATTLEFIELD_WG_NPC_MARSHAL_MAGRUDER, BATTLEFIELD_WG_NPC_PRIMALIST_MULFORT, BATTLEFIELD_WG_NPC_SENIOR_DEMOLITIONIST_LEGOSO, BATTLEFIELD_WG_NPC_SIEGE_MASTER_STOUTHANDLE, BATTLEFIELD_WG_NPC_SIEGESMITH_STRONGHOOF, BATTLEFIELD_WG_NPC_SORCERESS_KAYLANA, BATTLEFIELD_WG_NPC_STONE_GUARD_MUKAR, BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_AHBRAMIS, BATTLEFIELD_WG_NPC_TACTICAL_OFFICER_KILRATH, and BATTLEFIELD_WG_NPC_VIERON_BLAZEFEATHER.

Referenced by HandleKill().

◆ OnBattleEnd()

void BattlefieldWG::OnBattleEnd ( bool  endByTimer)
overridevirtual

Called when battle end.

  • Remove relic and turret
  • Change banner/npc in keep if it needed
  • Saving battlestate
  • Reward honor/mark to player
  • Remove vehicle
    Parameters
    endByTimer: true if battle ended when timer is at 00:00, false if battle ended by clicking on relic

Reimplemented from Battlefield.

345{
346 // Remove relic
347 if (GameObject* go = GetRelic())
348 go->RemoveFromWorld();
349
351
352 // Remove turret
353 for (GuidUnorderedSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
354 {
355 if (Creature* creature = GetCreature(*itr))
356 {
357 if (!endByTimer)
358 creature->SetFaction(WintergraspFaction[GetDefenderTeam()]);
359 HideNpc(creature);
360 }
361 }
362
363 // Change all npc in keep
364 for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
365 if (Creature* creature = GetCreature(*itr))
366 HideNpc(creature);
367
368 for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr)
369 if (Creature* creature = GetCreature(*itr))
370 ShowNpc(creature, true);
371
372 // Change all npc out of keep
373 for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
374 if (Creature* creature = GetCreature(*itr))
375 HideNpc(creature);
376
377 for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr)
378 if (Creature* creature = GetCreature(*itr))
379 ShowNpc(creature, true);
380
381 // Update all graveyard, control is to defender when no wartime
382 for (uint8 i = 0; i < BATTLEFIELD_WG_GY_HORDE; i++)
383 if (BfGraveyard* graveyard = GetGraveyardById(i))
385
386 for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetDefenderTeam()].begin(); itr != m_KeepGameObject[GetDefenderTeam()].end(); ++itr)
387 (*itr)->SetRespawnTime(RESPAWN_IMMEDIATELY);
388
389 for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetAttackerTeam()].begin(); itr != m_KeepGameObject[GetAttackerTeam()].end(); ++itr)
390 (*itr)->SetRespawnTime(RESPAWN_ONE_DAY);
391
392 // Update portal defender faction
393 for (GameObjectSet::const_iterator itr = DefenderPortalList.begin(); itr != DefenderPortalList.end(); ++itr)
394 (*itr)->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]);
395
396 // Saving data
397 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
398 {
399 (*itr)->Rebuild();
400 (*itr)->Save();
401 (*itr)->UpdateTurretAttack(true);
402 }
403
404 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
405 {
406 (*itr)->GiveControlTo((*itr)->workshopId == BATTLEFIELD_WG_WORKSHOP_SE || (*itr)->workshopId == BATTLEFIELD_WG_WORKSHOP_SW ? GetAttackerTeam() : GetDefenderTeam(), true);
407 (*itr)->Save();
408 }
409
410 for (uint8 team = 0; team < 2; ++team)
411 {
412 for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
413 if (Creature* creature = GetCreature(*itr))
414 creature->DespawnOrUnsummon(1);
415
416 m_vehicles[team].clear();
417 }
418
423 uint32 spellDamagedDef = SPELL_DAMAGED_TOWER;
424 uint32 spellFullDef = SPELL_DESTROYED_TOWER;
425 uint32 spellDamagedAtt = SPELL_DAMAGED_BUILDING;
426 uint32 spellFullAtt = SPELL_INTACT_BUILDING;
427
428 if (!endByTimer)
429 {
432 spellDamagedDef = SPELL_DAMAGED_BUILDING;
433 spellFullDef = SPELL_INTACT_BUILDING;
434 spellDamagedAtt = SPELL_DAMAGED_TOWER;
435 spellFullAtt = SPELL_DESTROYED_TOWER;
436 }
437
438 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
439 {
440 if (Player* player = ObjectAccessor::FindPlayer(*itr))
441 {
442 // Victory in Wintergrasp
443 player->AreaExploredOrEventHappens(GetDefenderTeam() ? 13183 : 13181); // HORDE / ALLY win wg quest id
444
445 player->CastSpell(player, SPELL_ESSENCE_OF_WINTERGRASP, true);
446 player->CastSpell(player, SPELL_VICTORY_REWARD, true);
447 RemoveAurasFromPlayer(player);
448
449 for (uint8 i = 0; i < damagedTowersDef; ++i)
450 player->CastSpell(player, spellDamagedDef, true);
451 for (uint8 i = 0; i < brokenTowersDef; ++i)
452 player->CastSpell(player, spellFullDef, true);
453 }
454 }
455
456 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
457 if (Player* player = ObjectAccessor::FindPlayer(*itr))
458 {
459 player->CastSpell(player, SPELL_DEFEAT_REWARD, true);
460 RemoveAurasFromPlayer(player);
461
462 for (uint8 i = 0; i < damagedTowersAtt; ++i)
463 player->CastSpell(player, spellDamagedAtt, true);
464 for (uint8 i = 0; i < brokenTowersAtt; ++i)
465 player->CastSpell(player, spellFullAtt, true);
466 }
467
468 if (!endByTimer)
469 {
470 for (uint8 team = 0; team < 2; ++team)
471 {
472 for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
473 {
474 if (Player* player = ObjectAccessor::FindPlayer(*itr))
475 {
476 player->RemoveAurasDueToSpell(m_DefenderTeam == TEAM_ALLIANCE ? SPELL_HORDE_CONTROL_PHASE_SHIFT : SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, player->GetGUID());
478 }
479 }
480 }
481 }
482
483 // Clear players in war list at the end.
485 m_PlayersInWar[TEAM_HORDE].clear();
486
487 if (!endByTimer) // win alli/horde
488 {
490 sWorld->setWorldState(worldStateId, sWorld->getWorldState(worldStateId) + 1);
491
493 }
494 else // defend alli/horde
495 {
497 sWorld->setWorldState(worldStateId, sWorld->getWorldState(worldStateId) + 1);
498
500 }
501}
@ RESPAWN_IMMEDIATELY
Definition: Battleground.h:164
@ RESPAWN_ONE_DAY
Definition: Battleground.h:163
const uint32 WintergraspFaction[3]
Definition: BattlefieldWG.h:43
@ SPELL_ESSENCE_OF_WINTERGRASP
Definition: BattlefieldWG.h:79
@ SPELL_HORDE_CONTROL_PHASE_SHIFT
Definition: BattlefieldWG.h:87
@ SPELL_VICTORY_REWARD
Definition: BattlefieldWG.h:64
@ SPELL_DAMAGED_BUILDING
Definition: BattlefieldWG.h:68
@ SPELL_ALLIANCE_CONTROL_PHASE_SHIFT
Definition: BattlefieldWG.h:88
@ SPELL_INTACT_BUILDING
Definition: BattlefieldWG.h:69
@ SPELL_DESTROYED_TOWER
Definition: BattlefieldWG.h:67
@ SPELL_DEFEAT_REWARD
Definition: BattlefieldWG.h:65
@ SPELL_DAMAGED_TOWER
Definition: BattlefieldWG.h:66
@ BATTLEFIELD_WG_TEXT_WIN_KEEP
Definition: BattlefieldWG.h:548
@ BATTLEFIELD_WG_TEXT_DEFEND_KEEP
Definition: BattlefieldWG.h:547
@ BATTLEFIELD_WG_DATA_INTACT_TOWER_ATT
Definition: BattlefieldWG.h:93
@ BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT
Definition: BattlefieldWG.h:95
@ BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT
Definition: BattlefieldWG.h:94
@ BATTLEFIELD_WG_WORKSHOP_SE
Definition: BattlefieldWG.h:515
@ BATTLEFIELD_WG_WORKSHOP_SW
Definition: BattlefieldWG.h:516
@ GAMEOBJECT_FACTION
Definition: UpdateFields.h:402
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
Creature * GetCreature(ObjectGuid const guid)
Definition: Battlefield.cpp:848
void ShowNpc(Creature *creature, bool aggressive)
Definition: Battlefield.cpp:502
TeamId m_DefenderTeam
Definition: Battlefield.h:369
void SendWarning(uint8 id, WorldObject const *target=nullptr)
Definition: Battlefield.cpp:473
void HideNpc(Creature *creature)
Definition: Battlefield.cpp:492
GameObjectSet m_KeepGameObject[2]
Definition: BattlefieldWG.h:464
void RemoveAurasFromPlayer(Player *player)
Definition: BattlefieldWG.cpp:832
GameObject * GetRelic()
Return pointer to relic object.
Definition: BattlefieldWG.h:390
GuidUnorderedSet CanonList
Definition: BattlefieldWG.h:468
GuidUnorderedSet KeepCreature[2]
Definition: BattlefieldWG.h:469
GuidUnorderedSet OutsideCreature[2]
Definition: BattlefieldWG.h:470
GameObjectSet DefenderPortalList
Definition: BattlefieldWG.h:463
Definition: Creature.h:46
Definition: GameObject.h:121
void Clear()
Definition: ObjectGuid.h:138

References BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT, BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT, BATTLEFIELD_WG_DATA_INTACT_TOWER_ATT, BATTLEFIELD_WG_GY_HORDE, BATTLEFIELD_WG_GY_WORKSHOP_SE, BATTLEFIELD_WG_GY_WORKSHOP_SW, BATTLEFIELD_WG_TEXT_DEFEND_KEEP, BATTLEFIELD_WG_TEXT_WIN_KEEP, BATTLEFIELD_WG_WORKSHOP_SE, BATTLEFIELD_WG_WORKSHOP_SW, BuildingsInZone, CanonList, ObjectGuid::Clear(), DefenderPortalList, ObjectAccessor::FindPlayer(), GAMEOBJECT_FACTION, Battlefield::GetAttackerTeam(), Battlefield::GetCreature(), GetData(), Battlefield::GetDefenderTeam(), Battlefield::GetGraveyardById(), GetRelic(), Battlefield::HideNpc(), KeepCreature, Battlefield::m_DefenderTeam, m_KeepGameObject, Battlefield::m_players, Battlefield::m_PlayersInWar, m_titansRelic, m_vehicles, OutsideCreature, RemoveAurasFromPlayer(), RESPAWN_IMMEDIATELY, RESPAWN_ONE_DAY, Battlefield::SendWarning(), Battlefield::ShowNpc(), SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, SPELL_DAMAGED_BUILDING, SPELL_DAMAGED_TOWER, SPELL_DEFEAT_REWARD, SPELL_DESTROYED_TOWER, SPELL_ESSENCE_OF_WINTERGRASP, SPELL_HORDE_CONTROL_PHASE_SHIFT, SPELL_INTACT_BUILDING, SPELL_VICTORY_REWARD, sWorld, TEAM_ALLIANCE, TEAM_HORDE, WintergraspFaction, WorkshopsList, WORLDSTATE_ALLIANCE_KEEP_CAPTURED, WORLDSTATE_ALLIANCE_KEEP_DEFENDED, WORLDSTATE_HORDE_KEEP_CAPTURED, and WORLDSTATE_HORDE_KEEP_DEFENDED.

◆ OnBattleStart()

void BattlefieldWG::OnBattleStart ( )
overridevirtual

Called when the battle start.

  • Spawn relic and turret
  • Rebuild tower and wall
  • Invite player to war

Reimplemented from Battlefield.

221{
222 // Spawn titan relic
223 GameObject* go = SpawnGameObject(GO_WINTERGRASP_TITAN_S_RELIC, 5440.0f, 2840.8f, 430.43f, 0);
224 if (go)
225 {
226 // Update faction of relic, only attacker can click on
228 // Set in use (not allow to click on before last door is broken)
230
231 // save guid
232 m_titansRelic = go->GetGUID();
233 }
234 else
235 LOG_ERROR("bg.battlefield", "WG: Failed to spawn titan relic.");
236
237 // Update tower visibility and update faction
238 for (GuidUnorderedSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
239 {
240 if (Creature* creature = GetCreature(*itr))
241 {
242 ShowNpc(creature, true);
243 creature->SetFaction(WintergraspFaction[GetDefenderTeam()]);
244 }
245 }
246
247 // Rebuild all wall
248 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
249 {
250 if (*itr)
251 {
252 (*itr)->Rebuild();
253 (*itr)->UpdateTurretAttack(false);
254 }
255 }
256
260
261 // Update graveyard (in no war time all graveyard is to deffender, in war time, depend of base)
262 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
263 if (*itr)
264 (*itr)->UpdateGraveyardAndWorkshop();
265
266 // Set Sliders capture points data to his owners when battle start
267 for (BfCapturePointVector::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
268 (*itr)->SetCapturePointData((*itr)->GetCapturePointGo(),
269 (*itr)->GetCapturePointGo()->GetEntry() == GO_WINTERGRASP_FACTORY_BANNER_SE || (*itr)->GetCapturePointGo()->GetEntry() == GO_WINTERGRASP_FACTORY_BANNER_SW ? GetAttackerTeam() : GetDefenderTeam());
270
271 for (uint8 team = 0; team < 2; ++team)
272 for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
273 {
274 // Kick player in orb room, TODO: offline player ?
275 if (Player* player = ObjectAccessor::FindPlayer(*itr))
276 {
277 float x, y, z;
278 player->GetPosition(x, y, z);
279 if (5500 > x && x > 5392 && y < 2880 && y > 2800 && z < 480)
280 player->TeleportTo(571, 5349.8686f, 2838.481f, 409.240f, 0.046328f);
281 SendInitWorldStatesTo(player);
282 }
283 }
284 // Initialize vehicle counter
286 // Send start warning to all players
288
289 // Xinef: reset tenacity counter
290 m_tenacityStack = 0;
291 m_tenacityUpdateTimer = 20000;
292
295}
@ BATTLEFIELD_WG_WORLD_START_MESSAGE
Definition: BattlefieldWG.h:165
uint8 const WG_MAX_ATTACKTOWERS
Definition: BattlefieldWG.h:804
@ GO_WINTERGRASP_FACTORY_BANNER_SW
Definition: BattlefieldWG.h:573
@ GO_WINTERGRASP_TITAN_S_RELIC
Definition: BattlefieldWG.h:575
@ GO_WINTERGRASP_FACTORY_BANNER_SE
Definition: BattlefieldWG.h:572
@ BATTLEFIELD_WG_TEXT_START
Definition: BattlefieldWG.h:538
@ CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE
Definition: IWorld.h:117
@ GO_FLAG_NOT_SELECTABLE
Definition: SharedDefines.h:1607
void SetData(uint32 dataId, uint32 value) override
Definition: Battlefield.h:273
GameObject * SpawnGameObject(uint32 entry, float x, float y, float z, float o)
Definition: Battlefield.cpp:824
BfCapturePointVector m_capturePoints
Definition: Battlefield.h:372
int32 m_tenacityStack
Definition: BattlefieldWG.h:473
void UpdateCounterVehicle(bool init)
Vehicle world states update.
Definition: BattlefieldWG.cpp:297
uint32 m_tenacityUpdateTimer
Definition: BattlefieldWG.h:474
void SendInitWorldStatesTo(Player *player)
Definition: BattlefieldWG.cpp:964
Definition: Chat.h:39
void SendWorldText(std::string_view str)
Definition: Chat.cpp:133
void SetGameObjectFlag(GameObjectFlags flags)
Definition: GameObject.h:219
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650

References BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT, BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT, BATTLEFIELD_WG_DATA_INTACT_TOWER_ATT, BATTLEFIELD_WG_TEXT_START, BATTLEFIELD_WG_WORLD_START_MESSAGE, BuildingsInZone, CanonList, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, ObjectAccessor::FindPlayer(), GAMEOBJECT_FACTION, Battlefield::GetAttackerTeam(), Battlefield::GetCreature(), Battlefield::GetDefenderTeam(), Object::GetGUID(), GO_FLAG_NOT_SELECTABLE, GO_WINTERGRASP_FACTORY_BANNER_SE, GO_WINTERGRASP_FACTORY_BANNER_SW, GO_WINTERGRASP_TITAN_S_RELIC, LOG_ERROR, Battlefield::m_capturePoints, Battlefield::m_players, m_tenacityStack, m_tenacityUpdateTimer, m_titansRelic, SendInitWorldStatesTo(), Battlefield::SendWarning(), ChatHandler::SendWorldText(), Battlefield::SetData(), GameObject::SetGameObjectFlag(), Object::SetUInt32Value(), Battlefield::ShowNpc(), Battlefield::SpawnGameObject(), sWorld, UpdateCounterVehicle(), WG_MAX_ATTACKTOWERS, WintergraspFaction, and WorkshopsList.

◆ OnCreatureCreate()

void BattlefieldWG::OnCreatureCreate ( Creature creature)
overridevirtual

Called when a creature is created.

  • Update vehicle count

Reimplemented from ZoneScript.

557{
558 // Accessing to db spawned creatures
559 switch (creature->GetEntry())
560 {
563 {
565 uint8 graveyardId = GetSpiritGraveyardId(creature->GetAreaId());
566 // xinef: little workaround, there are 2 spirit guides in same area
567 if (creature->IsWithinDist2d(5103.0f, 3461.5f, 5.0f))
568 graveyardId = BATTLEFIELD_WG_GY_WORKSHOP_NW;
569
570 if (m_GraveyardList[graveyardId])
571 m_GraveyardList[graveyardId]->SetSpirit(creature, teamId);
572 break;
573 }
574 }
575
576 // untested code - not sure if it is valid.
577 if (IsWarTime())
578 {
579 switch (creature->GetEntry())
580 {
585 {
586 if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID())
587 return;
588
590 if (!creator)
591 return;
592 TeamId team = creator->GetTeamId();
593
594 if (team == TEAM_HORDE)
595 {
597 {
599 creature->CastSpell(creature, SPELL_HORDE_FLAG, true);
600 m_vehicles[team].insert(creature->GetGUID());
602 }
603 else
604 {
605 creature->DespawnOrUnsummon();
606 return;
607 }
608 }
609 else
610 {
612 {
614 creature->CastSpell(creature, SPELL_ALLIANCE_FLAG, true);
615 m_vehicles[team].insert(creature->GetGUID());
617 }
618 else
619 {
620 creature->DespawnOrUnsummon();
621 return;
622 }
623 }
624 break;
625 }
628 {
629 if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID())
630 return;
631
632 if (Unit* owner = creature->ToTempSummon()->GetSummonerUnit())
633 creature->SetFaction(owner->GetFaction());
634 break;
635 }
636 }
637 }
638}
@ NPC_WINTERGRASP_SIEGE_ENGINE_HORDE
Definition: BattlefieldWG.h:213
@ NPC_WINTERGRASP_CATAPULT
Definition: BattlefieldWG.h:214
@ NPC_WINTERGRASP_DEMOLISHER
Definition: BattlefieldWG.h:215
@ NPC_DWARVEN_SPIRIT_GUIDE
Definition: BattlefieldWG.h:208
@ NPC_WINTERGRASP_SIEGE_ENGINE_TURRET_HORDE
Definition: BattlefieldWG.h:211
@ NPC_WINTERGRASP_SIEGE_ENGINE_TURRET_ALLIANCE
Definition: BattlefieldWG.h:210
@ NPC_TAUNKA_SPIRIT_GUIDE
Definition: BattlefieldWG.h:207
@ NPC_WINTERGRASP_SIEGE_ENGINE_ALLIANCE
Definition: BattlefieldWG.h:212
@ SPELL_HORDE_FLAG
Definition: BattlefieldWG.h:60
@ SPELL_ALLIANCE_FLAG
Definition: BattlefieldWG.h:59
GraveyardVect m_GraveyardList
Definition: Battlefield.h:400
void UpdateVehicleCountWG()
Definition: BattlefieldWG.cpp:322
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
Definition: Creature.cpp:2173
ObjectGuid GetSummonerGUID() const
Definition: TemporarySummon.h:55
Unit * GetSummonerUnit() const
Definition: TemporarySummon.cpp:44
uint32 GetEntry() const
Definition: Object.h:112
bool IsWithinDist2d(float x, float y, float dist) const
Definition: Object.cpp:1305
uint32 GetAreaId() const
Definition: Object.cpp:3152
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2088
Definition: Unit.h:630
void SetFaction(uint32 faction)
Definition: Unit.cpp:10018
TempSummon * ToTempSummon()
Definition: Unit.h:1716
bool IsSummon() const
Definition: Unit.h:707
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

References BATTLEFIELD_WG_DATA_MAX_VEHICLE_A, BATTLEFIELD_WG_DATA_MAX_VEHICLE_H, BATTLEFIELD_WG_DATA_VEHICLE_A, BATTLEFIELD_WG_DATA_VEHICLE_H, BATTLEFIELD_WG_GY_WORKSHOP_NW, Unit::CastSpell(), Creature::DespawnOrUnsummon(), ObjectAccessor::FindPlayer(), WorldObject::GetAreaId(), GetData(), Object::GetEntry(), Object::GetGUID(), GetSpiritGraveyardId(), TempSummon::GetSummonerGUID(), TempSummon::GetSummonerUnit(), Player::GetTeamId(), Unit::IsSummon(), Battlefield::IsWarTime(), WorldObject::IsWithinDist2d(), Battlefield::m_GraveyardList, m_vehicles, NPC_DWARVEN_SPIRIT_GUIDE, NPC_TAUNKA_SPIRIT_GUIDE, NPC_WINTERGRASP_CATAPULT, NPC_WINTERGRASP_DEMOLISHER, NPC_WINTERGRASP_SIEGE_ENGINE_ALLIANCE, NPC_WINTERGRASP_SIEGE_ENGINE_HORDE, NPC_WINTERGRASP_SIEGE_ENGINE_TURRET_ALLIANCE, NPC_WINTERGRASP_SIEGE_ENGINE_TURRET_HORDE, Unit::SetFaction(), SPELL_ALLIANCE_FLAG, SPELL_HORDE_FLAG, TEAM_ALLIANCE, TEAM_HORDE, Unit::ToTempSummon(), and UpdateVehicleCountWG().

◆ OnCreatureRemove()

void BattlefieldWG::OnCreatureRemove ( Creature creature)
overridevirtual

Called when a creature is removed.

  • Update vehicle count

Reimplemented from ZoneScript.

641{
642 /* possibly can be used later
643 if (IsWarTime())
644 {
645 switch (creature->GetEntry())
646 {
647 case NPC_WINTERGRASP_SIEGE_ENGINE_ALLIANCE:
648 case NPC_WINTERGRASP_SIEGE_ENGINE_HORDE:
649 case NPC_WINTERGRASP_CATAPULT:
650 case NPC_WINTERGRASP_DEMOLISHER:
651 {
652 uint8 team;
653 if (creature->GetFaction() == WintergraspFaction[TEAM_ALLIANCE])
654 team = TEAM_ALLIANCE;
655 else if (creature->GetFaction() == WintergraspFaction[TEAM_HORDE])
656 team = TEAM_HORDE;
657 else
658 return;
659
660 m_vehicles[team].erase(creature->GetGUID());
661 if (team == TEAM_HORDE)
662 UpdateData(BATTLEFIELD_WG_DATA_VEHICLE_H, -1);
663 else
664 UpdateData(BATTLEFIELD_WG_DATA_VEHICLE_A, -1);
665 UpdateVehicleCountWG();
666
667 break;
668 }
669 }
670 }*/
671}

◆ OnGameObjectCreate()

void BattlefieldWG::OnGameObjectCreate ( GameObject go)
overridevirtual

Called when a gameobject is created.

Reimplemented from ZoneScript.

674{
675 uint8 workshopId = 0;
676
677 switch (go->GetEntry())
678 {
680 workshopId = BATTLEFIELD_WG_WORKSHOP_NE;
681 break;
683 workshopId = BATTLEFIELD_WG_WORKSHOP_NW;
684 break;
686 workshopId = BATTLEFIELD_WG_WORKSHOP_SE;
687 break;
689 workshopId = BATTLEFIELD_WG_WORKSHOP_SW;
690 break;
691 default:
692 return;
693 }
694
695 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
696 {
697 if (WGWorkshop* workshop = (*itr))
698 {
699 if (workshop->workshopId == workshopId)
700 {
701 WintergraspCapturePoint* capturePoint = new WintergraspCapturePoint(this, workshop->teamControl);
702 //Sending neutral team at start to set normal capture points by workshop->teamControl, TEAM_NEUTRAL is ignored at first call
703 capturePoint->SetCapturePointData(go, TEAM_NEUTRAL);
704 capturePoint->LinkToWorkshop(workshop);
705 AddCapturePoint(capturePoint);
706 break;
707 }
708 }
709 }
710}
@ GO_WINTERGRASP_FACTORY_BANNER_NW
Definition: BattlefieldWG.h:571
@ GO_WINTERGRASP_FACTORY_BANNER_NE
Definition: BattlefieldWG.h:570
@ BATTLEFIELD_WG_WORKSHOP_NW
Definition: BattlefieldWG.h:514
@ BATTLEFIELD_WG_WORKSHOP_NE
Definition: BattlefieldWG.h:513
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
bool SetCapturePointData(GameObject *capturePoint, TeamId team)
Definition: Battlefield.cpp:925
void AddCapturePoint(BfCapturePoint *cp)
Definition: Battlefield.h:422
Definition: BattlefieldWG.h:259
void LinkToWorkshop(WGWorkshop *workshop)
Definition: BattlefieldWG.h:263
Definition: BattlefieldWG.h:1448

References Battlefield::AddCapturePoint(), BATTLEFIELD_WG_WORKSHOP_NE, BATTLEFIELD_WG_WORKSHOP_NW, BATTLEFIELD_WG_WORKSHOP_SE, BATTLEFIELD_WG_WORKSHOP_SW, Object::GetEntry(), GO_WINTERGRASP_FACTORY_BANNER_NE, GO_WINTERGRASP_FACTORY_BANNER_NW, GO_WINTERGRASP_FACTORY_BANNER_SE, GO_WINTERGRASP_FACTORY_BANNER_SW, WintergraspCapturePoint::LinkToWorkshop(), BfCapturePoint::SetCapturePointData(), TEAM_NEUTRAL, and WorkshopsList.

◆ OnPlayerEnterZone()

void BattlefieldWG::OnPlayerEnterZone ( Player player)
overridevirtual

Called when player enters in WG zone.

  • Update aura
  • Update worldstate
    Parameters
    player: Player who enters the zone

Reimplemented from Battlefield.

899{
900 if (!m_isActive)
901 RemoveAurasFromPlayer(player);
902
904 // Send worldstate to player
905 SendInitWorldStatesTo(player);
906
907 // xinef: Attacker, if hidden in relic room kick him out
908 if (player->GetTeamId() == GetAttackerTeam())
909 if (player->GetPositionX() > 5400.0f && player->GetPositionX() < 5490.0f && player->GetPositionY() > 2803.0f && player->GetPositionY() < 2878.0f)
911}
void KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
Definition: Battlefield.cpp:326
bool m_isActive
Definition: Battlefield.h:368
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:18819

References Unit::AddAura(), Battlefield::GetAttackerTeam(), Object::GetGUID(), Position::GetPositionX(), Position::GetPositionY(), Player::GetTeamId(), Battlefield::KickPlayerFromBattlefield(), Battlefield::m_DefenderTeam, Battlefield::m_isActive, RemoveAurasFromPlayer(), SendInitWorldStatesTo(), SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, SPELL_HORDE_CONTROL_PHASE_SHIFT, and TEAM_HORDE.

◆ OnPlayerJoinWar()

void BattlefieldWG::OnPlayerJoinWar ( Player player)
overridevirtual

Called when player accept invite to join battle.

  • Update aura
  • Teleport if it needed
  • Update worldstate
  • Update tenacity
    Parameters
    playerPlayer who accepted invite

Reimplemented from Battlefield.

845{
846 RemoveAurasFromPlayer(player);
847
848 player->CastSpell(player, SPELL_RECRUIT, true);
849 AddUpdateTenacity(player);
850
851 if (player->GetTeamId() == GetDefenderTeam())
852 player->TeleportTo(571, 5345, 2842, 410, 3.14f);
853 else
854 {
855 if (player->GetTeamId() == TEAM_HORDE)
856 player->TeleportTo(571, 5025.857422f, 3674.628906f, 362.737122f, 4.135169f);
857 else
858 player->TeleportTo(571, 5101.284f, 2186.564f, 365.549f, 3.812f);
859 }
860
861 if (player->GetTeamId() == GetAttackerTeam())
862 {
865 }
866 else
867 {
870 }
871 SendInitWorldStatesTo(player);
872}
@ SPELL_RECRUIT
Definition: BattlefieldWG.h:49
@ SPELL_TOWER_CONTROL
Definition: BattlefieldWG.h:54
void AddUpdateTenacity(Player *player)
Definition: BattlefieldWG.cpp:1112
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1330
void SetAuraStack(uint32 spellId, Unit *target, uint32 stack)
Definition: Unit.cpp:18858

References AddUpdateTenacity(), BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT, Unit::CastSpell(), Battlefield::GetAttackerTeam(), GetData(), Battlefield::GetDefenderTeam(), Player::GetTeamId(), RemoveAurasFromPlayer(), SendInitWorldStatesTo(), Unit::SetAuraStack(), SPELL_RECRUIT, SPELL_TOWER_CONTROL, TEAM_HORDE, and Player::TeleportTo().

◆ OnPlayerLeaveWar()

void BattlefieldWG::OnPlayerLeaveWar ( Player player)
overridevirtual

Called when player left the battle.

  • Update player aura
    Parameters
    player: Player who left the battle

Reimplemented from Battlefield.

875{
876 // Remove all aura from WG /// @todo: false we can go out of this zone on retail and keep Rank buff, remove on end of WG
877 if (!player->GetSession()->PlayerLogout())
878 {
879 if (player->GetVehicle()) // Remove vehicle of player if he go out.
880 player->GetVehicle()->Dismiss();
881 RemoveAurasFromPlayer(player);
882 }
883
884 RemoveUpdateTenacity(player);
885}
void RemoveUpdateTenacity(Player *player)
Definition: BattlefieldWG.cpp:1117
WorldSession * GetSession() const
Definition: Player.h:1978
Vehicle * GetVehicle() const
Definition: Unit.h:1673
void Dismiss()
Definition: Vehicle.cpp:521
bool PlayerLogout() const
Definition: WorldSession.h:338

References Vehicle::Dismiss(), Player::GetSession(), Unit::GetVehicle(), WorldSession::PlayerLogout(), RemoveAurasFromPlayer(), and RemoveUpdateTenacity().

◆ OnPlayerLeaveZone()

void BattlefieldWG::OnPlayerLeaveZone ( Player player)
overridevirtual

Called when player left the WG zone.

Parameters
player: Player who left the zone

Reimplemented from Battlefield.

888{
889 if (!m_isActive)
890 RemoveAurasFromPlayer(player);
891
896}
@ SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT
Definition: BattlefieldWG.h:85
@ SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT
Definition: BattlefieldWG.h:84
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4891

References Battlefield::m_isActive, Unit::RemoveAurasDueToSpell(), RemoveAurasFromPlayer(), SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT, SPELL_HORDE_CONTROL_PHASE_SHIFT, and SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT.

◆ OnStartGrouping()

void BattlefieldWG::OnStartGrouping ( )
overridevirtual

Called when grouping starts (15 minutes before battlestart)

  • Invite all player in zone to join queue

Reimplemented from Battlefield.

508{
509 if (!IsWarTime())
511}
@ BATTLEFIELD_WG_TEXT_WILL_START
Definition: BattlefieldWG.h:549

References BATTLEFIELD_WG_TEXT_WILL_START, Battlefield::IsWarTime(), and Battlefield::SendWarning().

◆ OnUnitDeath()

void BattlefieldWG::OnUnitDeath ( Unit unit)
overridevirtual

Reimplemented from ZoneScript.

791{
792 if (IsWarTime())
793 if (unit->IsVehicle())
796}
bool FindAndRemoveVehicleFromList(Unit *vehicle)
Definition: BattlefieldWG.cpp:773
bool IsVehicle() const
Definition: Unit.h:713

References FindAndRemoveVehicleFromList(), Unit::IsVehicle(), Battlefield::IsWarTime(), and UpdateVehicleCountWG().

◆ ProcessEvent()

void BattlefieldWG::ProcessEvent ( WorldObject obj,
uint32  eventId 
)
overridevirtual

Reimplemented from ZoneScript.

1050{
1051 if (!obj || !IsWarTime())
1052 return;
1053
1054 // We handle only gameobjects here
1055 GameObject* go = obj->ToGameObject();
1056 if (!go)
1057 return;
1058
1059 // On click on titan relic
1061 {
1063 {
1064 EndBattle(false);
1065 }
1066 else if (GameObject* relic = GetRelic())
1067 {
1068 relic->SetRespawnTime(RESPAWN_IMMEDIATELY);
1069 }
1070 }
1071
1072 // if destroy or damage event, search the wall/tower and update worldstate/send warning message
1073 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
1074 {
1075 if (GameObject* build = ObjectAccessor::GetGameObject(*obj, (*itr)->m_Build))
1076 {
1077 if (go->GetEntry() == build->GetEntry())
1078 {
1079 if (build->GetGOInfo()->building.damagedEvent == eventId)
1080 (*itr)->Damaged();
1081
1082 if (build->GetGOInfo()->building.destroyedEvent == eventId)
1083 (*itr)->Destroyed();
1084
1085 break;
1086 }
1087 }
1088 }
1089}
GameObject * GetGameObject(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:187
void EndBattle(bool endByTimer)
Definition: Battlefield.cpp:357
bool CanInteractWithRelic()
Define relic object.
Definition: BattlefieldWG.h:396
GameObject * ToGameObject()
Definition: Object.h:210

References BuildingsInZone, CanInteractWithRelic(), Battlefield::EndBattle(), Object::GetEntry(), ObjectAccessor::GetGameObject(), GetRelic(), GO_WINTERGRASP_TITAN_S_RELIC, Battlefield::IsWarTime(), RESPAWN_IMMEDIATELY, and Object::ToGameObject().

◆ PromotePlayer()

void BattlefieldWG::PromotePlayer ( Player killer)
800{
801 if (!m_isActive)
802 return;
803 // Updating rank of player
804 if (Aura* recruitAura = killer->GetAura(SPELL_RECRUIT))
805 {
806 if (recruitAura->GetStackAmount() >= 5)
807 {
808 killer->RemoveAura(SPELL_RECRUIT);
809 killer->CastSpell(killer, SPELL_CORPORAL, true);
811 }
812 else
813 {
814 killer->CastSpell(killer, SPELL_RECRUIT, true);
815 }
816 }
817 else if (Aura* corporalAura = killer->GetAura(SPELL_CORPORAL))
818 {
819 if (corporalAura->GetStackAmount() >= 5)
820 {
821 killer->RemoveAura(SPELL_CORPORAL);
822 killer->CastSpell(killer, SPELL_LIEUTENANT, true);
824 }
825 else
826 {
827 killer->CastSpell(killer, SPELL_CORPORAL, true);
828 }
829 }
830}
@ SPELL_CORPORAL
Definition: BattlefieldWG.h:50
@ BATTLEFIELD_WG_TEXT_SECONDRANK
Definition: BattlefieldWG.h:551
@ BATTLEFIELD_WG_TEXT_FIRSTRANK
Definition: BattlefieldWG.h:550
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition: Unit.cpp:5552
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4758
Definition: SpellAuras.h:87

References BATTLEFIELD_WG_TEXT_FIRSTRANK, BATTLEFIELD_WG_TEXT_SECONDRANK, Unit::CastSpell(), Unit::GetAura(), Battlefield::m_isActive, Unit::RemoveAura(), Battlefield::SendWarning(), SPELL_CORPORAL, SPELL_LIEUTENANT, and SPELL_RECRUIT.

Referenced by HandleKill().

◆ RemoveAurasFromPlayer()

◆ RemoveUpdateTenacity()

void BattlefieldWG::RemoveUpdateTenacity ( Player player)
1118{
1119 m_updateTenacityList.erase(player->GetGUID());
1121}
static ObjectGuid const Empty
Definition: ObjectGuid.h:120

References ObjectGuid::Empty, Object::GetGUID(), and m_updateTenacityList.

Referenced by OnPlayerLeaveWar().

◆ SendInitWorldStatesTo()

void BattlefieldWG::SendInitWorldStatesTo ( Player player)
965{
966 WorldPacket data(SMSG_INIT_WORLD_STATES, (4 + 4 + 4 + 2 + (BuildingsInZone.size() * 8) + (WorkshopsList.size() * 8)));
967
968 data << uint32(m_MapId);
969 data << uint32(m_ZoneId);
970 data << uint32(0);
971 data << uint16(14 + BuildingsInZone.size() + WorkshopsList.size()); // Number of fields
972
974
975 player->GetSession()->SendPacket(&data);
976}
std::uint16_t uint16
Definition: Define.h:108
@ SMSG_INIT_WORLD_STATES
Definition: Opcodes.h:736
uint32 m_MapId
Definition: Battlefield.h:385
uint32 m_ZoneId
Definition: Battlefield.h:384
void FillInitialWorldStates(WorldPacket &data) override
Definition: BattlefieldWG.cpp:936
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

References BuildingsInZone, FillInitialWorldStates(), Player::GetSession(), Battlefield::m_MapId, Battlefield::m_ZoneId, WorldSession::SendPacket(), SMSG_INIT_WORLD_STATES, and WorkshopsList.

Referenced by OnBattleStart(), OnPlayerEnterZone(), OnPlayerJoinWar(), and SendInitWorldStatesToAll().

◆ SendInitWorldStatesToAll()

void BattlefieldWG::SendInitWorldStatesToAll ( )
overridevirtual

Send all worldstate data to all player in zone.

Implements Battlefield.

979{
980 for (uint8 team = 0; team < 2; team++)
981 for (GuidUnorderedSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
982 if (Player* player = ObjectAccessor::FindPlayer(*itr))
983 SendInitWorldStatesTo(player);
984}

References ObjectAccessor::FindPlayer(), Battlefield::m_players, and SendInitWorldStatesTo().

Referenced by UpdatedDestroyedTowerCount().

◆ SetRelicInteractible()

void BattlefieldWG::SetRelicInteractible ( bool  allow)
inline

Define if player can interact with the relic.

399{ m_isRelicInteractible = allow; }

References m_isRelicInteractible.

Referenced by BfWGGameObjectBuilding::Destroyed().

◆ SetupBattlefield()

bool BattlefieldWG::SetupBattlefield ( )
overridevirtual

Called when battlefield is setup, at server start.

Reimplemented from Battlefield.

43{
44 m_TypeId = BATTLEFIELD_WG; // See enum BattlefieldTypes
48 m_Map = sMapMgr->FindMap(m_MapId, 0);
49
50 // init stalker AFTER setting map id... we spawn it at map=random memory value?...
52
54 m_IsEnabled = sWorld->getIntConfig(CONFIG_WINTERGRASP_ENABLE) == 1;
60
63 m_StartGrouping = false;
64
67
68 KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0);
70
72
74
75 m_saveTimer = 60000;
76
77 // Init GraveYards
79
80 // Load from db
81 if (!sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) &&
83 !sWorld->getWorldState(ClockWorldState[0]))
84 {
85 sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, uint64(false));
88 }
89
92
93 m_Timer = sWorld->getWorldState(ClockWorldState[0]);
94 if (m_isActive)
95 {
96 m_isActive = false;
98 }
99
100 for (uint8 i = 0; i < BATTLEFIELD_WG_GRAVEYARD_MAX; i++)
101 {
102 BfGraveyardWG* graveyard = new BfGraveyardWG(this);
103
104 // When between games, the graveyard is controlled by the defending team
105 if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL)
107 else
108 graveyard->Initialize(WGGraveYard[i].startcontrol, WGGraveYard[i].gyid);
109
110 graveyard->SetTextId(WGGraveYard[i].textid);
111 m_GraveyardList[i] = graveyard;
112 }
113
114 // Spawn workshop creatures and gameobjects
115 for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++)
116 {
117 WGWorkshop* workshop = new WGWorkshop(this, i);
119 workshop->GiveControlTo(GetAttackerTeam(), true);
120 else
121 workshop->GiveControlTo(GetDefenderTeam(), true);
122
123 // Note: Capture point is added once the gameobject is created.
124 WorkshopsList.insert(workshop);
125 }
126
127 // Spawn NPCs in the defender's keep, both Horde and Alliance
128 for (uint8 i = 0; i < WG_MAX_KEEP_NPC; i++)
129 {
130 // Horde npc
131 if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryHorde, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_HORDE))
132 KeepCreature[TEAM_HORDE].insert(creature->GetGUID());
133 // Alliance npc
134 if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryAlliance, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_ALLIANCE))
135 KeepCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
136 }
137
138 // Hide NPCs from the Attacker's team in the keep
139 for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
140 if (Creature* creature = GetCreature(*itr))
141 HideNpc(creature);
142
143 // Spawn Horde NPCs outside the keep
144 for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++)
145 if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryHorde, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_HORDE))
146 OutsideCreature[TEAM_HORDE].insert(creature->GetGUID());
147
148 // Spawn Alliance NPCs outside the keep
150 if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryAlliance, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_ALLIANCE))
151 OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
152
153 // Hide units outside the keep that are defenders
154 for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
155 if (Creature* creature = GetCreature(*itr))
156 HideNpc(creature);
157
158 // Spawn turrets and hide them per default
159 for (uint8 i = 0; i < WG_MAX_TURRET; i++)
160 {
161 Position towerCannonPos = WGTurret[i].GetPosition();
162 if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE))
163 {
164 CanonList.insert(creature->GetGUID());
165 HideNpc(creature);
166 }
167 }
168
169 // Spawn all gameobjects
170 for (uint8 i = 0; i < WG_MAX_OBJ; i++)
171 {
174 b->Init(go, WGGameObjectBuilding[i].type, WGGameObjectBuilding[i].WorldState, WGGameObjectBuilding[i].damageText, WGGameObjectBuilding[i].destroyText);
175 BuildingsInZone.insert(b);
176 }
177
178 // Spawning portal defender
179 for (uint8 i = 0; i < WG_MAX_TELEPORTER; i++)
180 {
182 DefenderPortalList.insert(go);
184 }
185
187 return true;
188}
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
constexpr auto MINUTE
Definition: Common.h:47
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
std::uint64_t uint64
Definition: Define.h:106
#define sMapMgr
Definition: MapMgr.h:221
@ BATTLEFIELD_WG_MAPID
Definition: BattlefieldWG.h:118
@ BATTLEFIELD_WG_ZONEID
Definition: BattlefieldWG.h:117
const uint8 WG_OUTSIDE_ALLIANCE_NPC
Definition: BattlefieldWG.h:484
const WintergraspTeleporterData WGPortalDefenderData[WG_MAX_TELEPORTER]
Definition: BattlefieldWG.h:769
@ BATTLEFIELD_WG_NPC_STALKER
Definition: BattlefieldWG.h:172
const WintergraspObjectPositionData WGOutsideNPC[WG_MAX_OUTSIDE_NPC]
Definition: BattlefieldWG.h:742
const Position WGTurret[WG_MAX_TURRET]
Definition: BattlefieldWG.h:662
const WintergraspObjectPositionData WGKeepNPC[WG_MAX_KEEP_NPC]
Definition: BattlefieldWG.h:683
const uint8 WG_MAX_OUTSIDE_NPC
Definition: BattlefieldWG.h:483
const uint8 WG_MAX_OBJ
Definition: BattlefieldWG.h:480
const uint8 WG_MAX_TELEPORTER
Definition: BattlefieldWG.h:485
const uint8 WG_MAX_TURRET
Definition: BattlefieldWG.h:481
@ BATTLEFIELD_WG_GRAVEYARD_MAX
Definition: BattlefieldWG.h:153
const uint8 WG_MAX_KEEP_NPC
Definition: BattlefieldWG.h:482
uint8 const WG_MAX_WORKSHOP
Definition: BattlefieldWG.h:1064
const BfWGCoordGY WGGraveYard[BATTLEFIELD_WG_GRAVEYARD_MAX]
Definition: BattlefieldWG.h:243
const WintergraspBuildingSpawnData WGGameObjectBuilding[WG_MAX_OBJ]
Definition: BattlefieldWG.h:614
@ BATTLEFIELD_WG_DATA_MAX
Definition: BattlefieldWG.h:100
float const WintergraspStalkerPos[4]
Definition: BattlefieldWG.h:44
@ BATTLEFIELD_WG
Definition: Battlefield.h:31
@ BATTLEFIELD_BATTLEID_WG
Definition: Battlefield.h:37
@ CONFIG_WINTERGRASP_PLR_MIN_LVL
Definition: IWorld.h:370
@ CONFIG_WINTERGRASP_BATTLETIME
Definition: IWorld.h:371
@ CONFIG_WINTERGRASP_NOBATTLETIME
Definition: IWorld.h:372
@ CONFIG_WINTERGRASP_RESTART_AFTER_CRASH
Definition: IWorld.h:373
@ CONFIG_WINTERGRASP_ENABLE
Definition: IWorld.h:325
@ CONFIG_WINTERGRASP_PLR_MAX
Definition: IWorld.h:368
@ CONFIG_WINTERGRASP_PLR_MIN
Definition: IWorld.h:369
void Initialize(TeamId startcontrol, uint32 gy)
Definition: Battlefield.cpp:673
uint32 m_MaxPlayer
Definition: Battlefield.h:387
std::vector< uint32 > m_Data32
Definition: Battlefield.h:409
uint32 m_NoWarBattleTime
Definition: Battlefield.h:391
uint32 m_BattleTime
Definition: Battlefield.h:390
uint32 m_TypeId
Definition: Battlefield.h:382
uint32 m_BattleId
Definition: Battlefield.h:383
Creature * SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId teamId)
Definition: Battlefield.cpp:784
uint32 m_StartGroupingTimer
Definition: Battlefield.h:403
Map * m_Map
Definition: Battlefield.h:386
void RegisterZone(uint32 zoneid)
Definition: Battlefield.cpp:487
uint32 m_TimeForAcceptInvite
Definition: Battlefield.h:393
uint32 m_RestartAfterCrash
Definition: Battlefield.h:392
uint32 m_MinLevel
Definition: Battlefield.h:389
void InitStalker(uint32 entry, float x, float y, float z, float o)
Definition: Battlefield.cpp:308
uint32 m_MinPlayer
Definition: Battlefield.h:388
bool m_IsEnabled
Definition: Battlefield.h:367
bool m_StartGrouping
Definition: Battlefield.h:404
WorldLocation KickPosition
Definition: Battlefield.h:395
void SetGraveyardNumber(uint32 number)
Definition: Battlefield.h:299
Definition: BattlefieldWG.h:134
void SetTextId(uint32 textid)
Definition: BattlefieldWG.h:138
uint32 m_saveTimer
Definition: BattlefieldWG.h:475
Definition: BattlefieldWG.h:1095
void Init(GameObject *gobj, uint32 type, uint32 worldstate, uint8 damageText, uint8 destroyText)
Definition: BattlefieldWG.h:1227
void GiveControlTo(TeamId team, bool init)
Definition: BattlefieldWG.h:1468
Definition: Position.h:28
void GetPosition(float &x, float &y) const
Definition: Position.h:122
void Relocate(float x, float y)
Definition: Position.h:73
uint32 m_mapId
Definition: Position.h:319

References BATTLEFIELD_BATTLEID_WG, BATTLEFIELD_WG, BATTLEFIELD_WG_DATA_MAX, BATTLEFIELD_WG_GRAVEYARD_MAX, BATTLEFIELD_WG_GY_WORKSHOP_SE, BATTLEFIELD_WG_GY_WORKSHOP_SW, BATTLEFIELD_WG_MAPID, BATTLEFIELD_WG_NPC_STALKER, BATTLEFIELD_WG_WORKSHOP_SE, BATTLEFIELD_WG_WORKSHOP_SW, BATTLEFIELD_WG_WORLD_STATE_ACTIVE, BATTLEFIELD_WG_WORLD_STATE_DEFENDER, BATTLEFIELD_WG_ZONEID, BuildingsInZone, CanonList, ObjectGuid::Clear(), ClockWorldState, CONFIG_WINTERGRASP_BATTLETIME, CONFIG_WINTERGRASP_ENABLE, CONFIG_WINTERGRASP_NOBATTLETIME, CONFIG_WINTERGRASP_PLR_MAX, CONFIG_WINTERGRASP_PLR_MIN, CONFIG_WINTERGRASP_PLR_MIN_LVL, CONFIG_WINTERGRASP_RESTART_AFTER_CRASH, DefenderPortalList, GAMEOBJECT_FACTION, Battlefield::GetAttackerTeam(), Battlefield::GetCreature(), Battlefield::GetDefenderTeam(), Position::GetPosition(), WGWorkshop::GiveControlTo(), Battlefield::HideNpc(), IN_MILLISECONDS, BfWGGameObjectBuilding::Init(), BfGraveyard::Initialize(), Battlefield::InitStalker(), KeepCreature, Battlefield::KickPosition, Battlefield::m_BattleId, Battlefield::m_BattleTime, Battlefield::m_Data32, Battlefield::m_DefenderTeam, Battlefield::m_GraveyardList, Battlefield::m_isActive, Battlefield::m_IsEnabled, Battlefield::m_Map, Battlefield::m_MapId, WorldLocation::m_mapId, Battlefield::m_MaxPlayer, Battlefield::m_MinLevel, Battlefield::m_MinPlayer, Battlefield::m_NoWarBattleTime, Battlefield::m_RestartAfterCrash, m_saveTimer, Battlefield::m_StartGrouping, Battlefield::m_StartGroupingTimer, m_tenacityStack, Battlefield::m_TimeForAcceptInvite, Battlefield::m_Timer, m_titansRelic, Battlefield::m_TypeId, Battlefield::m_ZoneId, MINUTE, NPC_WINTERGRASP_TOWER_CANNON, OutsideCreature, Battlefield::RegisterZone(), Position::Relocate(), Battlefield::SetGraveyardNumber(), BfGraveyardWG::SetTextId(), Object::SetUInt32Value(), sMapMgr, Battlefield::SpawnCreature(), Battlefield::SpawnGameObject(), sWorld, TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, UpdateCounterVehicle(), urand(), WG_MAX_KEEP_NPC, WG_MAX_OBJ, WG_MAX_OUTSIDE_NPC, WG_MAX_TELEPORTER, WG_MAX_TURRET, WG_MAX_WORKSHOP, WG_OUTSIDE_ALLIANCE_NPC, WGGameObjectBuilding, WGGraveYard, WGKeepNPC, WGOutsideNPC, WGPortalDefenderData, WGTurret, WintergraspFaction, WintergraspStalkerPos, and WorkshopsList.

◆ Update()

bool BattlefieldWG::Update ( uint32  diff)
overridevirtual

Called for update battlefield data.

  • Save battle timer in database every minutes
  • Update imunity aura from graveyard
    Parameters
    diff: time elapsed since the last call (in ms)

Reimplemented from Battlefield.

191{
192 bool m_return = Battlefield::Update(diff);
193 if (m_saveTimer <= diff)
194 {
197 sWorld->setWorldState(ClockWorldState[0], m_Timer);
199 }
200 else
201 m_saveTimer -= diff;
202
203 // Update Tenacity
204 if (IsWarTime())
205 {
206 if (m_tenacityUpdateTimer <= diff)
207 {
208 m_tenacityUpdateTimer = 10000;
209 if (!m_updateTenacityList.empty())
211 m_updateTenacityList.clear();
212 }
213 else
214 m_tenacityUpdateTimer -= diff;
215 }
216
217 return m_return;
218}
virtual bool Update(uint32 diff)
Called every time for update bf data and time.
Definition: Battlefield.cpp:142
void UpdateTenacity()
Definition: BattlefieldWG.cpp:1123

References BATTLEFIELD_WG_WORLD_STATE_ACTIVE, BATTLEFIELD_WG_WORLD_STATE_DEFENDER, ClockWorldState, IN_MILLISECONDS, Battlefield::IsWarTime(), Battlefield::m_DefenderTeam, Battlefield::m_isActive, m_saveTimer, m_tenacityUpdateTimer, Battlefield::m_Timer, m_updateTenacityList, sWorld, Battlefield::Update(), and UpdateTenacity().

◆ UpdateCounterVehicle()

void BattlefieldWG::UpdateCounterVehicle ( bool  init)

Vehicle world states update.

298{
299 if (init)
300 {
303 }
306
307 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
308 {
309 if (WGWorkshop* workshop = (*itr))
310 {
311 if (workshop->teamControl == TEAM_ALLIANCE)
313 else if (workshop->teamControl == TEAM_HORDE)
315 }
316 }
317
319}

References BATTLEFIELD_WG_DATA_MAX_VEHICLE_A, BATTLEFIELD_WG_DATA_MAX_VEHICLE_H, BATTLEFIELD_WG_DATA_VEHICLE_A, BATTLEFIELD_WG_DATA_VEHICLE_H, Battlefield::SetData(), TEAM_ALLIANCE, TEAM_HORDE, UpdateVehicleCountWG(), and WorkshopsList.

Referenced by WGWorkshop::GiveControlTo(), OnBattleStart(), and SetupBattlefield().

◆ UpdateDamagedTowerCount()

void BattlefieldWG::UpdateDamagedTowerCount ( TeamId  team)

Called when a tower is damaged.

  • Update tower count (for reward calcul)
1093{
1094 if (team == GetAttackerTeam())
1095 {
1098 }
1099}

References BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT, BATTLEFIELD_WG_DATA_INTACT_TOWER_ATT, and Battlefield::GetAttackerTeam().

Referenced by BfWGGameObjectBuilding::Damaged().

◆ UpdatedDestroyedTowerCount()

void BattlefieldWG::UpdatedDestroyedTowerCount ( TeamId  team,
GameObject go 
)

Called when tower is broken.

  • Update tower buff
  • check if three south tower is down for remove 10 minutes to wg
1001{
1002 // Destroy an attack tower
1003 if (team == GetAttackerTeam())
1004 {
1005 // Update counter
1008
1009 // Remove buff stack on attackers
1010 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
1011 if (Player* player = ObjectAccessor::FindPlayer(*itr))
1012 player->RemoveAuraFromStack(SPELL_TOWER_CONTROL);
1013
1014 // Add buff stack to defenders
1015 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
1016 if (Player* player = ObjectAccessor::FindPlayer(*itr))
1017 {
1018 // Quest - Wintergrasp - Southern Tower Kill
1019 if (go && player->GetDistance2d(go) < 200.0f)
1020 player->KilledMonsterCredit(NPC_QUEST_SOUTHERN_TOWER_KILL);
1021
1022 player->CastSpell(player, SPELL_TOWER_CONTROL, true);
1023 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_LEANING_TOWER_ACHIEVEMENT, 0, 0);
1024 }
1025
1026 // If all three south towers are destroyed (ie. all attack towers), remove ten minutes from battle time
1028 {
1029 if (int32(m_Timer - 600000) < 0)
1030 m_Timer = 0;
1031 else
1032 m_Timer -= 600000;
1034 }
1035 }
1036 else
1037 {
1038 // Xinef: rest of structures, quest credit
1039 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
1040 if (Player* player = ObjectAccessor::FindPlayer(*itr))
1041 {
1042 // Quest - Wintergrasp - Vehicle Protected
1043 if (go && player->GetDistance2d(go) < 100.0f)
1044 player->KilledMonsterCredit(NPC_QUEST_VEHICLE_PROTECTED);
1045 }
1046 }
1047}
std::int32_t int32
Definition: Define.h:103
@ NPC_QUEST_VEHICLE_PROTECTED
Definition: BattlefieldWG.h:219
@ NPC_QUEST_SOUTHERN_TOWER_KILL
Definition: BattlefieldWG.h:218
@ SPELL_LEANING_TOWER_ACHIEVEMENT
Definition: BattlefieldWG.h:81
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET
Definition: DBCEnums.h:142
void SendInitWorldStatesToAll() override
Send all worldstate data to all player in zone.
Definition: BattlefieldWG.cpp:978

References ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, BATTLEFIELD_WG_DATA_BROKEN_TOWER_ATT, BATTLEFIELD_WG_DATA_DAMAGED_TOWER_ATT, ObjectAccessor::FindPlayer(), Battlefield::GetAttackerTeam(), GetData(), Battlefield::GetDefenderTeam(), WorldObject::GetDistance2d(), Battlefield::m_PlayersInWar, Battlefield::m_Timer, NPC_QUEST_SOUTHERN_TOWER_KILL, NPC_QUEST_VEHICLE_PROTECTED, SendInitWorldStatesToAll(), SPELL_LEANING_TOWER_ACHIEVEMENT, and SPELL_TOWER_CONTROL.

Referenced by BfWGGameObjectBuilding::Destroyed().

◆ UpdateTenacity()

void BattlefieldWG::UpdateTenacity ( )
1124{
1125 TeamId team = TEAM_NEUTRAL;
1126 uint32 alliancePlayers = m_PlayersInWar[TEAM_ALLIANCE].size();
1127 uint32 hordePlayers = m_PlayersInWar[TEAM_HORDE].size();
1128 int32 newStack = 0;
1129
1130 if (alliancePlayers && hordePlayers)
1131 {
1132 if (alliancePlayers < hordePlayers)
1133 newStack = int32((((float)hordePlayers / alliancePlayers) - 1.0f) * 4.0f); // positive, should cast on alliance
1134 else if (alliancePlayers > hordePlayers)
1135 newStack = int32((1.0f - ((float)alliancePlayers / hordePlayers)) * 4.0f); // negative, should cast on horde
1136 }
1137
1138 // Return if no change in stack and apply tenacity to new player
1139 if (newStack == m_tenacityStack)
1140 {
1141 for (GuidUnorderedSet::const_iterator itr = m_updateTenacityList.begin(); itr != m_updateTenacityList.end(); ++itr)
1142 if (Player* newPlayer = ObjectAccessor::FindPlayer(*itr))
1143 if ((newPlayer->GetTeamId() == TEAM_ALLIANCE && m_tenacityStack > 0) || (newPlayer->GetTeamId() == TEAM_HORDE && m_tenacityStack < 0))
1144 {
1145 newStack = std::min(std::abs(newStack), 20);
1146 uint32 buff_honor = GetHonorBuff(newStack);
1147 newPlayer->SetAuraStack(SPELL_TENACITY, newPlayer, newStack);
1148 if (buff_honor)
1149 newPlayer->CastSpell(newPlayer, buff_honor, true);
1150 }
1151 return;
1152 }
1153
1154 if (m_tenacityStack != 0)
1155 {
1156 if (m_tenacityStack > 0 && newStack <= 0) // old buff was on alliance
1157 team = TEAM_ALLIANCE;
1158 else if (m_tenacityStack < 0 && newStack >= 0) // old buff was on horde
1159 team = TEAM_HORDE;
1160 }
1161
1162 m_tenacityStack = newStack;
1163 // Remove old buff
1164 if (team != TEAM_NEUTRAL)
1165 {
1166 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
1167 if (Player* player = ObjectAccessor::FindPlayer(*itr))
1168 player->RemoveAurasDueToSpell(SPELL_TENACITY);
1169
1170 for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
1171 if (Creature* creature = GetCreature(*itr))
1172 creature->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
1173 }
1174
1175 // Apply new buff
1176 if (newStack)
1177 {
1178 team = newStack > 0 ? TEAM_ALLIANCE : TEAM_HORDE;
1179 newStack = std::min(std::abs(newStack), 20);
1180 uint32 buff_honor = GetHonorBuff(newStack);
1181
1182 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
1183 if (Player* player = ObjectAccessor::FindPlayer(*itr))
1184 {
1185 player->SetAuraStack(SPELL_TENACITY, player, newStack);
1186 if (buff_honor)
1187 player->CastSpell(player, buff_honor, true);
1188 }
1189
1190 for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
1191 if (Creature* creature = GetCreature(*itr))
1192 {
1193 creature->SetAuraStack(SPELL_TENACITY_VEHICLE, creature, newStack);
1194 if (buff_honor)
1195 creature->CastSpell(creature, buff_honor, true);
1196 }
1197 }
1198}
@ SPELL_TENACITY_VEHICLE
Definition: BattlefieldWG.h:53
uint32 GetHonorBuff(int32 stack) const
Definition: BattlefieldWG.cpp:1101

References ObjectAccessor::FindPlayer(), Battlefield::GetCreature(), GetHonorBuff(), Battlefield::m_PlayersInWar, m_tenacityStack, m_updateTenacityList, m_vehicles, SPELL_TENACITY, SPELL_TENACITY_VEHICLE, TEAM_ALLIANCE, TEAM_HORDE, and TEAM_NEUTRAL.

Referenced by Update().

◆ UpdateVehicleCountWG()

Member Data Documentation

◆ BuildingsInZone

◆ CanonList

GuidUnorderedSet BattlefieldWG::CanonList
protected

◆ DefenderPortalList

GameObjectSet BattlefieldWG::DefenderPortalList
protected

Referenced by OnBattleEnd(), and SetupBattlefield().

◆ KeepCreature

GuidUnorderedSet BattlefieldWG::KeepCreature[2]
protected

Referenced by OnBattleEnd(), and SetupBattlefield().

◆ m_isRelicInteractible

bool BattlefieldWG::m_isRelicInteractible
protected

◆ m_KeepGameObject

GameObjectSet BattlefieldWG::m_KeepGameObject[2]
protected

Referenced by OnBattleEnd().

◆ m_saveTimer

uint32 BattlefieldWG::m_saveTimer
protected

Referenced by SetupBattlefield(), and Update().

◆ m_tenacityStack

int32 BattlefieldWG::m_tenacityStack
protected

◆ m_tenacityUpdateTimer

uint32 BattlefieldWG::m_tenacityUpdateTimer
protected

Referenced by OnBattleStart(), and Update().

◆ m_titansRelic

ObjectGuid BattlefieldWG::m_titansRelic
protected

◆ m_updateTenacityList

GuidUnorderedSet BattlefieldWG::m_updateTenacityList
protected

◆ m_vehicles

GuidUnorderedSet BattlefieldWG::m_vehicles[2]
protected

◆ OutsideCreature

GuidUnorderedSet BattlefieldWG::OutsideCreature[2]
protected

Referenced by OnBattleEnd(), and SetupBattlefield().

◆ WorkshopsList