AzeorthCore 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
 
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)
 
void SendWarningToAll (uint32 entry,...)
 
void SendMessageToAll (uint32 entry, ChatMsg type, Player const *source=nullptr)
 
void PSendMessageToAll (uint32 entry, ChatMsg type, Player const *source,...)
 
void SendMessage2ToAll (uint32 entry, ChatMsg type, Player const *source, uint32 strId1=0, uint32 strId2=0)
 
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.

40{
42 BgObjects.resize(BG_SA_MAXOBJ);
43 BgCreatures.resize(static_cast<uint16>(BG_SA_MAXNPC) + BG_SA_MAX_GY);
44 TimerEnabled = false;
46 SignaledRoundTwo = false;
48 InitSecondRound = false;
50 TotalTime = 0s;
51 EndRoundTimer = 0s;
52 ShipsStarted = false;
54
55 for (uint8 i = 0; i < 6; i++)
57
58 for (uint8 i = 0; i < 2; i++)
59 {
61 RoundScores[i].time = 0s;
62 }
63
67 memset(&GraveyardStatus, 0, sizeof(GraveyardStatus));
68}
std::uint8_t uint8
Definition: Define.h:110
std::uint16_t uint16
Definition: Define.h:109
@ BG_STARTING_EVENT_FOURTH
Definition: Battleground.h:237
@ 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
@ TEAM_ALLIANCE
Definition: SharedDefines.h:732
BGObjects BgObjects
Definition: Battleground.h:531
BGCreatures BgCreatures
Definition: Battleground.h:532
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:624
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
71{
72}

Member Function Documentation

◆ AddPlayer()

void BattlegroundSA::AddPlayer ( Player player)
overridevirtual

Called when a player join battle.

Reimplemented from Battleground.

501{
503 PlayerScores.emplace(player->GetGUID().GetCounter(), new BattlegroundSAScore(player->GetGUID()));
504
505 SendTransportInit(player);
507}
virtual void AddPlayer(Player *player)
Definition: Battleground.cpp:1077
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:611
Definition: BattlegroundSA.h:423
void SendTransportInit(Player *player)
Send packet to player for create boats (client part)
Definition: BattlegroundSA.cpp:1099
void TeleportToEntrancePosition(Player *player)
Definition: BattlegroundSA.cpp:554
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
LowType GetCounter() const
Definition: ObjectGuid.h:147

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

◆ AllowDefenseOfTheAncients()

bool BattlegroundSA::AllowDefenseOfTheAncients ( Player source)
1130{
1131 if (source->GetTeamId() == Attackers)
1132 return false;
1133
1134 for (uint8 i = 0; i <= 5; i++)
1135 {
1137 return false;
1138 }
1139
1140 return true;
1141}
@ BG_SA_GATE_DESTROYED
Definition: BattlegroundSA.h:42
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2058

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.

