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)
1104{
1105 m_updateTenacityList.insert(player->GetGUID());
1106}
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
978{
979 // might be some use for this in the future. old code commented out below. KL
980 /* if (team == GetDefenderTeam())
981 {
982 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
983 {
984 if (Player* player = ObjectAccessor::FindPlayer(*itr))
985 IncrementQuest(player, WGQuest[player->GetTeamId()][2], true);
986 }
987 }*/
988}

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)
330{
331 for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
332 for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
333 if (Player* player = ObjectAccessor::FindPlayer(*itr))
334 if (player->GetAreaId() == areaId)
335 player->UpdateAreaDependentAuras(areaId);
336}
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:374
Definition: Player.h:1046

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

Referenced by WGWorkshop::GiveControlTo().

◆ FillInitialWorldStates()

void BattlefieldWG::FillInitialWorldStates ( WorldPacket data)
overridevirtual

Implements Battlefield.

928{
931 data << uint32(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) << uint32(IsWarTime() ? 0 : 1); // Note: cleanup these two, their names look awkward
933
934 for (uint32 i = 0; i < 2; ++i)
935 data << ClockWorldState[i] << uint32(GameTime::GetGameTime().count() + (m_Timer / 1000));
936
941
946
947 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
948 data << (*itr)->m_WorldState << (*itr)->m_State;
949
950 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
951 if (*itr)
952 data << WorkshopsData[(*itr)->workshopId].worldstate << (*itr)->state;
953}
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:451
Seconds GetGameTime()
Definition: GameTime.cpp:38
uint32 m_Timer
Definition: Battlefield.h:365
TeamId GetDefenderTeam()
Definition: Battlefield.h:276
bool IsWarTime()
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:248
TeamId GetAttackerTeam()
Definition: Battlefield.h:277
uint32 GetData(uint32 data) const override
Definition: BattlefieldWG.cpp:904
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)
765{
766 for (uint32 itr = 0; itr < 2; ++itr)
767 {
768 if (m_vehicles[itr].find(vehicle->GetGUID()) != m_vehicles[itr].end())
769 {
770 //m_vehicles[itr].erase(vehicle->GetGUID());
771 if (itr == TEAM_HORDE)
773 else
775 return true;
776 }
777 }
778 return false;
779}
@ 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
531{
532 switch (gId)
533 {
542 }
543
544 return 0;
545}
@ 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.

905{
906 // xinef: little hack, same area for default horde graveyard
907 // this graveyard is the one of broken temple!
908 if (data == AREA_THE_CHILLED_QUAGMIRE)
910
911 switch (data)
912 {
913 // Used to determine when the phasing spells must be casted
914 // See: SpellArea::IsFitToRequirements
919 // Graveyards and Workshops are controlled by the same team.
920 if (BfGraveyard const* graveyard = GetGraveyardById(GetSpiritGraveyardId(data)))
921 return graveyard->GetControlTeamId();
922 }
923
924 return Battlefield::GetData(data);
925}
@ AREA_THE_CHILLED_QUAGMIRE
Definition: BattlefieldWG.h:126
Definition: Battlefield.h:147
uint32 GetData(uint32 dataId) const override
Definition: Battlefield.h:271
BfGraveyard * GetGraveyardById(uint32 id) const
Definition: Battlefield.cpp:576
uint8 GetSpiritGraveyardId(uint32 areaId) const
Definition: BattlefieldWG.cpp:504

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
1093{
1094 if (stack < 5)
1095 return 0;
1096 if (stack < 10)
1097 return SPELL_GREAT_HONOR;
1098 if (stack < 15)
1099 return SPELL_GREATER_HONOR;
1100 return SPELL_GREATEST_HONOR;
1101}
@ 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
505{
506 switch (areaId)
507 {
518 case AREA_WINTERGRASP:
522 default:
523 LOG_ERROR("bg.battlefield", "BattlefieldWG::GetSpiritGraveyardId: Unexpected Area Id {}", areaId);
524 break;
525 }
526
527 return 0;
528}
#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.

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

