Skip to content

Commit

Permalink
Clamp Engine Loaded Torque
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyunge committed Apr 17, 2024
1 parent 05e9388 commit d2e1d53
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lua/entities/acf_engine_update/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,9 @@ function ENT:CalcRPM(SelfTbl)
end
if ( GearboxCount > 0 ) then
GearboxRPM = GearboxRPM / GearboxCount
GearboxLoad = GearboxLoad / GearboxCount
-- GearboxLoad = GearboxLoad / GearboxCount
end

-- Calculate Engine Vacuum
SelfTbl.EngineBrakeTorque = SelfTbl.Displacement * (SelfTbl.FlyRPM / 60) * (1 - Throttle)

Expand All @@ -790,7 +790,7 @@ function ENT:CalcRPM(SelfTbl)
-- Calculate Engine Speed @ Gearbox Load
local SpeedDifference = math.max(0,GearboxRPM) - SelfTbl.FlyRPM

local EngineSpeed_Loaded = ( (SpeedDifference / 6) / SelfTbl.Inertia )
local EngineSpeed_Loaded = math.Clamp( ( (SpeedDifference / 6) / SelfTbl.Inertia ), -SelfTbl.PeakTorque, SelfTbl.PeakTorque )

-- Mix Unloaded & Loaded Engine Speeds.
local EngineSpeed = ( EngineSpeed_NoLoad * ( 1 - GearboxLoad ) ) + ( EngineSpeed_Loaded * GearboxLoad )
Expand All @@ -805,7 +805,6 @@ function ENT:CalcRPM(SelfTbl)
end
SelfTbl.FlyRPM = max( 0, SelfTbl.FlyRPM )


SelfTbl.FlywheelInertiaTorque = (SelfTbl.FlyRPM - SelfTbl.SpeedChange) / 60
SelfTbl.SpeedChange = SelfTbl.FlyRPM

Expand Down

0 comments on commit d2e1d53

Please sign in to comment.