821{
822 switch (objectId)
823 {
826 {
827 return false;
828 }
829 [[fallthrough]];
832 {
833 return false;
834 }
835 [[fallthrough]];
836 case BG_SA_LEFT_FLAG:
837 case BG_SA_RIGHT_FLAG:
839 {
840 return false;
841 }
842 break;
843 default:
844 ABORT();
845 break;
846 }
847
848 return true;
849}
#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
894{
895 if (GraveyardStatus[i] == Attackers || Source->GetTeamId() != Attackers)
896 return;
897
898 GraveyardStatus[i] = Source->GetTeamId();
899 // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard
900 GuidVector& ghost_list = m_ReviveQueue[BgCreatures[static_cast<uint16>(BG_SA_MAXNPC) + i]];
901 if (!ghost_list.empty())
902 {
903 GraveyardStruct const* ClosestGrave = nullptr;
904 for (ObjectGuid const& guid : ghost_list)
905 {
906 Player* player = ObjectAccessor::FindPlayer(guid);
907 if (!player)
908 continue;
909
910 if (!ClosestGrave) // cache
911 ClosestGrave = GetClosestGraveyard(player);
912
913 if (ClosestGrave)
914 player->TeleportTo(GetMapId(), ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, player->GetOrientation());
915 }
916
917 // xinef: clear resurrect queue for this creature
918 ghost_list.clear();
919 }
920
921 DelCreature(static_cast<uint16>(BG_SA_MAXNPC) + i);
922
923 GraveyardStruct const* sg = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
924 if (!sg)
925 {
926 LOG_ERROR("bg.battleground", "BattlegroundSA::CaptureGraveyard: non-existant GY entry: {}", BG_SA_GYEntries[i]);
927 return;
928 }
929
930 AddSpiritGuide(i + static_cast<uint16>(BG_SA_MAXNPC), sg->x, sg->y, sg->z, BG_SA_GYOrientation[i], GraveyardStatus[i]);
931 uint32 npc = 0;
932 uint32 flag = 0;
933
934 switch(i)
935 {
937 flag = BG_SA_LEFT_FLAG;
938 DelObject(flag);
939 AddObject(flag, (BG_SA_ObjEntries[flag] - (Source->GetTeamId() == TEAM_ALLIANCE ? 0 : 1)),
940 BG_SA_ObjSpawnlocs[flag][0], BG_SA_ObjSpawnlocs[flag][1],
941 BG_SA_ObjSpawnlocs[flag][2], BG_SA_ObjSpawnlocs[flag][3], 0, 0, 0, 0, RESPAWN_ONE_DAY);
942
947
948 for (uint8 j = BG_SA_DEMOLISHER_7; j <= BG_SA_DEMOLISHER_8; j++)
949 {
952 BG_SA_NpcSpawnlocs[j][2], BG_SA_NpcSpawnlocs[j][3], 600);
953
954 if (Creature* dem = GetBGCreature(j))
955 dem->SetFaction(BG_SA_Factions[Attackers]);
956 }
957
960 if (Source->GetTeamId() == TEAM_ALLIANCE)
962 else
964 break;
966 flag = BG_SA_RIGHT_FLAG;
967 DelObject(flag);
968 AddObject(flag, (BG_SA_ObjEntries[flag] - (Source->GetTeamId() == TEAM_ALLIANCE ? 0 : 1)),
969 BG_SA_ObjSpawnlocs[flag][0], BG_SA_ObjSpawnlocs[flag][1],
970 BG_SA_ObjSpawnlocs[flag][2], BG_SA_ObjSpawnlocs[flag][3], 0, 0, 0, 0, RESPAWN_ONE_DAY);
971
976
977 for (uint8 j = BG_SA_DEMOLISHER_5; j <= BG_SA_DEMOLISHER_6; j++)
978 {
980 BG_SA_NpcSpawnlocs[j][2], BG_SA_NpcSpawnlocs[j][3], 600);
981
982 if (Creature* dem = GetBGCreature(j))
983 dem->SetFaction(BG_SA_Factions[Attackers]);
984 }
985
988 if (Source->GetTeamId() == TEAM_ALLIANCE)
990 else
992 break;
994 flag = BG_SA_CENTRAL_FLAG;
995 DelObject(flag);
996 AddObject(flag, (BG_SA_ObjEntries[flag] - (Source->GetTeamId() == TEAM_ALLIANCE ? 0 : 1)),
997 BG_SA_ObjSpawnlocs[flag][0], BG_SA_ObjSpawnlocs[flag][1],
998 BG_SA_ObjSpawnlocs[flag][2], BG_SA_ObjSpawnlocs[flag][3], 0, 0, 0, 0, RESPAWN_ONE_DAY);
999
1002 if (Source->GetTeamId() == TEAM_ALLIANCE)
1004 else
1006 break;
1007 default:
1008 ABORT();
1009 break;
1010 }
1011}
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
@ RESPAWN_ONE_DAY
Definition: Battleground.h:163
@ 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
std::vector< ObjectGuid > GuidVector
Definition: ObjectGuid.h:258
#define sGraveyard
Definition: GameGraveyard.h:75
@ LANG_BG_SA_A_GY_SOUTH
Definition: Language.h:1275
@ LANG_BG_SA_H_GY_EAST
Definition: Language.h:1280
@ LANG_BG_SA_H_GY_SOUTH
Definition: Language.h:1278
@ LANG_BG_SA_A_GY_WEST
Definition: Language.h:1276
@ LANG_BG_SA_A_GY_EAST
Definition: Language.h:1277
@ LANG_BG_SA_H_GY_WEST
Definition: Language.h:1279
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:250
uint32 GetMapId() const
Definition: Battleground.h:420
bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, TeamId teamId)
Definition: Battleground.cpp:1593
void SendWarningToAll(uint32 entry,...)
Definition: Battleground.cpp:1642
bool DelCreature(uint32 type)
Definition: Battleground.cpp:1554
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:1369
std::map< ObjectGuid, GuidVector > m_ReviveQueue
Definition: Battleground.h:618
bool DelObject(uint32 type)
Definition: Battleground.cpp:1573
void UpdateWorldState(uint32 variable, uint32 value)
Definition: Battleground.cpp:770
Creature * AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime=0, MotionTransport *transport=nullptr)
Definition: Battleground.cpp:1491
Creature * GetBGCreature(uint32 type)
Definition: Battleground.cpp:1462
GraveyardStruct const * GetClosestGraveyard(Player *player) override
Return the nearest graveyard where player can respawn.
Definition: BattlegroundSA.cpp:776
Definition: Creature.h:46
Definition: ObjectGuid.h:120
float GetOrientation() const
Definition: Position.h:120
Definition: Player.h:1046
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1313
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(), ObjectAccessor::FindPlayer(), Battleground::GetBGCreature(), GetClosestGraveyard(), Battleground::GetMapId(), Position::GetOrientation(), 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_SOUTH, LANG_BG_SA_H_GY_WEST, LOG_ERROR, Battleground::m_ReviveQueue, RESPAWN_ONE_DAY, Battleground::SendWarningToAll(), 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 
)
576{
577 if (plr->GetTeamId() == Attackers)
578 return;
579
580 uint32 portal_num = 0;
581 //get it via X
582 switch( (uint32)portal->GetPositionX() )
583 {
584 case 1394:
585 portal_num = 0;
586 break;
587 case 1065:
588 portal_num = 1;
589 break;
590 case 1468:
591 portal_num = 2;
592 break;
593 case 1255:
594 portal_num = 3;
595 break;
596 case 1216:
597 portal_num = 4;
598 break;
599 }
600
601 plr->TeleportTo( plr->GetMapId(), SOTADefPortalDest[portal_num][0], SOTADefPortalDest[portal_num][1], SOTADefPortalDest[portal_num][2], SOTADefPortalDest[portal_num][3], TELE_TO_SPELL );
602}
const float SOTADefPortalDest[5][4]
Definition: BattlegroundSA.h:413
@ TELE_TO_SPELL
Definition: Player.h:818
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.