339{
340 // Remove relic
341 if (GameObject* go = GetRelic())
342 go->RemoveFromWorld();
343
345
346 // Remove turret
347 for (GuidUnorderedSet::const_iterator itr = CanonList.begin(); itr != CanonList.end(); ++itr)
348 {
349 if (Creature* creature = GetCreature(*itr))
350 {
351 if (!endByTimer)
352 creature->SetFaction(WintergraspFaction[GetDefenderTeam()]);
353 HideNpc(creature);
354 }
355 }
356
357 // Change all npc in keep
358 for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr)
359 if (Creature* creature = GetCreature(*itr))
360 HideNpc(creature);
361
362 for (GuidUnorderedSet::const_iterator itr = KeepCreature[GetDefenderTeam()].begin(); itr != KeepCreature[GetDefenderTeam()].end(); ++itr)
363 if (Creature* creature = GetCreature(*itr))
364 ShowNpc(creature, true);
365
366 // Change all npc out of keep
367 for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr)
368 if (Creature* creature = GetCreature(*itr))
369 HideNpc(creature);
370
371 for (GuidUnorderedSet::const_iterator itr = OutsideCreature[GetAttackerTeam()].begin(); itr != OutsideCreature[GetAttackerTeam()].end(); ++itr)
372 if (Creature* creature = GetCreature(*itr))
373 ShowNpc(creature, true);
374
375 // Update all graveyard, control is to defender when no wartime
376 for (uint8 i = 0; i < BATTLEFIELD_WG_GY_HORDE; i++)
377 if (BfGraveyard* graveyard = GetGraveyardById(i))
378 graveyard->GiveControlTo(GetDefenderTeam());
379
380 for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetDefenderTeam()].begin(); itr != m_KeepGameObject[GetDefenderTeam()].end(); ++itr)
381 (*itr)->SetRespawnTime(RESPAWN_IMMEDIATELY);
382
383 for (GameObjectSet::const_iterator itr = m_KeepGameObject[GetAttackerTeam()].begin(); itr != m_KeepGameObject[GetAttackerTeam()].end(); ++itr)
384 (*itr)->SetRespawnTime(RESPAWN_ONE_DAY);
385
386 // Update portal defender faction
387 for (GameObjectSet::const_iterator itr = DefenderPortalList.begin(); itr != DefenderPortalList.end(); ++itr)
388 (*itr)->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]);
389
390 // Saving data
391 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
392 {
393 (*itr)->Rebuild();
394 (*itr)->Save();
395 (*itr)->UpdateTurretAttack(true);
396 }
397
398 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
399 (*itr)->Save();
400
401 for (uint8 team = 0; team < 2; ++team)
402 {
403 for (GuidUnorderedSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); ++itr)
404 if (Creature* creature = GetCreature(*itr))
405 creature->DespawnOrUnsummon(1);
406
407 m_vehicles[team].clear();
408 }
409
414 uint32 spellDamagedDef = SPELL_DAMAGED_TOWER;
415 uint32 spellFullDef = SPELL_DESTROYED_TOWER;
416 uint32 spellDamagedAtt = SPELL_DAMAGED_BUILDING;
417 uint32 spellFullAtt = SPELL_INTACT_BUILDING;
418
419 if (!endByTimer)
420 {
423 spellDamagedDef = SPELL_DAMAGED_BUILDING;
424 spellFullDef = SPELL_INTACT_BUILDING;
425 spellDamagedAtt = SPELL_DAMAGED_TOWER;
426 spellFullAtt = SPELL_DESTROYED_TOWER;
427 }
428
429 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
430 {
431 if (Player* player = ObjectAccessor::FindPlayer(*itr))
432 {
433 // Victory in Wintergrasp
434 player->AreaExploredOrEventHappens(GetDefenderTeam() ? 13183 : 13181); // HORDE / ALLY win wg quest id
435
436 player->CastSpell(player, SPELL_ESSENCE_OF_WINTERGRASP, true);
437 player->CastSpell(player, SPELL_VICTORY_REWARD, true);
438 RemoveAurasFromPlayer(player);
439
440 for (uint8 i = 0; i < damagedTowersDef; ++i)
441 player->CastSpell(player, spellDamagedDef, true);
442 for (uint8 i = 0; i < brokenTowersDef; ++i)
443 player->CastSpell(player, spellFullDef, true);
444 }
445 }
446
447 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
448 if (Player* player = ObjectAccessor::FindPlayer(*itr))
449 {
450 player->CastSpell(player, SPELL_DEFEAT_REWARD, true);
451 RemoveAurasFromPlayer(player);
452
453 for (uint8 i = 0; i < damagedTowersAtt; ++i)
454 player->CastSpell(player, spellDamagedAtt, true);
455 for (uint8 i = 0; i < brokenTowersAtt; ++i)
456 player->CastSpell(player, spellFullAtt, true);
457 }
458
459 if (!endByTimer)
460 {
461 for (uint8 team = 0; team < 2; ++team)
462 {
463 for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
464 {
465 if (Player* player = ObjectAccessor::FindPlayer(*itr))
466 {
467 player->RemoveAurasDueToSpell(m_DefenderTeam == TEAM_ALLIANCE ? SPELL_HORDE_CONTROL_PHASE_SHIFT : SPELL_ALLIANCE_CONTROL_PHASE_SHIFT, player->GetGUID());
469 }
470 }
471 }
472 }
473
474 // Clear players in war list at the end.
476 m_PlayersInWar[TEAM_HORDE].clear();
477
478 if (!endByTimer) // win alli/horde
479 {
481 sWorld->setWorldState(worldStateId, sWorld->getWorldState(worldStateId) + 1);
482
484 }
485 else // defend alli/horde
486 {
488 sWorld->setWorldState(worldStateId, sWorld->getWorldState(worldStateId) + 1);
489
491 }
492}
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
@ 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:368
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:823
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_TEXT_DEFEND_KEEP, BATTLEFIELD_WG_TEXT_WIN_KEEP, 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 for (uint8 team = 0; team < 2; ++team)
266 for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
267 {
268 // Kick player in orb room, TODO: offline player ?
269 if (Player* player = ObjectAccessor::FindPlayer(*itr))
270 {
271 float x, y, z;
272 player->GetPosition(x, y, z);
273 if (5500 > x && x > 5392 && y < 2880 && y > 2800 && z < 480)
274 player->TeleportTo(571, 5349.8686f, 2838.481f, 409.240f, 0.046328f);
275 SendInitWorldStatesTo(player);
276 }
277 }
278 // Initialize vehicle counter
280 // Send start warning to all players
282
283 // Xinef: reset tenacity counter
284 m_tenacityStack = 0;
285 m_tenacityUpdateTimer = 20000;
286
289}
@ BATTLEFIELD_WG_WORLD_START_MESSAGE
Definition: BattlefieldWG.h:165
uint8 const WG_MAX_ATTACKTOWERS
Definition: BattlefieldWG.h:804
@ GO_WINTERGRASP_TITAN_S_RELIC
Definition: BattlefieldWG.h:575
@ BATTLEFIELD_WG_TEXT_START
Definition: BattlefieldWG.h:538
@ CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE
Definition: IWorld.h:116
@ GO_FLAG_NOT_SELECTABLE
Definition: SharedDefines.h:1579
void SetData(uint32 dataId, uint32 value) override
Definition: Battlefield.h:272
GameObject * SpawnGameObject(uint32 entry, float x, float y, float z, float o)
Definition: Battlefield.cpp:819
int32 m_tenacityStack
Definition: BattlefieldWG.h:473
void UpdateCounterVehicle(bool init)
Vehicle world states update.
Definition: BattlefieldWG.cpp:291
uint32 m_tenacityUpdateTimer
Definition: BattlefieldWG.h:474
void SendInitWorldStatesTo(Player *player)
Definition: BattlefieldWG.cpp:955
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_TITAN_S_RELIC, LOG_ERROR, 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.

