Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions conf/CFBG.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
# Default: 1 - (Enabled)
# 0 - (Disabled)
#
# CFBG.Battlefield.ReapplyOnResurrect.Enable
# Description: Re-apply a cross-faction player's assigned race/faction/morph
# when they resurrect inside Wintergrasp, so the ghost->alive
# transition does not revert them to their native faction.
# Requires CFBG.Battlefield.Enable = 1.
# Default: 1 - (Enabled)
# 0 - (Disabled)
#
# CFBG.Include.Avg.Ilvl.Enable
# Description: Enable check average item level for bg
# Default: 0
Expand Down Expand Up @@ -90,6 +98,7 @@
CFBG.Enable = 1
CFBG.Battlefield.Enable = 1
CFBG.Battlefield.TeamLock.Enable = 1
CFBG.Battlefield.ReapplyOnResurrect.Enable = 1
CFBG.BalancedTeams = 1
CFBG.BalancedTeams.Class.LowLevel = 0
CFBG.BalancedTeams.Class.MinLevel = 10
Expand Down
15 changes: 15 additions & 0 deletions src/CFBG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ void CFBG::LoadConfig()

_IsEnableWGSystem = sConfigMgr->GetOption<bool>("CFBG.Battlefield.Enable", true);
_IsEnableWGTeamLock = sConfigMgr->GetOption<bool>("CFBG.Battlefield.TeamLock.Enable", true);
_IsEnableWGReapplyOnResurrect = sConfigMgr->GetOption<bool>("CFBG.Battlefield.ReapplyOnResurrect.Enable", true);
_IsEnableAvgIlvl = sConfigMgr->GetOption<bool>("CFBG.Include.Avg.Ilvl.Enable", false);
_IsEnableBalancedTeams = sConfigMgr->GetOption<bool>("CFBG.BalancedTeams", false);
_IsEnableEvenTeams = sConfigMgr->GetOption<bool>("CFBG.EvenTeams.Enabled", false);
Expand Down Expand Up @@ -594,6 +595,20 @@ void CFBG::ClearFakePlayer(Player* player)
_fakePlayerStore.erase(player);
}

void CFBG::ReapplyFakePlayer(Player* player)
{
FakePlayer const* info = GetFakePlayer(player);
if (!info)
return;

// Re-push the stored fake values after a resurrect so the assigned faction
// and morph survive the ghost->alive transition.
player->setRace(info->FakeRace);
SetFactionForRace(player, info->FakeRace, info->FakeTeamID);
player->SetDisplayId(info->FakeMorph);
player->SetNativeDisplayId(info->FakeMorph);
}

bool CFBG::IsPlayerFake(Player* player)
{
return _fakePlayerStore.contains(player);
Expand Down
3 changes: 3 additions & 0 deletions src/CFBG.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class CFBG
inline bool IsEnableSystem() const { return _IsEnableSystem; }
inline bool IsEnableWGSystem() const { return _IsEnableWGSystem; }
inline bool IsEnableWGTeamLock() const { return _IsEnableWGTeamLock; }
inline bool IsEnableWGReapplyOnResurrect() const { return _IsEnableWGReapplyOnResurrect; }
inline bool IsEnableAvgIlvl() const { return _IsEnableAvgIlvl; }
inline bool IsEnableBalancedTeams() const { return _IsEnableBalancedTeams; }
inline bool IsEnableBalanceClassLowLevel() const { return _IsEnableBalanceClassLowLevel; }
Expand Down Expand Up @@ -174,6 +175,7 @@ class CFBG
void SetFakeRaceAndMorphForBF(Player* player, TeamId assignedTeam);
void SetFactionForRace(Player* player, uint8 Race, TeamId teamId);
void ClearFakePlayer(Player* player);
void ReapplyFakePlayer(Player* player);
void DoForgetPlayersInList(Player* player);
void FitPlayerInTeam(Player* player, bool action, Battleground* bg);
void DoForgetPlayersInBG(Player* player, Battleground* bg);
Expand Down Expand Up @@ -223,6 +225,7 @@ class CFBG
bool _IsEnableSystem;
bool _IsEnableWGSystem;
bool _IsEnableWGTeamLock;
bool _IsEnableWGReapplyOnResurrect;
bool _IsEnableAvgIlvl;
bool _IsEnableBalancedTeams;
bool _IsEnableBalanceClassLowLevel;
Expand Down
20 changes: 19 additions & 1 deletion src/CFBG_SC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class CFBG_Player : public PlayerScript
PLAYERHOOK_CAN_JOIN_IN_BATTLEGROUND_QUEUE,
PLAYERHOOK_ON_BEFORE_UPDATE,
PLAYERHOOK_ON_BEFORE_SEND_CHAT_MESSAGE,
PLAYERHOOK_ON_REPUTATION_CHANGE
PLAYERHOOK_ON_REPUTATION_CHANGE,
PLAYERHOOK_ON_PLAYER_RESURRECT
}) { }

void OnPlayerLogin(Player* player) override
Expand Down Expand Up @@ -215,6 +216,23 @@ class CFBG_Player : public PlayerScript
lang = LANG_UNIVERSAL;
}

void OnPlayerResurrect(Player* player, float /*restorePercent*/, bool& /*applySickness*/) override
{
if (!sCFBG->IsEnableSystem() || !sCFBG->IsEnableWGSystem() || !sCFBG->IsEnableWGReapplyOnResurrect())
return;

if (!sCFBG->IsPlayerFake(player))
return;

// Only re-apply for WG fakes. Battleground fakes are owned by the BG
// hooks and must not be touched here.
Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(player->GetZoneId());
if (!bf || bf->GetTypeId() != BATTLEFIELD_WG)
return;

sCFBG->ReapplyFakePlayer(player);
}

bool OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool /*incremental*/) override
{
uint32 repGain = player->GetReputation(factionID);
Expand Down
Loading