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.
 
void OnBattleEnd (bool endByTimer) override
 Called when battle end.
 
void OnStartGrouping () override
 Called when grouping starts (15 minutes before battlestart)
 
void OnPlayerJoinWar (Player *player) override
 Called when player accept invite to join battle.
 
void OnPlayerLeaveWar (Player *player) override
 Called when player left the battle.
 
void OnPlayerLeaveZone (Player *player) override
 Called when player left the WG zone.
 
void OnPlayerEnterZone (Player *player) override
 Called when player enters in WG zone.
 
bool Update (uint32 diff) override
 Called for update battlefield data.
 
void OnCreatureCreate (Creature *creature) override
 Called when a creature is created.
 
void OnCreatureRemove (Creature *creature) override
 Called when a creature is removed.
 
void OnGameObjectCreate (GameObject *go) override
 Called when a gameobject is created.
 
void BrokenWallOrTower (TeamId team)
 Called when a wall/tower is broken.
 
void UpdateDamagedTowerCount (TeamId team)
 Called when a tower is damaged.
 
void UpdatedDestroyedTowerCount (TeamId team, GameObject *go)
 Called when tower is broken.
 
void RemoveAurasFromPlayer (Player *player)
 
bool SetupBattlefield () override
 Called when battlefield is setup, at server start.
 
GameObjectGetRelic ()
 Return pointer to relic object.
 
bool CanInteractWithRelic ()
 Define relic object.
 
void SetRelicInteractible (bool allow)
 Define if player can interact with the relic.
 
void UpdateCounterVehicle (bool init)
 Vehicle world states update.
 
void UpdateVehicleCountWG ()
 
void CapturePointTaken (uint32 areaId)
 
void SendInitWorldStatesTo (Player *player)
 
void SendInitWorldStatesToAll () override
 Send all worldstate data to all player in zone.
 
void FillInitialWorldStates (WorldPacket &data) override
 
void HandleKill (Player *killer, Unit *victim) override
 Called when a Unit is kill in battlefield zone.
 
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.
 
 ~Battlefield () override
 Destructor.
 
virtual bool SetupBattlefield ()
 Call this to init the Battlefield.
 
void SendUpdateWorldState (uint32 field, uint32 value)
 Update data of a worldstate to all players present in zone.
 
virtual bool Update (uint32 diff)
 Called every time for update bf data and time.
 
void InvitePlayersInZoneToQueue ()
 Invite all players in zone to join the queue, called x minutes before battle start in Update()
 
void InvitePlayersInQueueToWar ()
 Invite all players in queue to join battle on battle start.
 
void InvitePlayersInZoneToWar ()
 Invite all players in zone to join battle on battle start.
 
virtual void HandleKill (Player *, Unit *)
 Called when a Unit is kill in battlefield zone.
 
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.
 
void ToggleBattlefield (bool enable)
 Enable or Disable battlefield.
 
bool IsEnabled ()
 Return if battlefield is enable.
 
void KickPlayerFromBattlefield (ObjectGuid guid)
 Kick player from battlefield and teleport him to kick-point location.
 
void HandlePlayerEnterZone (Player *player, uint32 zone)
 Called when player (player) enter in zone.
 
void HandlePlayerLeaveZone (Player *player, uint32 zone)
 Called when player (player) leave the zone.
 
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.
 
GroupGetGroupPlayer (ObjectGuid guid, TeamId TeamId)
 Return battlefield group where player is.
 
bool AddOrSetPlayerToCorrectBfGroup (Player *player)
 Force player to join a battlefield group.
 
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.
 
virtual void OnBattleEnd (bool)
 Called at the end of battle.
 
virtual void OnStartGrouping ()
 Called x minutes before battle start when player in zone are invite to join queue.
 
virtual void OnPlayerJoinWar (Player *)
 Called when a player accept to join the battle.
 
virtual void OnPlayerLeaveWar (Player *)
 Called when a player leave the battle.
 
virtual void OnPlayerLeaveZone (Player *)
 Called when a player leave battlefield zone.
 
virtual void OnPlayerEnterZone (Player *)
 Called when a player enter in battlefield zone.
 
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.
 
