Core/Auras: Corrected SPELL_AURA_MOD_HONOR_GAIN_PCT implementation - it should only increase honor gains from some sources

This commit is contained in:
Shauren
2025-09-24 00:21:31 +02:00
parent 5fad0fb43a
commit c56d18287d
10 changed files with 43 additions and 21 deletions

View File

@@ -576,7 +576,7 @@ void Battleground::RewardHonorToTeam(uint32 Honor, Team team)
{
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (Player* player = _GetPlayerForTeam(team, itr, "RewardHonorToTeam"))
UpdatePlayerScore(player, SCORE_BONUS_HONOR, Honor);
UpdatePlayerScore(player, SCORE_BONUS_HONOR, Honor, true, HonorGainSource::TeamContribution);
}
void Battleground::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, Team team)
@@ -726,7 +726,11 @@ void Battleground::EndBattleground(Team winner)
if (BattlegroundMgr::IsRandomBattleground(bgPlayer->queueTypeId.BattlemasterListId)
|| BattlegroundMgr::IsBGWeekend(BattlegroundTypeId(bgPlayer->queueTypeId.BattlemasterListId)))
{
UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(winnerKills));
HonorGainSource source = HonorGainSource::BGCompletion;
if (!player->GetRandomWinner())
source = BattlegroundMgr::IsRandomBattleground(bgPlayer->queueTypeId.BattlemasterListId) ? HonorGainSource::RandomBGCompletion : HonorGainSource::HolidayBGCompletion;
UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(winnerKills), true, source);
if (!player->GetRandomWinner())
{
player->SetRandomWinner(true);
@@ -756,7 +760,7 @@ void Battleground::EndBattleground(Team winner)
{
if (BattlegroundMgr::IsRandomBattleground(bgPlayer->queueTypeId.BattlemasterListId)
|| BattlegroundMgr::IsBGWeekend(BattlegroundTypeId(bgPlayer->queueTypeId.BattlemasterListId)))
UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(loserKills));
UpdatePlayerScore(player, SCORE_BONUS_HONOR, GetBonusHonorFromKill(loserKills), true, HonorGainSource::BGCompletion);
}
}
@@ -1279,14 +1283,14 @@ BattlegroundScore const* Battleground::GetBattlegroundScore(Player* player) cons
return Trinity::Containers::MapGetValuePtr(PlayerScores, player->GetGUID());
}
bool Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor)
bool Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor, Optional<HonorGainSource> source)
{
BattlegroundScoreMap::const_iterator itr = PlayerScores.find(player->GetGUID());
if (itr == PlayerScores.end()) // player not found...
return false;
if (type == SCORE_BONUS_HONOR && doAddHonor && isBattleground())
player->RewardHonor(nullptr, 1, value); // RewardHonor calls UpdatePlayerScore with doAddHonor = false
player->RewardHonor(nullptr, 1, value, source.value_or(HonorGainSource::Kill)); // RewardHonor calls UpdatePlayerScore with doAddHonor = false
else
itr->second->UpdateScore(type, value);

View File

@@ -21,6 +21,7 @@
#include "DBCEnums.h"
#include "Duration.h"
#include "ObjectGuid.h"
#include "Optional.h"
#include "Position.h"
#include "SharedDefines.h"
#include "UniqueTrackablePtr.h"
@@ -43,6 +44,7 @@ struct BattlegroundScore;
struct BattlegroundTemplate;
struct PVPDifficultyEntry;
struct WorldSafeLocsEntry;
enum class HonorGainSource : uint8;
namespace WorldPackets
{
@@ -378,7 +380,7 @@ class TC_GAME_API Battleground
BattlegroundScore const* GetBattlegroundScore(Player* player) const;
bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true, Optional<HonorGainSource> source = {});
void UpdatePvpStat(Player* player, uint32 pvpStatId, uint32 value);
static TeamId GetTeamIndexByTeamId(Team team) { return team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }

View File

@@ -134,7 +134,7 @@ inline void KillRewarder::_RewardHonor(Player* player)
{
// Rewarded player must be alive.
if (player->IsAlive())
player->RewardHonor(_victim, _count, -1, true);
player->RewardHonor(_victim, _count, -1, HonorGainSource::Kill);
}
inline void KillRewarder::_RewardXP(Player* player, float rate)

View File

@@ -6746,7 +6746,7 @@ void Player::UpdateHonorFields()
///Calculate the amount of honor gained based on the victim
///and the size of the group for which the honor is divided
///An exact honor value can also be given (overriding the calcs)
bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvptoken)
bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, HonorGainSource source)
{
// do not reward honor in arenas, but enable onkill spellproc
if (InArena())
@@ -6847,7 +6847,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
honor_f /= groupsize;
// apply honor multiplier from aura (not stacking-get highest)
AddPct(honor_f, GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN_PCT));
AddPct(honor_f, GetMaxPositiveAuraModifierByMiscMask(SPELL_AURA_MOD_HONOR_GAIN_PCT_FROM_SOURCE, 1 << AsUnderlyingType(source)));
honor_f += _restMgr->GetRestBonusFor(REST_TYPE_HONOR, honor_f);
}
@@ -6873,11 +6873,11 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
{
if (Battleground* bg = GetBattleground())
{
bg->UpdatePlayerScore(this, SCORE_BONUS_HONOR, honor, false); //false: prevent looping
bg->UpdatePlayerScore(this, SCORE_BONUS_HONOR, honor, false, source); //false: prevent looping
}
}
if (sWorld->getBoolConfig(CONFIG_PVP_TOKEN_ENABLE) && pvptoken)
if (sWorld->getBoolConfig(CONFIG_PVP_TOKEN_ENABLE) && source == HonorGainSource::Kill)
{
if (!victim || victim == this || victim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT))
return true;
@@ -7828,7 +7828,7 @@ void Player::DuelComplete(DuelCompleteType type)
// Honor points after duel (the winner) - ImpConfig
if (uint32 amount = sWorld->getIntConfig(CONFIG_HONOR_AFTER_DUEL))
opponent->RewardHonor(nullptr, 1, amount);
opponent->RewardHonor(nullptr, 1, amount, HonorGainSource::Kill);
break;
default:
@@ -15091,7 +15091,7 @@ void Player::RewardQuest(Quest const* quest, LootItemType rewardType, uint32 rew
// honor reward
if (uint32 honor = quest->CalculateHonorGain(GetLevel()))
RewardHonor(nullptr, 0, honor);
RewardHonor(nullptr, 0, honor, HonorGainSource::Quest);
// title reward
if (quest->GetRewTitle())

View File

@@ -336,6 +336,22 @@ enum ActionButtonType
ACTION_BUTTON_ITEM = 0x80
};
enum class HonorGainSource : uint8
{
Kill = 0,
Quest = 1,
ArenaCompletion = 2,
BGCompletion = 3,
LFG = 4,
TeamContribution = 5,
RankedBGCompletion = 6,
RatedArenaCompletion = 7,
ArenaSkirmishCompletion = 8,
RandomBGCompletion = 9,
HolidayBGCompletion = 10,
Spell = 11,
};
enum ReputationSource
{
REPUTATION_SOURCE_KILL,
@@ -2360,7 +2376,7 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
/*** PVP SYSTEM ***/
/*********************************************************/
void UpdateHonorFields();
bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, bool pvptoken = false);
bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, HonorGainSource source = HonorGainSource::Kill);
void ResetHonorStats();
uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) const;

