Module:ConsCalcs: Difference between revisions
From IdleOn MMO Wiki
Kiokurashi (talk | contribs) mNo edit summary |
Kiokurashi (talk | contribs) mNo edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
local frameArgs = frame.args | local frameArgs = frame.args | ||
local sb = frameArgs.sb -- Salt Base Value | local sb = tonumber(frameArgs.sb) -- Salt Base Value | ||
local cc = frameArgs.cc -- Cost Cruncher (Only to be used for Cost Cruncher) | local cc = tonumber(frameArgs.cc) -- Cost Cruncher (Only to be used for Cost Cruncher) | ||
local maxTL = frameArgs.maxTL -- Default Total Tower Level | local maxTL = tonumber(frameArgs.maxTL) -- Default Total Tower Level | ||
local bonusTL = frameArgs.bonusTL -- Bonus Total Tower Level | local bonusTL = tonumber(frameArgs.bonusTL) -- Bonus Total Tower Level | ||
local ccb = 1 -- Cost Cruncher base Bonus (hard-coded at 1) | local ccb = 1 -- Cost Cruncher base Bonus (hard-coded at 1) | ||
local ccl = 0 | local ccl = 0 | ||
local normalSum = 0 | local normalSum = 0 | ||
for l = 0, maxTL do | for l = 0, maxTL - 1 do | ||
if cc == 1 then ccl = l else ccl = 0 end | if cc == 1 then ccl = l else ccl = 0 end | ||
normalSum = normalSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor((ccl + 999) / 1000)) + math.max(0, ccl - 1) * ccb / 100)) * sb * (l + 1)) | normalSum = normalSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor((ccl + 999) / 1000)) + math.max(0, ccl - 1) * ccb / 100)) * sb * (l + 1)) | ||
end | end | ||
VariablesLua.vardefine( saltNorm, normalSum) | VariablesLua.vardefine( "saltNorm", normalSum) | ||
local bonusSum = 0 | local bonusSum = 0 | ||
for | if bonusTL > 0 then | ||
for b = 0, bonusTL - 1 do | |||
l = b + maxTL | |||
if cc == 1 then ccl = l else ccl = 0 end | |||
bonusSum = bonusSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor((ccl + 999) / 1000)) + math.max(0, ccl - 1) * ccb / 100)) * sb * (l + 1)) | |||
end | |||
end | end | ||
VariablesLua.vardefine( saltBonus, bonusSum ) | VariablesLua.vardefine( "saltBonus", bonusSum ) | ||
local totalSum = normalSum + bonusSum | local totalSum = normalSum + bonusSum | ||
VariablesLua.vardefine( saltTotal, totalSum ) | VariablesLua.vardefine( "saltTotal", totalSum ) | ||
end | end | ||
Line 33: | Line 36: | ||
local frameArgs = frame.args | local frameArgs = frame.args | ||
local mb = frameArgs.mb -- Material Base Value | local mb = tonumber(frameArgs.mb) -- Material Base Value | ||
local ms = frameArgs.ms -- Material Scaling Value | local ms = tonumber(frameArgs.ms) -- Material Scaling Value | ||
local cc = frameArgs.cc -- Cost Cruncher (Only to be used for Cost Cruncher) | local cc = tonumber(frameArgs.cc) -- Cost Cruncher (Only to be used for Cost Cruncher) | ||
local maxTL = frameArgs.maxTL -- Default Total Tower Level | local maxTL = tonumber(frameArgs.maxTL) -- Default Total Tower Level | ||
local bonusTL = frameArgs.bonusTL -- Bonus Total Tower Level | local bonusTL = tonumber(frameArgs.bonusTL) -- Bonus Total Tower Level | ||
local ccb = 1 -- Cost Cruncher base Bonus (hard-coded at 1) | local ccb = 1 -- Cost Cruncher base Bonus (hard-coded at 1) | ||
local ccl = 0 | local ccl = 0 | ||
local normalSum = 0 | local normalSum = 0 | ||
for l = 0, maxTL do | for l = 0, maxTL - 1 do | ||
if cc == 1 then ccl = l else ccl = 0 end | if cc == 1 then ccl = l else ccl = 0 end | ||
normalSum = normalSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor(((ccl) + 999) / 1000)) + math.max(0, (ccl) - 1) * 1 / 100)) * mb * math.pow(ms + 0.03 - (ms + 0.03 - 1.05) * l / (maxTL / 2 + l), l)) | normalSum = normalSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor(((ccl) + 999) / 1000)) + math.max(0, (ccl) - 1) * 1 / 100)) * mb * math.pow(ms + 0.03 - (ms + 0.03 - 1.05) * l / (maxTL / 2 + l), l)) | ||
end | end | ||
VariablesLua.vardefine( matNorm, normalSum) | VariablesLua.vardefine( "matNorm", normalSum) | ||
local bonusSum = 0 | local bonusSum = 0 | ||
for | if bonusTL > 0 then | ||
for b = 0, bonusTL - 1 do | |||
l = b + maxTL | |||
if cc == 1 then ccl = l else ccl = 0 end | |||
bonusSum = bonusSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor(((ccl) + 999) / 1000)) + math.max(0, (ccl) - 1) * 1 / 100)) * mb * math.pow(ms + 0.03 - (ms + 0.03 - 1.05) * l / (maxTL / 2 + l), l)) | |||
end | |||
end | end | ||
VariablesLua.vardefine( matBonus, bonusSum ) | VariablesLua.vardefine( "matBonus", bonusSum ) | ||
local totalSum = normalSum + bonusSum | local totalSum = normalSum + bonusSum | ||
VariablesLua.vardefine( matTotal, totalSum ) | VariablesLua.vardefine( "matTotal", totalSum ) | ||
end | end | ||
return calc | return calc |
Latest revision as of 15:35, 21 November 2023
Documentation for this module may be created at Module:ConsCalcs/doc
local calc = {}
VariablesLua = mw.ext.VariablesLua
function calc.salt(frame)
-- "TowerSaltCost" = FLOOR.MATH(MAX(0.2, 1 - (MIN(0.1, 0.1 * FLOOR.MATH((CCL + 999) / 1000)) + MAX(0, CCL - 1) * CCB / 100)) * SB * (TL + 1))
local frameArgs = frame.args
local sb = tonumber(frameArgs.sb) -- Salt Base Value
local cc = tonumber(frameArgs.cc) -- Cost Cruncher (Only to be used for Cost Cruncher)
local maxTL = tonumber(frameArgs.maxTL) -- Default Total Tower Level
local bonusTL = tonumber(frameArgs.bonusTL) -- Bonus Total Tower Level
local ccb = 1 -- Cost Cruncher base Bonus (hard-coded at 1)
local ccl = 0
local normalSum = 0
for l = 0, maxTL - 1 do
if cc == 1 then ccl = l else ccl = 0 end
normalSum = normalSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor((ccl + 999) / 1000)) + math.max(0, ccl - 1) * ccb / 100)) * sb * (l + 1))
end
VariablesLua.vardefine( "saltNorm", normalSum)
local bonusSum = 0
if bonusTL > 0 then
for b = 0, bonusTL - 1 do
l = b + maxTL
if cc == 1 then ccl = l else ccl = 0 end
bonusSum = bonusSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor((ccl + 999) / 1000)) + math.max(0, ccl - 1) * ccb / 100)) * sb * (l + 1))
end
end
VariablesLua.vardefine( "saltBonus", bonusSum )
local totalSum = normalSum + bonusSum
VariablesLua.vardefine( "saltTotal", totalSum )
end
function calc.mat(frame)
-- "TowerMatCost" = FLOOR.MATH(MAX(.2, 1 - (MIN(.1, .1 * FLOOR.MATH(((CCL) + 999) / 1e3)) + MAX(0, (CCL) - 1) * 1 / 100)) * MB * POWER(MS + .03 - (MS + .03 - 1.05) * TL / (TML / 2 + TL), TL))
local frameArgs = frame.args
local mb = tonumber(frameArgs.mb) -- Material Base Value
local ms = tonumber(frameArgs.ms) -- Material Scaling Value
local cc = tonumber(frameArgs.cc) -- Cost Cruncher (Only to be used for Cost Cruncher)
local maxTL = tonumber(frameArgs.maxTL) -- Default Total Tower Level
local bonusTL = tonumber(frameArgs.bonusTL) -- Bonus Total Tower Level
local ccb = 1 -- Cost Cruncher base Bonus (hard-coded at 1)
local ccl = 0
local normalSum = 0
for l = 0, maxTL - 1 do
if cc == 1 then ccl = l else ccl = 0 end
normalSum = normalSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor(((ccl) + 999) / 1000)) + math.max(0, (ccl) - 1) * 1 / 100)) * mb * math.pow(ms + 0.03 - (ms + 0.03 - 1.05) * l / (maxTL / 2 + l), l))
end
VariablesLua.vardefine( "matNorm", normalSum)
local bonusSum = 0
if bonusTL > 0 then
for b = 0, bonusTL - 1 do
l = b + maxTL
if cc == 1 then ccl = l else ccl = 0 end
bonusSum = bonusSum + math.floor(math.max(0.2, 1 - (math.min(0.1, 0.1 * math.floor(((ccl) + 999) / 1000)) + math.max(0, (ccl) - 1) * 1 / 100)) * mb * math.pow(ms + 0.03 - (ms + 0.03 - 1.05) * l / (maxTL / 2 + l), l))
end
end
VariablesLua.vardefine( "matBonus", bonusSum )
local totalSum = normalSum + bonusSum
VariablesLua.vardefine( "matTotal", totalSum )
end
return calc