Skip to content

Commit

Permalink
XP: Fix diminishing of kill reputation
Browse files Browse the repository at this point in the history
Closes #553
  • Loading branch information
JJBcku authored and killerwife committed Jul 31, 2024
1 parent 66906de commit 3055652
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6282,15 +6282,25 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32

uint32 currentLevel = GetLevel();

if (MaNGOS::XP::IsTrivialLevelDifference(currentLevel, creatureOrQuestLevel))
percent *= minRate;
else
// Level zero seems to be treated as always equal to players current level in IsTrivialLevelDifference therefore I have skipped level difference penalty computations for that value
if (creatureOrQuestLevel > 0)
{
// Pre-3.0.8: Declines with 20% for each level if 6 levels or more below the player down to a minimum (default: 20%)
const uint32 treshold = (creatureOrQuestLevel + 5);
if (source == REPUTATION_SOURCE_KILL)
{
if (MaNGOS::XP::IsTrivialLevelDifference(currentLevel, creatureOrQuestLevel))
{
const uint32 greenRange = MaNGOS::XP::GetQuestGreenRange(currentLevel);
percent *= std::max(minRate, (1.0f - (0.2f * (currentLevel - greenRange - creatureOrQuestLevel))));
}
}
else if (source == REPUTATION_SOURCE_QUEST)
{
// Pre-3.0.8: Declines with 20% for each level if 6 levels or more below the player down to a minimum (default: 20%)
const uint32 treshold = (creatureOrQuestLevel + 5);

if (currentLevel > treshold)
percent *= std::max(minRate, (1.0f - (0.2f * (currentLevel - treshold))));
if (currentLevel > treshold)
percent *= std::max(minRate, (1.0f - (0.2f * (currentLevel - treshold))));
}
}

if (percent <= 0.0f)
Expand Down
30 changes: 30 additions & 0 deletions src/game/Tools/Formulas.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,36 @@ namespace MaNGOS
return false;
}

inline uint32 GetQuestGreenRange(uint32 unitLvl)
{
switch (unitLvl / 5)
{
case 0: // 0-4
case 1: // 5-9
return 4;
case 2: // 10-14
case 3: // 15-19
return 5;
case 4: // 20-24
case 5: // 25-29
return 6;
case 6: // 30-34
case 7: // 35-39
return 7;
case 8: // 40-44
return 8;
case 9: // 45-49
return 9;
case 10: // 50-54
return 10;
case 11: // 55-59
return 11;
default: // 60+
return 12;
}
return false;
}

enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY };

inline uint32 GetGrayLevel(uint32 pl_level)
Expand Down

0 comments on commit 3055652

Please sign in to comment.