virtual void FillInitialWorldStates (WorldPacket &)=0
 
bool CanFlyIn ()
 Return if we can use mount in battlefield.
 
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
 
- 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

33{
34 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
35 delete *itr;
36
37 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
38 delete *itr;
39}
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)
1112{
1113 m_updateTenacityList.insert(player->GetGUID());
1114}
GuidUnorderedSet m_updateTenacityList
Definition: BattlefieldWG.h:471
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106

References Object::GetGUID(), and m_updateTenacityList.

Referenced by OnPlayerJoinWar().

◆ BrokenWallOrTower()

void BattlefieldWG::BrokenWallOrTower ( TeamId  team)

Called when a wall/tower is broken.

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

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)
335{
336 for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
337 for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
338 if (Player* player = ObjectAccessor::FindPlayer(*itr))
339 if (player->GetAreaId() == areaId)
340 player->UpdateAreaDependentAuras(areaId);
341}
std::uint8_t uint8
Definition: Define.h:110
uint8 constexpr PVP_TEAMS_COUNT
Definition: SharedDefines.h:3417
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:250
GuidUnorderedSet m_players[PVP_TEAMS_COUNT]
Definition: Battlefield.h:375
Definition: Player.h:1056

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

Referenced by WGWorkshop::GiveControlTo().

◆ FillInitialWorldStates()

void BattlefieldWG::FillInitialWorldStates ( WorldPacket data)
overridevirtual

Implements Battlefield.

936{
939 data << uint32(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) << uint32(IsWarTime() ? 0 : 1); // Note: cleanup these two, their names look awkward
941
942 for (uint32 i = 0; i < 2; ++i)
943 data << ClockWorldState[i] << uint32(GameTime::GetGameTime().count() + (m_Timer / 1000));
944
949
954
955 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
956 data << (*itr)->m_WorldState << (*itr)->m_State;
957
958 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
959 if (*itr)
960 data << WorkshopsData[(*itr)->workshopId].worldstate << (*itr)->state;
961}
std::uint32_t uint32
Definition: Define.h:108
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:447
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:912
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)
773{
774 for (uint32 itr = 0; itr < 2; ++itr)
775 {
776 if (m_vehicles[itr].find(vehicle->GetGUID()) != m_vehicles[itr].end())
777 {
778 //m_vehicles[itr].erase(vehicle->GetGUID());
779 if (itr == TEAM_HORDE)
781 else
783 return true;
784 }
785 }
786 return false;
787}
@ TEAM_HORDE
Definition: SharedDefines.h:733
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
539{
540 switch (gId)
541 {
550 }
551
552 return 0;
553}
@ 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.

913{
914 // xinef: little hack, same area for default horde graveyard
915 // this graveyard is the one of broken temple!
916 if (data == AREA_THE_CHILLED_QUAGMIRE)
918
919 switch (data)
920 {
921 // Used to determine when the phasing spells must be casted
922 // See: SpellArea::IsFitToRequirements
927 // Graveyards and Workshops are controlled by the same team.
928 if (BfGraveyard const* graveyard = GetGraveyardById(GetSpiritGraveyardId(data)))
929 return graveyard->GetControlTeamId();
930 }
931
932 return Battlefield::GetData(data);
933}
@ 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:576
uint8 GetSpiritGraveyardId(uint32 areaId) const
Definition: BattlefieldWG.cpp:512

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
1101{
1102 if (stack < 5)
1103 return 0;
1104 if (stack < 10)
1105 return SPELL_GREAT_HONOR;
1106 if (stack < 15)
1107 return SPELL_GREATER_HONOR;
1108 return SPELL_GREATEST_HONOR;
1109}
@ 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:851
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
513{
514 switch (areaId)
515 {
526 case AREA_WINTERGRASP:
530 default:
531 LOG_ERROR("bg.battlefield", "BattlefieldWG::GetSpiritGraveyardId: Unexpected Area Id {}", areaId);
532 break;
533 }
534
535 return 0;
536}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
@ 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.

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

