Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions gamedata/alldefs_post.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ end
-- DEFS POST PROCESSING
-------------------------

local modOptions = Spring.GetModOptions()

local wreckMetalRatio = 0.6
local heapMetalRatio = 0.25

if modOptions.wreckage_metal_ratio ~= 0.6 then
-- An actual f(x): [0,1] -> [0,1/3], with f(0.6)=0.25 would be a hermite polynomial or something
local low, mid, high = 0, 1 / 3, 1 -- so ignore that and do something over-simple, because, gamedev
wreckMetalRatio = math.clamp(modOptions.wreckage_metal_ratio, low, high)
heapMetalRatio = math.clamp((wreckMetalRatio + 0.15) / 3, low, mid)
end

--[[ 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). ]]
Expand Down Expand Up @@ -75,8 +87,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

Expand Down Expand Up @@ -920,14 +930,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
Expand Down
4 changes: 4 additions & 0 deletions luaui/Widgets/gui_reclaim_field_highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
if Spring.GetModOptions().wreckage_metal_ratio then
local ratio = Spring.GetModOptions().wreckage_metal_ratio / 0.6 -- 0.3333 to 1.25
minFeatureValue = minFeatureValue * (ratio ^ 1 / 3) -- gravitate strongly 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
Expand Down
13 changes: 13 additions & 0 deletions modoptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,19 @@ local options = {
section = "options",
},

{
key = "wreckage_metal_ratio",
name = "Unit Wreck Metal Percentage",
desc = "Percent of unit metal that is left in its wrecks (and heaps)",
hidden = true,
type = "number",
section = "options",
def = 0.6,
min = 0, -- see usage in alldefs_post for actual bounds
max = 1,
step = 0.05,
},

{
key = "coop",
name = "Cooperative mode",
Expand Down
Loading