Skip to content

Commit

Permalink
Clamp armor thickness when surpassing mass limit
Browse files Browse the repository at this point in the history
  • Loading branch information
thecraftianman committed Nov 29, 2023
1 parent e6502e9 commit 1af8ce0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/weapons/gmod_tool/stools/acfarmorprop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ if CLIENT then

end

-- clamp thickness if the change in ductility puts mass out of range
-- Clamp thickness if the change in ductility puts mass out of range
cvars.AddChangeCallback("acfarmorprop_ductility", function(_, _, value)

local area = ArmorProp_Area:GetFloat()
Expand All @@ -257,7 +257,7 @@ if CLIENT then
end
end)

-- clamp ductility if the change in thickness puts mass out of range
-- Clamp ductility and thickness if the change in thickness puts mass out of range
cvars.AddChangeCallback("acfarmorprop_thickness", function(_, _, value)

local area = ArmorProp_Area:GetFloat()
Expand All @@ -274,6 +274,9 @@ if CLIENT then

ductility = -(39 * area * thickness - mass * 50000) / (39 * area * thickness)
ArmorProp_Ductility:SetFloat(math.Clamp(ductility * 100, -80, 80))

thickness = ACF_CalcArmor(area, ductility, mass)
ArmorProp_Thickness:SetFloat(math.Clamp(thickness, MinimumArmor, MaximumArmor))
end
end)

Expand Down

0 comments on commit 1af8ce0

Please sign in to comment.