694{
695 if (!BgCreatures[0])
696 return;
697
698 for (uint8 i = BG_SA_DEMOLISHER_1; i <= BG_SA_DEMOLISHER_4; i++)
699 if (Creature* dem = GetBGCreature(i))
700 {
701 if (start)
703 else
705 }
706
707 for (uint8 i = BG_SA_GUN_1; i <= BG_SA_GUN_10; i++)
708 if (Creature* gun = GetBGCreature(i))
709 {
710 if (start)
712 else
714 }
715
716 // xinef: enable first gates damaging at start
717 if (!start)
718 {
720 go->SetDestructibleBuildingModifyState(true);
722 go->SetDestructibleBuildingModifyState(true);
723 }
724}
@ 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: Unit.h:449
@ UNIT_FLAG_NOT_SELECTABLE
Definition: Unit.h:473
GameObject * GetBGObject(uint32 type)
Definition: Battleground.cpp:1453
Definition: GameObject.h:813

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.

727{
729 if (!GateStatus[i])
730 return;
731
732 if (GameObject* g = GetBGObject(i))
733 {
734 if (g->GetGOValue()->Building.Health == 0)
735 {
737 if (uint32 uws = GetWorldStateFromGateID(i))
739
740 bool rewardHonor = true;
741 switch (i)
742 {
743 case BG_SA_GREEN_GATE:
745 rewardHonor = false;
746 break;
747 case BG_SA_BLUE_GATE:
749 rewardHonor = false;
750 break;
751 case BG_SA_RED_GATE:
753 rewardHonor = false;
754 break;
757 rewardHonor = false;
758 break;
759 }
760
762
763 if (i < 5)
764 DelObject(i + 9);
765
766 if (player)
767 {
769 if (rewardHonor)
771 }
772 }
773 }
774}
@ 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:1308
uint32 GetBonusHonorFromKill(uint32 kills) const
Definition: Battleground.cpp:922
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:862
uint32 GetEntry() const
Definition: Object.h:109

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.

1055{
1056 //honor reward for winning
1057 RewardHonorToTeam(GetBonusHonorFromKill(1), winnerTeamId);
1058
1059 //complete map_end rewards (even if no team wins)
1062
1063 Battleground::EndBattleground(winnerTeamId);
1064}
@ TEAM_HORDE
Definition: SharedDefines.h:733
void EndBattleground(PvPTeamId winnerTeamId)
Definition: Battleground.cpp:778
void RewardHonorToTeam(uint32 honor, TeamId teamId)
Definition: Battleground.cpp:720

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.

870{
871 switch (gameObject->GetEntry())
872 {
873 case 191307:
874 case 191308:
877 break;
878 case 191305:
879 case 191306:
882 break;
883 case 191310:
884 case 191309:
887 break;
888 default:
889 return;
890 }
891}
void CaptureGraveyard(BG_SA_Graveyards i, Player *Source)
Called when a graveyard is capture -Update spiritguide -Update gameobject (flag) -Update Worldstate -...
Definition: BattlegroundSA.cpp:893
bool CanInteractWithObject(uint32 objectId)
Checks if a player can interact with the given object.
Definition: BattlegroundSA.cpp:820

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.

