From 07dc43b40cf47c25fa9c198845a5697ad6ef43d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Wed, 11 Aug 2021 09:48:28 -0700 Subject: [PATCH] separately configurable multipliers --- MWSE/mods/celediel/ASinkingFeeling/config.lua | 13 ++++++++++- MWSE/mods/celediel/ASinkingFeeling/main.lua | 10 ++++---- MWSE/mods/celediel/ASinkingFeeling/mcm.lua | 23 +++++++++++-------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/MWSE/mods/celediel/ASinkingFeeling/config.lua b/MWSE/mods/celediel/ASinkingFeeling/config.lua index 82d065d..671d1ae 100644 --- a/MWSE/mods/celediel/ASinkingFeeling/config.lua +++ b/MWSE/mods/celediel/ASinkingFeeling/config.lua @@ -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 diff --git a/MWSE/mods/celediel/ASinkingFeeling/main.lua b/MWSE/mods/celediel/ASinkingFeeling/main.lua index e7e7341..f8ec4be 100644 --- a/MWSE/mods/celediel/ASinkingFeeling/main.lua +++ b/MWSE/mods/celediel/ASinkingFeeling/main.lua @@ -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 diff --git a/MWSE/mods/celediel/ASinkingFeeling/mcm.lua b/MWSE/mods/celediel/ASinkingFeeling/mcm.lua index 399464b..59a60ef 100644 --- a/MWSE/mods/celediel/ASinkingFeeling/mcm.lua +++ b/MWSE/mods/celediel/ASinkingFeeling/mcm.lua @@ -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"), - min = 0, - max = 300, - step = 1, - jump = 10 -}) +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",