548{
549 // Accessing to db spawned creatures
550 switch (creature->GetEntry())
551 {
554 {
556 uint8 graveyardId = GetSpiritGraveyardId(creature->GetAreaId());
557 // xinef: little workaround, there are 2 spirit guides in same area
558 if (creature->IsWithinDist2d(5103.0f, 3461.5f, 5.0f))
559 graveyardId = BATTLEFIELD_WG_GY_WORKSHOP_NW;
560
561 if (m_GraveyardList[graveyardId])
562 m_GraveyardList[graveyardId]->SetSpirit(creature, teamId);
563 break;
564 }
565 }
566
567 // untested code - not sure if it is valid.
568 if (IsWarTime())
569 {
570 switch (creature->GetEntry())
571 {
576 {
577 if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID())
578 return;
579
581 if (!creator)
582 return;
583 TeamId team = creator->GetTeamId();
584
585 if (team == TEAM_HORDE)
586 {
588 {
590 creature->CastSpell(creature, SPELL_HORDE_FLAG, true);
591 m_vehicles[team].insert(creature->GetGUID());
593 }
594 else
595 {
596 creature->DespawnOrUnsummon();
597 return;
598 }
599 }
600 else
601 {
603 {
605 creature->CastSpell(creature, SPELL_ALLIANCE_FLAG, true);
606 m_vehicles[team].insert(creature->GetGUID());
608 }
609 else
610 {
611 creature->DespawnOrUnsummon();
612 return;
613 }
614 }
615 break;
616 }
619 {
620 if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID())
621 return;
622
623 if (Unit* owner = creature->ToTempSummon()->GetSummonerUnit())
624 creature->SetFaction(owner->GetFaction());
625 break;
626 }
627 }
628 }
629}
@ 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:399
void UpdateVehicleCountWG()
Definition: BattlefieldWG.cpp:316
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:3083
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2059
Definition: Unit.h:1290
void SetFaction(uint32 faction)
Definition: Unit.cpp:10029
TempSummon * ToTempSummon()
Definition: Unit.h:2400
bool IsSummon() const
Definition: Unit.h:1410
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.

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

