Skip to content

Commit

Permalink
Tweak traction parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
StyledStrike committed Dec 18, 2024
1 parent eb54db0 commit d5baa94
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 48 deletions.
9 changes: 5 additions & 4 deletions lua/entities/base_glide/sv_wheels.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ function ENT:WheelInit()
brakePower = 3000,

-- Side traction
tractionMultiplier = 30,
tractionCurveMinAng = 60,
tractionCurveMin = 2800.0,
tractionCurveMax = 1600.0
tractionMultiplier = 25,
tractionCurveMinAng = 25,
tractionCurveMin = 3000,
tractionCurveMax = 900,
tractionExtra = 2
}
end

Expand Down
15 changes: 1 addition & 14 deletions lua/entities/base_glide_car/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function ENT:OnPostInitialize()
self:SetBrakePower( params.brakePower )

-- Side traction parameters
self:SetTractionBias( -0.15 )
self:SetTractionBias( 0.0 )
self:SetTractionMultiplier( params.tractionMultiplier )
self:SetTractionCurveMinAng( params.tractionCurveMinAng )
self:SetTractionCurveMin( params.tractionCurveMin )
Expand Down Expand Up @@ -509,19 +509,6 @@ function ENT:CreateWheel( offset, params )
return wheel
end

--- Implement this base class function.
function ENT:OnSimulatePhysics( phys, dt, outLin, _ )
if self.groundedCount < 1 then return end

local rt = self:GetRight()
local cornerForce = rt:Dot( phys:GetVelocity() ) * phys:GetMass() * self.ExtraCorneringForce
local force = ( self:GetForward() * Abs( cornerForce ) ) - ( cornerForce * rt )

outLin[1] = outLin[1] + force[1] * dt
outLin[2] = outLin[2] + force[2] * dt
outLin[3] = outLin[3] + force[3] * dt
end

local traction, tractionFront, tractionRear
local frontTorque, rearTorque, steerAngle, frontBrake, rearBrake, frontVelMult, rearVelMult
local groundedCount, rpm, avgRPM, totalSideSlip, totalForwardSlip
Expand Down
5 changes: 1 addition & 4 deletions lua/entities/base_glide_car/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,8 @@ if SERVER then
-- Bodygroup toggles for break, reverse and headlights
ENT.LightBodygroups = {}

-- Extra force applied when slipping sideways
ENT.ExtraCorneringForce = 20

-- How much force to apply when trying to turn while doing a burnout?
ENT.BurnoutForce = 45
ENT.BurnoutForce = 35

-- How much force to apply when the driver tries to unflip the vehicle?
ENT.UnflipForce = 3
Expand Down
10 changes: 9 additions & 1 deletion lua/entities/base_glide_car/sv_engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,16 @@ function ENT:AutoGearSwitch( throttle )
return
end

-- While not on ground, first gear
if self.groundedCount < self.wheelCount then
if self:GetGear() < 1 then
self:SwitchGear( 1, 0 )
end

return
end

if self.forwardSpeed < 0 and throttle < 0.1 then return end
if self.groundedCount < self.wheelCount then return end
if Abs( self.avgForwardSlip ) > 1 then return end

local minRPM, maxRPM = self:GetMinRPM(), self:GetMaxRPM()
Expand Down
15 changes: 7 additions & 8 deletions lua/entities/base_glide_motorcycle/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ function ENT:OnPostInitialize()

-- Change steering parameters to better suit bikes
self:SetSteerConeChangeRate( 10 )
self:SetSteerConeMaxSpeed( 1000 )
self:SetSteerConeMaxSpeed( 1200 )
self:SetSteerConeMaxAngle( 0.15 )
self:SetPowerDistribution( -1 )

-- Change slip parameters to better suit bikes
self:SetExtremumValue( 7 )
self:SetAsymptoteSlip( 0.8 )
self:SetAsymptoteValue( 3 )

self:SetMaxSlip( 35 )
self:SetSlipForce( 50 )
-- Change traction parameters to better suit bikes
self:SetTractionBias( -0.3 )
self:SetTractionMultiplier( 50 )
self:SetTractionCurveMinAng( 70 )
self:SetTractionCurveMin( 4500 )
self:SetTractionCurveMax( 3500 )
end

function ENT:SetStaySpright( toggle )
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/base_glide_motorcycle/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if SERVER then
ENT.AirMaxAngularVelocity = Vector( 600, 600, 500 ) -- Roll, pitch, yaw

-- Bike-specific variables
ENT.TiltForce = 600
ENT.TiltForce = 550
ENT.YawDrag = -5

ENT.KeepUprightForce = 1500
Expand Down
2 changes: 0 additions & 2 deletions lua/entities/base_glide_plane/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ function ENT:OnPostInitialize()
params.suspensionLength = 10
params.springStrength = 1000
params.springDamper = 4000

-- TODO: traction parameters
end

--- Override this base class function.
Expand Down
5 changes: 4 additions & 1 deletion lua/entities/base_glide_tank/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ function ENT:OnPostInitialize()
params.springStrength = 6000
params.springDamper = 30000

-- TODO: traction parameters
params.tractionMultiplier = 800
params.tractionCurveMinAng = 70
params.tractionCurveMin = 25000.0
params.tractionCurveMax = 22000.0

self:SetEngineThrottle( 0 )
self:SetEnginePower( 0 )
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/base_glide_tank/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ if SERVER then
ENT.EngineTorque = 40000