605{
606 if (!go || !go->GetGOInfo())
607 return;
608
609 if (eventType == go->GetGOInfo()->building.damagedEvent)
610 {
614 if (uws)
616 }
617
618 if (eventType == go->GetGOInfo()->building.destroyedEvent)
619 {
620 if (go->GetGOInfo()->building.destroyedEvent == 19837)
622 else
624
626 switch (i)
627 {
628 case BG_SA_BLUE_GATE:
629 case BG_SA_GREEN_GATE:
630 {
631 if (auto redGate = GetBGObject(BG_SA_RED_GATE))
632 {
633 redGate->SetDestructibleBuildingModifyState(true);
634 }
635 if (auto purpleGate = GetBGObject(BG_SA_PURPLE_GATE))
636 {
637 purpleGate->SetDestructibleBuildingModifyState(true);
638 }
639 break;
640 }
641 case BG_SA_RED_GATE:
643 if (auto yellowGate = GetBGObject(BG_SA_YELLOW_GATE))
644 {
645 yellowGate->SetDestructibleBuildingModifyState(true);
646 }
647 break;
649 if (auto ancientGate = GetBGObject(BG_SA_ANCIENT_GATE))
650 {
651 ancientGate->SetDestructibleBuildingModifyState(true);
652 }
653 break;
654 }
655 }
656
657 if (eventType == go->GetGOInfo()->building.damageEvent)
659}
@ BG_SA_GATE_DAMAGED
Definition: BattlegroundSA.h:41
@ LANG_BG_SA_WAS_DESTROYED
Definition: Language.h:1268
@ LANG_BG_SA_CHAMBER_BREACHED
Definition: Language.h:1274
@ LANG_BG_SA_IS_UNDER_ATTACK
Definition: Language.h:1267
uint32 damageEvent
Definition: GameObject.h:383
struct GameObjectTemplate::@209::@237 building
std::string name
Definition: GameObject.h:45
uint32 destroyedEvent
Definition: GameObject.h:375
uint32 damagedEvent
Definition: GameObject.h:370
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:829

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, GateStatus, Battleground::GetBGObject(), Object::GetEntry(), GetGateIDFromEntry(), GameObject::GetGOInfo(), GetWorldStateFromGateID(), LANG_BG_SA_CHAMBER_BREACHED, LANG_BG_SA_IS_UNDER_ATTACK, LANG_BG_SA_WAS_DESTROYED, GameObjectTemplate::name, Battleground::SendWarningToAll(), and Battleground::UpdateWorldState().

◆ EventPlayerUsedGO()

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

Called when a player use a gamobject (relic)

Reimplemented from Battleground.

1014{
1016 {
1017 if (Source->GetTeamId() == Attackers)
1018 {
1019 if (Source->GetTeamId() == TEAM_ALLIANCE)
1022
1023 if (Status == BG_SA_ROUND_ONE)
1024 {
1025 _relicClicked = true;
1026 }
1027 else if (Status == BG_SA_ROUND_TWO)
1028 {
1031 ToggleTimer();
1032 //Achievement Storm the Beach (1310)
1033 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
1034 if (itr->second->GetTeamId() == Attackers && RoundScores[1].winner == Attackers)
1035 itr->second->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246);
1036
1037 if (RoundScores[0].time == RoundScores[1].time)
1039 else if (RoundScores[0].time < RoundScores[1].time)
1040 EndBattleground(RoundScores[0].winner);
1041 else
1042 EndBattleground(RoundScores[1].winner);
1043 }
1044 }
1045 }
1046}
@ BG_SA_ROUND_ONE
Definition: BattlegroundSA.h:32
@ BG_SA_ROUND_TWO
Definition: BattlegroundSA.h:34
@ LANG_BG_SA_HORDE_CAPTURED_RELIC
Definition: Language.h:1271
@ LANG_BG_SA_ALLIANCE_CAPTURED_RELIC
Definition: Language.h:1270
@ ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET
Definition: DBCEnums.h:148
@ CHAT_MSG_BG_SYSTEM_NEUTRAL
Definition: SharedDefines.h:3160
@ TEAM_NEUTRAL
Definition: SharedDefines.h:734
void SendMessageToAll(uint32 entry, ChatMsg type, Player const *source=nullptr)
Definition: Battleground.cpp:1617
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:393
bool _relicClicked
Definition: BattlegroundSA.h:647
void ToggleTimer()
Switch on/off timer worldstate.
Definition: BattlegroundSA.cpp:1048
void EndBattleground(TeamId winnerTeamId) override
Called on battleground ending.
Definition: BattlegroundSA.cpp:1054

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(), CHAT_MSG_BG_SYSTEM_NEUTRAL, EndBattleground(), Object::GetEntry(), Battleground::GetPlayers(), Player::GetTeamId(), LANG_BG_SA_ALLIANCE_CAPTURED_RELIC, LANG_BG_SA_HORDE_CAPTURED_RELIC, RoundScores, Battleground::SendMessageToAll(), Status, TEAM_ALLIANCE, 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.