◆ OnGameObjectCreate()

void BattlefieldWG::OnGameObjectCreate ( GameObject go)
overridevirtual

Called when a gameobject is created.

Reimplemented from ZoneScript.

665{
666 uint8 workshopId = 0;
667
668 switch (go->GetEntry())
669 {
671 workshopId = BATTLEFIELD_WG_WORKSHOP_NE;
672 break;
674 workshopId = BATTLEFIELD_WG_WORKSHOP_NW;
675 break;
677 workshopId = BATTLEFIELD_WG_WORKSHOP_SE;
678 break;
680 workshopId = BATTLEFIELD_WG_WORKSHOP_SW;
681 break;
682 default:
683 return;
684 }
685
686 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
687 {
688 if (WGWorkshop* workshop = (*itr))
689 {
690 if (workshop->workshopId == workshopId)
691 {
693
694 capturePoint->SetCapturePointData(go);
695 capturePoint->LinkToWorkshop(workshop);
696 AddCapturePoint(capturePoint);
697 break;
698 }
699 }
700 }
701}
@ GO_WINTERGRASP_FACTORY_BANNER_SW
Definition: BattlefieldWG.h:573
@ GO_WINTERGRASP_FACTORY_BANNER_NW
Definition: BattlefieldWG.h:571
@ GO_WINTERGRASP_FACTORY_BANNER_NE
Definition: BattlefieldWG.h:570
@ GO_WINTERGRASP_FACTORY_BANNER_SE
Definition: BattlefieldWG.h:572
@ BATTLEFIELD_WG_WORKSHOP_SE
Definition: BattlefieldWG.h:515
@ BATTLEFIELD_WG_WORKSHOP_NW
Definition: BattlefieldWG.h:514
@ BATTLEFIELD_WG_WORKSHOP_SW
Definition: BattlefieldWG.h:516
@ BATTLEFIELD_WG_WORKSHOP_NE
Definition: BattlefieldWG.h:513
bool SetCapturePointData(GameObject *capturePoint)
Definition: Battlefield.cpp:920
void AddCapturePoint(BfCapturePoint *cp)
Definition: Battlefield.h:421
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, Battlefield::GetAttackerTeam(), 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(), 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.

