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

Class for manage Strand of Ancient battleground. More...

#include "BattlegroundSA.h"

Inheritance diagram for BattlegroundSA:
Battleground

Public Member Functions

 BattlegroundSA ()
 
 ~BattlegroundSA () override
 
void PostUpdateImpl (uint32 diff) override
 Called every time for update battle data -Update timer -Round switch. More...
 
void AddPlayer (Player *player) override
 Called when a player join battle. More...
 
void StartingEventCloseDoors () override
 Called when battle start. More...
 
void StartingEventOpenDoors () override
 
bool SetupBattleground () override
 Called for ini battleground, after that the first player be entered. More...
 
void Init () override
 
void FillInitialWorldStates (WorldPacket &data) override
 Called for generate packet contain worldstate data. More...
 
void EventPlayerDamagedGO (Player *player, GameObject *go, uint32 eventType) override
 Called when a player deal damage to building (door) More...
 
void HandleKillUnit (Creature *creature, Player *killer) override
 Called when a player kill a unit in bg. More...
 
GraveyardStruct const * GetClosestGraveyard (Player *player) override
 Return the nearest graveyard where player can respawn. More...
 
void EventPlayerClickedOnFlag (Player *Source, GameObject *gameObject) override
 Called when a player click on flag (graveyard flag) More...
 
void EventPlayerUsedGO (Player *Source, GameObject *object) override
 Called when a player use a gamobject (relic) More...
 
uint32 GetWorldStateFromGateID (uint32 id)
 Return worldstate id, according to door id. More...
 
void EndBattleground (TeamId winnerTeamId) override
 Called on battleground ending. More...
 
void RemovePlayer (Player *player) override
 CAlled when a player leave battleground. More...
 
void HandleAreaTrigger (Player *player, uint32 trigger) override
 
void DefendersPortalTeleport (GameObject *portal, Player *plr)
 
bool AllowDefenseOfTheAncients (Player *source)
 
bool notEvenAScratch (TeamId teamId) const
 
- Public Member Functions inherited from Battleground
 Battleground ()
 
virtual ~Battleground ()
 
void Update (uint32 diff)
 
virtual bool SetupBattleground ()
 
virtual void Init ()
 
virtual void StartingEventCloseDoors ()
 
virtual void StartingEventOpenDoors ()
 
virtual void ResetBGSubclass ()
 
virtual void DestroyGate (Player *, GameObject *)
 
virtual bool AllNodesConrolledByTeam (TeamId) const
 
void StartTimedAchievement (AchievementCriteriaTimedTypes type, uint32 entry)
 
std::string GetName () const
 
BattlegroundTypeId GetBgTypeID (bool GetRandom=false) const
 
BattlegroundBracketId GetBracketId () const
 
uint32 GetInstanceID () const
 
BattlegroundStatus GetStatus () const
 
uint32 GetClientInstanceID () const
 
uint32 GetStartTime () const
 
uint32 GetEndTime () const
 
uint32 GetLastResurrectTime () const
 
uint32 GetMinLevel () const
 
uint32 GetMaxLevel () const
 
uint32 GetMaxPlayersPerTeam () const
 
uint32 GetMinPlayersPerTeam () const
 
int32 GetStartDelayTime () const
 
uint8 GetArenaType () const
 
PvPTeamId GetWinner () const
 
uint32 GetScriptId () const
 
uint32 GetBonusHonorFromKill (uint32 kills) const
 
void SpiritOfCompetitionEvent (PvPTeamId winnerTeamId) const
 
bool IsRandom ()
 
void SetName (std::string_view name)
 
void SetBgTypeID (BattlegroundTypeId TypeID)
 
void SetRandomTypeID (BattlegroundTypeId TypeID)
 
void SetBracket (PvPDifficultyEntry const *bracketEntry)
 
void SetInstanceID (uint32 InstanceID)
 
void SetStatus (BattlegroundStatus Status)
 
void SetClientInstanceID (uint32 InstanceID)
 
void SetStartTime (uint32 Time)
 
void SetEndTime (uint32 Time)
 
void SetLastResurrectTime (uint32 Time)
 
void SetLevelRange (uint32 min, uint32 max)
 
void SetRated (bool state)
 
void SetArenaType (uint8 type)
 
void SetArenaorBGType (bool _isArena)
 
void SetWinner (PvPTeamId winner)
 
void SetScriptId (uint32 scriptId)
 
void SetRandom (bool isRandom)
 
void ModifyStartDelayTime (int32 diff)
 
void SetStartDelayTime (int32 Time)
 
void SetMaxPlayersPerTeam (uint32 MaxPlayers)
 
void SetMinPlayersPerTeam (uint32 MinPlayers)
 
void AddToBGFreeSlotQueue ()
 
void RemoveFromBGFreeSlotQueue ()
 
void DecreaseInvitedCount (TeamId teamId)
 
void IncreaseInvitedCount (TeamId teamId)
 
uint32 GetInvitedCount (TeamId teamId) const
 
bool HasFreeSlots () const
 
uint32 GetFreeSlotsForTeam (TeamId teamId) const
 
uint32 GetMaxFreeSlots () const
 
void AddSpectator (Player *p)
 
void RemoveSpectator (Player *p)
 
bool HaveSpectators ()
 
const SpectatorListGetSpectators () const
 
void AddToBeTeleported (ObjectGuid spectator, ObjectGuid participant)
 
void RemoveToBeTeleported (ObjectGuid spectator)
 
void SpectatorsSendPacket (WorldPacket &data)
 
bool isArena () const
 
bool isBattleground () const
 
bool isRated () const
 
BattlegroundPlayerMap const & GetPlayers () const
 
uint32 GetPlayersSize () const
 
void ReadyMarkerClicked (Player *p)
 
BattlegroundScoreMap const * GetPlayerScores () const
 
std::size_t GetPlayerScoresSize () const
 
uint32 GetReviveQueueSize () const
 
void AddPlayerToResurrectQueue (ObjectGuid npc_guid, ObjectGuid player_guid)
 
void RemovePlayerFromResurrectQueue (Player *player)
 
void RelocateDeadPlayers (ObjectGuid queueIndex)
 Relocate all players in ReviveQueue to the closest graveyard. More...
 
void StartBattleground ()
 
GameObjectGetBGObject (uint32 type)
 
CreatureGetBGCreature (uint32 type)
 
void SetMapId (uint32 MapID)
 
uint32 GetMapId () const
 
void SetBgMap (BattlegroundMap *map)
 
BattlegroundMapGetBgMap () const
 
BattlegroundMapFindBgMap () const
 
void SetTeamStartPosition (TeamId teamId, Position const &pos)
 
Position const * GetTeamStartPosition (TeamId teamId) const
 
void SetStartMaxDist (float startMaxDist)
 
float GetStartMaxDist () const
 
virtual void FillInitialWorldStates (WorldPacket &)
 
void SendPacketToTeam (TeamId teamId, WorldPacket const *packet, Player *sender=nullptr, bool self=true)
 
void SendPacketToAll (WorldPacket const *packet)
 
void YellToAll (Creature *creature, const char *text, uint32 language)
 
void SendChatMessage (Creature *source, uint8 textId, WorldObject *target=nullptr)
 
void SendBroadcastText (uint32 id, ChatMsg msgType, WorldObject const *target=nullptr)
 
template<class Do >
void BroadcastWorker (Do &_do)
 
void PlaySoundToAll (uint32 soundId)
 
void CastSpellOnTeam (uint32 spellId, TeamId teamId)
 
void RemoveAuraOnTeam (uint32 spellId, TeamId teamId)
 
void RewardHonorToTeam (uint32 honor, TeamId teamId)
 
void RewardReputationToTeam (uint32 factionId, uint32 reputation, TeamId teamId)
 
uint32 GetRealRepFactionForPlayer (uint32 factionId, Player *player)
 
void UpdateWorldState (uint32 variable, uint32 value)
 
void EndBattleground (PvPTeamId winnerTeamId)
 
virtual void EndBattleground (TeamId winnerTeamId)
 
void BlockMovement (Player *player)
 
GroupGetBgRaid (TeamId teamId) const
 
void SetBgRaid (TeamId teamId, Group *bg_raid)
 
void BuildPvPLogDataPacket (WorldPacket &data)
 
virtual bool UpdatePlayerScore (Player *player, uint32 type, uint32 value, bool doAddHonor=true)
 
uint32 GetPlayersCountByTeam (TeamId teamId) const
 
uint32 GetAlivePlayersCountByTeam (TeamId teamId) const
 
void UpdatePlayersCountByTeam (TeamId teamId, bool remove)
 
virtual void CheckWinConditions ()
 
void SetArenaTeamIdForTeam (TeamId teamId, uint32 ArenaTeamId)
 
uint32 GetArenaTeamIdForTeam (TeamId teamId) const
 
void SetArenaMatchmakerRating (TeamId teamId, uint32 MMR)
 
uint32 GetArenaMatchmakerRating (TeamId teamId) const
 
virtual void HandleAreaTrigger (Player *, uint32)
 
virtual void HandleKillPlayer (Player *player, Player *killer)
 
virtual void HandleKillUnit (Creature *, Player *)
 
virtual void EventPlayerDroppedFlag (Player *)
 
virtual void EventPlayerClickedOnFlag (Player *, GameObject *)
 
virtual void EventPlayerDamagedGO (Player *, GameObject *, uint32)
 
virtual void EventPlayerUsedGO (Player *, GameObject *)
 
virtual void DoAction (uint32, ObjectGuid)
 
virtual void HandlePlayerResurrect (Player *)
 
virtual GraveyardStruct const * GetClosestGraveyard (Player *player)
 
virtual void AddPlayer (Player *player)
 
void AddOrSetPlayerToCorrectBgGroup (Player *player, TeamId teamId)
 
virtual void RemovePlayerAtLeave (Player *player)
 
void HandleTriggerBuff (GameObject *gameObject)
 
void SetHoliday (bool is_holiday)
 
void SpawnBGObject (uint32 type, uint32 respawntime, uint32 forceRespawnDelay=0)
 
bool AddObject (uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime=0, GOState goState=GO_STATE_READY)
 
CreatureAddCreature (uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime=0, MotionTransport *transport=nullptr)
 
bool DelCreature (uint32 type)
 
bool DelObject (uint32 type)
 
bool AddSpiritGuide (uint32 type, float x, float y, float z, float o, TeamId teamId)
 
int32 GetObjectType (ObjectGuid guid)
 
void DoorOpen (uint32 type)
 
void DoorClose (uint32 type)
 
const char * GetAcoreString (int32 entry)
 
virtual bool HandlePlayerUnderMap (Player *)
 
bool IsPlayerInBattleground (ObjectGuid guid) const
 
bool ToBeDeleted () const
 
void RewardXPAtKill (Player *killer, Player *victim)
 
virtual ObjectGuid GetFlagPickerGUID (TeamId=TEAM_NEUTRAL) const
 
virtual void SetDroppedFlagGUID (ObjectGuid, TeamId=TEAM_NEUTRAL)
 
uint32 GetTeamScore (TeamId teamId) const
 
virtual TeamId GetPrematureWinner ()
 
uint8 GetUniqueBracketId () const
 
BattlegroundAVToBattlegroundAV ()
 
BattlegroundAV const * ToBattlegroundAV () const
 
BattlegroundWSToBattlegroundWS ()
 
BattlegroundWS const * ToBattlegroundWS () const
 
BattlegroundABToBattlegroundAB ()
 
BattlegroundAB const * ToBattlegroundAB () const
 
BattlegroundNAToBattlegroundNA ()
 
