Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player: Modified reputation gain calculations #553

Closed
wants to merge 6 commits into from
Closed
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
26 changes: 19 additions & 7 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6282,15 +6282,27 @@ 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);
// Old code seems to have been correct for computing level difference penalties for quests
if (source == REPUTATION_SOURCE_KILL)
{
if (MaNGOS::XP::IsTrivialLevelDifference(currentLevel, creatureOrQuestLevel))
{
// For kill reputiation gains the penalties value seems to have been 20% for each level below lowest green level down to a minimum (default: 20%)
const uint32 greenRange = MaNGOS::XP::GetQuestGreenRange(currentLevel);
percent *= std::max(minRate, (1.0f - (0.2f * (currentLevel - greenRange - creatureOrQuestLevel))));
}

if (currentLevel > treshold)
percent *= std::max(minRate, (1.0f - (0.2f * (currentLevel - treshold))));
} 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 (percent <= 0.0f)
Expand Down
32 changes: 31 additions & 1 deletion 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 All @@ -281,7 +311,7 @@ namespace MaNGOS
return pl_level - 5 - pl_level / 10;
if (pl_level <= 59)
return pl_level - 1 - pl_level / 5;
return pl_level - 9;
return pl_level - 13;
}

inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level)
Expand Down