mirror of
https://github.com/Xevion/research-multipliers.git
synced 2025-12-10 06:08:17 -06:00
multiplier applicator logic
This commit is contained in:
@@ -41,5 +41,34 @@ for name, technology in pairs(data.raw.technology) do
|
||||
log(name .. " : trigger=" .. technology.research_trigger.type)
|
||||
end
|
||||
|
||||
-- TODO: Reduce multiplier precision to 3 decimal places
|
||||
|
||||
-- don't apply multiplier if it would do nothing
|
||||
if (multiplier == 1) then
|
||||
goto continue;
|
||||
elseif (multiplier <= 0) then
|
||||
log("Multiplier is less than 0, skipping " .. name .. " (" .. multiplier .. ")")
|
||||
goto continue;
|
||||
end
|
||||
|
||||
-- Multiplier has been calculated, apply it
|
||||
if (technology.unit.count_formula) then
|
||||
-- formula-based
|
||||
if (multiplier < 1) then
|
||||
-- if multiplier is less than 100%, we need to ensure the result is at least 1
|
||||
-- MathExpression has a max() function for formulas
|
||||
technology.unit.count_formula = 'max(1, ' .. technology.unit.count_formula .. ')*' .. multiplier
|
||||
else
|
||||
technology.unit.count_formula = '(' .. technology.unit.count_formula .. ')*' .. multiplier
|
||||
end
|
||||
else
|
||||
-- simple count
|
||||
if (multiplier < 1) then
|
||||
technology.unit.count = math.max(math.ceil(technology.unit.count*multiplier), 1)
|
||||
else
|
||||
technology.unit.count = technology.unit.count*multiplier;
|
||||
end
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
Reference in New Issue
Block a user