BattlegroundNA const * ToBattlegroundNA () const
 
BattlegroundBEToBattlegroundBE ()
 
BattlegroundBE const * ToBattlegroundBE () const
 
BattlegroundEYToBattlegroundEY ()
 
BattlegroundEY const * ToBattlegroundEY () const
 
BattlegroundRLToBattlegroundRL ()
 
BattlegroundRL const * ToBattlegroundRL () const
 
BattlegroundSAToBattlegroundSA ()
 
BattlegroundSA const * ToBattlegroundSA () const
 
BattlegroundDSToBattlegroundDS ()
 
BattlegroundDS const * ToBattlegroundDS () const
 
BattlegroundRVToBattlegroundRV ()
 
BattlegroundRV const * ToBattlegroundRV () const
 
BattlegroundICToBattlegroundIC ()
 
BattlegroundIC const * ToBattlegroundIC () const
 

Private Member Functions

uint32 GetGateIDFromEntry (uint32 id)
 Return gate id, relative to bg data, according to gameobject id. More...
 
bool ResetObjs ()
 Called on setup and between the two round -Delete all gameobject / creature -Respawn all gameobject / creature to have good faction. More...
 
void StartShips ()
 Called for start ship movement. More...
 
void TeleportPlayers ()
 Called between the two round -Teleport all players to good location. More...
 
void TeleportToEntrancePosition (Player *player)
 
void OverrideGunFaction ()
 Called on start and between the two round -Update faction of all vehicle. More...
 
void DemolisherStartState (bool start)
 Set selectable or not demolisher, called on battle start, when boats arrive to dock. More...
 
bool CanInteractWithObject (uint32 objectId)
 Checks if a player can interact with the given object. More...
 
void UpdateObjectInteractionFlags (uint32 objectId)
 Updates interaction flags of specific objects. More...
 
void UpdateObjectInteractionFlags ()
 
void DestroyGate (Player *player, GameObject *go) override
 Called when a gate is destroy -Give honor to player witch destroy it -Update worldstate -Delete gameobject in front of door (lighting object, with different colours for each door) More...
 
void SendTime ()
 Update timer worldstate. More...
 
void CaptureGraveyard (BG_SA_Graveyards i, Player *Source)
 Called when a graveyard is capture -Update spiritguide -Update gameobject (flag) -Update Worldstate -Send warning for announce this. More...
 
void ToggleTimer ()
 Switch on/off timer worldstate. More...
 
void UpdateDemolisherSpawns ()
 Respawn dead demolisher. More...
 
void SendTransportInit (Player *player)
 Send packet to player for create boats (client part) More...
 
void SendTransportsRemove (Player *player)
 Send packet to player for destroy boats (client part) More...
 

Private Attributes

TeamId Attackers
 Id of attacker team. More...
 
Milliseconds TotalTime
 Totale elapsed time of current round. More...
 
Milliseconds EndRoundTimer
 Max time of round. More...
 
bool ShipsStarted
 For know if boats has start moving or not yet. More...
 
BG_SA_GateState GateStatus [6]
 Status of each gate (Destroy/Damage/Intact) More...
 
BG_SA_Status Status
 Statu of battle (Start or not, and what round) More...
 
TeamId GraveyardStatus [BG_SA_MAX_GY]
 Team witch conntrol each graveyard. More...
 
BG_SA_RoundScore RoundScores [2]
 Score of each round. More...
 
bool TimerEnabled
 used for know we are in timer phase or not (used for worldstate update) More...
 
uint32 UpdateWaitTimer
 5secs before starting the 1min countdown for second round More...
 
bool SignaledRoundTwo
 for know if warning about second round start has been sent More...
 
bool SignaledRoundTwoHalfMin
 for know if warning about second round start has been sent More...
 
bool InitSecondRound
 for know if second round has been init More...
 
std::map< uint32, uint32DemoliserRespawnList
 
bool _relicClicked
 
bool _notEvenAScratch [PVP_TEAMS_COUNT]
 

Additional Inherited Members

- Public Types inherited from Battleground
typedef std::set< Player * > SpectatorList
 
typedef std::map< ObjectGuid, ObjectGuidToBeTeleportedMap
 
typedef std::map< ObjectGuid, Player * > BattlegroundPlayerMap
 
typedef std::unordered_map< ObjectGuid::LowType, BattlegroundScore * > BattlegroundScoreMap
 
typedef std::unordered_map< ObjectGuid, ArenaLogEntryDataArenaLogEntryDataMap
 
typedef GuidVector BGObjects
 
typedef GuidVector BGCreatures
 
- Static Public Member Functions inherited from Battleground
static TeamId GetOtherTeamId (TeamId teamId)
 
- Public Attributes inherited from Battleground
GuidSet readyMarkerClickedSet
 
ArenaLogEntryDataMap ArenaLogEntries
 
BGObjects BgObjects
 
BGCreatures BgCreatures
 
- Protected Member Functions inherited from Battleground
void EndNow ()
 
void PlayerAddedToBGCheckIfBGIsRunning (Player *player)
 
void _ProcessResurrect (uint32 diff)
 
void _ProcessProgress (uint32 diff)
 
void _ProcessLeave (uint32 diff)
 
void _ProcessJoin (uint32 diff)
 
void _CheckSafePositions (uint32 diff)
 
virtual void RemovePlayer (Player *)
 
- Protected Attributes inherited from Battleground
BattlegroundScoreMap PlayerScores
 
BattlegroundPlayerMap m_Players
 
std::map< ObjectGuid, GuidVectorm_ReviveQueue
 
uint8 m_Events
 
BattlegroundStartTimeIntervals StartDelayTimes [BG_STARTING_EVENT_COUNT]
 
uint32 StartMessageIds [BG_STARTING_EVENT_COUNT]
 
bool m_BuffChange
 
bool m_IsRandom
 
BGHonorMode m_HonorMode
 
int32 m_TeamScores [PVP_TEAMS_COUNT]
 
ArenaTeamScore _arenaTeamScores [PVP_TEAMS_COUNT]
 
uint32 m_UpdateTimer
 
EventProcessor _reviveEvents
 

Detailed Description

Class for manage Strand of Ancient battleground.

Constructor & Destructor Documentation

◆ BattlegroundSA()

BattlegroundSA::BattlegroundSA ( )

This is here to prevent an uninitialised variable warning The warning only occurs when SetUpBattleGround fails though. In the future this function should be called BEFORE sending initial worldstates.

41{
43 BgObjects.resize(BG_SA_MAXOBJ);
44 BgCreatures.resize(static_cast<uint16>(BG_SA_MAXNPC) + BG_SA_MAX_GY);
45 TimerEnabled = false;
47 SignaledRoundTwo = false;
49 InitSecondRound = false;
51 TotalTime = 0s;
52 EndRoundTimer = 0s;
53 ShipsStarted = false;
55
56 for (uint8 i = 0; i < 6; i++)
58
59 for (uint8 i = 0; i < 2; i++)
60 {
62 RoundScores[i].time = 0s;
63 }
64
68 memset(&GraveyardStatus, 0, sizeof(GraveyardStatus));
69}
std::uint8_t uint8
Definition: Define.h:109
std::uint16_t uint16
Definition: Define.h:108
@ BG_SA_MAX_GY
Definition: BattlegroundSA.h:377
@ BG_SA_GATE_OK
Definition: BattlegroundSA.h:40
@ BG_SA_NOTSTARTED
Definition: BattlegroundSA.h:30
@ BG_SA_MAXOBJ
Definition: BattlegroundSA.h:215
@ BG_SA_MAXNPC
Definition: BattlegroundSA.h:109
@ BG_STARTING_EVENT_FOURTH
Definition: Battleground.h:237
@ TEAM_ALLIANCE
Definition: SharedDefines.h:760
BGObjects BgObjects
Definition: Battleground.h:532
BGCreatures BgCreatures
Definition: Battleground.h:533
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:625
Milliseconds time
Definition: BattlegroundSA.h:410
TeamId winner
Definition: BattlegroundSA.h:409
bool TimerEnabled
used for know we are in timer phase or not (used for worldstate update)
Definition: BattlegroundSA.h:635
BG_SA_Status Status
Statu of battle (Start or not, and what round)
Definition: BattlegroundSA.h:629
TeamId Attackers
Id of attacker team.
Definition: BattlegroundSA.h:619
bool SignaledRoundTwo
for know if warning about second round start has been sent
Definition: BattlegroundSA.h:639
bool SignaledRoundTwoHalfMin
for know if warning about second round start has been sent
Definition: BattlegroundSA.h:641
BG_SA_RoundScore RoundScores[2]
Score of each round.
Definition: BattlegroundSA.h:633
uint32 UpdateWaitTimer
5secs before starting the 1min countdown for second round
Definition: BattlegroundSA.h:637
BG_SA_GateState GateStatus[6]
Status of each gate (Destroy/Damage/Intact)
Definition: BattlegroundSA.h:627
bool ShipsStarted
For know if boats has start moving or not yet.
Definition: BattlegroundSA.h:625
bool InitSecondRound
for know if second round has been init
Definition: BattlegroundSA.h:643
Milliseconds EndRoundTimer
Max time of round.
Definition: BattlegroundSA.h:623
Milliseconds TotalTime
Totale elapsed time of current round.
Definition: BattlegroundSA.h:621
TeamId GraveyardStatus[BG_SA_MAX_GY]
Team witch conntrol each graveyard.
Definition: BattlegroundSA.h:631

References Attackers, BG_SA_GATE_OK, BG_SA_MAX_GY, BG_SA_MAXNPC, BG_SA_MAXOBJ, BG_SA_NOTSTARTED, BG_STARTING_EVENT_FOURTH, Battleground::BgCreatures, Battleground::BgObjects, EndRoundTimer, GateStatus, GraveyardStatus, InitSecondRound, RoundScores, ShipsStarted, SignaledRoundTwo, SignaledRoundTwoHalfMin, Battleground::StartMessageIds, Status, TEAM_ALLIANCE, BG_SA_RoundScore::time, TimerEnabled, TotalTime, UpdateWaitTimer, and BG_SA_RoundScore::winner.

◆ ~BattlegroundSA()

BattlegroundSA::~BattlegroundSA ( )
override
72{
73}

Member Function Documentation

◆ AddPlayer()

void BattlegroundSA::AddPlayer ( Player player)
overridevirtual

Called when a player join battle.

Reimplemented from Battleground.

511{
513 PlayerScores.emplace(player->GetGUID().GetCounter(), new BattlegroundSAScore(player->GetGUID()));
514
515 SendTransportInit(player);
517}
virtual void AddPlayer(Player *player)
Definition: Battleground.cpp:1113
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:612
Definition: BattlegroundSA.h:423
void SendTransportInit(Player *player)
Send packet to player for create boats (client part)
Definition: BattlegroundSA.cpp:1131
void TeleportToEntrancePosition(Player *player)
Definition: BattlegroundSA.cpp:564
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
LowType GetCounter() const
Definition: ObjectGuid.h:145

References Battleground::AddPlayer(), ObjectGuid::GetCounter(), Object::GetGUID(), Battleground::PlayerScores, SendTransportInit(), and TeleportToEntrancePosition().

◆ AllowDefenseOfTheAncients()

bool BattlegroundSA::AllowDefenseOfTheAncients ( Player source)
1162{
1163 if (source->GetTeamId() == Attackers)
1164 return false;
1165
1166 for (uint8 i = 0; i <= 5; i++)
1167 {
1169 return false;
1170 }
1171
1172 return true;
1173}
@ BG_SA_GATE_DESTROYED
Definition: BattlegroundSA.h:42
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2088

