|
| 1 | +-- Copyright (C) 2026 SAMURAI (xesdoog) & Contributors. |
| 2 | +-- This file is part of Samurai's Scripts. |
| 3 | +-- |
| 4 | +-- Permission is hereby granted to copy, modify, and redistribute |
| 5 | +-- this code as long as you respect these conditions: |
| 6 | +-- * Credit the owner and contributors. |
| 7 | +-- * Provide a copy of or a link to the original license (GPL-3.0 or later); see LICENSE.md or <https://www.gnu.org/licenses/>. |
| 8 | + |
| 9 | + |
| 10 | +-- [[Summary]] |
| 11 | +-- |
| 12 | +-- Handling presets define what vehicle flags they toggle and what vehicle types they are compatible with. |
| 13 | +-- This file extends that by defining additional logic that a handling preset can execute when enabled, when disabled, or both. |
| 14 | +-- User-generated presets can provide an additional file name parameter in their metadata, which would point to a user-defined file that looks exactly like this one (minus the LuaLS annotations). |
| 15 | +-- The reason they must define a separate file is so that script updates do not touch their custom logic (if custom preset logic is defined here, it will be wiped with each update). |
| 16 | +-- And the reason code execution is defined in a separate file in the first place is because both Lua's load and loadstring functions are removed from this sandbox. |
| 17 | +-- |
| 18 | +-- NOTE: This file is only for default callbacks. Please do not edit unless you're contributing a new default handling preset. |
| 19 | +-- For user-generated callbacks, you can define a new file with the same structure of this one. |
| 20 | + |
| 21 | +---@alias HandlingPresetCallback fun(self: HandlingPreset, editor: HandlingEditor): boolean |
| 22 | +---@alias HandlingPresetCallbackData { onEnable: HandlingPresetCallback, onDisable: HandlingPresetCallback } |
| 23 | + |
| 24 | +---@type dict<HandlingPresetCallbackData> |
| 25 | +return { |
| 26 | + ["VEH_KERS_BOOST"] = { |
| 27 | + onEnable = function(_) |
| 28 | + local PV = LocalPlayer:GetVehicle() |
| 29 | + if (not PV:IsValid()) then return true end |
| 30 | + VEHICLE.SET_VEHICLE_KERS_ALLOWED(PV:GetHandle(), true) |
| 31 | + return true |
| 32 | + end, |
| 33 | + onDisable = function(_) |
| 34 | + local PV = LocalPlayer:GetVehicle() |
| 35 | + if (not PV:IsValid()) then return true end |
| 36 | + VEHICLE.SET_VEHICLE_KERS_ALLOWED(PV:GetHandle(), false) |
| 37 | + return true |
| 38 | + end |
| 39 | + }, |
| 40 | + ["VEH_ROCKET_BOOST"] = { |
| 41 | + onEnable = function(_) |
| 42 | + Game.RequestNamedPtfxAsset("VEH_IMPEXP_ROCKET") |
| 43 | + return true |
| 44 | + end, |
| 45 | + onDisable = function(_) |
| 46 | + STREAMING.REMOVE_NAMED_PTFX_ASSET("VEH_IMPEXP_ROCKET") |
| 47 | + return true |
| 48 | + end |
| 49 | + }, |
| 50 | + ["VEH_JUMP"] = { |
| 51 | + onEnable = function(_) |
| 52 | + local PV = LocalPlayer:GetVehicle() |
| 53 | + if (not PV:IsValid()) then return true end |
| 54 | + VEHICLE.SET_USE_HIGHER_CAR_JUMP(PV:GetHandle(), true) |
| 55 | + return true |
| 56 | + end, |
| 57 | + onDisable = function(_) |
| 58 | + local PV = LocalPlayer:GetVehicle() |
| 59 | + if (not PV:IsValid()) then return true end |
| 60 | + VEHICLE.SET_USE_HIGHER_CAR_JUMP(PV:GetHandle(), false) |
| 61 | + return true |
| 62 | + end |
| 63 | + }, |
| 64 | + ["VEH_OFFROAD_ABILITIES"] = { |
| 65 | + onEnable = function(_) |
| 66 | + local PV = LocalPlayer:GetVehicle() |
| 67 | + if (not PV:IsValid()) then return true end |
| 68 | + local stancer = PV.m_stancer |
| 69 | + local deltas = stancer.m_deltas |
| 70 | + local front = deltas[Enums.eWheelAxle.FRONT] |
| 71 | + local rear = deltas[Enums.eWheelAxle.REAR] |
| 72 | + front.m_susp_comp = 0.1207 |
| 73 | + front.m_track_width = -0.047 |
| 74 | + rear.m_susp_comp = 0.1201 |
| 75 | + rear.m_track_width = -0.052 |
| 76 | + PV:ActivatePhysics() |
| 77 | + return true |
| 78 | + end, |
| 79 | + onDisable = function(_) |
| 80 | + local PV = LocalPlayer:GetVehicle() |
| 81 | + if (not PV:IsValid()) then return true end |
| 82 | + PV.m_stancer:ResetDeltas(true) |
| 83 | + PV:ActivatePhysics() |
| 84 | + return true |
| 85 | + end |
| 86 | + }, |
| 87 | +} |
0 commit comments