Skip to content

Commit 77040ae

Browse files
committed
Removal of RNG element from MC system
1 parent bb7a05c commit 77040ae

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

server/learn.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ local function accountForMultiSkills(user, skill, actionPoints)
113113

114114
end
115115

116+
local accumulatedExperience = {}
116117

117118
function M.learn(user, skill, actionPoints, learnLimit)
118119

@@ -140,12 +141,20 @@ function M.learn(user, skill, actionPoints, learnLimit)
140141

141142
local minorIncrease = scalingFactor * skillFactor * MCfactor * actionpointFactor * (1 + attributeBonus + intelligenceBonus)
142143

143-
if common.Chance(minorIncrease-math.floor(minorIncrease)) then
144-
minorIncrease=math.floor(minorIncrease)+1
145-
else
146-
minorIncrease=math.floor(minorIncrease)
144+
if not accumulatedExperience[user.id] then
145+
accumulatedExperience[user.id] = {}
147146
end
148147

148+
if accumulatedExperience[user.id][skill] then
149+
minorIncrease = minorIncrease + accumulatedExperience[user.id][skill]
150+
end
151+
152+
local excess = minorIncrease-math.floor(minorIncrease)
153+
-- Skill points only work in whole integers, so we store the decimal for later instead of relying on RNG
154+
accumulatedExperience[user.id][skill] = excess
155+
156+
minorIncrease = math.floor(minorIncrease) --The whole integer we will increase by
157+
149158
--For debugging, use the following line.
150159
--[[user:inform("Skill="..user:getSkillName(skill)..", actionPoints="..actionPoints..", skillFactor="
151160
..skillFactor..", MCfactor="..MCfactor..", attributeBonus="..attributeBonus..", intelligenceBonus="

0 commit comments

Comments
 (0)