References Attackers, BG_SA_GATE_DESTROYED, GateStatus, and Player::GetTeamId().

Referenced by achievement_sa_defense_of_the_ancients::OnCheck().

◆ CanInteractWithObject()

bool BattlegroundSA::CanInteractWithObject ( uint32  objectId)
private

Checks if a player can interact with the given object.

837{
838 switch (objectId)
839 {
842 {
843 return false;
844 }
845 [[fallthrough]];
848 {
849 return false;
850 }
851 [[fallthrough]];
852 case BG_SA_LEFT_FLAG:
853 case BG_SA_RIGHT_FLAG:
855 {
856 return false;
857 }
858 break;
859 default:
860 ABORT();
861 break;
862 }
863
864 return true;
865}
#define ABORT
Definition: Errors.h:76
@ BG_SA_YELLOW_GATE
Definition: BattlegroundSA.h:190
@ BG_SA_GREEN_GATE
Definition: BattlegroundSA.h:189
@ BG_SA_CENTRAL_FLAG
Definition: BattlegroundSA.h:206
@ BG_SA_RED_GATE
Definition: BattlegroundSA.h:192
@ BG_SA_PURPLE_GATE
Definition: BattlegroundSA.h:193
@ BG_SA_RIGHT_FLAG
Definition: BattlegroundSA.h:207
@ BG_SA_BLUE_GATE
Definition: BattlegroundSA.h:191
@ BG_SA_ANCIENT_GATE
Definition: BattlegroundSA.h:194
@ BG_SA_LEFT_FLAG
Definition: BattlegroundSA.h:208
@ BG_SA_TITAN_RELIC
Definition: BattlegroundSA.h:195

References ABORT, BG_SA_ANCIENT_GATE, BG_SA_BLUE_GATE, BG_SA_CENTRAL_FLAG, BG_SA_GATE_DESTROYED, BG_SA_GREEN_GATE, BG_SA_LEFT_FLAG, BG_SA_PURPLE_GATE, BG_SA_RED_GATE, BG_SA_RIGHT_FLAG, BG_SA_TITAN_RELIC, BG_SA_YELLOW_GATE, and GateStatus.

Referenced by EventPlayerClickedOnFlag(), EventPlayerUsedGO(), and UpdateObjectInteractionFlags().

◆ CaptureGraveyard()

void BattlegroundSA::CaptureGraveyard ( BG_SA_Graveyards  i,
Player Source 
)
private

Called when a graveyard is capture -Update spiritguide -Update gameobject (flag) -Update Worldstate -Send warning for announce this.

Parameters
i: id of graveyard
Source: Player who capture gy
910{
911 if (GraveyardStatus[i] == Attackers || Source->GetTeamId() != Attackers)
912 return;
913
914 GraveyardStatus[i] = Source->GetTeamId();
915 // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard
916 GuidVector& ghost_list = m_ReviveQueue[BgCreatures[static_cast<uint16>(BG_SA_MAXNPC) + i]];
917 if (!ghost_list.empty())
918 {
919 GraveyardStruct const* ClosestGrave = nullptr;
920 for (ObjectGuid const& guid : ghost_list)
921 {
922 Player* player = ObjectAccessor::FindPlayer(guid);
923 if (!player)
924 continue;
925
926 if (!ClosestGrave) // cache
927 ClosestGrave = GetClosestGraveyard(player);
928
929 if (ClosestGrave)
930 player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
931 }
932
933 // xinef: clear resurrect queue for this creature
934 ghost_list.clear();
935 }
936
937 DelCreature(static_cast<uint16>(BG_SA_MAXNPC) + i);
938
939 GraveyardStruct const* sg = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
940 if (!sg)
941 {
942 LOG_ERROR("bg.battleground", "BattlegroundSA::CaptureGraveyard: non-existant GY entry: {}", BG_SA_GYEntries[i]);
943 return;
944 }
945
946 AddSpiritGuide(i + static_cast<uint16>(BG_SA_MAXNPC), sg->x, sg->y, sg->z, BG_SA_GYOrientation[i], GraveyardStatus[i]);
947 uint32 npc = 0;
948 uint32 flag = 0;
949
950 switch (i)
951 {
953 flag = BG_SA_LEFT_FLAG;
954 DelObject(flag);
955 AddObject(flag, (BG_SA_ObjEntries[flag] - (Source->GetTeamId() == TEAM_ALLIANCE ? 0 : 1)),
956 BG_SA_ObjSpawnlocs[flag][0], BG_SA_ObjSpawnlocs[flag][1],
957 BG_SA_ObjSpawnlocs[flag][2], BG_SA_ObjSpawnlocs[flag][3], 0, 0, 0, 0, RESPAWN_ONE_DAY);
958
963
964 for (uint8 j = BG_SA_DEMOLISHER_7; j <= BG_SA_DEMOLISHER_8; j++)
965 {
968 BG_SA_NpcSpawnlocs[j][2], BG_SA_NpcSpawnlocs[j][3], 600);
969
970 if (Creature* dem = GetBGCreature(j))
971 dem->SetFaction(BG_SA_Factions[Attackers]);
972 }
973
976 GetBgMap()->DoForAllPlayers([&](Player* player)
977 {
978 if (player->GetTeamId() == TEAM_ALLIANCE)
980 else
982 });
983 break;
985 flag = BG_SA_RIGHT_FLAG;
986 DelObject(flag);
987 AddObject(flag, (BG_SA_ObjEntries[flag] - (Source->GetTeamId() == TEAM_ALLIANCE ? 0 : 1)),
988 BG_SA_ObjSpawnlocs[flag][0], BG_SA_ObjSpawnlocs[flag][1],
989 BG_SA_ObjSpawnlocs[flag][2], BG_SA_ObjSpawnlocs[flag][3], 0, 0, 0, 0, RESPAWN_ONE_DAY);
990
995
996 for (uint8 j = BG_SA_DEMOLISHER_5; j <= BG_SA_DEMOLISHER_6; j++)
997 {
999 BG_SA_NpcSpawnlocs[j][2], BG_SA_NpcSpawnlocs[j][3], 600);
1000
1001 if (Creature* dem = GetBGCreature(j))
1002 dem->SetFaction(BG_SA_Factions[Attackers]);
1003 }
1004
1007 GetBgMap()->DoForAllPlayers([&](Player* player)
1008 {
1009 if (player->GetTeamId() == TEAM_ALLIANCE)
1011 else
1013 });
1014 break;
1016 flag = BG_SA_CENTRAL_FLAG;
1017 DelObject(flag);
1018 AddObject(flag, (BG_SA_ObjEntries[flag] - (Source->GetTeamId() == TEAM_ALLIANCE ? 0 : 1)),
1019 BG_SA_ObjSpawnlocs[flag][0], BG_SA_ObjSpawnlocs[flag][1],
1020 BG_SA_ObjSpawnlocs[flag][2], BG_SA_ObjSpawnlocs[flag][3], 0, 0, 0, 0, RESPAWN_ONE_DAY);
1021
1024 GetBgMap()->DoForAllPlayers([&](Player* player)
1025 {
1026 if (player->GetTeamId() == TEAM_ALLIANCE)
1028 else
1030 });
1031 break;
1032 default:
1033 ABORT();
1034 break;
1035 }
1036}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
std::uint32_t uint32
Definition: Define.h:107
@ BG_SA_CENTRAL_CAPTURABLE_GY
Definition: BattlegroundSA.h:376
@ BG_SA_LEFT_CAPTURABLE_GY
Definition: BattlegroundSA.h:375
@ BG_SA_RIGHT_CAPTURABLE_GY
Definition: BattlegroundSA.h:374
@ BG_SA_CENTER_GY_ALLIANCE
Definition: BattlegroundSA.h:60
@ BG_SA_LEFT_GY_ALLIANCE
Definition: BattlegroundSA.h:58
@ BG_SA_LEFT_GY_HORDE
Definition: BattlegroundSA.h:68
@ BG_SA_RIGHT_GY_ALLIANCE
Definition: BattlegroundSA.h:59
@ BG_SA_CENTER_GY_HORDE
Definition: BattlegroundSA.h:69
@ BG_SA_RIGHT_GY_HORDE
Definition: BattlegroundSA.h:67
const uint32 BG_SA_GYEntries[BG_SA_MAX_GY]
Definition: BattlegroundSA.h:380
uint32 const BG_SA_ObjEntries[BG_SA_MAXOBJ+BG_SA_FLAG_AMOUNT]
Definition: BattlegroundSA.h:334
float const BG_SA_GYOrientation[BG_SA_MAX_GY]
Definition: BattlegroundSA.h:389
uint32 const BG_SA_Factions[2]
Definition: BattlegroundSA.h:364
npc
Definition: BattlegroundSA.h:75
float const BG_SA_NpcSpawnlocs[BG_SA_MAXNPC][4]
Definition: BattlegroundSA.h:153
float const BG_SA_ObjSpawnlocs[BG_SA_MAXOBJ][4]
Definition: BattlegroundSA.h:218
@ BG_SA_DEMOLISHER_6
Definition: BattlegroundSA.h:104
@ BG_SA_DEMOLISHER_7
Definition: BattlegroundSA.h:105
@ BG_SA_DEMOLISHER_5
Definition: BattlegroundSA.h:103
@ BG_SA_NPC_RIGSPARK
Definition: BattlegroundSA.h:108
@ BG_SA_NPC_SPARKLIGHT
Definition: BattlegroundSA.h:107
@ BG_SA_DEMOLISHER_8
Definition: BattlegroundSA.h:106
uint32 const BG_SA_NpcEntries[BG_SA_MAXNPC]
Definition: BattlegroundSA.h:120
@ RESPAWN_ONE_DAY
Definition: Battleground.h:163
#define sGraveyard
Definition: GameGraveyard.h:75
@ LANG_BG_SA_A_GY_SOUTH
Definition: Language.h:1273
@ LANG_BG_SA_H_GY_EAST
Definition: Language.h:1278
@ LANG_BG_SA_A_GY_WEST
Definition: Language.h:1274
@ LANG_BG_SA_A_GY_EAST
Definition: Language.h:1275
@ LANG_BG_SA_H_GY_WEST
Definition: Language.h:1277
std::vector< ObjectGuid > GuidVector
Definition: ObjectGuid.h:256
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
uint32 GetMapId() const
Definition: Battleground.h:428
bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, TeamId teamId)
Definition: Battleground.cpp:1629
bool DelCreature(uint32 type)
Definition: Battleground.cpp:1590
bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime=0, GOState goState=GO_STATE_READY)
Definition: Battleground.cpp:1405
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:432
std::map< ObjectGuid, GuidVector > m_ReviveQueue
Definition: Battleground.h:619
bool DelObject(uint32 type)
Definition: Battleground.cpp:1609
void UpdateWorldState(uint32 variable, uint32 value)
Definition: Battleground.cpp:778
Creature * AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime=0, MotionTransport *transport=nullptr)
Definition: Battleground.cpp:1527
Creature * GetBGCreature(uint32 type)
Definition: Battleground.cpp:1498
GraveyardStruct const * GetClosestGraveyard(Player *player) override
Return the nearest graveyard where player can respawn.
Definition: BattlegroundSA.cpp:792
Definition: Chat.h:39
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:213
Definition: Creature.h:46
Definition: ObjectGuid.h:118
float GetOrientation() const
Definition: Position.h:120
Definition: Player.h:1064
WorldSession * GetSession() const
Definition: Player.h:1978
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1330
void DoForAllPlayers(std::function< void(Player *)> exec)
Definition: Map.cpp:3824
Definition: GameGraveyard.h:28
float z
Definition: GameGraveyard.h:33
float x
Definition: GameGraveyard.h:31
float y
Definition: GameGraveyard.h:32