890{
891 if (!m_isActive)
892 RemoveAurasFromPlayer(player);
893
895 // Send worldstate to player
896 SendInitWorldStatesTo(player);
897
898 // xinef: Attacker, if hidden in relic room kick him out
899 if (player->GetTeamId() == GetAttackerTeam())
900 if (player->GetPositionX() > 5400.0f && player->GetPositionX() < 5490.0f && player->GetPositionY() > 2803.0f && player->GetPositionY() < 2878.0f)
902}
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:367
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
Aura * AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:19031

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.

836{
837 RemoveAurasFromPlayer(player);
838
839 player->CastSpell(player, SPELL_RECRUIT, true);
840 AddUpdateTenacity(player);
841
842 if (player->GetTeamId() == GetDefenderTeam())
843 player->TeleportTo(571, 5345, 2842, 410, 3.14f);
844 else
845 {
846 if (player->GetTeamId() == TEAM_HORDE)
847 player->TeleportTo(571, 5025.857422f, 3674.628906f, 362.737122f, 4.135169f);
848 else
849 player->TeleportTo(571, 5101.284f, 2186.564f, 373.549f, 3.812f);
850 }
851
852 if (player->GetTeamId() == GetAttackerTeam())
853 {
856 }
857 else
858 {
861 }
862 SendInitWorldStatesTo(player);
863}
@ SPELL_RECRUIT
Definition: BattlefieldWG.h:49
@ SPELL_TOWER_CONTROL
Definition: BattlefieldWG.h:54
void AddUpdateTenacity(Player *player)
Definition: BattlefieldWG.cpp:1103
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:19070

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.

866{
867 // 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
868 if (!player->GetSession()->PlayerLogout())
869 {
870 if (player->GetVehicle()) // Remove vehicle of player if he go out.
871 player->GetVehicle()->Dismiss();
872 RemoveAurasFromPlayer(player);
873 }
874
875 RemoveUpdateTenacity(player);
876}
void RemoveUpdateTenacity(Player *player)
Definition: BattlefieldWG.cpp:1108
WorldSession * GetSession() const
Definition: Player.h:1948
Vehicle * GetVehicle() const
Definition: Unit.h:2354
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.

879{
880 if (!m_isActive)
881 RemoveAurasFromPlayer(player);
882
887}
@ 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:4835

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.

499{
500 if (!IsWarTime())
502}
@ 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.

782{
783 if (IsWarTime())
784 if (unit->IsVehicle())
787}
bool FindAndRemoveVehicleFromList(Unit *vehicle)
Definition: BattlefieldWG.cpp:764
bool IsVehicle() const
Definition: Unit.h:1416

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

◆ ProcessEvent()

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

Reimplemented from ZoneScript.