References ObjectAccessor::FindPlayer(), Object::GetEntry(), Player::GetTeamId(), Object::GetTypeId(), Unit::HasAura(), Unit::IsFriendlyTo(), IsKeepNpc(), 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, TYPEID_PLAYER, 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.

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

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.

220{
221 // Spawn titan relic
222 GameObject* go = SpawnGameObject(GO_WINTERGRASP_TITAN_S_RELIC, 5440.0f, 2840.8f, 430.43f, 0);
223 if (go)
224 {
225 // Update faction of relic, only attacker can click on
227 // Set in use (not allow to click on before last door is broken)
229
230 // save guid
231 m_titansRelic = go->GetGUID();
232 }
233 else
234 LOG_ERROR("bg.battlefield", "WG: Failed to spawn titan relic.");
235
236 // Update tower visibility and update faction
237 for (GuidUnorderedSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
238 {
239 if (Creature* creature = GetCreature(*itr))
240 {
241 ShowNpc(creature, true);
242 creature->SetFaction(WintergraspFaction[GetDefenderTeam()]);
243 }
244 }
245
246 // Rebuild all wall
247 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
248 {
249 if (*itr)
250 {
251 (*itr)->Rebuild();
252 (*itr)->UpdateTurretAttack(false);
253 }
254 }
255
259
260 // Update graveyard (in no war time all graveyard is to deffender, in war time, depend of base)
261 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
262 if (*itr)
263 (*itr)->UpdateGraveyardAndWorkshop();
264
265 // Set Sliders capture points data to his owners when battle start
266 for (BfCapturePointVector::const_iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
267 (*itr)->SetCapturePointData((*itr)->GetCapturePointGo(),
268 (*itr)->GetCapturePointGo()->GetEntry() == GO_WINTERGRASP_FACTORY_BANNER_SE || (*itr)->GetCapturePointGo()->GetEntry() == GO_WINTERGRASP_FACTORY_BANNER_SW ? GetAttackerTeam() : GetDefenderTeam());
269
270 for (uint8 team = 0; team < 2; ++team)
271 for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
272 {
273 // Kick player in orb room, TODO: offline player ?
274 if (Player* player = ObjectAccessor::FindPlayer(*itr))
275 {
276 float x, y, z;
277 player->GetPosition(x, y, z);
278 if (5500 > x && x > 5392 && y < 2880 && y > 2800 && z < 480)
279 player->TeleportTo(571, 5349.8686f, 2838.481f, 409.240f, 0.046328f);
280 SendInitWorldStatesTo(player);
281 }
282 }
283 // Initialize vehicle counter
285 // Send start warning to all players
287
288 // Xinef: reset tenacity counter
289 m_tenacityStack = 0;
290 m_tenacityUpdateTimer = 20000;
291
294}
@ 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:1579
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:819
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:296
uint32 m_tenacityUpdateTimer
Definition: BattlefieldWG.h:474
void SendInitWorldStatesTo(Player *player)
Definition: BattlefieldWG.cpp:963
void SetGameObjectFlag(GameObjectFlags flags)
Definition: GameObject.h:220
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(), 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.

556{
557 // Accessing to db spawned creatures
558 switch (creature->GetEntry())
559 {
562 {
564 uint8 graveyardId = GetSpiritGraveyardId(creature->GetAreaId());
565 // xinef: little workaround, there are 2 spirit guides in same area
566 if (creature->IsWithinDist2d(5103.0f, 3461.5f, 5.0f))
567 graveyardId = BATTLEFIELD_WG_GY_WORKSHOP_NW;
568
569 if (m_GraveyardList[graveyardId])
570 m_GraveyardList[graveyardId]->SetSpirit(creature, teamId);
571 break;
572 }
573 }
574
575 // untested code - not sure if it is valid.
576 if (IsWarTime())
577 {
578 switch (creature->GetEntry())
579 {
584 {
585 if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID())
586 return;
587
589 if (!creator)
590 return;
591 TeamId team = creator->GetTeamId();
592
593 if (team == TEAM_HORDE)
594 {
596 {
598 creature->CastSpell(creature, SPELL_HORDE_FLAG, true);
599 m_vehicles[team].insert(creature->GetGUID());
601 }
602 else
603 {
604 creature->DespawnOrUnsummon();
605 return;
606 }
607 }
608 else
609 {
611 {
613 creature->CastSpell(creature, SPELL_ALLIANCE_FLAG, true);
614 m_vehicles[team].insert(creature->GetGUID());
616 }
617 else
618 {
619 creature->DespawnOrUnsummon();
620 return;
621 }
622 }
623 break;
624 }
627 {
628 if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID())
629 return;
630
631 if (Unit* owner = creature->ToTempSummon()->GetSummonerUnit())
632 creature->SetFaction(owner->GetFaction());
633 break;
634 }
635 }
636 }
637}
@ 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:321
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
Definition: Creature.cpp:2108
ObjectGuid GetSummonerGUID() const
Definition: TemporarySummon.h:55
Unit * GetSummonerUnit() const
Definition: TemporarySummon.cpp:45
uint32 GetEntry() const
Definition: Object.h:109
bool IsWithinDist2d(float x, float y, float dist) const
Definition: Object.cpp:1305
uint32 GetAreaId() const
Definition: Object.cpp:3108
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2069
Definition: Unit.h:1302
void SetFaction(uint32 faction)
Definition: Unit.cpp:10056
TempSummon * ToTempSummon()
Definition: Unit.h:2412
bool IsSummon() const
Definition: Unit.h:1422
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:1169

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.

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

◆ OnGameObjectCreate()

void BattlefieldWG::OnGameObjectCreate ( GameObject go)
overridevirtual

Called when a gameobject is created.

Reimplemented from ZoneScript.

673{
674 uint8 workshopId = 0;
675
676 switch (go->GetEntry())
677 {
679 workshopId = BATTLEFIELD_WG_WORKSHOP_NE;
680 break;
682 workshopId = BATTLEFIELD_WG_WORKSHOP_NW;
683 break;
685 workshopId = BATTLEFIELD_WG_WORKSHOP_SE;
686 break;
688 workshopId = BATTLEFIELD_WG_WORKSHOP_SW;
689 break;
690 default:
691 return;
692 }
693
694 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
695 {
696 if (WGWorkshop* workshop = (*itr))
697 {
698 if (workshop->workshopId == workshopId)
699 {
700 WintergraspCapturePoint* capturePoint = new WintergraspCapturePoint(this, workshop->teamControl);
701 //Sending neutral team at start to set normal capture points by workshop->teamControl, TEAM_NEUTRAL is ignored at first call
702 capturePoint->SetCapturePointData(go, TEAM_NEUTRAL);
703 capturePoint->LinkToWorkshop(workshop);
704 AddCapturePoint(capturePoint);
705 break;
706 }
707 }
708 }
709}
@ 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:734
bool SetCapturePointData(GameObject *capturePoint, TeamId team)
Definition: Battlefield.cpp:920
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.

898{
899 if (!m_isActive)
900 RemoveAurasFromPlayer(player);
901
903 // Send worldstate to player
904 SendInitWorldStatesTo(player);
905
906 // xinef: Attacker, if hidden in relic room kick him out
907 if (player->GetTeamId() == GetAttackerTeam())
908 if (player->GetPositionX() > 5400.0f && player->GetPositionX() < 5490.0f && player->GetPositionY() > 2803.0f && player->GetPositionY() < 2878.0f)
910}
void KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
Definition: Battlefield.cpp:321
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:19111

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.

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

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.

874{
875 // 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
876 if (!player->GetSession()->PlayerLogout())
877 {
878 if (player->GetVehicle()) // Remove vehicle of player if he go out.
879 player->GetVehicle()->Dismiss();
880 RemoveAurasFromPlayer(player);
881 }
882
883 RemoveUpdateTenacity(player);
884}
void RemoveUpdateTenacity(Player *player)
Definition: BattlefieldWG.cpp:1116
WorldSession * GetSession() const
Definition: Player.h:1958
Vehicle * GetVehicle() const
Definition: Unit.h:2366
void Dismiss()
Definition: Vehicle.cpp:526
bool PlayerLogout() const
Definition: WorldSession.h:336

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.