References ABORT, Battleground::AddCreature(), Battleground::AddObject(), Battleground::AddSpiritGuide(), Attackers, BG_SA_CENTER_GY_ALLIANCE, BG_SA_CENTER_GY_HORDE, BG_SA_CENTRAL_CAPTURABLE_GY, BG_SA_CENTRAL_FLAG, BG_SA_DEMOLISHER_5, BG_SA_DEMOLISHER_6, BG_SA_DEMOLISHER_7, BG_SA_DEMOLISHER_8, BG_SA_Factions, BG_SA_GYEntries, BG_SA_GYOrientation, BG_SA_LEFT_CAPTURABLE_GY, BG_SA_LEFT_FLAG, BG_SA_LEFT_GY_ALLIANCE, BG_SA_LEFT_GY_HORDE, BG_SA_MAXNPC, BG_SA_NPC_RIGSPARK, BG_SA_NPC_SPARKLIGHT, BG_SA_NpcEntries, BG_SA_NpcSpawnlocs, BG_SA_ObjEntries, BG_SA_ObjSpawnlocs, BG_SA_RIGHT_CAPTURABLE_GY, BG_SA_RIGHT_FLAG, BG_SA_RIGHT_GY_ALLIANCE, BG_SA_RIGHT_GY_HORDE, Battleground::BgCreatures, Battleground::DelCreature(), Battleground::DelObject(), Map::DoForAllPlayers(), ObjectAccessor::FindPlayer(), Battleground::GetBGCreature(), Battleground::GetBgMap(), GetClosestGraveyard(), Battleground::GetMapId(), Position::GetOrientation(), Player::GetSession(), Player::GetTeamId(), GraveyardStatus, LANG_BG_SA_A_GY_EAST, LANG_BG_SA_A_GY_SOUTH, LANG_BG_SA_A_GY_WEST, LANG_BG_SA_H_GY_EAST, LANG_BG_SA_H_GY_WEST, LOG_ERROR, Battleground::m_ReviveQueue, ChatHandler::PSendSysMessage(), RESPAWN_ONE_DAY, sGraveyard, TEAM_ALLIANCE, Player::TeleportTo(), Battleground::UpdateWorldState(), GraveyardStruct::x, GraveyardStruct::y, and GraveyardStruct::z.

Referenced by EventPlayerClickedOnFlag().

◆ DefendersPortalTeleport()

void BattlegroundSA::DefendersPortalTeleport ( GameObject portal,
Player plr 
)
586{
587 if (plr->GetTeamId() == Attackers)
588 return;
589
590 uint32 portal_num = 0;
591 //get it via X
592 switch ((uint32)portal->GetPositionX())
593 {
594 case 1394:
595 portal_num = 0;
596 break;
597 case 1065:
598 portal_num = 1;
599 break;
600 case 1468:
601 portal_num = 2;
602 break;
603 case 1255:
604 portal_num = 3;
605 break;
606 case 1216:
607 portal_num = 4;
608 break;
609 }
610
611 plr->TeleportTo( plr->GetMapId(), SOTADefPortalDest[portal_num][0], SOTADefPortalDest[portal_num][1], SOTADefPortalDest[portal_num][2], SOTADefPortalDest[portal_num][3], TELE_TO_SPELL );
612}
const float SOTADefPortalDest[5][4]
Definition: BattlegroundSA.h:413
@ TELE_TO_SPELL
Definition: Player.h:825
float GetPositionX() const
Definition: Position.h:117
uint32 GetMapId() const
Definition: Position.h:276

References Attackers, WorldLocation::GetMapId(), Position::GetPositionX(), Player::GetTeamId(), SOTADefPortalDest, TELE_TO_SPELL, and Player::TeleportTo().

Referenced by Spell::EffectScriptEffect().

◆ DemolisherStartState()

void BattlegroundSA::DemolisherStartState ( bool  start)
private

Set selectable or not demolisher, called on battle start, when boats arrive to dock.

710{
711 if (!BgCreatures[0])
712 return;
713
714 for (uint8 i = BG_SA_DEMOLISHER_1; i <= BG_SA_DEMOLISHER_4; i++)
715 if (Creature* dem = GetBGCreature(i))
716 {
717 if (start)
719 else
721 }
722
723 for (uint8 i = BG_SA_GUN_1; i <= BG_SA_GUN_10; i++)
724 if (Creature* gun = GetBGCreature(i))
725 {
726 if (start)
728 else
730 }
731
732 // xinef: enable first gates damaging at start
733 if (!start)
734 {
736 go->SetDestructibleBuildingModifyState(true);
738 go->SetDestructibleBuildingModifyState(true);
739 }
740}
@ BG_SA_GUN_10
Definition: BattlegroundSA.h:93
@ BG_SA_DEMOLISHER_1
Definition: BattlegroundSA.h:99
@ BG_SA_DEMOLISHER_4
Definition: BattlegroundSA.h:102
@ BG_SA_GUN_1
Definition: BattlegroundSA.h:84
@ UNIT_FLAG_NON_ATTACKABLE
Definition: UnitDefines.h:230
@ UNIT_FLAG_NOT_SELECTABLE
Definition: UnitDefines.h:254
GameObject * GetBGObject(uint32 type)
Definition: Battleground.cpp:1489
Definition: GameObject.h:121

References BG_SA_BLUE_GATE, BG_SA_DEMOLISHER_1, BG_SA_DEMOLISHER_4, BG_SA_GREEN_GATE, BG_SA_GUN_1, BG_SA_GUN_10, Battleground::BgCreatures, Battleground::GetBGCreature(), Battleground::GetBGObject(), UNIT_FLAG_NON_ATTACKABLE, and UNIT_FLAG_NOT_SELECTABLE.

Referenced by PostUpdateImpl(), and ResetObjs().

◆ DestroyGate()

void BattlegroundSA::DestroyGate ( Player player,
GameObject go 
)
overrideprivatevirtual

Called when a gate is destroy -Give honor to player witch destroy it -Update worldstate -Delete gameobject in front of door (lighting object, with different colours for each door)

Reimplemented from Battleground.

743{
745 if (!GateStatus[i])
746 return;
747
748 if (GameObject* g = GetBGObject(i))
749 {
750 if (g->GetGOValue()->Building.Health == 0)
751 {
753 if (uint32 uws = GetWorldStateFromGateID(i))
755
756 bool rewardHonor = true;
757 switch (i)
758 {
759 case BG_SA_GREEN_GATE:
761 rewardHonor = false;
762 break;
763 case BG_SA_BLUE_GATE:
765 rewardHonor = false;
766 break;
767 case BG_SA_RED_GATE:
769 rewardHonor = false;
770 break;
773 rewardHonor = false;
774 break;
775 }
776
778
779 if (i < 5)
780 DelObject(i + 9);
781
782 if (player)
783 {
785 if (rewardHonor)
787 }
788 }
789 }
790}
@ SCORE_BONUS_HONOR
Definition: BattlegroundScore.h:32
@ SCORE_DESTROYED_WALL
Definition: BattlegroundScore.h:55
virtual bool UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true)
Definition: Battleground.cpp:1344
uint32 GetBonusHonorFromKill(uint32 kills) const
Definition: Battleground.cpp:958
uint32 GetWorldStateFromGateID(uint32 id)
Return worldstate id, according to door id.
Definition: BattlegroundSA.h:491
uint32 GetGateIDFromEntry(uint32 id)
Return gate id, relative to bg data, according to gameobject id.
Definition: BattlegroundSA.h:536
void UpdateObjectInteractionFlags()
Definition: BattlegroundSA.cpp:878
uint32 GetEntry() const
Definition: Object.h:112

References BG_SA_BLUE_GATE, BG_SA_GATE_DESTROYED, BG_SA_GREEN_GATE, BG_SA_PURPLE_GATE, BG_SA_RED_GATE, Battleground::DelObject(), GateStatus, Battleground::GetBGObject(), Battleground::GetBonusHonorFromKill(), Object::GetEntry(), GetGateIDFromEntry(), GetWorldStateFromGateID(), SCORE_BONUS_HONOR, SCORE_DESTROYED_WALL, UpdateObjectInteractionFlags(), Battleground::UpdatePlayerScore(), and Battleground::UpdateWorldState().

◆ EndBattleground()

void BattlegroundSA::EndBattleground ( TeamId  winnerTeamId)
overridevirtual

Called on battleground ending.

Reimplemented from Battleground.

1087{
1088 //honor reward for winning
1089 RewardHonorToTeam(GetBonusHonorFromKill(1), winnerTeamId);
1090
1091 //complete map_end rewards (even if no team wins)
1094
1095 Battleground::EndBattleground(winnerTeamId);
1096}
@ TEAM_HORDE
Definition: SharedDefines.h:761
void EndBattleground(PvPTeamId winnerTeamId)
Definition: Battleground.cpp:786
void RewardHonorToTeam(uint32 honor, TeamId teamId)
Definition: Battleground.cpp:728

References Battleground::EndBattleground(), Battleground::GetBonusHonorFromKill(), Battleground::RewardHonorToTeam(), TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by EventPlayerUsedGO(), and PostUpdateImpl().

◆ EventPlayerClickedOnFlag()

void BattlegroundSA::EventPlayerClickedOnFlag ( Player Source,
GameObject gameObject 
)
overridevirtual

Called when a player click on flag (graveyard flag)

Reimplemented from Battleground.

886{
887 switch (gameObject->GetEntry())
888 {
889 case 191307:
890 case 191308:
893 break;
894 case 191305:
895 case 191306:
898 break;
899 case 191310:
900 case 191309:
903 break;
904 default:
905 return;
906 }
907}
void CaptureGraveyard(BG_SA_Graveyards i, Player *Source)
Called when a graveyard is capture -Update spiritguide -Update gameobject (flag) -Update Worldstate -...
Definition: BattlegroundSA.cpp:909
bool CanInteractWithObject(uint32 objectId)
Checks if a player can interact with the given object.
Definition: BattlegroundSA.cpp:836

References BG_SA_CENTRAL_CAPTURABLE_GY, BG_SA_CENTRAL_FLAG, BG_SA_LEFT_CAPTURABLE_GY, BG_SA_LEFT_FLAG, BG_SA_RIGHT_CAPTURABLE_GY, BG_SA_RIGHT_FLAG, CanInteractWithObject(), CaptureGraveyard(), and Object::GetEntry().

◆ EventPlayerDamagedGO()

void BattlegroundSA::EventPlayerDamagedGO ( Player player,
GameObject go,
uint32  eventType 
)
overridevirtual

Called when a player deal damage to building (door)

Reimplemented from Battleground.