461{
462 uint32 ally_attacks = uint32(Attackers == TEAM_ALLIANCE ? 1 : 0);
463 uint32 horde_attacks = uint32(Attackers == TEAM_HORDE ? 1 : 0);
464
471
472 data << uint32(BG_SA_BONUS_TIMER) << uint32(0);
473
474 data << uint32(BG_SA_HORDE_ATTACKS) << horde_attacks;
475 data << uint32(BG_SA_ALLY_ATTACKS) << ally_attacks;
476
477 //Time will be sent on first update...
478 data << uint32(BG_SA_ENABLE_TIMER) << ((TimerEnabled) ? uint32(1) : uint32(0));
479 data << uint32(BG_SA_TIMER_MINS) << uint32(0);
480 data << uint32(BG_SA_TIMER_SEC_TENS) << uint32(0);
481 data << uint32(BG_SA_TIMER_SEC_DECS) << uint32(0);
482
486
490
491 data << uint32(BG_SA_HORDE_DEFENCE_TOKEN) << ally_attacks;
492 data << uint32(BG_SA_ALLIANCE_DEFENCE_TOKEN) << horde_attacks;
493
494 data << uint32(BG_SA_LEFT_ATT_TOKEN_HRD) << horde_attacks;
495 data << uint32(BG_SA_RIGHT_ATT_TOKEN_HRD) << horde_attacks;
496 data << uint32(BG_SA_RIGHT_ATT_TOKEN_ALL) << ally_attacks;
497 data << uint32(BG_SA_LEFT_ATT_TOKEN_ALL) << ally_attacks;
498}
@ 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.

777{
778 GraveyardStruct const* closest = nullptr;
779 float mindist = 999999.0f;
780 float x, y;
781
782 player->GetPosition(x, y);
783
784 for (uint8 i = BG_SA_BEACH_GY; i < BG_SA_MAX_GY; i++)
785 {
786 if (GraveyardStatus[i] != player->GetTeamId())
787 continue;
788
789 GraveyardStruct const* ret = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
790
791 // if on beach
792 if (i == BG_SA_BEACH_GY)
793 {
794 if (x > 1400)
795 return ret;
796 continue;
797 }
798
799 float dist = std::sqrt(pow(ret->x - x, 2) * pow(ret->y - y, 2));
800 if (dist < mindist)
801 {
802 mindist = dist;
803 closest = ret;
804 }
805 }
806 if (!closest && GraveyardStatus[BG_SA_BEACH_GY] == player->GetTeamId())
807 return sGraveyard->GetGraveyard(BG_SA_GYEntries[BG_SA_BEACH_GY]);
808
809 return closest;
810}
@ 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.

514{
515 // this is wrong way to implement these things. On official it done by gameobject spell cast.
517 return;
518}
@ STATUS_IN_PROGRESS
Definition: Battleground.h:197
BattlegroundStatus GetStatus() const
Definition: Battleground.h:322

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.

662{
663 if (creature->GetEntry() == NPC_DEMOLISHER_SA)
664 {
667 creature->SetVisible(false);
668 }
669}
@ SCORE_DESTROYED_DEMOLISHER
Definition: BattlegroundScore.h:54
@ NPC_DEMOLISHER_SA
Definition: BattlegroundSA.h:77
bool _notEvenAScratch[PVP_TEAMS_COUNT]
Definition: BattlegroundSA.h:650
void SetVisible(bool x)
Definition: Unit.cpp:14973

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

◆ Init()

void BattlegroundSA::Init ( )
overridevirtual

Reimplemented from Battleground.

75{
77
78 TotalTime = 0s;
80 for (uint8 i = 0; i <= 5; i++)
82 ShipsStarted = false;
86 _relicClicked = false;
87}
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ BG_SA_WARMUP
Definition: BattlegroundSA.h:31
virtual void Init()
Definition: Battleground.cpp:1028

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.

676{
677 if (!BgCreatures[0])
678 return;
679
680 for (uint8 i = BG_SA_GUN_1; i <= BG_SA_GUN_10; i++)
681 {
682 if (Creature* gun = GetBGCreature(i))
683 gun->SetFaction(BG_SA_Factions[Attackers ? TEAM_ALLIANCE : TEAM_HORDE]);
684 }
685
686 for (uint8 i = BG_SA_DEMOLISHER_1; i <= BG_SA_DEMOLISHER_4; i++)
687 {
688 if (Creature* dem = GetBGCreature(i))
689 dem->SetFaction(BG_SA_Factions[Attackers]);
690 }
691}

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.

