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
6 changes: 5 additions & 1 deletion SSV2/includes/backend.lua
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,11 @@ function Backend:RegisterHandlers()
Translator:OnTick()

yield()
end)
end, {
exception_handler = function()
Backend:Cleanup()
end
})

ThreadManager:RegisterLooped("SS_POOLMGR", function()
self:PoolMgr()
Expand Down
29 changes: 13 additions & 16 deletions SSV2/includes/classes/Set.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@
--------------------------------------
-- Class: Set
--------------------------------------
---@generic T
---@class Set<T> : { [T]: true }
---@field protected m_data table<anyval, true>
---@field protected m_data table<T, true>
---@field protected m_data_type string
---@overload fun(...): Set<...>
Set = {}
---@field new fun(...: T): Set<T>
---@overload fun(...: T): Set<T>
Set = { __type = "Set" }
Set.__index = Set
Set.__type = "Set"

---@diagnostic disable-next-line: param-type-mismatch
setmetatable(Set, {
__call = function(_, ...)
return Set.new(...)
end
})

---@generic T
---@param ... T
---@return Set<T>
function Set.new(...)
---@diagnostic disable-next-line: param-type-mismatch
local instance = setmetatable({ m_data = {} }, Set)
local args = { ... }
local args = { ... }

if (#args > 0) then
instance.m_data_type = type(args[1])
Expand All @@ -43,7 +40,7 @@ function Set.new(...)
return instance
end

---@param element anyval
---@param element T
function Set:Push(element)
if (element == nil) then
return
Expand All @@ -67,20 +64,16 @@ function Set:Push(element)
self.m_data[element] = true
end

---@param element anyval
---@param element T
function Set:Pop(element)
if (type(element) ~= self.m_data_type) then
return
end

self.m_data[element] = nil
end

function Set:Clear()
self.m_data = {}
end

---@param element anyval
---@param element T
---@return boolean
function Set:Contains(element)
return self.m_data[element] == true
Expand All @@ -96,10 +89,14 @@ function Set:Size()
return table.getlen(self.m_data)
end

---@return fun(t: table<T, true>, index?: T): T, true
---@return table<T, true>
function Set:Iter()
return pairs(self.m_data)
end

---@return fun(t: table<T, true>, index?: T): T, true
---@return table<T, true>
function Set:__pairs()
return pairs(self.m_data)
end
Expand Down
2 changes: 1 addition & 1 deletion SSV2/includes/classes/gta/CEntity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local CEntity = Class("CEntity", { symbolic_size = 0x028C })
---@param entity handle
---@return CEntity
function CEntity:init(entity)
if (not Game.IsScriptHandle(entity)) then
if (not ENTITY.DOES_ENTITY_EXIST(entity)) then
error("Invalid entity!")
end

Expand Down
2 changes: 1 addition & 1 deletion SSV2/includes/classes/gta/CPed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local CPed = Class("CPed", { parent = CEntity, symbolic_size = 0x161C })
---@param ped handle
---@return CPed
function CPed:init(ped)
if (not Game.IsScriptHandle(ped) or not ENTITY.IS_ENTITY_A_PED(ped)) then
if (not ENTITY.IS_ENTITY_A_PED(ped)) then
error("Invalid entity!")
end

Expand Down
28 changes: 19 additions & 9 deletions SSV2/includes/classes/gta/CVehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local CCarHandlingData = require("includes.classes.gta.CCarHandlingData")
---@ignore
---@class CVehicle : CEntity
---@field protected m_ptr pointer
---@field public m_physics_fragments phFragInst //0x30 `struct rage::phFragInst`
---@field public m_physics_fragments phFragInst //0x0030 `struct rage::phFragInst`
---@field public m_draw_data CVehicleDrawData
---@field public m_handling_data CHandlingData
---@field public m_model_info CVehicleModelInfo
Expand All @@ -39,16 +39,21 @@ local CCarHandlingData = require("includes.classes.gta.CCarHandlingData")
---@field public m_velocity pointer<vec3>
---@field public m_deform_god pointer<uint8_t>
---@field public m_water_damage pointer<uint32_t>
---@field public m_next_gear pointer<int16_t>
---@field public m_current_gear pointer<int16_t>
---@field public m_top_gear pointer<int8_t>
---@field public m_next_gear pointer<uint8_t>
---@field public m_current_gear pointer<uint8_t>
---@field public m_top_gear pointer<uint8_t>
---@field public m_rpm pointer<float>
---@field public m_rpm_2 pointer<float>
---@field public m_clutch pointer<float> // 0x08D4
---@field public m_throttle pointer<float> -- these two might be flipped
---@field public m_throttle_input pointer<float> //
---@field public m_engine_health pointer<float>
---@field public m_steering_input pointer<float> // 0xD4 name might not correctly reflect what this actually is but this seems to store controller input (value is between 0.99 (left) .. -0.99 (right))
---@field public m_current_steering pointer<float> 0xDC // actual wheel steer. Wr'll use it to rewrite last known wheel steer after exiting a vehicle in IV-Style Exit so we'll no longer need to teleport outside or patch CTaskVehicleExit
---@field public m_steering_input pointer<float> // 0x00D4 name might not correctly reflect what this actually is but this seems to store controller input (value is between 0.99 (left) .. -0.99 (right))
---@field public m_current_steering pointer<float> 0x00DC // actual wheel steer. Wr'll use it to rewrite last known wheel steer after exiting a vehicle in IV-Style Exit so we'll no longer need to teleport outside or patch CTaskVehicleExit
---@field public m_is_targetable pointer<byte> `bool`
---@field public m_door_lock_status pointer<uint32_t>
---@field public m_wheels atArray<CWheel> -- 0xC30
---@field public m_num_wheels number -- 0xC38
---@field public m_wheels atArray<CWheel> -- 0x0C30
---@field public m_num_wheels integer -- 0x0C38
---@field public m_ride_height pointer<float>
---@field private DumpFlags fun(self: CVehicle, enum_flags: Enum, get_func: fun(self: CVehicle, flag: integer): boolean): nil
---@overload fun(vehicle: integer): CVehicle|nil
Expand All @@ -57,7 +62,7 @@ local CVehicle = Class("CVehicle", { parent = CEntity, symbolic_size = 0xC40 })
---@param vehicle handle
---@return CVehicle
function CVehicle:init(vehicle)
if (not Game.IsScriptHandle(vehicle) or not ENTITY.IS_ENTITY_A_VEHICLE(vehicle)) then
if (not ENTITY.IS_ENTITY_A_VEHICLE(vehicle)) then
error("Invalid entity!")
end

Expand All @@ -79,6 +84,11 @@ function CVehicle:init(vehicle)
instance.m_next_gear = ptr:add(0x0880)
instance.m_current_gear = ptr:add(0x0882)
instance.m_top_gear = ptr:add(0x0886)
instance.m_rpm = ptr:add(0x08C8)
instance.m_rpm_2 = ptr:add(0x08CC)
instance.m_clutch = ptr:add(0x08D4)
instance.m_throttle = ptr:add(0x08D8)
instance.m_throttle_input = ptr:add(0x08E0)
instance.m_engine_health = ptr:add(0x0910)
instance.m_handling_data = CHandlingData(ptr:add(0x0960):deref(), instance.m_model_info:GetVehicleType())
instance.m_deform_god = ptr:add(0x096C)
Expand Down
13 changes: 6 additions & 7 deletions SSV2/includes/classes/gta/CVehicleModelInfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ local CVehicleModelInfo = CStructView("CVehicleModelInfo", 0x08DC)
---@return CVehicleModelInfo
function CVehicleModelInfo.new(ptr)
return setmetatable({
m_ptr = ptr,
m_vehicle_layout = ptr:add(0x00B0),
m_vehicle_type = ptr:add(0x0340),
m_wheel_scale = ptr:add(0x048C),
m_wheel_scale_rear = ptr:add(0x0490),
m_model_info_flags = ptr:add(0x057C),
m_throttle_position = ptr:add(0x08D8),
m_ptr = ptr,
m_vehicle_layout = ptr:add(0x00B0),
m_vehicle_type = ptr:add(0x0340),
m_wheel_scale = ptr:add(0x048C),
m_wheel_scale_rear = ptr:add(0x0490),
m_model_info_flags = ptr:add(0x057C),
---@diagnostic disable-next-line: param-type-mismatch
}, CVehicleModelInfo)
end
Expand Down
76 changes: 53 additions & 23 deletions SSV2/includes/data/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,59 +42,79 @@ local Config <const> = {
auto_close = false,
},
keyboard_keybinds = {
gui_toggle = "F5",
gui_toggle = "F5",
kill_all_enemies = "F7",
enemies_flee = "F8",
-- missile_defence = "F9",
cobra_maneuver = "X",
flatbed = "X",
laser_sights = "L",
nos = "MOUSE5",
panik = "F12",
nos_purge = "X",
rod = "X",
drift_mode = "SHIFT",
-- trigger_bot = "SHIFT",
veh_mine = "NUMPAD0",
stop_anim = "G"
enemies_flee = "F8",
-- missile_defence = "F9",
cobra_maneuver = "X",
flatbed = "X",
laser_sights = "L",
nos = "MOUSE5",
rolling_launch = "N",
panik = "F12",
nos_purge = "X",
rod = "X",
drift_mode = "SHIFT",
-- trigger_bot = "SHIFT",
veh_mine = "NUMPAD0",
stop_anim = "G",
shift_up = "NUMPAD9",
shift_down = "NUMPAD3",
clutch = "NUMPAD5",
},
gamepad_keybinds = {
flatbed = {
flatbed = {
code = 288,
name = "A"
},
laser_sights = {
laser_sights = {
code = 303,
name = "DPAD UP"
},
nos = {
nos = {
code = 289,
name = "X"
},
nos_purge = {
nos_purge = {
code = 288,
name = "A"
},
rod = {
rod = {
code = 288,
name = "A"
},
drift_mode = {
drift_mode = {
code = 288,
name = "A"
},
-- trigger_bot = {
-- code = 0,
-- name = "Unbound"
-- },
veh_mine = {
veh_mine = {
code = 0,
name = "Unbound"
},
stop_anim = {
stop_anim = {
code = 0,
name = "Unbound"
}
},
rolling_launch = {
code = 0,
name = "Unbound"
},
shift_up = {
code = 0,
name = "Unbound"
},
shift_down = {
code = 0,
name = "Unbound"
},
clutch = {
code = 0,
name = "Unbound"
},
},
features = {
self = {
Expand Down Expand Up @@ -140,6 +160,15 @@ local Config <const> = {
}
},
},
default_station = {
enabled = false,
station_name = "OFF",
display_name = "Off"
},
manual_gearbox = {
enabled = false,
mode = 0,
},
bangs_rpm_max = 9000.0,
bangs_rpm_min = 4000.0,
performance_only = false,
Expand All @@ -163,6 +192,7 @@ local Config <const> = {
mines = {
enabled = false,
selected_type_hash = -647126932, -- spike mines default
name = nil ---@type string?
},
missile_defence = false,
strong_crash = false,
Expand Down
4 changes: 2 additions & 2 deletions SSV2/includes/data/enums/vehicle_advanced_flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ local eVehicleAdvancedFlags <const> = {
GEARBOX_MANUAL = 10,
GEARBOX_DIRECT_SHIFT = 11,
GEARBOX_ELECTRIC = 12,
ASSIST_TRACTION_CONTROL = 13,
ASSIST_STABILITY_CONTROL = 14,
DISABLE_TRACTION_CONTROL = 13,
DISABLE_STABILITY_CONTROL = 14,
ALLOW_REDUCED_SUSPENSION_FORCE = 15,
HARD_REV_LIMIT = 16,
HOLD_GEAR_WITH_WHEELSPIN = 17,
Expand Down
Loading