615{
616 if (!go || !go->GetGOInfo())
617 return;
618
619 if (eventType == go->GetGOInfo()->building.damagedEvent)
620 {
624 if (uws)
626 }
627
628 if (eventType == go->GetGOInfo()->building.destroyedEvent)
629 {
630 GetBgMap()->DoForAllPlayers([&](Player* player)
631 {
632 if (go->GetGOInfo()->building.destroyedEvent == 19837)
634 else
636 });
637
639 switch (i)
640 {
641 case BG_SA_BLUE_GATE:
642 case BG_SA_GREEN_GATE:
643 {
644 if (auto redGate = GetBGObject(BG_SA_RED_GATE))
645 {
646 redGate->SetDestructibleBuildingModifyState(true);
647 }
648 if (auto purpleGate = GetBGObject(BG_SA_PURPLE_GATE))
649 {
650 purpleGate->SetDestructibleBuildingModifyState(true);
651 }
652 break;
653 }
654 case BG_SA_RED_GATE:
656 if (auto yellowGate = GetBGObject(BG_SA_YELLOW_GATE))
657 {
658 yellowGate->SetDestructibleBuildingModifyState(true);
659 }
660 break;
662 if (auto ancientGate = GetBGObject(BG_SA_ANCIENT_GATE))
663 {
664 ancientGate->SetDestructibleBuildingModifyState(true);
665 }
666 break;
667 }
668 }
669
670 if (eventType == go->GetGOInfo()->building.damageEvent)
671 GetBgMap()->DoForAllPlayers([&](Player* player)
672 {
674 });
675}
@ BG_SA_GATE_DAMAGED
Definition: BattlegroundSA.h:41
@ LANG_BG_SA_WAS_DESTROYED
Definition: Language.h:1266
@ LANG_BG_SA_CHAMBER_BREACHED
Definition: Language.h:1272
@ LANG_BG_SA_IS_UNDER_ATTACK
Definition: Language.h:1265
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:137
uint32 damageEvent
Definition: GameObjectData.h:374
std::string name
Definition: GameObjectData.h:36
struct GameObjectTemplate::@227::@255 building
uint32 destroyedEvent
Definition: GameObjectData.h:366
uint32 damagedEvent
Definition: GameObjectData.h:361

References BG_SA_ANCIENT_GATE, BG_SA_BLUE_GATE, BG_SA_GATE_DAMAGED, BG_SA_GREEN_GATE, BG_SA_PURPLE_GATE, BG_SA_RED_GATE, BG_SA_YELLOW_GATE, GameObjectTemplate::building, GameObjectTemplate::damagedEvent, GameObjectTemplate::damageEvent, GameObjectTemplate::destroyedEvent, Map::DoForAllPlayers(), GateStatus, Battleground::GetBgMap(), Battleground::GetBGObject(), Object::GetEntry(), GetGateIDFromEntry(), GameObject::GetGOInfo(), Player::GetSession(), GetWorldStateFromGateID(), LANG_BG_SA_CHAMBER_BREACHED, LANG_BG_SA_IS_UNDER_ATTACK, LANG_BG_SA_WAS_DESTROYED, GameObjectTemplate::name, ChatHandler::PSendSysMessage(), and Battleground::UpdateWorldState().

◆ EventPlayerUsedGO()

void BattlegroundSA::EventPlayerUsedGO ( Player Source,
GameObject object 
)
overridevirtual

Called when a player use a gamobject (relic)

Reimplemented from Battleground.

1039{
1041 {
1042 if (Source->GetTeamId() == Attackers)
1043 {
1044 GetBgMap()->DoForAllPlayers([&](Player* player)
1045 {
1046 if (player->GetTeamId() == Attackers)
1047 {
1048 if (player->GetTeamId() == TEAM_ALLIANCE)
1049 ChatHandler(player->GetSession()).PSendSysMessage(LANG_BG_SA_ALLIANCE_CAPTURED_RELIC);
1050 else
1051 ChatHandler(player->GetSession()).PSendSysMessage(LANG_BG_SA_HORDE_CAPTURED_RELIC);
1052 }
1053 });
1054
1055 if (Status == BG_SA_ROUND_ONE)
1056 {
1057 _relicClicked = true;
1058 }
1059 else if (Status == BG_SA_ROUND_TWO)
1060 {
1063 ToggleTimer();
1064 //Achievement Storm the Beach (1310)
1065 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
1066 if (itr->second->GetTeamId() == Attackers && RoundScores[1].winner == Attackers)
1067 itr->second->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246);
1068
1069 if (RoundScores[0].time == RoundScores[1].time)
1071 else if (RoundScores[0].time < RoundScores[1].time)
1072 EndBattleground(RoundScores[0].winner);
1073 else
1074 EndBattleground(RoundScores[1].winner);
1075 }
1076 }
1077 }
1078}
@ BG_SA_ROUND_ONE
Definition: BattlegroundSA.h:32
@ BG_SA_ROUND_TWO
Definition: BattlegroundSA.h:34
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET
Definition: DBCEnums.h:142
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:401
bool _relicClicked
Definition: BattlegroundSA.h:647
void ToggleTimer()
Switch on/off timer worldstate.
Definition: BattlegroundSA.cpp:1080
void EndBattleground(TeamId winnerTeamId) override
Called on battleground ending.
Definition: BattlegroundSA.cpp:1086

References _relicClicked, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, Attackers, BG_SA_ObjEntries, BG_SA_ROUND_ONE, BG_SA_ROUND_TWO, BG_SA_TITAN_RELIC, CanInteractWithObject(), Map::DoForAllPlayers(), EndBattleground(), Battleground::GetBgMap(), Object::GetEntry(), Battleground::GetPlayers(), Player::GetTeamId(), RoundScores, Status, TEAM_NEUTRAL, BG_SA_RoundScore::time, ToggleTimer(), TotalTime, and BG_SA_RoundScore::winner.

◆ FillInitialWorldStates()

void BattlegroundSA::FillInitialWorldStates ( WorldPacket data)
overridevirtual

Called for generate packet contain worldstate data.

Reimplemented from Battleground.

471{
472 uint32 ally_attacks = uint32(Attackers == TEAM_ALLIANCE ? 1 : 0);
473 uint32 horde_attacks = uint32(Attackers == TEAM_HORDE ? 1 : 0);
474
481
482 data << uint32(BG_SA_BONUS_TIMER) << uint32(0);
483
484 data << uint32(BG_SA_HORDE_ATTACKS) << horde_attacks;
485 data << uint32(BG_SA_ALLY_ATTACKS) << ally_attacks;
486
487 //Time will be sent on first update...
488 data << uint32(BG_SA_ENABLE_TIMER) << ((TimerEnabled) ? uint32(1) : uint32(0));
489 data << uint32(BG_SA_TIMER_MINS) << uint32(0);
490 data << uint32(BG_SA_TIMER_SEC_TENS) << uint32(0);
491 data << uint32(BG_SA_TIMER_SEC_DECS) << uint32(0);
492
496
500
501 data << uint32(BG_SA_HORDE_DEFENCE_TOKEN) << ally_attacks;
502 data << uint32(BG_SA_ALLIANCE_DEFENCE_TOKEN) << horde_attacks;
503
504 data << uint32(BG_SA_LEFT_ATT_TOKEN_HRD) << horde_attacks;
505 data << uint32(BG_SA_RIGHT_ATT_TOKEN_HRD) << horde_attacks;
506 data << uint32(BG_SA_RIGHT_ATT_TOKEN_ALL) << ally_attacks;
507 data << uint32(BG_SA_LEFT_ATT_TOKEN_ALL) << ally_attacks;
508}
@ BG_SA_ENABLE_TIMER
Definition: BattlegroundSA.h:71
@ BG_SA_ANCIENT_GATEWS
Definition: BattlegroundSA.h:57
@ BG_SA_LEFT_ATT_TOKEN_ALL
Definition: BattlegroundSA.h:62
@ BG_SA_PURPLE_GATEWS
Definition: BattlegroundSA.h:52
@ BG_SA_TIMER_SEC_TENS
Definition: BattlegroundSA.h:48
@ BG_SA_RED_GATEWS
Definition: BattlegroundSA.h:53
@ BG_SA_BLUE_GATEWS
Definition: BattlegroundSA.h:54
@ BG_SA_RIGHT_ATT_TOKEN_HRD
Definition: BattlegroundSA.h:64
@ BG_SA_RIGHT_ATT_TOKEN_ALL
Definition: BattlegroundSA.h:61
@ BG_SA_YELLOW_GATEWS
Definition: BattlegroundSA.h:56
@ BG_SA_ALLIANCE_DEFENCE_TOKEN
Definition: BattlegroundSA.h:66
@ BG_SA_HORDE_DEFENCE_TOKEN
Definition: BattlegroundSA.h:65
@ BG_SA_LEFT_ATT_TOKEN_HRD
Definition: BattlegroundSA.h:63
@ BG_SA_GREEN_GATEWS
Definition: BattlegroundSA.h:55
@ BG_SA_ALLY_ATTACKS
Definition: BattlegroundSA.h:50
@ BG_SA_HORDE_ATTACKS
Definition: BattlegroundSA.h:51
@ BG_SA_TIMER_SEC_DECS
Definition: BattlegroundSA.h:49
@ BG_SA_BONUS_TIMER
Definition: BattlegroundSA.h:70
@ BG_SA_TIMER_MINS
Definition: BattlegroundSA.h:47

References Attackers, BG_SA_ALLIANCE_DEFENCE_TOKEN, BG_SA_ALLY_ATTACKS, BG_SA_ANCIENT_GATE, BG_SA_ANCIENT_GATEWS, BG_SA_BLUE_GATE, BG_SA_BLUE_GATEWS, BG_SA_BONUS_TIMER, BG_SA_CENTER_GY_ALLIANCE, BG_SA_CENTER_GY_HORDE, BG_SA_CENTRAL_CAPTURABLE_GY, BG_SA_ENABLE_TIMER, BG_SA_GREEN_GATE, BG_SA_GREEN_GATEWS, BG_SA_HORDE_ATTACKS, BG_SA_HORDE_DEFENCE_TOKEN, BG_SA_LEFT_ATT_TOKEN_ALL, BG_SA_LEFT_ATT_TOKEN_HRD, BG_SA_LEFT_CAPTURABLE_GY, BG_SA_LEFT_GY_ALLIANCE, BG_SA_LEFT_GY_HORDE, BG_SA_PURPLE_GATE, BG_SA_PURPLE_GATEWS, BG_SA_RED_GATE, BG_SA_RED_GATEWS, BG_SA_RIGHT_ATT_TOKEN_ALL, BG_SA_RIGHT_ATT_TOKEN_HRD, BG_SA_RIGHT_CAPTURABLE_GY, BG_SA_RIGHT_GY_ALLIANCE, BG_SA_RIGHT_GY_HORDE, BG_SA_TIMER_MINS, BG_SA_TIMER_SEC_DECS, BG_SA_TIMER_SEC_TENS, BG_SA_YELLOW_GATE, BG_SA_YELLOW_GATEWS, GateStatus, GraveyardStatus, TEAM_ALLIANCE, TEAM_HORDE, and TimerEnabled.

◆ GetClosestGraveyard()

GraveyardStruct const * BattlegroundSA::GetClosestGraveyard ( Player player)
overridevirtual

Return the nearest graveyard where player can respawn.

Reimplemented from Battleground.

793{
794 GraveyardStruct const* closest = nullptr;
795 float mindist = 999999.0f;
796 float x, y;
797
798 player->GetPosition(x, y);
799
800 for (uint8 i = BG_SA_BEACH_GY; i < BG_SA_MAX_GY; i++)
801 {
802 if (GraveyardStatus[i] != player->GetTeamId())
803 continue;
804
805 GraveyardStruct const* ret = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
806
807 // if on beach
808 if (i == BG_SA_BEACH_GY)
809 {
810 if (x > 1400)
811 return ret;
812 continue;
813 }
814
815 float dist = std::sqrt(pow(ret->x - x, 2) * pow(ret->y - y, 2));
816 if (dist < mindist)
817 {
818 mindist = dist;
819 closest = ret;
820 }
821 }
822 if (!closest && GraveyardStatus[BG_SA_BEACH_GY] == player->GetTeamId())
823 return sGraveyard->GetGraveyard(BG_SA_GYEntries[BG_SA_BEACH_GY]);
824
825 return closest;
826}
@ BG_SA_BEACH_GY
Definition: BattlegroundSA.h:372
void GetPosition(float &x, float &y) const
Definition: Position.h:122

