Skip to content

Commit

Permalink
Scale effects and value by enchant capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaakma committed Jun 2, 2022
1 parent a26cdbf commit bff8434
Show file tree
Hide file tree
Showing 4 changed files with 423 additions and 402 deletions.
47 changes: 31 additions & 16 deletions Data Files/MWSE/mods/mer/drip/components/Loot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,9 @@ function Loot:new(lootData)
loot:applyModifications()
loot:applyMultipliers()

--Roll for wild

--Try build name with wild parameter
--If name too long, cancel wild



loot.object.enchantment = Loot:makeComplexEnchantment(loot.modifiers)
loot:applyEnchantCapacityScaling()

logger:debug("Checking for wild")
if loot:canHaveWild() and loot:rollForWild() then
Expand Down Expand Up @@ -103,7 +98,8 @@ end
function Loot:applyValueModifiers()
for _, modifier in ipairs(self.modifiers) do
if modifier.value then
self.object.value = self.object.value + modifier.value
local enchantCapacityMultiplier = self:getEnchantCapacityMultiplier()
self.object.value = self.object.value + (modifier.value * enchantCapacityMultiplier)
end
end
for _, modifier in ipairs(self.modifiers) do
Expand All @@ -130,6 +126,34 @@ function Loot:applyModifications()
end
end

function Loot:getEnchantCapacityMultiplier()
local enchantCapacity = math.min(self.baseObject.enchantCapacity, config.maxEnchantCapacty)
local enchantCapacityEffect = math.remap(enchantCapacity, config.minEnchantCapacity, config.maxEnchantCapacty, 1, config.maxEnchantEffect)
logger:debug("%s enchant capacity: %s, effect: %s", self.baseObject.name, enchantCapacity, enchantCapacityEffect)
return enchantCapacityEffect
end

--[[
For each effect in each modifier, scale the min and max values by the enchant capacity of the base object
]]
function Loot:applyEnchantCapacityScaling()
local enchantCapacityEffect = self:getEnchantCapacityMultiplier()
---@param modifier DripModifier
if self.object.enchantment then
---@param effect tes3effect
for _, effect in ipairs(self.object.enchantment.effects) do
if effect.min and effect.max and effect.min > 0 then
logger:debug("new min: %s", effect.min * enchantCapacityEffect)
effect.min = math.ceil(effect.min * enchantCapacityEffect)
logger:debug("new max: %s", effect.max * enchantCapacityEffect)
effect.max = math.ceil(effect.max * enchantCapacityEffect)
end
if effect.duration then
effect.duration = math.ceil(effect.duration * enchantCapacityEffect)
end
end
end
end

function Loot:applyMultipliers()
for _, modifier in ipairs(self.modifiers) do
Expand Down Expand Up @@ -157,13 +181,6 @@ function Loot:removeMaterialPrefix(name)
end

return name
-- local split = string.split(name, " ")
-- local prefix = split[1]:lower()
-- if config.materials[prefix] then
-- return string.sub(name, string.len(prefix) + 2)
-- else
-- return name
-- end
end

function Loot:getLootName(e)
Expand Down Expand Up @@ -215,9 +232,7 @@ end
---@param effects DripModifierEffect[]
function Loot:mergeEffects(effects)
--Compare effects in list to find duplicates

local duplicates = {}

for i, effectOuter in ipairs(effects) do
for j, effectInner in ipairs(effects) do
if j > i then --only look at effects after this one to avoid checking twice
Expand Down
23 changes: 14 additions & 9 deletions Data Files/MWSE/mods/mer/drip/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ Drip adds Diablo 2 style loot to Morrowind. Unique weapons, armor, clothing and
selfRepairPercentPerHour = 1,
multiplierFieldDecimals= {
speed = 2,
}
},
minEnchantCapacity = 10,
maxEnchantCapacty = 500,
maxEnchantEffect = 5,
--registered configs
materials = {},
modifiers = {
prefixes = {},
suffixes = {},
},
weapons = {},
clothing = {},
armor = {},
}
local cache
config.materials = {}
config.modifiers = {
prefixes = {},
suffixes = {},
}
config.weapons = {}
config.clothing = {}
config.armor = {}


--Static Configs

Expand Down
Loading

0 comments on commit bff8434

Please sign in to comment.
  翻译: