Permalink
Browse files

Add WG script definitions and enable initial battlefield setup

Also fix some code alignment issues from previous commits

Signed-off-by: Xfurry <xfurry.cmangos@outlook.com>
  • Loading branch information...
Zakamurite authored and xfurry committed Jan 13, 2018
1 parent 60828af commit 18bde5ac4ee72b21319042e565bea443c3d74147
Showing with 917 additions and 116 deletions.
  1. +107 −107 src/game/Battlefield/Battlefield.h
  2. +142 −7 src/game/Battlefield/BattlefieldWG.cpp
  3. +668 −2 src/game/Battlefield/BattlefieldWG.h
@@ -56,165 +56,165 @@ enum BattlefieldGoState
class BattlefieldBuilding
{
public:
BattlefieldBuilding(uint32 goEntry) : entry(goEntry) {};
public:
BattlefieldBuilding(uint32 goEntry) : entry(goEntry) {};
virtual void SetupBuilding(Team owner, bool reset) {};
virtual void SetupBuilding(Team owner, bool reset) {};
bool IsIntact() { return state == BF_GO_STATE_NEUTRAL_INTACT || state == BF_GO_STATE_HORDE_INTACT || state == BF_GO_STATE_ALLIANCE_INTACT;; };
bool IsDamaged() { return state == BF_GO_STATE_NEUTRAL_DAMAGED || state == BF_GO_STATE_HORDE_DAMAGED || state == BF_GO_STATE_ALLIANCE_DAMAGED; };
bool IsDestroyed() { return state == BF_GO_STATE_NEUTRAL_DESTROYED || state == BF_GO_STATE_HORDE_DESTROYED || state == BF_GO_STATE_ALLIANCE_DESTROYED; };
bool IsIntact() { return state == BF_GO_STATE_NEUTRAL_INTACT || state == BF_GO_STATE_HORDE_INTACT || state == BF_GO_STATE_ALLIANCE_INTACT;; };

This comment has been minimized.

Show comment
Hide comment
@RazzorX

RazzorX Jan 13, 2018

Typo: double semicolon after BF_GO_STATE_ALLIANCE_INTACT

@RazzorX

RazzorX Jan 13, 2018

Typo: double semicolon after BF_GO_STATE_ALLIANCE_INTACT

bool IsDamaged() { return state == BF_GO_STATE_NEUTRAL_DAMAGED || state == BF_GO_STATE_HORDE_DAMAGED || state == BF_GO_STATE_ALLIANCE_DAMAGED; };
bool IsDestroyed() { return state == BF_GO_STATE_NEUTRAL_DESTROYED || state == BF_GO_STATE_HORDE_DESTROYED || state == BF_GO_STATE_ALLIANCE_DESTROYED; };
Team GetOwner() { return owner; }
void SetOwner(Team newOwner) { owner = newOwner; }
Team GetOwner() { return owner; }
void SetOwner(Team newOwner) { owner = newOwner; }
uint32 GetWorldState() { return worldState; }
void SetWorldState(uint32 newWorldState) { worldState = newWorldState; }
uint32 GetWorldState() { return worldState; }
void SetWorldState(uint32 newWorldState) { worldState = newWorldState; }
uint32 GetGoState() { return (uint32)state; }
void SetGoState(BattlefieldGoState newState) { state = newState; };
uint32 GetGoState() { return (uint32)state; }
void SetGoState(BattlefieldGoState newState) { state = newState; };
private:
Team owner;
private:
Team owner;
uint32 entry;
uint32 worldState;
uint32 entry;
uint32 worldState;
BattlefieldGoState state;
ObjectGuid guid;
BattlefieldGoState state;
ObjectGuid guid;
};
class BattlefieldPlayer
{
public:
BattlefieldPlayer() : removeTime(0), removeDelay(0) {}
public:
BattlefieldPlayer() : removeTime(0), removeDelay(0) {}
time_t removeTime;
uint32 removeDelay;
time_t removeTime;
uint32 removeDelay;
};
typedef std::map<ObjectGuid /*playerGuid*/, BattlefieldPlayer* /*playerData*/> BattlefieldPlayerMap;
class Battlefield : public OutdoorPvP
{
public:
Battlefield();
public:
Battlefield();
// Player related stuff
virtual void HandlePlayerEnterZone(Player* /*player*/, bool /*isMainZone*/) override;
virtual void HandlePlayerLeaveZone(Player* /*player*/, bool /*isMainZone*/) override;
// Player related stuff
virtual void HandlePlayerEnterZone(Player* /*player*/, bool /*isMainZone*/) override;
virtual void HandlePlayerLeaveZone(Player* /*player*/, bool /*isMainZone*/) override;
// session response / requests
void HandleQueueInviteResponse(Player* /*player*/, bool /*accepted*/);
void HandleWarInviteResponse(Player* /*player*/, bool /*accepted*/);
void HandleExitRequest(Player* /*player*/);
// session response / requests
void HandleQueueInviteResponse(Player* /*player*/, bool /*accepted*/);
void HandleWarInviteResponse(Player* /*player*/, bool /*accepted*/);
void HandleExitRequest(Player* /*player*/);
// handle players which get AFK status
void HandlePlayerAFK(Player* /*player*/);
// handle players which get AFK status
void HandlePlayerAFK(Player* /*player*/);
// handle player login (if already active)
void HandlePlayerLoggedIn(Player* /*player*/);
// handle player login (if already active)
void HandlePlayerLoggedIn(Player* /*player*/);
// handle battle start and end
virtual void StartBattle(Team /*defender*/);
virtual void EndBattle(Team /*winner*/, bool /*byTimer*/);
// handle battle start and end
virtual void StartBattle(Team /*defender*/);
virtual void EndBattle(Team /*winner*/, bool /*byTimer*/);
virtual void Update(uint32 /*diff*/) override;
virtual void Update(uint32 /*diff*/) override;
// get defender or attacker team
Team GetDefender() const { return m_zoneOwner; }
Team GetAttacker() const { return m_zoneOwner == ALLIANCE ? HORDE : ALLIANCE; }
// get defender or attacker team
Team GetDefender() const { return m_zoneOwner; }
Team GetAttacker() const { return m_zoneOwner == TEAM_NONE ? TEAM_NONE : m_zoneOwner == ALLIANCE ? HORDE : ALLIANCE; }
// Group system related
void RemovePlayerFromRaid(ObjectGuid playerGuid);
void HandleBattlefieldGroupDisband(Player* player);
bool HasPlayer(ObjectGuid playerGuid);
bool CanDeleteBattlefieldGroup(Group* group);
// Group system related
void RemovePlayerFromRaid(ObjectGuid playerGuid);
void HandleBattlefieldGroupDisband(Player* player);
bool HasPlayer(ObjectGuid playerGuid);
bool CanDeleteBattlefieldGroup(Group* group);
// get battlefield status
BattlefieldStatus GetBattlefieldStatus() const { return m_status; }
// get battlefield status
BattlefieldStatus GetBattlefieldStatus() const { return m_status; }
// get or set the cooldown/battle timer
void SetTimer(uint32 value) { m_timer = value; }
// get or set the cooldown/battle timer
void SetTimer(uint32 value) { m_timer = value; }
// get battlefield id
uint32 GetBattlefieldId() const { return m_battleFieldId; }
// get battlefield id
uint32 GetBattlefieldId() const { return m_battleFieldId; }
protected:
// reset function for battlefields
virtual void Reset() {};
protected:
// reset function for battlefields
virtual void Reset() {};
// store the player data for the current battlefield
virtual void InitPlayerBattlefieldData(Player* /*player*/);
// store the player data for the current battlefield
virtual void InitPlayerBattlefieldData(Player* /*player*/);
// get the kick location for players depending on the current battlefield
virtual bool GetPlayerKickLocation(Player* player, float& x, float& y, float& z) { return false; }
// get the kick location for players depending on the current battlefield
virtual bool GetPlayerKickLocation(Player* player, float& x, float& y, float& z) { return false; }
// called when the battlefield player composition is updated
virtual void OnBattlefieldPlayersUpdate() {};
// called when the battlefield player composition is updated
virtual void OnBattlefieldPlayersUpdate() {};
// called when the player accepts the battlefield teleport
virtual void UpdatePlayerOnWarResponse(Player* /*player*/) {};
// called when the player accepts the battlefield teleport
virtual void UpdatePlayerOnWarResponse(Player* /*player*/) {};
// invite player to join battlefield queue
void InvitePlayerToQueue(Player* /*player*/);
// invite player to join battlefield queue
void InvitePlayerToQueue(Player* /*player*/);
// kick player from battlefield
void KickBattlefieldPlayer(Player* /*player*/);
// kick player from battlefield
void KickBattlefieldPlayer(Player* /*player*/);
// init all players on battle start
void InitPlayersBeforeBattle();
// init all players on battle start
void InitPlayersBeforeBattle();
// refresh battlefield players
void UpdateBattlefieldPlayers();
// refresh battlefield players
void UpdateBattlefieldPlayers();
// sends a raid warning to all players in the zone
void SendZoneWarning(int32 /*entry*/);
// sends a raid warning to all players in the zone
void SendZoneWarning(int32 /*entry*/);
// update the graveyard on capture event
virtual void UpdateGraveyardOwner(uint8 id, PvpTeamIndex newOwner) {};
// update the graveyard on capture event
virtual void UpdateGraveyardOwner(uint8 id, PvpTeamIndex newOwner) {};
// reward players
virtual void RewardPlayersOnBattleEnd(Team /*winner*/) {};
// reward players
virtual void RewardPlayersOnBattleEnd(Team /*winner*/) {};
// ToDo!!! for review!
void QuestCreditTeam(uint32 credit, Team team, WorldObject* source = NULL, float radius = -1.0f);
// ToDo!!! for review!
void QuestCreditTeam(uint32 credit, Team team, WorldObject* source = NULL, float radius = -1.0f);
// Group system
bool CanAddPlayerToRaid(Player* /*player*/);
bool IsTeamFull(PvpTeamIndex /*teamIdx*/);
Group* GetFreeRaid(PvpTeamIndex /*teamIdx*/);
Group* GetGroupFor(ObjectGuid /*playerGuid*/);
uint32 GetPlayerCountByTeam(PvpTeamIndex /*teamIdx*/);
// Group system
bool CanAddPlayerToRaid(Player* /*player*/);
bool IsTeamFull(PvpTeamIndex /*teamIdx*/);
Group* GetFreeRaid(PvpTeamIndex /*teamIdx*/);
Group* GetGroupFor(ObjectGuid /*playerGuid*/);
uint32 GetPlayerCountByTeam(PvpTeamIndex /*teamIdx*/);
// load player positions
void SetupPlayerPositions();
virtual void SetupPlayerPosition(Player* player) { };
// load player positions
void SetupPlayerPositions();
virtual void SetupPlayerPosition(Player* player) { };
// variables
BattlefieldPlayerMap m_activePlayers;
// variables
BattlefieldPlayerMap m_activePlayers;
std::set<Group*> m_battlefieldRaids[PVP_TEAM_COUNT];
std::set<ObjectGuid> m_queuedPlayers[PVP_TEAM_COUNT]; // players that are in queue
std::map<ObjectGuid, time_t> m_invitedPlayers[PVP_TEAM_COUNT]; // player to whom teleport invitation is send and who are expected to accept
std::set<Group*> m_battlefieldRaids[PVP_TEAM_COUNT];
std::set<ObjectGuid> m_queuedPlayers[PVP_TEAM_COUNT]; // players that are in queue
std::map<ObjectGuid, time_t> m_invitedPlayers[PVP_TEAM_COUNT]; // player to whom teleport invitation is send and who are expected to accept
uint32 m_battleFieldId;
uint32 m_zoneId;
uint32 m_queueUpdateTimer;
uint32 m_playersUpdateTimer;
uint32 m_battleFieldId;
uint32 m_zoneId;
uint32 m_queueUpdateTimer;
uint32 m_playersUpdateTimer;
BattlefieldStatus m_status;
Team m_zoneOwner;
uint32 m_timer;
BattlefieldStatus m_status;
Team m_zoneOwner;
uint32 m_timer;
uint32 m_battleDuration;
uint32 m_startInviteDelay;
uint32 m_cooldownDuration;
uint32 m_maxPlayersPerTeam;
uint32 m_battleDuration;
uint32 m_startInviteDelay;
uint32 m_cooldownDuration;
uint32 m_maxPlayersPerTeam;
time_t m_startTime;
time_t m_startTime;
bool m_playersInvited;
bool m_playersInvited;
};
#endif
Oops, something went wrong.

1 comment on commit 18bde5a

@Dramacydal

This comment has been minimized.

Show comment
Hide comment
@Dramacydal

Dramacydal Jan 18, 2018

Member

Oh my god

Member

Dramacydal commented on 18bde5a Jan 18, 2018

Oh my god

Please sign in to comment.