Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/entities/base_glide_car/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ function ENT:DrawVehicleHUD( screenW, screenH )
local iconSize = size * 0.11
DrawIcon( x + size - iconSize, y + size - iconSize * 0.5, "glide/icons/engine.png", iconSize, self:IsEngineOn() and colors.icon or colors.iconDisabled )

-- Cruise control state
DrawIcon( x + size - iconSize * 2.12, y + size - iconSize * 0.5, "glide/icons/cruise_control.png", iconSize, self:GetIsCruiseControlEnabled() and colors.icon or colors.iconDisabled )

-- Engine RPM
local stream = self.stream
local meterR = r * 0.9
Expand Down
15 changes: 14 additions & 1 deletion lua/entities/base_glide_car/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ end
function ENT:OnDriverExit()
local keepOn = IsValid( self.lastDriver ) and self.lastDriver:KeyDown( IN_WALK )

if not self.hasTheDriverBeenRagdolled and not keepOn then
if not self.hasTheDriverBeenRagdolled and not keepOn and not self:GetIsCruiseControlEnabled() then
self:TurnOff()
end

Expand Down Expand Up @@ -247,6 +247,19 @@ function ENT:OnSeatInput( seatIndex, action, pressed )

elseif action == "accelerate" and self:GetEngineState() == 0 and self:GetEngineRPM() < 1 then
self:TurnOn()
elseif action == "toggle_cruise_control" then
self:SetIsCruiseControlEnabled( not self:GetIsCruiseControlEnabled() )

if not self:GetIsCruiseControlEnabled() then
self.cruiseTargetSpeed = 0
end

Glide.SendNotification( self:GetAllPlayers(), {
text = self:GetIsCruiseControlEnabled() and "#glide.notify.cruise_control_on" or "#glide.notify.cruise_control_off",
icon = "materials/glide/icons/car.png",
immediate = true,
formatArgs = { self:GetIsCruiseControlEnabled() and "on" or "off" }
} )
end

if not self.inputManualShift then return end
Expand Down
1 change: 1 addition & 0 deletions lua/entities/base_glide_car/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function ENT:SetupDataTables()
-- these slots when creating your own on child classes!
self:NetworkVar( "Bool", "IsRedlining" )
self:NetworkVar( "Bool", "IsHonking" )
self:NetworkVar( "Bool", "IsCruiseControlEnabled" )
self:NetworkVar( "Int", "SirenState" )

self:NetworkVar( "Int", "Gear" )
Expand Down
18 changes: 18 additions & 0 deletions lua/entities/base_glide_car/sv_engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ function ENT:EngineInit()
self.avgSideSlip = 0
self.avgPoweredRPM = 0
self.avgForwardSlip = 0

self.cruiseTargetSpeed = 0
end

--- Returns a list of available transmission gears.
Expand Down Expand Up @@ -269,6 +271,22 @@ function ENT:EngineThink( dt, selfTbl )
inputBrake = self:GetInputFloat( 1, "brake", selfTbl )
inputHandbrake = self:GetInputBool( 1, "handbrake", selfTbl )

if self:GetIsCruiseControlEnabled() and not amphibiousMode then
if inputBrake > 0.1 or inputThrottle > 0.1 then
self:SetIsCruiseControlEnabled( false )
selfTbl.cruiseTargetSpeed = 0
else
if not selfTbl.cruiseTargetSpeed or selfTbl.cruiseTargetSpeed < 0.1 then
selfTbl.cruiseTargetSpeed = Max( selfTbl.forwardSpeed, 0 )
end

local cruiseThrottle = Clamp( ( selfTbl.cruiseTargetSpeed - selfTbl.forwardSpeed ) * 0.01, 0, 1 )

inputThrottle = Max( inputThrottle, cruiseThrottle )
inputBrake = 0
end
end

if amphibiousMode then
selfTbl.burnout = 0
self:BoatEngineThink( dt )
Expand Down
1 change: 1 addition & 0 deletions lua/glide/sh_input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Glide.AddInputAction( "land_controls", "throttle_modifier", KEY_LSHIFT )
Glide.AddInputAction( "land_controls", "horn", KEY_R )
Glide.AddInputAction( "land_controls", "siren", KEY_L )
Glide.AddInputAction( "land_controls", "detach_trailer", KEY_K )
Glide.AddInputAction( "land_controls", "toggle_cruise_control", KEY_C )

Glide.AddInputAction( "land_controls", "lean_forward", KEY_UP )
Glide.AddInputAction( "land_controls", "lean_back", KEY_DOWN )
Expand Down
Binary file added materials/glide/icons/cruise_control.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resource/localization/en/glide_vehicles.properties
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ glide.input.siren=Siren
glide.input.headlights=Toggle headlights
glide.input.toggle_engine=Toggle engine
glide.input.detach_trailer=Detach trailer
glide.input.cruise_control=Cruise control

glide.input.throttle_modifier=Throttle modifier
glide.input.throttle_mod_mode=Throttle modifier mode
Expand Down Expand Up @@ -197,6 +198,8 @@ glide.notify.vehicle_locked=This vehicle has been locked, only the vehicle creat
glide.notify.vehicle_unlocked=This vehicle has been unlocked, anyone can enter it.
glide.notify.reduced_throttle_on=Reduced throttle.
glide.notify.reduced_throttle_off=Full throttle.
glide.notify.cruise_control_on=You have activated cruise control.
glide.notify.cruise_control_off=You have deactivated cruise control.
glide.notify.tip.headlights=Press %s to switch headlights.\n\nYou can also configure if they should turn on/off automatically when you are on a dim place.
glide.notify.tip.homing_launcher=Hold the right mouse button to lock on occupied vehicles.
glide.notify.tip.heli_controls=Use the mouse to aim the helicopter.\n\nYou can switch to WAC-like or GTA-like controls in the settings.
Expand Down
3 changes: 3 additions & 0 deletions resource/localization/fr/glide_vehicles.properties
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ glide.input.siren=Sirène
glide.input.headlights=Activer/désactiver les phares
glide.input.toggle_engine=Allumer/éteindre le moteur
glide.input.detach_trailer=Détacher la remorque
glide.input.cruise_control=Régulateur de vitesse

glide.input.throttle_modifier=Modificateur d'accélérateur
glide.input.throttle_mod_mode=Mode de modif. d'accélérateur
Expand Down Expand Up @@ -198,6 +199,8 @@ glide.notify.vehicle_locked=Ce véhicule a été verrouillé, seuls le créateur
glide.notify.vehicle_unlocked=Ce véhicule a été déverrouillé, tout le monde peut y entrer.
glide.notify.reduced_throttle_on=Gaz réduit.
glide.notify.reduced_throttle_off=Plein régime.
glide.notify.cruise_control_on=Vous avez activé le régulateur de vitesse.
glide.notify.cruise_control_off=Vous avez désactivé le régulateur de vitesse.
glide.notify.tip.headlights=Appuyez sur %s pour allumer/éteindre les phares.\n\nVous pouvez également configurer leur activation/désactivation automatique dans les endroits sombres.
glide.notify.tip.homing_launcher=Maintenez le clic droit pour verrouiller les véhicules occupés.
glide.notify.tip.heli_controls=Utilisez la souris pour piloter l'hélicoptère.\n\nVous pouvez passer à des contrôles de style WAC ou GTA dans les paramètres.
Expand Down
Loading