References BG_SA_BEACH_GY, BG_SA_GYEntries, BG_SA_MAX_GY, Position::GetPosition(), Player::GetTeamId(), GraveyardStatus, sGraveyard, GraveyardStruct::x, and GraveyardStruct::y.

Referenced by CaptureGraveyard().

◆ GetGateIDFromEntry()

uint32 BattlegroundSA::GetGateIDFromEntry ( uint32  id)
inlineprivate

Return gate id, relative to bg data, according to gameobject id.

537 {
538 uint32 i = 0;
539 switch (id)
540 {
541 case 190722:
543 break; //Green gate destroyed
544 case 190724:
545 i = BG_SA_BLUE_GATE;
546 break; //blue gate
547 case 190726:
548 i = BG_SA_RED_GATE;
549 break; //red gate
550 case 190723:
552 break; //purple gate
553 case 190727:
555 break; //yellow gate
556 case 192549:
558 break; //ancient gate
559 }
560 return i;
561 }

References BG_SA_ANCIENT_GATE, BG_SA_BLUE_GATE, BG_SA_GREEN_GATE, BG_SA_PURPLE_GATE, BG_SA_RED_GATE, and BG_SA_YELLOW_GATE.

Referenced by DestroyGate(), and EventPlayerDamagedGO().

◆ GetWorldStateFromGateID()

uint32 BattlegroundSA::GetWorldStateFromGateID ( uint32  id)
inline

Return worldstate id, according to door id.

492 {
493 uint32 uws = 0;
494 switch (id)
495 {
496 case BG_SA_GREEN_GATE:
497 uws = BG_SA_GREEN_GATEWS;
498 break;
501 break;
502 case BG_SA_BLUE_GATE:
503 uws = BG_SA_BLUE_GATEWS;
504 break;
505 case BG_SA_RED_GATE:
506 uws = BG_SA_RED_GATEWS;
507 break;
510 break;
513 break;
514 }
515 return uws;
516 }

References BG_SA_ANCIENT_GATE, BG_SA_ANCIENT_GATEWS, BG_SA_BLUE_GATE, BG_SA_BLUE_GATEWS, BG_SA_GREEN_GATE, BG_SA_GREEN_GATEWS, BG_SA_PURPLE_GATE, BG_SA_PURPLE_GATEWS, BG_SA_RED_GATE, BG_SA_RED_GATEWS, BG_SA_YELLOW_GATE, and BG_SA_YELLOW_GATEWS.

Referenced by DestroyGate(), and EventPlayerDamagedGO().

◆ HandleAreaTrigger()

void BattlegroundSA::HandleAreaTrigger ( Player player,
uint32  trigger 
)
overridevirtual

Reimplemented from Battleground.

524{
525 // this is wrong way to implement these things. On official it done by gameobject spell cast.
527 return;
528}
@ STATUS_IN_PROGRESS
Definition: Battleground.h:197
BattlegroundStatus GetStatus() const
Definition: Battleground.h:327

References Battleground::GetStatus(), and STATUS_IN_PROGRESS.

◆ HandleKillUnit()

void BattlegroundSA::HandleKillUnit ( Creature creature,
Player killer 
)
overridevirtual

Called when a player kill a unit in bg.

Reimplemented from Battleground.

678{
679 if (creature->GetEntry() == NPC_DEMOLISHER_SA)
680 {
683 creature->SetVisible(false);
684 }
685}
@ NPC_DEMOLISHER_SA
Definition: BattlegroundSA.h:77
@ SCORE_DESTROYED_DEMOLISHER
Definition: BattlegroundScore.h:54
bool _notEvenAScratch[PVP_TEAMS_COUNT]
Definition: BattlegroundSA.h:650
void SetVisible(bool x)
Definition: Unit.cpp:14189

References _notEvenAScratch, Attackers, Object::GetEntry(), NPC_DEMOLISHER_SA, SCORE_DESTROYED_DEMOLISHER, Unit::SetVisible(), and Battleground::UpdatePlayerScore().

◆ Init()

void BattlegroundSA::Init ( )
overridevirtual

Reimplemented from Battleground.

76{
78
79 TotalTime = 0s;
81 for (uint8 i = 0; i <= 5; i++)
83 ShipsStarted = false;
87 _relicClicked = false;
88}
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ BG_SA_WARMUP
Definition: BattlegroundSA.h:31
virtual void Init()
Definition: Battleground.cpp:1064

References _notEvenAScratch, _relicClicked, Attackers, BG_SA_GATE_OK, BG_SA_WARMUP, GateStatus, Battleground::Init(), ShipsStarted, Status, TEAM_ALLIANCE, TEAM_HORDE, TotalTime, and urand().

◆ notEvenAScratch()

bool BattlegroundSA::notEvenAScratch ( TeamId  teamId) const
inline
532{ return _notEvenAScratch[teamId]; }

Referenced by achievement_not_even_a_scratch::OnCheck().

◆ OverrideGunFaction()

void BattlegroundSA::OverrideGunFaction ( )
private

Called on start and between the two round -Update faction of all vehicle.

692{
693 if (!BgCreatures[0])
694 return;
695
696 for (uint8 i = BG_SA_GUN_1; i <= BG_SA_GUN_10; i++)
697 {
698 if (Creature* gun = GetBGCreature(i))
699 gun->SetFaction(BG_SA_Factions[Attackers ? TEAM_ALLIANCE : TEAM_HORDE]);
700 }
701
702 for (uint8 i = BG_SA_DEMOLISHER_1; i <= BG_SA_DEMOLISHER_4; i++)
703 {
704 if (Creature* dem = GetBGCreature(i))
705 dem->SetFaction(BG_SA_Factions[Attackers]);
706 }
707}

References Attackers, BG_SA_DEMOLISHER_1, BG_SA_DEMOLISHER_4, BG_SA_Factions, BG_SA_GUN_1, BG_SA_GUN_10, Battleground::BgCreatures, Battleground::GetBGCreature(), TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by ResetObjs().

◆ PostUpdateImpl()

void BattlegroundSA::PostUpdateImpl ( uint32  diff)
overridevirtual

Called every time for update battle data -Update timer -Round switch.

Reimplemented from Battleground.

317{
318 if (InitSecondRound)
319 {
320 if (UpdateWaitTimer < diff)
321 {
322 if (!SignaledRoundTwo)
323 {
324 SignaledRoundTwo = true;
325 InitSecondRound = false;
327 }
328 }
329 else
330 {
331 UpdateWaitTimer -= diff;
332 return;
333 }
334 }
335 TotalTime += Milliseconds(diff);
336
337 if (Status == BG_SA_WARMUP)
338 {
341 {
342 TotalTime = 0s;
343 ToggleTimer();
347 }
349 StartShips();
350 return;
351 }
352 else if (Status == BG_SA_SECOND_WARMUP)
353 {
354 if (RoundScores[0].time < BG_SA_ROUNDLENGTH)
356 else
358
359 if (TotalTime >= 1min)
360 {
361 GetBgMap()->DoForAllPlayers([&](Player* player)
362 {
364 });
365
366 TotalTime = 0s;
367 ToggleTimer();
371
372 // status was set to STATUS_WAIT_JOIN manually for Preparation, set it back now
374 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
375 itr->second->RemoveAurasDueToSpell(SPELL_PREPARATION);
376 }
377 if (TotalTime >= 30s)
378 {
380 {
383 }
384 }
385 StartShips();
386 return;
387 }
388 else if (GetStatus() == STATUS_IN_PROGRESS)
389 {
390 if (Status == BG_SA_ROUND_ONE)
391 {
393 {
394 if (_relicClicked)
395 {
398 //Achievement Storm the Beach (1310)
399 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
400 if (itr->second->GetTeamId() == Attackers)
401 itr->second->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246);
402 }
403 else
404 {
405 // cast this before Attackers variable is switched
406 // cast this spell only upon timer end, no other ability for defenders to win :)
407 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
408 itr->second->CastSpell(itr->second, SPELL_SA_END_OF_ROUND, true);
409
412 }
413
414 _relicClicked = false;
417 TotalTime = 0s;
418 ToggleTimer();
419
420 GetBgMap()->DoForAllPlayers([&](Player* player)
421 {
423 });
424
425 UpdateWaitTimer = 5000;
426 SignaledRoundTwo = false;
428 InitSecondRound = true;
429 ResetObjs();
430
431 return;
432 }
433 }
434 else if (Status == BG_SA_ROUND_TWO)
435 {
437 {
438 // cast this spell only upon timer end, no other ability for defenders to win :)
439 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
440 itr->second->CastSpell(itr->second, SPELL_SA_END_OF_ROUND, true);
441
444
445 if (RoundScores[0].time == RoundScores[1].time)
447 else if (RoundScores[0].time < RoundScores[1].time)
448 EndBattleground(RoundScores[0].winner);
449 else
450 EndBattleground(RoundScores[1].winner);
451 return;
452 }
453 }
455 {
456 SendTime();
458 }
459 }
460}
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:27
#define SPELL_SA_END_OF_ROUND
Definition: BattlegroundSA.h:26
@ BG_SA_SECOND_WARMUP
Definition: BattlegroundSA.h:33
@ BG_SA_TEXT_ROUND_TWO_START_ONE_MINUTE
Definition: BattlegroundSA.h:403
@ BG_SA_TEXT_ROUND_TWO_START_HALF_MINUTE
Definition: BattlegroundSA.h:404
constexpr Milliseconds BG_SA_ROUNDLENGTH
Definition: BattlegroundSA.cpp:31
constexpr Milliseconds BG_SA_BOAT_START
Definition: BattlegroundSA.cpp:29
constexpr Milliseconds BG_SA_WARMUPLENGTH
Definition: BattlegroundSA.cpp:30
@ SPELL_PREPARATION
Definition: Battleground.h:137
@ LANG_BG_SA_HAS_BEGUN
Definition: Language.h:1264
@ LANG_BG_SA_ROUND_ONE_END
Definition: Language.h:1267
@ CHAT_MSG_BG_SYSTEM_NEUTRAL
Definition: SharedDefines.h:3188
@ ACHIEVEMENT_TIMED_TYPE_EVENT
Definition: DBCEnums.h:110
static TeamId GetOtherTeamId(TeamId teamId)
Definition: Battleground.cpp:1752
void SetStatus(BattlegroundStatus Status)
Definition: Battleground.h:356
void SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject const *target=nullptr)
Definition: Battleground.cpp:686
void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
Definition: Battleground.cpp:1828
void DemolisherStartState(bool start)
Set selectable or not demolisher, called on battle start, when boats arrive to dock.
Definition: BattlegroundSA.cpp:709
void SendTime()
Update timer worldstate.
Definition: BattlegroundSA.cpp:828
void UpdateDemolisherSpawns()
Respawn dead demolisher.
Definition: BattlegroundSA.cpp:1098
bool ResetObjs()
Called on setup and between the two round -Delete all gameobject / creature -Respawn all gameobject /...
Definition: BattlegroundSA.cpp:95
void StartShips()
Called for start ship movement.
Definition: BattlegroundSA.cpp:294