887{
888 if (!m_isActive)
889 RemoveAurasFromPlayer(player);
890
895}
@ 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:4845

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.

507{
508 if (!IsWarTime())
510}
@ 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.

790{
791 if (IsWarTime())
792 if (unit->IsVehicle())
795}
bool FindAndRemoveVehicleFromList(Unit *vehicle)
Definition: BattlefieldWG.cpp:772
bool IsVehicle() const
Definition: Unit.h:1428

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

◆ ProcessEvent()

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

Reimplemented from ZoneScript.

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

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)
799{
800 if (!m_isActive)
801 return;
802 // Updating rank of player
803 if (Aura* recruitAura = killer->GetAura(SPELL_RECRUIT))
804 {
805 if (recruitAura->GetStackAmount() >= 5)
806 {
807 killer->RemoveAura(SPELL_RECRUIT);
808 killer->CastSpell(killer, SPELL_CORPORAL, true);
810 }
811 else
812 {
813 killer->CastSpell(killer, SPELL_RECRUIT, true);
814 }
815 }
816 else if (Aura* corporalAura = killer->GetAura(SPELL_CORPORAL))
817 {
818 if (corporalAura->GetStackAmount() >= 5)
819 {
820 killer->RemoveAura(SPELL_CORPORAL);
821 killer->CastSpell(killer, SPELL_LIEUTENANT, true);
823 }
824 else
825 {
826 killer->CastSpell(killer, SPELL_CORPORAL, true);
827 }
828 }
829}
@ 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:5509
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4712
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)
1117{
1118 m_updateTenacityList.erase(player->GetGUID());
1120}
static ObjectGuid const Empty
Definition: ObjectGuid.h:122

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

Referenced by OnPlayerLeaveWar().

◆ SendInitWorldStatesTo()

void BattlefieldWG::SendInitWorldStatesTo ( Player player)
964{
965 WorldPacket data(SMSG_INIT_WORLD_STATES, (4 + 4 + 4 + 2 + (BuildingsInZone.size() * 8) + (WorkshopsList.size() * 8)));
966
967 data << uint32(m_MapId);
968 data << uint32(m_ZoneId);
969 data << uint32(0);
970 data << uint16(14 + BuildingsInZone.size() + WorkshopsList.size()); // Number of fields
971
973
974 player->GetSession()->SendPacket(&data);
975}
std::uint16_t uint16
Definition: Define.h:109
@ 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:935
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:207

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.

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

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.

