don't spam logs if formula calculates 0

This commit is contained in:
Lilian Jónsdóttir 2021-08-08 20:12:01 -07:00
parent 226942e931
commit 9ec8148562

View file

@ -49,37 +49,37 @@ local function sinkInWater(e)
if config.playerOnly and mobile.actorType ~= tes3.actorType.player then return end if config.playerOnly and mobile.actorType ~= tes3.actorType.player then return end
local downPull = 0 local downPull = 0
local debugStr = ""
-- calculate the down-pull with the configured formula -- calculate the down-pull with the configured formula
if config.mode == common.modes.equippedArmour then if config.mode == common.modes.equippedArmour then
local armourClass = getTotalArmourClass(actor) local armourClass = getTotalArmourClass(actor)
downPull = (config.downPullMultiplier / 10) * armourClass downPull = (config.downPullMultiplier / 10) * armourClass
if config.debug then debugStr = string.format("Pulling %s down by %s using equipped armour mode (%s total armour class)",
common.log("Pulling %s down by %s using equipped armour mode (%s total armour class)", ref.id, downPull, armourClass)
ref.id, downPull, armourClass)
end
elseif config.mode == common.modes.allEquipment then elseif config.mode == common.modes.allEquipment then
local totalWeight = getTotalEquipmentWeight(actor) local totalWeight = getTotalEquipmentWeight(actor)
-- doubling this keeps this formula somewhat uniform with armour class @ multiplier 100 -- doubling this keeps this formula somewhat uniform with armour class @ multiplier 100
downPull = ((config.downPullMultiplier / 100) * totalWeight) * 2 downPull = ((config.downPullMultiplier / 100) * totalWeight) * 2
if config.debug then debugStr = string.format("Pulling %s down by %s using equipment weight mode (%s total equipment weight)",
common.log("Pulling %s down by %s using equipment weight mode (%s total equipment weight)", ref.id, downPull, totalWeight)
ref.id, downPull, totalWeight)
end
elseif config.mode == common.modes.encumbrancePercentage then elseif config.mode == common.modes.encumbrancePercentage then
local encumbrance = mobile.encumbrance local encumbrance = mobile.encumbrance
-- tripling this keeps this formula somewhat uniform with armour class @ multiplier 100 -- tripling this keeps this formula somewhat uniform with armour class @ multiplier 100
downPull = (config.downPullMultiplier * encumbrance.normalized) * 3 downPull = (config.downPullMultiplier * encumbrance.normalized) * 3
if config.debug then debugStr = string.format("Pulling %s down by %s using encumbrance mode (%s/%s = %s encumbrance)",
common.log("Pulling %s down by %s using encumbrance mode (%s/%s = %s encumbrance)", ref.id, downPull, encumbrance.current, encumbrance.base, encumbrance.normalized)
ref.id, downPull, encumbrance.current, encumbrance.base, encumbrance.normalized)
end
end end
-- finally add down-pull from configured formula to tes3.mobilePlayer.velocity.z to simulate being pulled down -- finally add down-pull from configured formula to tes3.mobilePlayer.velocity.z to simulate being pulled down
if downPull ~= 0 then mobile.velocity.z = -downPull end if downPull ~= 0 then
mobile.velocity.z = -downPull
if config.debug then
common.log(debugStr)
end
end
end end
local function onInitialized() local function onInitialized()