View File

@@ -296,7 +296,7 @@ enum AuraType : uint32
SPELL_AURA_MOD_MOUNTED_FLIGHT_SPEED_ALWAYS = 209,
SPELL_AURA_MOD_VEHICLE_SPEED_ALWAYS = 210,
SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK = 211,
SPELL_AURA_MOD_HONOR_GAIN_PCT = 212,
SPELL_AURA_MOD_HONOR_GAIN_PCT_FROM_SOURCE = 212,
SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT = 213,
SPELL_AURA_214 = 214,
SPELL_AURA_ARENA_PREPARATION = 215,

View File

@@ -281,7 +281,7 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleAuraModIncreaseFlightSpeed, //209 SPELL_AURA_MOD_MOUNTED_FLIGHT_SPEED_ALWAYS
&AuraEffect::HandleAuraModIncreaseFlightSpeed, //210 SPELL_AURA_MOD_VEHICLE_SPEED_ALWAYS
&AuraEffect::HandleAuraModIncreaseFlightSpeed, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK
&AuraEffect::HandleNoImmediateEffect, //212 SPELL_AURA_MOD_HONOR_GAIN_PCT implemented in Player::RewardHonor
&AuraEffect::HandleNoImmediateEffect, //212 SPELL_AURA_MOD_HONOR_GAIN_PCT_FROM_SOURCE implemented in Player::RewardHonor
&AuraEffect::HandleNoImmediateEffect, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage
&AuraEffect::HandleNULL, //214 Tamed Pet Passive
&AuraEffect::HandleArenaPreparation, //215 SPELL_AURA_ARENA_PREPARATION

View File

@@ -664,7 +664,7 @@ struct battleground_strand_of_the_ancients : BattlegroundScript
{
battleground->UpdatePvpStat(player, PVP_STAT_GATES_DESTROYED, 1);
if (rewardHonor)
battleground->UpdatePlayerScore(player, SCORE_BONUS_HONOR, battleground->GetBonusHonorFromKill(1));
battleground->UpdatePlayerScore(player, SCORE_BONUS_HONOR, battleground->GetBonusHonorFromKill(1), true, HonorGainSource::TeamContribution);
}
}
}

View File

@@ -72,7 +72,7 @@ public:
if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
return false;
target->RewardHonor(nullptr, 1, amount);
target->RewardHonor(nullptr, 1, amount, HonorGainSource::Spell);
return true;
}
@@ -91,7 +91,7 @@ public:
if (handler->HasLowerSecurity(player, ObjectGuid::Empty))
return false;
handler->GetSession()->GetPlayer()->RewardHonor(target, 1);
handler->GetSession()->GetPlayer()->RewardHonor(target, 1, -1, HonorGainSource::Kill);
return true;
}

View File

@@ -107,7 +107,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger, bool /*ente
// reward player
player->CastSpell(player, SI_TRACES_OF_SILITHYST, true);
// add 19 honor
player->RewardHonor(nullptr, 1, 19);
player->RewardHonor(nullptr, 1, 19, HonorGainSource::TeamContribution);
// add 20 cenarion circle repu
player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
// complete quest
@@ -133,7 +133,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger, bool /*ente
// reward player
player->CastSpell(player, SI_TRACES_OF_SILITHYST, true);
// add 19 honor
player->RewardHonor(nullptr, 1, 19);
player->RewardHonor(nullptr, 1, 19, HonorGainSource::TeamContribution);
// add 20 cenarion circle repu
player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20);
// complete quest