diff --git a/gamedata/alldefs_post.lua b/gamedata/alldefs_post.lua index d3e699229cf..b40b420382e 100644 --- a/gamedata/alldefs_post.lua +++ b/gamedata/alldefs_post.lua @@ -41,6 +41,11 @@ end -- DEFS POST PROCESSING ------------------------- +local modOptions = Spring.GetModOptions() + +local wreckMetalRatio = math.clamp(modOptions.wreck_metal_ratio, 0, 1) +local heapMetalRatio = math.clamp(modOptions.heap_metal_ratio, 0, wreckMetalRatio) + --[[ Sanitize to whole frames (plus leeways because float arithmetic is bonkers). The engine uses full frames for actual reload times, but forwards the raw value to LuaUI (so for example calculated DPS is incorrect without sanitisation). ]] @@ -75,8 +80,6 @@ local function processWeapons(unitDefName, unitDef) end function UnitDef_Post(name, uDef) - local modOptions = Spring.GetModOptions() - local isScav = string.sub(name, -5, -1) == "_scav" local basename = isScav and string.sub(name, 1, -6) or name @@ -920,14 +923,14 @@ function UnitDef_Post(name, uDef) if uDef.featuredefs.dead then uDef.featuredefs.dead.damage = uDef.health if uDef.metalcost and uDef.energycost then - uDef.featuredefs.dead.metal = math.floor(uDef.metalcost * 0.6) + uDef.featuredefs.dead.metal = math.floor(uDef.metalcost * wreckMetalRatio) end end -- heaps if uDef.featuredefs.heap then uDef.featuredefs.heap.damage = uDef.health if uDef.metalcost and uDef.energycost then - uDef.featuredefs.heap.metal = math.floor(uDef.metalcost * 0.25) + uDef.featuredefs.heap.metal = math.floor(uDef.metalcost * heapMetalRatio) end end end diff --git a/luaui/Widgets/gui_reclaim_field_highlight.lua b/luaui/Widgets/gui_reclaim_field_highlight.lua index 634c1f7c216..2ae996e4cbf 100644 --- a/luaui/Widgets/gui_reclaim_field_highlight.lua +++ b/luaui/Widgets/gui_reclaim_field_highlight.lua @@ -74,6 +74,10 @@ local checkFrequency = 0.66 -- Update rate, in seconds local epsilon = 300 -- Clustering distance - increased to merge nearby fields and prevent overlaps local minFeatureValue = 9 +do + local ratio = math.clamp(Spring.GetModOptions().wreck_metal_ratio / 0.6, 0, 1.5) + minFeatureValue = minFeatureValue * (0.75 + ratio * 0.25) -- gravitate toward 1 +end -- Maximum cluster size in elmos - clusters larger than this will be split into sub-clusters local maxClusterSize = 3000 -- Adjust this value: smaller = more sub-clusters, larger = fewer but bigger fields diff --git a/modoptions.lua b/modoptions.lua index b2e0486da82..c880d814157 100644 --- a/modoptions.lua +++ b/modoptions.lua @@ -505,6 +505,32 @@ local options = { section = "options", }, + { + key = "wreck_metal_ratio", + name = "Wreck Metal Percent", + desc = "Percent of unit metal that is left in its wrecks", + hidden = true, + type = "number", + section = "options", + def = 0.6, + min = 0, -- see usage in alldefs_post when changing actual bounds + max = 1, + step = 0.05, + }, + + { + key = "heap_metal_ratio", + name = "Heap Metal Percent", + desc = "Percent of unit metal that is left in its heaps", + hidden = true, + type = "number", + section = "options", + def = 0.25, + min = 0, + max = 1, -- bounded in alldefs_post to wreck_metal_ratio + step = 0.05, + }, + { key = "coop", name = "Cooperative mode",