References _relicClicked, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, ACHIEVEMENT_TIMED_TYPE_EVENT, Attackers, BG_SA_BOAT_START, BG_SA_ROUND_ONE, BG_SA_ROUND_TWO, BG_SA_ROUNDLENGTH, BG_SA_SECOND_WARMUP, BG_SA_TEXT_ROUND_TWO_START_HALF_MINUTE, BG_SA_TEXT_ROUND_TWO_START_ONE_MINUTE, BG_SA_WARMUP, BG_SA_WARMUPLENGTH, CHAT_MSG_BG_SYSTEM_NEUTRAL, DemolisherStartState(), Map::DoForAllPlayers(), EndBattleground(), EndRoundTimer, Battleground::GetBgMap(), Battleground::GetOtherTeamId(), Battleground::GetPlayers(), Player::GetSession(), Battleground::GetStatus(), InitSecondRound, LANG_BG_SA_HAS_BEGUN, LANG_BG_SA_ROUND_ONE_END, ChatHandler::PSendSysMessage(), ResetObjs(), RoundScores, Battleground::SendBroadcastText(), SendTime(), Battleground::SetStatus(), SignaledRoundTwo, SignaledRoundTwoHalfMin, SPELL_PREPARATION, SPELL_SA_END_OF_ROUND, StartShips(), Battleground::StartTimedAchievement(), Status, STATUS_IN_PROGRESS, TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, BG_SA_RoundScore::time, ToggleTimer(), TotalTime, UpdateDemolisherSpawns(), UpdateWaitTimer, and BG_SA_RoundScore::winner.

◆ RemovePlayer()

void BattlegroundSA::RemovePlayer ( Player player)
overridevirtual

CAlled when a player leave battleground.

Reimplemented from Battleground.

520{
521}

◆ ResetObjs()

bool BattlegroundSA::ResetObjs ( )
private

Called on setup and between the two round -Delete all gameobject / creature -Respawn all gameobject / creature to have good faction.

96{
97 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
98 SendTransportsRemove(itr->second);
99
102
103 for (uint8 i = 0; i < BG_SA_MAXOBJ; i++)
104 DelObject(i);
105
106 for (uint8 i = 0; i < BG_SA_MAXNPC; i++)
107 DelCreature(i);
108
109 for (uint8 i = BG_SA_MAXNPC; i < static_cast<uint16>(BG_SA_MAXNPC) + BG_SA_MAX_GY; i++)
110 DelCreature(i);
111
112 for (uint8 i = 0; i < 6; ++i)
114
115 for (uint8 i = 0; i < BG_SA_BOAT_ONE; i++)
116 {
118 return false;
119 }
120
121 for (uint8 i = BG_SA_BOAT_ONE; i < BG_SA_SIGIL_1; i++)
122 {
123 uint32 boatid = 0;
124 switch (i)
125 {
126 case BG_SA_BOAT_ONE:
128 break;
129 case BG_SA_BOAT_TWO:
131 break;
132 }
133 if (!AddObject(i, boatid, BG_SA_ObjSpawnlocs[i][0],
134 BG_SA_ObjSpawnlocs[i][1],
135 BG_SA_ObjSpawnlocs[i][2] + (Attackers ? -3.750f : 0),
136 BG_SA_ObjSpawnlocs[i][3], 0, 0, 0, 0, RESPAWN_ONE_DAY))
137 return false;
138 }
139
140 for (uint8 i = BG_SA_SIGIL_1; i < BG_SA_CENTRAL_FLAG; i++)
141 {
142 if (!AddObject(i, BG_SA_ObjEntries[i],
145 0, 0, 0, 0, RESPAWN_ONE_DAY))
146 return false;
147 }
148
149 // MAD props for Kiper for discovering those values - 4 hours of his work.
150 GetBGObject(BG_SA_BOAT_ONE)->SetTransportPathRotation(0.0f, 0.0f, 1.0f, 0.0002f);
151 GetBGObject(BG_SA_BOAT_TWO)->SetTransportPathRotation(0.0f, 0.0f, 1.0f, 0.00001f);
154
155 //Cannons and demolishers - NPCs are spawned
156 //By capturing GYs.
157 for (uint8 i = 0; i < BG_SA_DEMOLISHER_5; i++)
158 {
159 if (!AddCreature(BG_SA_NpcEntries[i], i,
161 BG_SA_NpcSpawnlocs[i][2], BG_SA_NpcSpawnlocs[i][3], 600))
162 return false;
163 }
164
167
168 for (uint8 i = BG_SA_GREEN_GATE; i <= BG_SA_TITAN_RELIC; i++)
169 {
171 if (GameObject* go = GetBGObject(i))
172 {
173 go->setActive(true);
174 go->SetUInt32Value(GAMEOBJECT_FACTION, defF);
175 go->SetDestructibleBuildingModifyState(false);
176 }
177 }
178
181
182 TotalTime = 0s;
183 ShipsStarted = false;
184
185 //Graveyards!
186 for (uint8 i = 0; i < BG_SA_MAX_GY; i++)
187 {
188 GraveyardStruct const* sg = nullptr;
189 sg = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
190
191 if (!sg)
192 {
193 LOG_ERROR("bg.battleground", "SOTA: Can't find GY entry {}", BG_SA_GYEntries[i]);
194 return false;
195 }
196
197 if (i == BG_SA_BEACH_GY)
198 {
201 }
202 else
203 {
206 LOG_ERROR("bg.battleground", "SOTA: couldn't spawn GY: {}", i);
207 }
208 }
209
210 //GY capture points
212 {
213 AddObject(i, (BG_SA_ObjEntries[i] - (Attackers == TEAM_ALLIANCE ? 1 : 0)),
216 0, 0, 0, 0, RESPAWN_ONE_DAY);
218 }
219
221 {
225 0, 0, 0, 0, RESPAWN_ONE_DAY);
227 }
228
230
231 for (uint8 i = BG_SA_BOMB; i < BG_SA_MAXOBJ; i++)
232 {
236 0, 0, 0, 0, RESPAWN_ONE_DAY);
238 }
239
240 //Player may enter BEFORE we set up bG - lets update his worldstates anyway...
244
248
250 {
253
258
261 }
262 else
263 {
266
271
274 }
275
282
283 for (int i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++)
284 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
285 SendTransportInit(itr->second);
286
287 // set status manually so preparation is cast correctly in 2nd round too
289
291 return true;
292}
@ BG_SA_BOAT_ONE_H
Definition: BattlegroundSA.h:116
@ BG_SA_BOAT_TWO_H
Definition: BattlegroundSA.h:115
@ BG_SA_BOAT_ONE_A
Definition: BattlegroundSA.h:114
@ BG_SA_BOAT_TWO_A
Definition: BattlegroundSA.h:117
@ BG_SA_BOAT_ONE
Definition: BattlegroundSA.h:196
@ BG_SA_SIGIL_1
Definition: BattlegroundSA.h:198
@ BG_SA_PORTAL_DEFFENDER_BLUE
Definition: BattlegroundSA.h:209
@ BG_SA_BOAT_TWO
Definition: BattlegroundSA.h:197
@ BG_SA_BOMB
Definition: BattlegroundSA.h:214
@ RESPAWN_IMMEDIATELY
Definition: Battleground.h:164
@ STATUS_WAIT_JOIN
Definition: Battleground.h:196
@ GAMEOBJECT_FACTION
Definition: UpdateFields.h:402
void SpawnBGObject(uint32 type, uint32 respawntime, uint32 forceRespawnDelay=0)
Definition: Battleground.cpp:1507
void OverrideGunFaction()
Called on start and between the two round -Update faction of all vehicle.
Definition: BattlegroundSA.cpp:691
void TeleportPlayers()
Called between the two round -Teleport all players to good location.
Definition: BattlegroundSA.cpp:530
void SendTransportsRemove(Player *player)
Send packet to player for destroy boats (client part)
Definition: BattlegroundSA.cpp:1146
void SetTransportPathRotation(float qx, float qy, float qz, float qw)
Definition: GameObject.cpp:2247
void Refresh()
Definition: GameObject.cpp:917
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650

References Battleground::AddCreature(), Battleground::AddObject(), Battleground::AddSpiritGuide(), Attackers, BG_SA_ALLIANCE_DEFENCE_TOKEN, BG_SA_ALLY_ATTACKS, BG_SA_ANCIENT_GATEWS, BG_SA_BEACH_GY, BG_SA_BLUE_GATEWS, BG_SA_BOAT_ONE, BG_SA_BOAT_ONE_A, BG_SA_BOAT_ONE_H, BG_SA_BOAT_TWO, BG_SA_BOAT_TWO_A, BG_SA_BOAT_TWO_H, BG_SA_BOMB, BG_SA_CENTER_GY_ALLIANCE, BG_SA_CENTER_GY_HORDE, BG_SA_CENTRAL_CAPTURABLE_GY, BG_SA_CENTRAL_FLAG, BG_SA_DEMOLISHER_5, BG_SA_Factions, BG_SA_GATE_OK, BG_SA_GREEN_GATE, BG_SA_GREEN_GATEWS, BG_SA_GYEntries, BG_SA_GYOrientation, BG_SA_HORDE_ATTACKS, BG_SA_HORDE_DEFENCE_TOKEN, BG_SA_LEFT_ATT_TOKEN_ALL, BG_SA_LEFT_ATT_TOKEN_HRD, BG_SA_LEFT_CAPTURABLE_GY, BG_SA_LEFT_GY_ALLIANCE, BG_SA_LEFT_GY_HORDE, BG_SA_MAX_GY, BG_SA_MAXNPC, BG_SA_MAXOBJ, BG_SA_NpcEntries, BG_SA_NpcSpawnlocs, BG_SA_ObjEntries, BG_SA_ObjSpawnlocs, BG_SA_PORTAL_DEFFENDER_BLUE, BG_SA_PURPLE_GATEWS, BG_SA_RED_GATEWS, BG_SA_RIGHT_ATT_TOKEN_ALL, BG_SA_RIGHT_ATT_TOKEN_HRD, BG_SA_RIGHT_CAPTURABLE_GY, BG_SA_RIGHT_GY_ALLIANCE, BG_SA_RIGHT_GY_HORDE, BG_SA_SIGIL_1, BG_SA_TITAN_RELIC, BG_SA_YELLOW_GATEWS, Battleground::DelCreature(), Battleground::DelObject(), DemolisherStartState(), GAMEOBJECT_FACTION, GateStatus, Battleground::GetBGObject(), Battleground::GetOtherTeamId(), Battleground::GetPlayers(), GraveyardStatus, LOG_ERROR, OverrideGunFaction(), GameObject::Refresh(), RESPAWN_IMMEDIATELY, RESPAWN_ONE_DAY, SendTransportInit(), SendTransportsRemove(), Battleground::SetStatus(), GameObject::SetTransportPathRotation(), Object::SetUInt32Value(), sGraveyard, ShipsStarted, Battleground::SpawnBGObject(), STATUS_WAIT_JOIN, TEAM_ALLIANCE, TEAM_HORDE, TeleportPlayers(), TotalTime, UpdateObjectInteractionFlags(), Battleground::UpdateWorldState(), GraveyardStruct::x, GraveyardStruct::y, and GraveyardStruct::z.

Referenced by PostUpdateImpl(), and SetupBattleground().

◆ SendTime()

void BattlegroundSA::SendTime ( )
private

Update timer worldstate.

829{
830 Milliseconds end_of_round = (EndRoundTimer - TotalTime);
831 UpdateWorldState(BG_SA_TIMER_MINS, end_of_round / 1min);
832 UpdateWorldState(BG_SA_TIMER_SEC_TENS, (end_of_round % 1min) / 10s);
833 UpdateWorldState(BG_SA_TIMER_SEC_DECS, ((end_of_round % 1min) % 10s) / 1s);
834}

