Core/Misc: Add functionality to allow low level quests/kills/discoveries to grant experience
Port From (https://github.com/TrinityCore/TrinityCore/commit/502f77fe8cb082843f7eb385159dd5038a059443)
This commit is contained in:
@@ -5007,7 +5007,7 @@ namespace Game.Entities
|
||||
uint k_grey = Formulas.GetGrayLevel(GetLevel());
|
||||
|
||||
// Victim level less gray level
|
||||
if (v_level < k_grey)
|
||||
if (v_level < k_grey && WorldConfig.GetIntValue(WorldCfg.MinCreatureScaledXpRatio) == 0)
|
||||
return false;
|
||||
|
||||
Creature creature = victim.ToCreature();
|
||||
@@ -6172,6 +6172,12 @@ namespace Game.Entities
|
||||
XP = (uint)(Global.ObjectMgr.GetBaseXP(areaLevel) * WorldConfig.GetFloatValue(WorldCfg.RateXpExplore));
|
||||
}
|
||||
|
||||
if (WorldConfig.GetIntValue(WorldCfg.MinDiscoveredScaledXpRatio) != 0)
|
||||
{
|
||||
uint minScaledXP = (uint)(Global.ObjectMgr.GetBaseXP(areaLevel) * WorldConfig.GetFloatValue(WorldCfg.RateXpExplore)) * WorldConfig.GetUIntValue(WorldCfg.MinDiscoveredScaledXpRatio) / 100;
|
||||
XP = Math.Max(minScaledXP, XP);
|
||||
}
|
||||
|
||||
GiveXP(XP, null);
|
||||
SendExplorationExperience(areaId, XP);
|
||||
}
|
||||
|
||||
@@ -136,6 +136,13 @@ namespace Game
|
||||
baseGain = 0;
|
||||
}
|
||||
|
||||
if (WorldConfig.GetIntValue(WorldCfg.MinCreatureScaledXpRatio) != 0 && pl_level != mob_level)
|
||||
{
|
||||
// Use mob level instead of player level to avoid overscaling on gain in a min is enforced
|
||||
uint baseGainMin = BaseGain(pl_level, pl_level) * WorldConfig.GetUIntValue(WorldCfg.MinCreatureScaledXpRatio) / 100;
|
||||
baseGain = Math.Max(baseGainMin, baseGain);
|
||||
}
|
||||
|
||||
Global.ScriptMgr.OnBaseGainCalculation(baseGain, pl_level, mob_level);
|
||||
return baseGain;
|
||||
}
|
||||
|
||||
@@ -294,14 +294,13 @@ namespace Game
|
||||
if (player.GetLevel() >= Global.ObjectMgr.GetMaxLevelForExpansion(PlayerConst.CurrentExpansion - 1) && player.GetSession().GetExpansion() == PlayerConst.CurrentExpansion && Expansion < (int)PlayerConst.CurrentExpansion)
|
||||
xp = (uint)(xp / 9.0f);
|
||||
|
||||
if (xp <= 100)
|
||||
xp = 5 * ((xp + 2) / 5);
|
||||
else if (xp <= 500)
|
||||
xp = 10 * ((xp + 5) / 10);
|
||||
else if (xp <= 1000)
|
||||
xp = 25 * ((xp + 12) / 25);
|
||||
else
|
||||
xp = 50 * ((xp + 25) / 50);
|
||||
xp = RoundXPValue(xp);
|
||||
|
||||
if (WorldConfig.GetUIntValue(WorldCfg.MinQuestScaledXpRatio) != 0)
|
||||
{
|
||||
uint minScaledXP = RoundXPValue((uint)(questXp.Difficulty[RewardXPDifficulty] * RewardXPMultiplier)) * WorldConfig.GetUIntValue(WorldCfg.MinQuestScaledXpRatio) / 100;
|
||||
xp = Math.Max(minScaledXP, xp);
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
@@ -558,6 +557,18 @@ namespace Game
|
||||
QueryData.Info.TimeAllowed = LimitTime;
|
||||
}
|
||||
|
||||
public static uint RoundXPValue(uint xp)
|
||||
{
|
||||
if (xp <= 100)
|
||||
return 5 * ((xp + 2) / 5);
|
||||
else if (xp <= 500)
|
||||
return 10 * ((xp + 5) / 10);
|
||||
else if (xp <= 1000)
|
||||
return 25 * ((xp + 12) / 25);
|
||||
else
|
||||
return 50 * ((xp + 25) / 50);
|
||||
}
|
||||
|
||||
public bool HasFlag(QuestFlags flag) { return (Flags & flag) != 0; }
|
||||
public bool HasFlagEx(QuestFlagsEx flag) { return (FlagsEx & flag) != 0; }
|
||||
public bool HasFlagEx(QuestFlagsEx2 flag) { return (FlagsEx2 & flag) != 0; }
|
||||
|
||||
@@ -295,6 +295,28 @@ namespace Game
|
||||
|
||||
Values[WorldCfg.GroupXpDistance] = GetDefaultValue("MaxGroupXPDistance", 74.0f);
|
||||
Values[WorldCfg.MaxRecruitAFriendDistance] = GetDefaultValue("MaxRecruitAFriendBonusDistance", 100.0f);
|
||||
Values[WorldCfg.MinQuestScaledXpRatio] = GetDefaultValue("MinQuestScaledXPRatio", 0);
|
||||
if ((int)Values[WorldCfg.MinQuestScaledXpRatio] > 100)
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"MinQuestScaledXPRatio ({Values[WorldCfg.MinQuestScaledXpRatio]}) must be in range 0..100. Set to 0.");
|
||||
Values[WorldCfg.MinQuestScaledXpRatio] = 0;
|
||||
}
|
||||
|
||||
Values[WorldCfg.MinCreatureScaledXpRatio] = GetDefaultValue("MinCreatureScaledXPRatio", 0);
|
||||
if ((int)Values[WorldCfg.MinCreatureScaledXpRatio] > 100)
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"MinCreatureScaledXPRatio ({Values[WorldCfg.MinCreatureScaledXpRatio]}) must be in range 0..100. Set to 0.");
|
||||
Values[WorldCfg.MinCreatureScaledXpRatio] = 0;
|
||||
}
|
||||
|
||||
Values[WorldCfg.MinDiscoveredScaledXpRatio] = GetDefaultValue("MinDiscoveredScaledXPRatio", 0);
|
||||
if ((int)Values[WorldCfg.MinDiscoveredScaledXpRatio] > 100)
|
||||
{
|
||||
Log.outError(LogFilter.ServerLoading, $"MinDiscoveredScaledXPRatio ({Values[WorldCfg.MinDiscoveredScaledXpRatio]}) must be in range 0..100. Set to 0.");
|
||||
Values[WorldCfg.MinDiscoveredScaledXpRatio] = 0;
|
||||
}
|
||||
|
||||
/// @todo Add MonsterSight (with meaning) in worldserver.conf or put them as define
|
||||
Values[WorldCfg.SightMonster] = GetDefaultValue("MonsterSight", 50.0f);
|
||||
|
||||
if (reload)
|
||||
|
||||
Reference in New Issue
Block a user