1041{
1042 if (!obj || !IsWarTime())
1043 return;
1044
1045 // We handle only gameobjects here
1046 GameObject* go = obj->ToGameObject();
1047 if (!go)
1048 return;
1049
1050 // On click on titan relic
1052 {
1054 {
1055 EndBattle(false);
1056 }
1057 else if (GameObject* relic = GetRelic())
1058 {
1059 relic->SetRespawnTime(RESPAWN_IMMEDIATELY);
1060 }
1061 }
1062
1063 // if destroy or damage event, search the wall/tower and update worldstate/send warning message
1064 for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
1065 {
1066 if (GameObject* build = ObjectAccessor::GetGameObject(*obj, (*itr)->m_Build))
1067 {
1068 if (go->GetEntry() == build->GetEntry())
1069 {
1070 if (build->GetGOInfo()->building.damagedEvent == eventId)
1071 (*itr)->Damaged();
1072
1073 if (build->GetGOInfo()->building.destroyedEvent == eventId)
1074 (*itr)->Destroyed();
1075
1076 break;
1077 }
1078 }
1079 }
1080}
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)
791{
792 if (!m_isActive)
793 return;
794 // Updating rank of player
795 if (Aura* recruitAura = killer->GetAura(SPELL_RECRUIT))
796 {
797 if (recruitAura->GetStackAmount() >= 5)
798 {
799 killer->RemoveAura(SPELL_RECRUIT);
800 killer->CastSpell(killer, SPELL_CORPORAL, true);
802 }
803 else
804 {
805 killer->CastSpell(killer, SPELL_RECRUIT, true);
806 }
807 }
808 else if (Aura* corporalAura = killer->GetAura(SPELL_CORPORAL))
809 {
810 if (corporalAura->GetStackAmount() >= 5)
811 {
812 killer->RemoveAura(SPELL_CORPORAL);
813 killer->CastSpell(killer, SPELL_LIEUTENANT, true);
815 }
816 else
817 {
818 killer->CastSpell(killer, SPELL_CORPORAL, true);
819 }
820 }
821}
@ 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:5499
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4708
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)
1109{
1110 m_updateTenacityList.erase(player->GetGUID());
1112}
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)
956{
957 WorldPacket data(SMSG_INIT_WORLD_STATES, (4 + 4 + 4 + 2 + (BuildingsInZone.size() * 8) + (WorkshopsList.size() * 8)));
958
959 data << uint32(m_MapId);
960 data << uint32(m_ZoneId);
961 data << uint32(0);
962 data << uint16(14 + BuildingsInZone.size() + WorkshopsList.size()); // Number of fields
963
965
966 player->GetSession()->SendPacket(&data);
967}
std::uint16_t uint16
Definition: Define.h:109
@ SMSG_INIT_WORLD_STATES
Definition: Opcodes.h:736
uint32 m_MapId
Definition: Battlefield.h:384
uint32 m_ZoneId
Definition: Battlefield.h:383
void FillInitialWorldStates(WorldPacket &data) override
Definition: BattlefieldWG.cpp:927
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.

