1
0
mirror of https://github.com/IkarusHD/ICF-3.git synced 2025-03-04 03:03:12 -05:00

Update init.lua to solve weight inaccuracy

Resolves an issue introduced with gun scaling corrections (e5fa45de64) where guns, if they had a corrective scale factor, did not weigh what they should
This commit is contained in:
yoseij 2024-12-23 19:39:25 -08:00 committed by GitHub
parent 387945561c
commit 2988315445
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -114,14 +114,13 @@ do -- Spawn and Update functions --------------------------------
return Result
end
local function GetMass(Model, PhysObj, Class, Weapon)
if Weapon then return Weapon.Mass end
local Volume = PhysObj:GetVolume()
local Factor = Volume / ModelData.GetModelVolume(Model)
return math.Round(Class.Mass * Factor)
end
local function GetMass(Caliber, Class, Weapon)
if Weapon then return Weapon.Mass end
local Factor = Caliber / Class.Caliber.Base
return math.Round(Class.Mass * Factor ^ 3) -- 3d space so scaling has a cubing effect
end
local function UpdateWeapon(Entity, Data, Class, Weapon)
local Model = Weapon and Weapon.Model or Class.Model
@ -190,7 +189,7 @@ do -- Spawn and Update functions --------------------------------
local PhysObj = Entity.ACF.PhysObj
if IsValid(PhysObj) then
local Mass = GetMass(Model, PhysObj, Class, Weapon)
local Mass = GetMass(Caliber, Class, Weapon)
Contraption.SetMass(Entity, Mass)
end