42{
43 m_TypeId = BATTLEFIELD_WG; // See enum BattlefieldTypes
47 m_Map = sMapMgr->FindMap(m_MapId, 0);
48
49 // init stalker AFTER setting map id... we spawn it at map=random memory value?...
51
53 m_IsEnabled = sWorld->getIntConfig(CONFIG_WINTERGRASP_ENABLE) == 1;
59
62 m_StartGrouping = false;
63
66
67 KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0);
69
71
73
74 m_saveTimer = 60000;
75
76 // Init GraveYards
78
79 // Load from db
80 if (!sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) &&
82 !sWorld->getWorldState(ClockWorldState[0]))
83 {
84 sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, uint64(false));
87 }
88
91
92 m_Timer = sWorld->getWorldState(ClockWorldState[0]);
93 if (m_isActive)
94 {
95 m_isActive = false;
97 }
98
99 for (uint8 i = 0; i < BATTLEFIELD_WG_GRAVEYARD_MAX; i++)
100 {
101 BfGraveyardWG* graveyard = new BfGraveyardWG(this);
102
103 // When between games, the graveyard is controlled by the defending team
104 if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL)
106 else
107 graveyard->Initialize(WGGraveYard[i].startcontrol, WGGraveYard[i].gyid);
108
109 graveyard->SetTextId(WGGraveYard[i].textid);
110 m_GraveyardList[i] = graveyard;
111 }
112
113 // Spawn workshop creatures and gameobjects
114 for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++)
115 {
116 WGWorkshop* workshop = new WGWorkshop(this, i);
118 workshop->GiveControlTo(GetAttackerTeam(), true);
119 else
120 workshop->GiveControlTo(GetDefenderTeam(), true);
121
122 // Note: Capture point is added once the gameobject is created.
123 WorkshopsList.insert(workshop);
124 }
125
126 // Spawn NPCs in the defender's keep, both Horde and Alliance
127 for (uint8 i = 0; i < WG_MAX_KEEP_NPC; i++)
128 {
129 // Horde npc
130 if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryHorde, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_HORDE))
131 KeepCreature[TEAM_HORDE].insert(creature->GetGUID());
132 // Alliance npc
133 if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryAlliance, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_ALLIANCE))
134 KeepCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
135 }
136
137 // Hide NPCs from the Attacker's team in the keep
138 for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
139 if (Creature* creature = GetCreature(*itr))
140 HideNpc(creature);
141
142 // Spawn Horde NPCs outside the keep
143 for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++)
144 if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryHorde, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_HORDE))
145 OutsideCreature[TEAM_HORDE].insert(creature->GetGUID());
146
147 // Spawn Alliance NPCs outside the keep
149 if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryAlliance, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_ALLIANCE))
150 OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID());
151
152 // Hide units outside the keep that are defenders
153 for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
154 if (Creature* creature = GetCreature(*itr))
155 HideNpc(creature);
156
157 // Spawn turrets and hide them per default
158 for (uint8 i = 0; i < WG_MAX_TURRET; i++)
159 {
160 Position towerCannonPos = WGTurret[i].GetPosition();
161 if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE))
162 {
163 CanonList.insert(creature->GetGUID());
164 HideNpc(creature);
165 }
166 }
167
168 // Spawn all gameobjects
169 for (uint8 i = 0; i < WG_MAX_OBJ; i++)
170 {
173 b->Init(go, WGGameObjectBuilding[i].type, WGGameObjectBuilding[i].WorldState, WGGameObjectBuilding[i].damageText, WGGameObjectBuilding[i].destroyText);
174 BuildingsInZone.insert(b);
175 }
176
177 // Spawning portal defender
178 for (uint8 i = 0; i < WG_MAX_TELEPORTER; i++)
179 {
181 DefenderPortalList.insert(go);
183 }
184
186 return true;
187}
constexpr auto IN_MILLISECONDS
Definition: Common.h:62
constexpr auto MINUTE
Definition: Common.h:56
std::uint64_t uint64
Definition: Define.h:107
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ BATTLEFIELD_WG
Definition: Battlefield.h:31
@ BATTLEFIELD_BATTLEID_WG
Definition: Battlefield.h:37
@ 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
#define sMapMgr
Definition: MapMgr.h:221
@ CONFIG_WINTERGRASP_PLR_MIN_LVL
Definition: IWorld.h:366
@ CONFIG_WINTERGRASP_BATTLETIME
Definition: IWorld.h:367
@ CONFIG_WINTERGRASP_NOBATTLETIME
Definition: IWorld.h:368
@ CONFIG_WINTERGRASP_RESTART_AFTER_CRASH
Definition: IWorld.h:369
@ CONFIG_WINTERGRASP_ENABLE
Definition: IWorld.h:321
@ CONFIG_WINTERGRASP_PLR_MAX
Definition: IWorld.h:364
@ CONFIG_WINTERGRASP_PLR_MIN
Definition: IWorld.h:365
void Initialize(TeamId startcontrol, uint32 gy)
Definition: Battlefield.cpp:668
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:779
uint32 m_StartGroupingTimer
Definition: Battlefield.h:403
Map * m_Map
Definition: Battlefield.h:386
void RegisterZone(uint32 zoneid)
Definition: Battlefield.cpp:482
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:303
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.

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

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.

297{
298 if (init)
299 {
302 }
305
306 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
307 {
308 if (WGWorkshop* workshop = (*itr))
309 {
310 if (workshop->teamControl == TEAM_ALLIANCE)
312 else if (workshop->teamControl == TEAM_HORDE)
314 }
315 }
316
318}

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)
1092{
1093 if (team == GetAttackerTeam())
1094 {
1097 }
1098}

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

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

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