@@ -14,10 +14,10 @@ local CHandlingData = require("includes.classes.gta.CHandlingData")
1414local CEntity = require (" includes.classes.gta.CEntity" )
1515local CVehicleDrawData = require (" includes.classes.gta.CVehicleDrawData" )
1616local CVehicleModelInfo = require (" includes.classes.gta.CVehicleModelInfo" )
17+ local CTransmission = require (" includes.classes.gta.CTransmission" )
1718local CWheel = require (" includes.classes.gta.CWheel" )
1819local fMatrix44 = require (" includes.classes.gta.fMatrix44" )
1920local phFragInst = require (" includes.classes.gta.phFragInst" )
20- local CCarHandlingData = require (" includes.classes.gta.CCarHandlingData" )
2121
2222
2323--- @class CAdvancedData
@@ -30,25 +30,26 @@ local CCarHandlingData = require("includes.classes.gta.CCarHandlingData")
3030--- @ignore
3131--- @class CVehicle : CEntity
3232--- @field protected m_ptr pointer
33- --- @field public m_physics_fragments phFragInst //0x30 ` struct rage::phFragInst`
3433--- @field public m_draw_data CVehicleDrawData
3534--- @field public m_handling_data CHandlingData
3635--- @field public m_model_info CVehicleModelInfo
3736--- @field public m_vehicle_damage pointer<CVehicleDamage>
3837--- @field public m_can_boost_jump pointer<byte> ` bool`
3938--- @field public m_velocity pointer<vec3>
39+ --- @field public m_transmission CTransmission
4040--- @field public m_deform_god pointer<uint8_t>
41+ --- @field public m_frag_inst phFragInst //0x09C0 ` fragInstGTA`
42+ --- @field public m_turbo pointer<float>
4143--- @field public m_water_damage pointer<uint32_t>
42- --- @field public m_next_gear pointer<int16_t>
43- --- @field public m_current_gear pointer<int16_t>
44- --- @field public m_top_gear pointer<int8_t>
4544--- @field public m_engine_health pointer<float>
46- --- @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 ))
47- --- @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
45+ --- @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 1.0 (left ) .. -1.0 (right ))
46+ --- @field public m_steering_angle pointer<float> 0x00DC // steering angle ? . We ' ll use it to rewrite last known steering value after exiting a vehicle in IV-Style Exit so we' ll no longer have to teleport outside or patch CTaskVehicleExit
47+ --- @field public m_throttle_power pointer<float> m_steering_angle + 0x8
48+ --- @field public m_brake_power pointer<float>
4849--- @field public m_is_targetable pointer<byte> ` bool`
4950--- @field public m_door_lock_status pointer<uint32_t>
50- --- @field public m_wheels atArray<CWheel> -- 0xC30
51- --- @field public m_num_wheels number -- 0xC38
51+ --- @field public m_wheels atArray<CWheel> -- 0x0C30
52+ --- @field public m_num_wheels integer -- 0x0C38
5253--- @field public m_ride_height pointer<float>
5354--- @field private DumpFlags fun (self : CVehicle , enum_flags : Enum , get_func : fun ( self : CVehicle , flag : integer ): boolean ): nil
5455--- @overload fun ( vehicle : integer ): CVehicle | nil
@@ -57,7 +58,7 @@ local CVehicle = Class("CVehicle", { parent = CEntity, symbolic_size = 0xC40 })
5758--- @param vehicle handle
5859--- @return CVehicle
5960function CVehicle :init (vehicle )
60- if (not Game . IsScriptHandle ( vehicle ) or not ENTITY .IS_ENTITY_A_VEHICLE (vehicle )) then
61+ if (not ENTITY .IS_ENTITY_A_VEHICLE (vehicle )) then
6162 error (" Invalid entity!" )
6263 end
6364
@@ -66,30 +67,32 @@ function CVehicle:init(vehicle)
6667 local instance = setmetatable ({}, CVehicle )
6768 instance :super ().init (instance , vehicle )
6869
69- local ptr = memory .handle_to_ptr (vehicle )
70- instance .m_ptr = ptr
71- instance .m_model_info = CVehicleModelInfo (ptr :add (0x0020 ):deref ())
72- instance .m_water_damage = ptr :add (0x00D8 )
73- instance .m_physics_fragments = phFragInst (ptr :add (0x0030 ):deref ())
74- instance .m_draw_data = CVehicleDrawData (ptr :add (0x0048 ):deref ())
75- instance .m_can_boost_jump = ptr :add (0x03A4 )
76- instance .m_vehicle_damage = ptr :add (0x0420 )
77- instance .m_velocity = ptr :add (0x07D0 )
78- instance .m_is_targetable = ptr :add (0x0AEE )
79- instance .m_next_gear = ptr :add (0x0880 )
80- instance .m_current_gear = ptr :add (0x0882 )
81- instance .m_top_gear = ptr :add (0x0886 )
82- instance .m_engine_health = ptr :add (0x0910 )
83- instance .m_handling_data = CHandlingData (ptr :add (0x0960 ):deref (), instance .m_model_info :GetVehicleType ())
84- instance .m_deform_god = ptr :add (0x096C )
85- instance .m_steering_input = ptr :add (0x09D4 )
86- instance .m_current_steering = ptr :add (0x09DC )
87- instance .m_door_lock_status = ptr :add (0x13D0 )
88-
89- local array_ptr = ptr :add (0x0C30 )
90- instance .m_wheels = atArray (array_ptr , CWheel )
91- instance .m_num_wheels = array_ptr :add (0x8 ):get_int ()
92- instance .m_ride_height = array_ptr :deref ():add (0x007C )
70+ local ptr = memory .handle_to_ptr (vehicle )
71+ instance .m_ptr = ptr
72+ instance .m_model_info = CVehicleModelInfo (ptr :add (0x0020 ):deref ())
73+ instance .m_draw_data = CVehicleDrawData (ptr :add (0x0048 ):deref ())
74+ instance .m_turbo = ptr :add (0x007C )
75+ instance .m_water_damage = ptr :add (0x00D8 )
76+ instance .m_can_boost_jump = ptr :add (0x03A4 )
77+ instance .m_vehicle_damage = ptr :add (0x0420 )
78+ instance .m_velocity = ptr :add (0x07D0 )
79+ instance .m_transmission = CTransmission (ptr :add (0x0880 ))
80+ instance .m_engine_health = ptr :add (0x0910 )
81+ instance .m_handling_data = CHandlingData (ptr :add (0x0960 ):deref (), instance .m_model_info :GetVehicleType ())
82+ instance .m_deform_god = ptr :add (0x096C )
83+ instance .m_frag_inst = phFragInst (ptr :add (0x09C0 ):deref ())
84+ instance .m_steering_input = ptr :add (0x09D4 )
85+ instance .m_steering_angle = ptr :add (0x09DC )
86+ instance .m_throttle_power = ptr :add (0x09E4 )
87+ instance .m_brake_power = ptr :add (0x09E8 )
88+ instance .m_is_targetable = ptr :add (0x0AEE )
89+
90+ local array_ptr = ptr :add (0x0C30 )
91+ instance .m_wheels = atArray (array_ptr , CWheel )
92+ instance .m_num_wheels = array_ptr :add (0x8 ):get_int ()
93+ instance .m_ride_height = array_ptr :deref ():add (0x007C )
94+
95+ instance .m_door_lock_status = ptr :add (0x13D0 )
9396
9497 return instance
9598end
@@ -115,14 +118,6 @@ function CVehicle:GetDeformMultiplier()
115118 end )
116119end
117120
118- -- ---@param handlingType eHandlingType
119- -- ---@return CCarHandlingData|CBikeHandlingData|CFlyingHandlingData|any
120- -- function CVehicle:GetSubHandlingData(handlingType)
121- -- return self:__safecall(nil, function()
122- -- return self.m_handling_data:GetSubHandlingData(handlingType)
123- -- end)
124- -- end
125-
126121--- @return pointer< (CCarHandlingData | CBikeHandlingData | CFlyingHandlingData )? >
127122function CVehicle :GetSubHandlingData ()
128123 return self .m_handling_data :GetSubHandlingData ()
322317--- @param boneIndex integer
323318--- @return fMatrix44
324319function CVehicle :GetBoneMatrix (boneIndex )
325- local ph_frag_inst = self .m_physics_fragments
320+ local ph_frag_inst = self .m_frag_inst
326321 if not ph_frag_inst then
327322 return fMatrix44 :zero ()
328323 end
338333--- @param boneIndex integer
339334--- @param matrix fMatrix44
340335function CVehicle :SetBoneMatrix (boneIndex , matrix )
341- local ph_frag_inst = self .m_physics_fragments
336+ local ph_frag_inst = self .m_frag_inst
342337 if not ph_frag_inst then
343338 return
344339 end
0 commit comments