316{
317 if (InitSecondRound)
318 {
319 if (UpdateWaitTimer < diff)
320 {
321 if (!SignaledRoundTwo)
322 {
323 SignaledRoundTwo = true;
324 InitSecondRound = false;
326 }
327 }
328 else
329 {
330 UpdateWaitTimer -= diff;
331 return;
332 }
333 }
334 TotalTime += Milliseconds(diff);
335
336 if (Status == BG_SA_WARMUP)
337 {
340 {
341 TotalTime = 0s;
342 ToggleTimer();
346 }
348 StartShips();
349 return;
350 }
351 else if (Status == BG_SA_SECOND_WARMUP)
352 {
353 if (RoundScores[0].time < BG_SA_ROUNDLENGTH)
355 else
357
358 if (TotalTime >= 1min)
359 {
361 TotalTime = 0s;
362 ToggleTimer();
366
367 // status was set to STATUS_WAIT_JOIN manually for Preparation, set it back now
369 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
370 itr->second->RemoveAurasDueToSpell(SPELL_PREPARATION);
371 }
372 if (TotalTime >= 30s)
373 {
375 {
378 }
379 }
380 StartShips();
381 return;
382 }
383 else if (GetStatus() == STATUS_IN_PROGRESS)
384 {
385 if (Status == BG_SA_ROUND_ONE)
386 {
388 {
389 if (_relicClicked)
390 {
393 //Achievement Storm the Beach (1310)
394 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
395 if (itr->second->GetTeamId() == Attackers)
396 itr->second->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, 65246);
397 }
398 else
399 {
400 // cast this before Attackers variable is switched
401 // cast this spell only upon timer end, no other ability for defenders to win :)
402 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
403 itr->second->CastSpell(itr->second, SPELL_SA_END_OF_ROUND, true);
404
407 }
408
409 _relicClicked = false;
412 TotalTime = 0s;
413 ToggleTimer();
415 UpdateWaitTimer = 5000;
416 SignaledRoundTwo = false;
418 InitSecondRound = true;
419 ResetObjs();
420
421 return;
422 }
423 }
424 else if (Status == BG_SA_ROUND_TWO)
425 {
427 {
428 // cast this spell only upon timer end, no other ability for defenders to win :)
429 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
430 itr->second->CastSpell(itr->second, SPELL_SA_END_OF_ROUND, true);
431
434
435 if (RoundScores[0].time == RoundScores[1].time)
437 else if (RoundScores[0].time < RoundScores[1].time)
438 EndBattleground(RoundScores[0].winner);
439 else
440 EndBattleground(RoundScores[1].winner);
441 return;
442 }
443 }
445 {
446 SendTime();
448 }
449 }
450}
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:27
@ SPELL_PREPARATION
Definition: Battleground.h:137
constexpr Milliseconds BG_SA_ROUNDLENGTH
Definition: BattlegroundSA.cpp:30
constexpr Milliseconds BG_SA_BOAT_START
Definition: BattlegroundSA.cpp:28
constexpr Milliseconds BG_SA_WARMUPLENGTH
Definition: BattlegroundSA.cpp:29
#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
@ LANG_BG_SA_HAS_BEGUN
Definition: Language.h:1266
@ LANG_BG_SA_ROUND_ONE_END
Definition: Language.h:1269
@ ACHIEVEMENT_TIMED_TYPE_EVENT
Definition: DBCEnums.h:116
static TeamId GetOtherTeamId(TeamId teamId)
Definition: Battleground.cpp:1773
void SetStatus(BattlegroundStatus Status)
Definition: Battleground.h:348
void SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject const *target=nullptr)
Definition: Battleground.cpp:678
void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
Definition: Battleground.cpp:1849
void DemolisherStartState(bool start)
Set selectable or not demolisher, called on battle start, when boats arrive to dock.
Definition: BattlegroundSA.cpp:693
void SendTime()
Update timer worldstate.
Definition: BattlegroundSA.cpp:812
void UpdateDemolisherSpawns()
Respawn dead demolisher.
Definition: BattlegroundSA.cpp:1066
bool ResetObjs()
Called on setup and between the two round -Delete all gameobject / creature -Respawn all gameobject /...
Definition: BattlegroundSA.cpp:94
void StartShips()
Called for start ship movement.
Definition: BattlegroundSA.cpp:293

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(), EndBattleground(), EndRoundTimer, Battleground::GetOtherTeamId(), Battleground::GetPlayers(), Battleground::GetStatus(), InitSecondRound, LANG_BG_SA_HAS_BEGUN, LANG_BG_SA_ROUND_ONE_END, ResetObjs(), RoundScores, Battleground::SendBroadcastText(), SendTime(), Battleground::SendWarningToAll(), 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.

510{
511}

◆ 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.