970{
971 for (uint8 team = 0; team < 2; team++)
972 for (GuidUnorderedSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
973 if (Player* player = ObjectAccessor::FindPlayer(*itr))
974 SendInitWorldStatesTo(player);
975}

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)
105 graveyard->Initialize(m_DefenderTeam, WGGraveYard[i].gyid);
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
@ BATTLEFIELD_WG_WORKSHOP_KEEP_WEST
Definition: BattlefieldWG.h:517
float const WintergraspStalkerPos[4]
Definition: BattlefieldWG.h:44
#define sMapMgr
Definition: MapMgr.h:221
@ CONFIG_WINTERGRASP_PLR_MIN_LVL
Definition: IWorld.h:362
@ CONFIG_WINTERGRASP_BATTLETIME
Definition: IWorld.h:363
@ CONFIG_WINTERGRASP_NOBATTLETIME
Definition: IWorld.h:364
@ CONFIG_WINTERGRASP_RESTART_AFTER_CRASH
Definition: IWorld.h:365
@ CONFIG_WINTERGRASP_ENABLE
Definition: IWorld.h:319
@ CONFIG_WINTERGRASP_PLR_MAX
Definition: IWorld.h:360
@ CONFIG_WINTERGRASP_PLR_MIN
Definition: IWorld.h:361
@ TEAM_NEUTRAL
Definition: SharedDefines.h:734
void Initialize(TeamId startcontrol, uint32 gy)
Definition: Battlefield.cpp:668
uint32 m_MaxPlayer
Definition: Battlefield.h:386
std::vector< uint32 > m_Data32
Definition: Battlefield.h:408
uint32 m_NoWarBattleTime
Definition: Battlefield.h:390
uint32 m_BattleTime
Definition: Battlefield.h:389
uint32 m_TypeId
Definition: Battlefield.h:381
uint32 m_BattleId
Definition: Battlefield.h:382
Creature * SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId teamId)
Definition: Battlefield.cpp:779
uint32 m_StartGroupingTimer
Definition: Battlefield.h:402
Map * m_Map
Definition: Battlefield.h:385
void RegisterZone(uint32 zoneid)
Definition: Battlefield.cpp:482
uint32 m_TimeForAcceptInvite
Definition: Battlefield.h:392
uint32 m_RestartAfterCrash
Definition: Battlefield.h:391
uint32 m_MinLevel
Definition: Battlefield.h:388
void InitStalker(uint32 entry, float x, float y, float z, float o)
Definition: Battlefield.cpp:303
uint32 m_MinPlayer
Definition: Battlefield.h:387
bool m_IsEnabled
Definition: Battlefield.h:366
bool m_StartGrouping
Definition: Battlefield.h:403
WorldLocation KickPosition
Definition: Battlefield.h:394
void SetGraveyardNumber(uint32 number)
Definition: Battlefield.h:298
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_MAPID, BATTLEFIELD_WG_NPC_STALKER, BATTLEFIELD_WG_WORKSHOP_KEEP_WEST, 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:1114

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.

292{
293 if (init)
294 {
297 }
300
301 for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
302 {
303 if (WGWorkshop* workshop = (*itr))
304 {
305 if (workshop->teamControl == TEAM_ALLIANCE)
307 else if (workshop->teamControl == TEAM_HORDE)
309 }
310 }
311
313}

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)
1084{
1085 if (team == GetAttackerTeam())
1086 {
1089 }
1090}

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
992{
993 // Destroy an attack tower
994 if (team == GetAttackerTeam())
995 {
996 // Update counter
999
1000 // Remove buff stack on attackers
1001 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
1002 if (Player* player = ObjectAccessor::FindPlayer(*itr))
1003 player->RemoveAuraFromStack(SPELL_TOWER_CONTROL);
1004
1005 // Add buff stack to defenders
1006 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetDefenderTeam()].begin(); itr != m_PlayersInWar[GetDefenderTeam()].end(); ++itr)
1007 if (Player* player = ObjectAccessor::FindPlayer(*itr))
1008 {
1009 // Quest - Wintergrasp - Southern Tower Kill
1010 if (go && player->GetDistance2d(go) < 200.0f)
1011 player->KilledMonsterCredit(NPC_QUEST_SOUTHERN_TOWER_KILL);
1012
1013 player->CastSpell(player, SPELL_TOWER_CONTROL, true);
1014 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, SPELL_LEANING_TOWER_ACHIEVEMENT, 0, 0);
1015 }
1016
1017 // If all three south towers are destroyed (ie. all attack towers), remove ten minutes from battle time
1019 {
1020 if (int32(m_Timer - 600000) < 0)
1021 m_Timer = 0;
1022 else
1023 m_Timer -= 600000;
1025 }
1026 }
1027 else
1028 {
1029 // Xinef: rest of structures, quest credit
1030 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[GetAttackerTeam()].begin(); itr != m_PlayersInWar[GetAttackerTeam()].end(); ++itr)
1031 if (Player* player = ObjectAccessor::FindPlayer(*itr))
1032 {
1033 // Quest - Wintergrasp - Vehicle Protected
1034 if (go && player->GetDistance2d(go) < 100.0f)
1035 player->KilledMonsterCredit(NPC_QUEST_VEHICLE_PROTECTED);
1036 }
1037 }
1038}
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:969

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

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