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

Port From (https://github.com/TrinityCore/TrinityCore/commit/c56d18287dad88b214b4a33ccd785484b165acbe)
This commit is contained in:
Hondacrx
2025-12-08 14:03:10 -05:00
parent b267c12273
commit b3b42d29ad
8 changed files with 35 additions and 15 deletions
+16
View File
@@ -1005,4 +1005,20 @@ namespace Framework.Constants
CharacterContentpushIndex = 8,
CharacterQuestCompletedIndex = 9,
}
public enum HonorGainSource
{
Kill = 0,
Quest = 1,
ArenaCompletion = 2,
BGCompletion = 3,
LFG = 4,
TeamContribution = 5,
RankedBGCompletion = 6,
RatedArenaCompletion = 7,
ArenaSkirmishCompletion = 8,
RandomBGCompletion = 9,
HolidayBGCompletion = 10,
Spell = 11,
}
}
@@ -219,7 +219,7 @@ namespace Framework.Constants
ModMountedFlightSpeedAlways = 209,
ModVehicleSpeedAlways = 210,
ModFlightSpeedNotStack = 211,
ModHonorGainPct = 212,
ModHonorGainPctFromSource = 212,
ModRageFromDamageDealt = 213,
Unk214 = 214,
ArenaPreparation = 215,
+9 -5
View File
@@ -525,7 +525,7 @@ namespace Game.BattleGrounds
{
Player player = _GetPlayerForTeam(team, pair, "RewardHonorToTeam");
if (player != null)
UpdatePlayerScore(player, ScoreType.BonusHonor, Honor);
UpdatePlayerScore(player, ScoreType.BonusHonor, Honor, true, HonorGainSource.TeamContribution);
}
}
@@ -683,7 +683,11 @@ namespace Game.BattleGrounds
if (Global.BattlegroundMgr.IsRandomBattleground((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId)
|| Global.BattlegroundMgr.IsBGWeekend((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId))
{
UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(winnerKills));
HonorGainSource source = HonorGainSource.BGCompletion;
if (!player.GetRandomWinner())
source = Global.BattlegroundMgr.IsRandomBattleground((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId) ? HonorGainSource.RandomBGCompletion : HonorGainSource.HolidayBGCompletion;
UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(winnerKills), true, source);
if (!player.GetRandomWinner())
{
player.SetRandomWinner(true);
@@ -716,7 +720,7 @@ namespace Game.BattleGrounds
{
if (Global.BattlegroundMgr.IsRandomBattleground((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId)
|| Global.BattlegroundMgr.IsBGWeekend((BattlegroundTypeId)bgPlayer.queueTypeId.BattlemasterListId))
UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(loserKills));
UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(loserKills), true, HonorGainSource.BGCompletion);
}
}
@@ -1233,14 +1237,14 @@ namespace Game.BattleGrounds
return PlayerScores.LookupByKey(player.GetGUID());
}
public bool UpdatePlayerScore(Player player, ScoreType type, uint value, bool doAddHonor = true)
public bool UpdatePlayerScore(Player player, ScoreType type, uint value, bool doAddHonor = true, HonorGainSource? source = null)
{
var bgScore = PlayerScores.LookupByKey(player.GetGUID());
if (bgScore == null) // player not found...
return false;
if (type == ScoreType.BonusHonor && doAddHonor && IsBattleground())
player.RewardHonor(null, 1, (int)value);
player.RewardHonor(null, 1, (int)value, source.GetValueOrDefault(HonorGainSource.Kill));
else
bgScore.UpdateScore(type, value);
+2 -2
View File
@@ -45,7 +45,7 @@ namespace Game.Chat.Commands
if (handler.HasLowerSecurity(target, ObjectGuid.Empty))
return false;
target.RewardHonor(null, 1, amount);
target.RewardHonor(null, 1, amount, HonorGainSource.Spell);
return true;
}
@@ -65,7 +65,7 @@ namespace Game.Chat.Commands
if (handler.HasLowerSecurity(player, ObjectGuid.Empty))
return false;
handler.GetPlayer().RewardHonor(target, 1);
handler.GetPlayer().RewardHonor(target, 1, -1, HonorGainSource.Kill);
return true;
}
}
+1 -1
View File
@@ -147,7 +147,7 @@ namespace Game.Entities
{
// Rewarded player must be alive.
if (player.IsAlive())
player.RewardHonor(_victim, _count, -1, true);
player.RewardHonor(_victim, _count, -1, HonorGainSource.Kill);
}
void _RewardXP(Player player, float rate)
+1 -1
View File
@@ -478,7 +478,7 @@ namespace Game.Entities
// Honor points after duel (the winner) - ImpConfig
int amount = WorldConfig.GetIntValue(WorldCfg.HonorAfterDuel);
if (amount != 0)
opponent.RewardHonor(null, 1, amount);
opponent.RewardHonor(null, 1, amount, HonorGainSource.Kill);
break;
default:
+4 -4
View File
@@ -45,7 +45,7 @@ namespace Game.Entities
m_lastHonorUpdateTime = now;
}
public bool RewardHonor(Unit victim, uint groupsize, int honor = -1, bool pvptoken = false)
public bool RewardHonor(Unit victim, uint groupsize, int honor = -1, HonorGainSource source = HonorGainSource.Kill)
{
// do not reward honor in arenas, but enable onkill spellproc
if (InArena())
@@ -146,7 +146,7 @@ namespace Game.Entities
honor_f /= groupsize;
// apply honor multiplier from aura (not stacking-get highest)
MathFunctions.AddPct(ref honor_f, GetMaxPositiveAuraModifier(AuraType.ModHonorGainPct));
MathFunctions.AddPct(ref honor_f, GetMaxPositiveAuraModifierByMiscMask(AuraType.ModHonorGainPctFromSource, 1u << (int)source));
honor_f += _restMgr.GetRestBonusFor(RestTypes.Honor, (uint)honor_f);
}
@@ -173,11 +173,11 @@ namespace Game.Entities
Battleground bg = GetBattleground();
if (bg != null)
{
bg.UpdatePlayerScore(this, ScoreType.BonusHonor, (uint)honor, false); //false: prevent looping
bg.UpdatePlayerScore(this, ScoreType.BonusHonor, (uint)honor, false, source); //false: prevent looping
}
}
if (WorldConfig.GetBoolValue(WorldCfg.PvpTokenEnable) && pvptoken)
if (WorldConfig.GetBoolValue(WorldCfg.PvpTokenEnable) && source == HonorGainSource.Kill)
{
if (victim == null || victim == this || victim.HasAuraType(AuraType.NoPvpCredit))
return true;
+1 -1
View File
@@ -1118,7 +1118,7 @@ namespace Game.Entities
// honor reward
uint honor = quest.CalculateHonorGain(GetLevel());
if (honor != 0)
RewardHonor(null, 0, (int)honor);
RewardHonor(null, 0, (int)honor, HonorGainSource.Quest);
// title reward
if (quest.RewardTitleId != 0)