95{
96 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
97 SendTransportsRemove(itr->second);
98
101
102 for (uint8 i = 0; i < BG_SA_MAXOBJ; i++)
103 DelObject(i);
104
105 for (uint8 i = 0; i < BG_SA_MAXNPC; i++)
106 DelCreature(i);
107
108 for (uint8 i = BG_SA_MAXNPC; i < static_cast<uint16>(BG_SA_MAXNPC) + BG_SA_MAX_GY; i++)
109 DelCreature(i);
110
111 for (uint8 i = 0; i < 6; ++i)
113
114 for (uint8 i = 0; i < BG_SA_BOAT_ONE; i++)
115 {
117 return false;
118 }
119
120 for (uint8 i = BG_SA_BOAT_ONE; i < BG_SA_SIGIL_1; i++)
121 {
122 uint32 boatid = 0;
123 switch (i)
124 {
125 case BG_SA_BOAT_ONE:
127 break;
128 case BG_SA_BOAT_TWO:
130 break;
131 }
132 if (!AddObject(i, boatid, BG_SA_ObjSpawnlocs[i][0],
133 BG_SA_ObjSpawnlocs[i][1],
134 BG_SA_ObjSpawnlocs[i][2] + (Attackers ? -3.750f : 0),
135 BG_SA_ObjSpawnlocs[i][3], 0, 0, 0, 0, RESPAWN_ONE_DAY))
136 return false;
137 }
138
139 for (uint8 i = BG_SA_SIGIL_1; i < BG_SA_CENTRAL_FLAG; i++)
140 {
141 if (!AddObject(i, BG_SA_ObjEntries[i],
144 0, 0, 0, 0, RESPAWN_ONE_DAY))
145 return false;
146 }
147
148 // MAD props for Kiper for discovering those values - 4 hours of his work.
149 GetBGObject(BG_SA_BOAT_ONE)->SetTransportPathRotation(0.0f, 0.0f, 1.0f, 0.0002f);
150 GetBGObject(BG_SA_BOAT_TWO)->SetTransportPathRotation(0.0f, 0.0f, 1.0f, 0.00001f);
153
154 //Cannons and demolishers - NPCs are spawned
155 //By capturing GYs.
156 for (uint8 i = 0; i < BG_SA_DEMOLISHER_5; i++)
157 {
158 if (!AddCreature(BG_SA_NpcEntries[i], i,
160 BG_SA_NpcSpawnlocs[i][2], BG_SA_NpcSpawnlocs[i][3], 600))
161 return false;
162 }
163
166
167 for (uint8 i = BG_SA_GREEN_GATE; i <= BG_SA_TITAN_RELIC; i++)
168 {
170 if (GameObject* go = GetBGObject(i))
171 {
172 go->setActive(true);
173 go->SetUInt32Value(GAMEOBJECT_FACTION, defF);
174 go->SetDestructibleBuildingModifyState(false);
175 }
176 }
177
180
181 TotalTime = 0s;
182 ShipsStarted = false;
183
184 //Graveyards!
185 for (uint8 i = 0; i < BG_SA_MAX_GY; i++)
186 {
187 GraveyardStruct const* sg = nullptr;
188 sg = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
189
190 if (!sg)
191 {
192 LOG_ERROR("bg.battleground", "SOTA: Can't find GY entry {}", BG_SA_GYEntries[i]);
193 return false;
194 }
195
196 if (i == BG_SA_BEACH_GY)
197 {
200 }
201 else
202 {
205 LOG_ERROR("bg.battleground", "SOTA: couldn't spawn GY: {}", i);
206 }
207 }
208
209 //GY capture points
211 {
212 AddObject(i, (BG_SA_ObjEntries[i] - (Attackers == TEAM_ALLIANCE ? 1 : 0)),
215 0, 0, 0, 0, RESPAWN_ONE_DAY);
217 }
218
220 {
224 0, 0, 0, 0, RESPAWN_ONE_DAY);
226 }
227
229
230 for (uint8 i = BG_SA_BOMB; i < BG_SA_MAXOBJ; i++)
231 {
235 0, 0, 0, 0, RESPAWN_ONE_DAY);
237 }
238
239 //Player may enter BEFORE we set up bG - lets update his worldstates anyway...
243
247
249 {
252
257
260 }
261 else
262 {
265
270
273 }
274
281
282 for (int i = BG_SA_BOAT_ONE; i <= BG_SA_BOAT_TWO; i++)
283 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
284 SendTransportInit(itr->second);
285
286 // set status manually so preparation is cast correctly in 2nd round too
288
290 return true;
291}
@ RESPAWN_IMMEDIATELY
Definition: Battleground.h:164
@ STATUS_WAIT_JOIN
Definition: Battleground.h:196
@ 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
@ GAMEOBJECT_FACTION
Definition: UpdateFields.h:402
void SpawnBGObject(uint32 type, uint32 respawntime, uint32 forceRespawnDelay=0)
Definition: Battleground.cpp:1471
void OverrideGunFaction()
Called on start and between the two round -Update faction of all vehicle.
Definition: BattlegroundSA.cpp:675
void TeleportPlayers()
Called between the two round -Teleport all players to good location.
Definition: BattlegroundSA.cpp:520
void SendTransportsRemove(Player *player)
Send packet to player for destroy boats (client part)
Definition: BattlegroundSA.cpp:1114
void SetTransportPathRotation(float qx, float qy, float qz, float qw)
Definition: GameObject.cpp:2225
void Refresh()
Definition: GameObject.cpp:887
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:652

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.