-- How much extra torque to apply when trying to spin in place?
ENT.SpinEngineTorqueMultiplier = 2
ENT.SpinEngineTorqueMultiplier = 3

ENT.MaxSpeed = 700
ENT.MaxSteerAngle = 35
Expand Down
1 change: 1 addition & 0 deletions lua/entities/glide_wheel/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ function ENT:DoPhysics( vehicle, phys, params, traceData, outLin, outAng, dt )
maxTraction = TractionCurve( slipAngle )
sideTraction = -rt:Dot( vel * params.tractionMultiplier )
sideTraction = Clamp( sideTraction, -maxTraction, maxTraction )
sideTraction = sideTraction - velR * params.tractionExtra

force:Add( sideTraction * tractionMult * rt )

Expand Down
7 changes: 4 additions & 3 deletions lua/entities/gtav_airbus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ if SERVER then
self:SetMinRPMTorque( 1100 )
self:SetMaxRPMTorque( 1200 )

self:SetSlipForce( 110 )
self:SetExtremumValue( 6 )
self:SetAsymptoteValue( 2.5 )
self:SetTractionBias( -0.25 )
self:SetTractionMultiplier( 60 )
self:SetTractionCurveMin( 3000 )
self:SetTractionCurveMax( 2500 )

self:CreateSeat( Vector( 230, 35.5, -4 ), Angle( 0, 270, -5 ), Vector( 250, -100, 5 ), true )

Expand Down
9 changes: 7 additions & 2 deletions lua/entities/gtav_blazer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,13 @@ if SERVER then
}

function ENT:CreateFeatures()
self:SetSteerConeChangeRate( 10 )
self:SetSteerConeMaxSpeed( 1000 )
self:SetSteerConeMaxAngle( 0.2 )
self:SetSteerConeMaxSpeed( 800 )

self:SetTractionBias( -0.1 )
self:SetTractionCurveMinAng( 50 )
self:SetTractionCurveMin( 2000 )
self:SetTractionCurveMax( 1000 )

self:SetPowerDistribution( -0.7 )
self:SetDifferentialRatio( 1.2 )
Expand Down
5 changes: 3 additions & 2 deletions lua/entities/gtav_gauntlet_classic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if SERVER then
duplicator.RegisterEntityClass( "gtav_gauntlet_classic", Glide.VehicleFactory, "Data" )

ENT.SpawnPositionOffset = Vector( 0, 0, 30 )
ENT.BurnoutForce = 65
ENT.BurnoutForce = 40

function ENT:GetGears()
return {
Expand All @@ -83,8 +83,9 @@ if SERVER then
}

function ENT:CreateFeatures()
self:SetWheelInertia( 9 )
self:SetWheelInertia( 10 )
self:SetDifferentialRatio( 1.9 )
self:SetTractionMultiplier( 30 )

self:SetMaxRPM( 25000 )
self:SetMinRPMTorque( 1200 )
Expand Down
2 changes: 1 addition & 1 deletion lua/entities/gtav_sanchez.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if SERVER then

ENT.SpawnPositionOffset = Vector( 0, 0, 40 )
ENT.StartupTime = 0.4
ENT.BurnoutForce = 180
ENT.BurnoutForce = 200

ENT.LightBodygroups = {
{ type = "headlight", bodyGroupId = 6, subModelId = 1 }, -- Headlight
Expand Down
6 changes: 3 additions & 3 deletions lua/entities/gtav_speedo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if SERVER then

ENT.SpawnPositionOffset = Vector( 0, 0, 50 )
ENT.ChassisMass = 900
ENT.BurnoutForce = 50
ENT.BurnoutForce = 30

ENT.AirControlForce = Vector( 0.4, 0.2, 0.1 ) -- Roll, pitch, yaw
ENT.AirMaxAngularVelocity = Vector( 200, 200, 150 ) -- Roll, pitch, yaw
Expand All @@ -66,11 +66,11 @@ if SERVER then
self:SetWheelInertia( 10 )
self:SetSpringStrength( 700 )
self:SetSteerConeMaxSpeed( 1000 )
self:SetAsymptoteValue( 1.5 )
self:SetTractionBias( -0.15 )

self:SetDifferentialRatio( 2.3 )
self:SetTransmissionEfficiency( 0.75 )
self:SetPowerDistribution( -0.75 )
self:SetPowerDistribution( 0.8 )
self:SetBrakePower( 3000 )

self:SetMinRPMTorque( 1000 )
Expand Down
1 change: 1 addition & 0 deletions lua/entities/gtav_strikeforce.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ if SERVER then
self.wheelParams.springStrength = 1500
self.wheelParams.springDamper = 6000
self.wheelParams.brakePower = 2000
self.wheelParams.tractionMultiplier = 40

-- Front
self:CreateWheel( Vector( 180, -12, -25 ), {
Expand Down
3 changes: 2 additions & 1 deletion lua/entities/gtav_wolfsbane.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ if SERVER then
ENT.SpawnPositionOffset = Vector( 0, 0, 30 )
ENT.StartupTime = 0.5

ENT.BurnoutForce = 150
ENT.BurnoutForce = 160
ENT.WheelieForce = 400

ENT.LightBodygroups = {
Expand All @@ -135,6 +135,7 @@ if SERVER then
self:SetDifferentialRatio( 1.8 )
self:SetBrakePower( 2000 )
self:SetWheelInertia( 9 )
self:SetTractionBias( -0.35 )

self:SetMaxRPM( 15000 )
self:SetMinRPMTorque( 500 )
Expand Down

0 comments on commit d5baa94

Please sign in to comment.