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

Merge pull request #442 from yoseij/patch-2

Update init.lua to solve weight inaccuracy
This commit is contained in:
march 2024-12-25 13:08:10 -08:00 committed by GitHub
commit 8176e1b420
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,7 +32,6 @@ local function UpdateTotalAmmo(Entity)
end
do -- Spawn and Update functions --------------------------------
local ModelData = ACF.ModelData
local WireIO = Utilities.WireIO
local Entities = Classes.Entities
local Weapons = Classes.Weapons
@ -114,14 +113,13 @@ do -- Spawn and Update functions --------------------------------
return Result
end
local function GetMass(Model, PhysObj, Class, Weapon)
if Weapon then return Weapon.Mass end
local function GetMass(Caliber, Class, Weapon)
if Weapon then return Weapon.Mass end
local Volume = PhysObj:GetVolume()
local Factor = Volume / ModelData.GetModelVolume(Model)
local Factor = Caliber / Class.Caliber.Base
return math.Round(Class.Mass * Factor)
end
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 +188,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