813{
814 Milliseconds end_of_round = (EndRoundTimer - TotalTime);
815 UpdateWorldState(BG_SA_TIMER_MINS, end_of_round / 1min);
816 UpdateWorldState(BG_SA_TIMER_SEC_TENS, (end_of_round % 1min) / 10s);
817 UpdateWorldState(BG_SA_TIMER_SEC_DECS, ((end_of_round % 1min) % 10s) / 1s);
818}

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)

1100{
1102 {
1103 UpdateData transData;
1108 WorldPacket packet;
1109 transData.BuildPacket(&packet);
1110 player->GetSession()->SendPacket(&packet);
1111 }
1112}
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const
Definition: Object.cpp:191
Definition: UpdateData.h:52
bool BuildPacket(WorldPacket *packet)
Definition: UpdateData.cpp:105
WorldSession * GetSession() const
Definition: Player.h:1947
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:208

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)

1115{
1117 {
1118 UpdateData transData;
1123 WorldPacket packet;
1124 transData.BuildPacket(&packet);
1125 player->GetSession()->SendPacket(&packet);
1126 }
1127}
void BuildOutOfRangeUpdateBlock(UpdateData *data) const
Definition: Object.cpp:271

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.

90{
91 return ResetObjs();
92}

References ResetObjs().

◆ StartingEventCloseDoors()

void BattlegroundSA::StartingEventCloseDoors ( )
overridevirtual

Called when battle start.

Reimplemented from Battleground.

453{
454}

◆ StartingEventOpenDoors()

void BattlegroundSA::StartingEventOpenDoors ( )
overridevirtual

Reimplemented from Battleground.

457{
458}

◆ StartShips()

void BattlegroundSA::StartShips ( )
private

Called for start ship movement.

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

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.

521{
522 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
523 {
524 if (Player* player = itr->second)
525 {
526 // should remove spirit of redemption
527 if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
528 player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
529
530 if (!player->IsAlive())
531 {
532 player->ResurrectPlayer(1.0f);
533 player->SpawnCorpseBones();
534 }
535
537 {
538 player->CastSpell(player, SPELL_PREPARATION, true);
539 player->GetMotionMaster()->MovementExpired();
540 }
541
542 player->ResetAllPowers();
543 player->CombatStopWithPets(true);
544
546
547 // xinef: one more time, just to be sure
549 player->GetMotionMaster()->Clear(false);
550 }
551 }
552}
@ 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
555{
556 if (player->GetTeamId() != Attackers)
557 {
558 player->TeleportTo(607, 1209.7f, -65.16f, 70.1f, 0.0f, 0);
559 }
560 else
561 {
562 if (!ShipsStarted)
563 {
564 player->CastSpell(player, 12438, true);//Without this player falls before boat loads...
565 if (urand(0, 1))
566 player->TeleportTo(607, 2682.936f, -830.368f, 15.0f, 2.895f, 0);
567 else
568 player->TeleportTo(607, 2577.003f, 980.261f, 15.0f, 0.807f, 0);
569 }
570 else
571 player->TeleportTo(607, 1600.381f, -106.263f, 8.8745f, 3.78f, 0);
572 }
573}
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:1428

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.

1067{
1068 for (uint8 i = BG_SA_DEMOLISHER_1; i <= BG_SA_DEMOLISHER_8; i++)
1069 {
1070 if (BgCreatures[i])
1071 {
1072 if (Creature* Demolisher = GetBGCreature(i))
1073 {
1074 if (Demolisher->isDead())
1075 {
1076 // Demolisher is not in list
1077 if (DemoliserRespawnList.find(i) == DemoliserRespawnList.end())
1078 {
1079 DemoliserRespawnList[i] = GameTime::GetGameTimeMS().count() + 30000;
1080 }
1081 else
1082 {
1084 {
1085 Demolisher->Relocate(BG_SA_NpcSpawnlocs[i][0], BG_SA_NpcSpawnlocs[i][1],
1087
1088 Demolisher->SetVisible(true);
1089 Demolisher->Respawn();
1090 DemoliserRespawnList.erase(i);
1091 }
1092 }
1093 }
1094 }
1095 }
1096 }
1097}
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.

852{
853 if (GameObject* go = GetBGObject(objectId))
854 {
855 if (CanInteractWithObject(objectId))
856 go->RemoveGameObjectFlag(GO_FLAG_NOT_SELECTABLE | GO_FLAG_INTERACT_COND | GO_FLAG_IN_USE);
857 else
858 go->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
859 }
860}
@ GO_FLAG_INTERACT_COND
Definition: SharedDefines.h:1577
@ GO_FLAG_NOT_SELECTABLE
Definition: SharedDefines.h:1579
@ GO_FLAG_IN_USE
Definition: SharedDefines.h:1575

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().