separately configurable multipliers

This commit is contained in:
Lilian Jónsdóttir 2021-08-11 09:48:28 -07:00
parent e79c142fe9
commit 07dc43b40c
3 changed files with 30 additions and 16 deletions

View file

@ -1,6 +1,17 @@
local common = require("celediel.ASinkingFeeling.common")
local defaultConfig = {enabled = true, debug = false, playerOnly = false, downPullMultiplier = 100, mode = common.modes.equippedArmour.value}
local defaultConfig = {
enabled = true,
debug = false,
playerOnly = false,
multipliers = {
equippedArmour = 100,
allEquipment = 100,
encumbrancePercentage = 100
},
mode = common.modes.equippedArmour.value
}
local config = mwse.loadConfig(common.configString, defaultConfig)
return config

View file

@ -37,7 +37,7 @@ local formulas = {}
formulas.equippedArmour = function(actor, ref)
local armourClass = getTotalArmourClass(actor)
local downPull = (config.downPullMultiplier / 10) * armourClass
local downPull = (config.multipliers.equippedArmour / 10) * armourClass
local debugStr = string.format("Pulling %s down by %s using equipped armour mode (%s total armour class)",
ref.id, downPull, armourClass)
return downPull, debugStr
@ -46,7 +46,7 @@ end
formulas.allEquipment = function(actor, ref)
local totalWeight = getTotalEquipmentWeight(actor)
-- doubling this keeps this formula somewhat uniform with armour class @ multiplier 100
local downPull = ((config.downPullMultiplier / 100) * totalWeight) * 2
local downPull = ((config.multipliers.allEquipment / 100) * totalWeight) * 2
local debugStr = string.format("Pulling %s down by %s using equipment weight mode (%s total equipment weight)",
ref.id, downPull, totalWeight)
return downPull, debugStr
@ -56,8 +56,8 @@ formulas.allEquipmentNecroEdit = function(actor, ref)
local totalWeight = getTotalEquipmentWeight(actor)
-- Thanks Necrolesian for this formula
-- https://forums.nexusmods.com/index.php?/topic/10349253-a-sinking-feeling/page-2#entry97870268
local term1 = ((config.downPullMultiplier / 100) * totalWeight) * 2
local term2 = ((config.downPullMultiplier / 100) * (totalWeight - 135) * 0.2) + 270
local term1 = ((config.multipliers.allEquipment / 100) * totalWeight) * 2
local term2 = ((config.multipliers.allEquipment / 100) * (totalWeight - 135) * 0.2) + 270
local downPull = math.min(term1, term2)
local debugStr = string.format("Pulling %s down by %s (instead of %s) using equipment weight mode (necro edit) (%s total equipment weight)",
ref.id, downPull, math.max(term1, term2), totalWeight)
@ -67,7 +67,7 @@ end
formulas.encumbrancePercentage = function(mobile, ref)
local encumbrance = mobile.encumbrance
-- tripling this keeps this formula somewhat uniform with armour class @ multiplier 100
local downPull = (config.downPullMultiplier * encumbrance.normalized) * 3
local downPull = (config.multipliers.encumbrancePercentage * encumbrance.normalized) * 3
local debugStr = string.format("Pulling %s down by %s using encumbrance mode (%s/%s = %s encumbrance)",
ref.id, downPull, encumbrance.current, encumbrance.base, encumbrance.normalized)
return downPull, debugStr

View file

@ -1,7 +1,7 @@
local common = require("celediel.ASinkingFeeling.common")
local config = require("celediel.ASinkingFeeling.config")
local function createTableVar(id) return mwse.mcm.createTableVariable {id = id, table = config} end
local function createTableVar(id) return mwse.mcm.createTableVariable({id = id, table = config}) end
local function createDescriptions()
local description = "Formula used to calculate down-pull amount.\n\nOptions are: "
@ -65,15 +65,18 @@ category:createDropdown({
variable = createTableVar("mode")
})
category:createSlider({
label = "Down-pull multiplier",
description = "Multiplier used in the selected formula.\n\nDefault value of 100 acts similarly in all formulas.",
variable = createTableVar("downPullMultiplier"),
for name, _ in pairs(config.multipliers) do
local title = common.camelCaseToWords(name)
category:createSlider({
label = title .. " multiplier",
description = "Multiplier used for " .. title .." formula. Default value: 100",
variable = mwse.mcm.createTableVariable({id = name, table = config.multipliers}),
min = 0,
max = 300,
step = 1,
jump = 10
})
})
end
category:createYesNoButton({
label = "Debug logging",