Core/Battleground: Fix reputation assignment in case of switched team

This commit is contained in:
mik1893
2016-07-28 19:06:33 +01:00
committed by Yehonal
parent 69aa0b47b8
commit 5d3a91576e
2 changed files with 45 additions and 3 deletions

View File

@@ -665,17 +665,48 @@ void Battleground::RewardHonorToTeam(uint32 honor, TeamId teamId)
void Battleground::RewardReputationToTeam(uint32 factionId, uint32 reputation, TeamId teamId)
{
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId))
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (itr->second->GetBgTeamId() == teamId)
{
uint32 realFactionId = GetRealRepFactionForPlayer(factionId, itr->second);
uint32 repGain = reputation;
AddPct(repGain, itr->second->GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
AddPct(repGain, itr->second->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, factionId));
AddPct(repGain, itr->second->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, realFactionId));
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(realFactionId))
itr->second->GetReputationMgr().ModifyReputation(factionEntry, repGain);
}
}
uint32 Battleground::GetRealRepFactionForPlayer(uint32 factionId, Player* player)
{
if (player)
{
// if the bg team is not the original team, reverse reputation
if (player->GetBgTeamId() != player->GetTeamId(true))
{
switch (factionId)
{
case BG_REP_AB_ALLIANCE:
return BG_REP_AB_HORDE;
case BG_REP_AB_HORDE:
return BG_REP_AB_ALLIANCE;
case BG_REP_AV_ALLIANCE:
return BG_REP_AV_HORDE;
case BG_REP_AV_HORDE:
return BG_REP_AV_ALLIANCE;
case BG_REP_WS_ALLIANCE:
return BG_REP_WS_HORDE;
case BG_REP_WS_HORDE:
return BG_REP_WS_ALLIANCE;
}
}
}
return factionId;
}
void Battleground::UpdateWorldState(uint32 Field, uint32 Value)
{
WorldPacket data;

View File

@@ -116,6 +116,16 @@ enum BattlegroundSpells
SPELL_THE_LAST_STANDING = 26549, // Arena achievement related
};
enum BattlegroundReputations
{
BG_REP_AV_HORDE = 729,
BG_REP_AV_ALLIANCE = 730,
BG_REP_AB_HORDE = 510,
BG_REP_AB_ALLIANCE = 509,
BG_REP_WS_HORDE = 889,
BG_REP_WS_ALLIANCE = 890,
};
enum BattlegroundTimeIntervals
{
CHECK_PLAYER_POSITION_INVERVAL = 9000, // ms
@@ -453,6 +463,7 @@ class Battleground
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 Field, uint32 Value);
void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* player);