References BG_SA_TIMER_MINS, BG_SA_TIMER_SEC_DECS, BG_SA_TIMER_SEC_TENS, EndRoundTimer, TotalTime, and Battleground::UpdateWorldState().

Referenced by PostUpdateImpl().

◆ SendTransportInit()

void BattlegroundSA::SendTransportInit ( Player player)
private

Send packet to player for create boats (client part)

1132{
1134 {
1135 UpdateData transData;
1140 WorldPacket packet;
1141 transData.BuildPacket(packet);
1142 player->GetSession()->SendPacket(&packet);
1143 }
1144}
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition: Object.cpp:189
Definition: UpdateData.h:52
bool BuildPacket(WorldPacket &packet)
Definition: UpdateData.cpp:48
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

References BG_SA_BOAT_ONE, BG_SA_BOAT_TWO, Battleground::BgObjects, Object::BuildCreateUpdateBlockForPlayer(), UpdateData::BuildPacket(), Battleground::GetBGObject(), Player::GetSession(), and WorldSession::SendPacket().

Referenced by AddPlayer(), and ResetObjs().

◆ SendTransportsRemove()

void BattlegroundSA::SendTransportsRemove ( Player player)
private

Send packet to player for destroy boats (client part)

1147{
1149 {
1150 UpdateData transData;
1155 WorldPacket packet;
1156 transData.BuildPacket(packet);
1157 player->GetSession()->SendPacket(&packet);
1158 }
1159}
void BuildOutOfRangeUpdateBlock(UpdateData *data) const
Definition: Object.cpp:269

References BG_SA_BOAT_ONE, BG_SA_BOAT_TWO, Battleground::BgObjects, Object::BuildOutOfRangeUpdateBlock(), UpdateData::BuildPacket(), Battleground::GetBGObject(), Player::GetSession(), and WorldSession::SendPacket().

Referenced by ResetObjs().

◆ SetupBattleground()

bool BattlegroundSA::SetupBattleground ( )
overridevirtual

Called for ini battleground, after that the first player be entered.

Reimplemented from Battleground.

91{
92 return ResetObjs();
93}

References ResetObjs().

◆ StartingEventCloseDoors()

void BattlegroundSA::StartingEventCloseDoors ( )
overridevirtual

Called when battle start.

Reimplemented from Battleground.

463{
464}

◆ StartingEventOpenDoors()

void BattlegroundSA::StartingEventOpenDoors ( )
overridevirtual

Reimplemented from Battleground.

467{
468}

◆ StartShips()

void BattlegroundSA::StartShips ( )
private

Called for start ship movement.

295{
296 if (ShipsStarted)
297 return;
298
301
302 for (int i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++)
303 {
304 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
305 {
306 UpdateData data;
307 WorldPacket pkt;
308 GetBGObject(i)->BuildValuesUpdateBlockForPlayer(&data, itr->second);
309 data.BuildPacket(pkt);
310 itr->second->GetSession()->SendPacket(&pkt);
311 }
312 }
313 ShipsStarted = true;
314}
void DoorOpen(uint32 type)
Definition: Battleground.cpp:1477
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition: Object.cpp:257

References BG_SA_BOAT_ONE, BG_SA_BOAT_TWO, UpdateData::BuildPacket(), Object::BuildValuesUpdateBlockForPlayer(), Battleground::DoorOpen(), Battleground::GetBGObject(), Battleground::GetPlayers(), and ShipsStarted.

Referenced by PostUpdateImpl().

◆ TeleportPlayers()

void BattlegroundSA::TeleportPlayers ( )
private

Called between the two round -Teleport all players to good location.

531{
532 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
533 {
534 if (Player* player = itr->second)
535 {
536 // should remove spirit of redemption
537 if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
538 player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
539
540 if (!player->IsAlive())
541 {
542 player->ResurrectPlayer(1.0f);
543 player->SpawnCorpseBones();
544 }
545
547 {
548 player->CastSpell(player, SPELL_PREPARATION, true);
549 player->GetMotionMaster()->MovementExpired();
550 }
551
552 player->ResetAllPowers();
553 player->CombatStopWithPets(true);
554
556
557 // xinef: one more time, just to be sure
559 player->GetMotionMaster()->Clear(false);
560 }
561 }
562}
@ SPELL_AURA_MOD_SHAPESHIFT
Definition: SpellAuraDefines.h:99
@ SPELL_AURA_SPIRIT_OF_REDEMPTION
Definition: SpellAuraDefines.h:239

References BG_SA_SECOND_WARMUP, Battleground::GetPlayers(), SPELL_AURA_MOD_SHAPESHIFT, SPELL_AURA_SPIRIT_OF_REDEMPTION, SPELL_PREPARATION, Status, and TeleportToEntrancePosition().

Referenced by ResetObjs().

◆ TeleportToEntrancePosition()

void BattlegroundSA::TeleportToEntrancePosition ( Player player)
private
565{
566 if (player->GetTeamId() != Attackers)
567 {
568 player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
569 }
570 else
571 {
572 if (!ShipsStarted)
573 {
574 player->CastSpell(player, 12438, true);//Without this player falls before boat loads...
575 if (urand(0, 1))
576 player->TeleportTo(607, 2682.936f, -830.368f, 15.0f, 2.895f, 0);
577 else
578 player->TeleportTo(607, 2577.003f, 980.261f, 15.0f, 0.807f, 0);
579 }
580 else
581 player->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0);
582 }
583}
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1168

References Attackers, Unit::CastSpell(), Player::GetTeamId(), ShipsStarted, Player::TeleportTo(), and urand().

Referenced by AddPlayer(), and TeleportPlayers().

◆ ToggleTimer()

void BattlegroundSA::ToggleTimer ( )
private

Switch on/off timer worldstate.

References BG_SA_ENABLE_TIMER, TimerEnabled, and Battleground::UpdateWorldState().

Referenced by EventPlayerUsedGO(), and PostUpdateImpl().

◆ UpdateDemolisherSpawns()

void BattlegroundSA::UpdateDemolisherSpawns ( )
private

Respawn dead demolisher.

1099{
1100 for (uint8 i = BG_SA_DEMOLISHER_1; i <= BG_SA_DEMOLISHER_8; i++)
1101 {
1102 if (BgCreatures[i])
1103 {
1104 if (Creature* Demolisher = GetBGCreature(i))
1105 {
1106 if (Demolisher->isDead())
1107 {
1108 // Demolisher is not in list
1109 if (DemoliserRespawnList.find(i) == DemoliserRespawnList.end())
1110 {
1111 DemoliserRespawnList[i] = GameTime::GetGameTimeMS().count() + 30000;
1112 }
1113 else
1114 {
1116 {
1117 Demolisher->Relocate(BG_SA_NpcSpawnlocs[i][0], BG_SA_NpcSpawnlocs[i][1],
1119
1120 Demolisher->SetVisible(true);
1121 Demolisher->Respawn();
1122 DemoliserRespawnList.erase(i);
1123 }
1124 }
1125 }
1126 }
1127 }
1128 }
1129}
Milliseconds GetGameTimeMS()
Definition: GameTime.cpp:43
std::map< uint32, uint32 > DemoliserRespawnList
Definition: BattlegroundSA.h:644

References BG_SA_DEMOLISHER_1, BG_SA_DEMOLISHER_8, BG_SA_NpcSpawnlocs, Battleground::BgCreatures, DemoliserRespawnList, Battleground::GetBGCreature(), and GameTime::GetGameTimeMS().

Referenced by PostUpdateImpl().

◆ UpdateObjectInteractionFlags() [1/2]

void BattlegroundSA::UpdateObjectInteractionFlags ( )
private

◆ UpdateObjectInteractionFlags() [2/2]

void BattlegroundSA::UpdateObjectInteractionFlags ( uint32  objectId)
private

Updates interaction flags of specific objects.

868{
869 if (GameObject* go = GetBGObject(objectId))
870 {
871 if (CanInteractWithObject(objectId))
872 go->RemoveGameObjectFlag(GO_FLAG_NOT_SELECTABLE | GO_FLAG_INTERACT_COND | GO_FLAG_IN_USE);
873 else
874 go->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
875 }
876}
@ GO_FLAG_INTERACT_COND
Definition: SharedDefines.h:1605
@ GO_FLAG_NOT_SELECTABLE
Definition: SharedDefines.h:1607
@ GO_FLAG_IN_USE
Definition: SharedDefines.h:1603

References CanInteractWithObject(), Battleground::GetBGObject(), GO_FLAG_IN_USE, GO_FLAG_INTERACT_COND, and GO_FLAG_NOT_SELECTABLE.

Member Data Documentation

◆ _notEvenAScratch

bool BattlegroundSA::_notEvenAScratch[PVP_TEAMS_COUNT]
private

Referenced by HandleKillUnit(), and Init().

◆ _relicClicked

bool BattlegroundSA::_relicClicked
private

◆ Attackers

◆ DemoliserRespawnList

std::map<uint32, uint32> BattlegroundSA::DemoliserRespawnList
private

Referenced by UpdateDemolisherSpawns().

◆ EndRoundTimer

Milliseconds BattlegroundSA::EndRoundTimer
private

Max time of round.

Referenced by BattlegroundSA(), PostUpdateImpl(), and SendTime().

◆ GateStatus

BG_SA_GateState BattlegroundSA::GateStatus[6]
private

◆ GraveyardStatus

TeamId BattlegroundSA::GraveyardStatus[BG_SA_MAX_GY]
private

Team witch conntrol each graveyard.

Referenced by BattlegroundSA(), CaptureGraveyard(), FillInitialWorldStates(), GetClosestGraveyard(), and ResetObjs().

◆ InitSecondRound

bool BattlegroundSA::InitSecondRound
private

for know if second round has been init

Referenced by BattlegroundSA(), and PostUpdateImpl().

◆ RoundScores

BG_SA_RoundScore BattlegroundSA::RoundScores[2]
private

Score of each round.

Referenced by BattlegroundSA(), EventPlayerUsedGO(), and PostUpdateImpl().

◆ ShipsStarted

bool BattlegroundSA::ShipsStarted
private

For know if boats has start moving or not yet.

Referenced by BattlegroundSA(), Init(), ResetObjs(), StartShips(), and TeleportToEntrancePosition().

◆ SignaledRoundTwo

bool BattlegroundSA::SignaledRoundTwo
private

for know if warning about second round start has been sent

Referenced by BattlegroundSA(), and PostUpdateImpl().

◆ SignaledRoundTwoHalfMin

bool BattlegroundSA::SignaledRoundTwoHalfMin
private

for know if warning about second round start has been sent

Referenced by BattlegroundSA(), and PostUpdateImpl().

◆ Status

BG_SA_Status BattlegroundSA::Status
private

Statu of battle (Start or not, and what round)

Referenced by BattlegroundSA(), EventPlayerUsedGO(), Init(), PostUpdateImpl(), and TeleportPlayers().

◆ TimerEnabled

bool BattlegroundSA::TimerEnabled
private

used for know we are in timer phase or not (used for worldstate update)

Referenced by BattlegroundSA(), FillInitialWorldStates(), and ToggleTimer().

◆ TotalTime

Milliseconds BattlegroundSA::TotalTime
private

Totale elapsed time of current round.

Referenced by BattlegroundSA(), EventPlayerUsedGO(), Init(), PostUpdateImpl(), ResetObjs(), and SendTime().

◆ UpdateWaitTimer

uint32 BattlegroundSA::UpdateWaitTimer
private

5secs before starting the 1min countdown for second round

Referenced by BattlegroundSA(), and PostUpdateImpl().