11--- @diagnostic disable : param-type-mismatch
22
3+ --- @enum eWheelFlags
4+ Enums .eWheelFlags = {
5+ HIT = 0 ,
6+ HIT_PREV = 1 ,
7+ ON_GAS = 2 ,
8+ ON_FIRE = 3 ,
9+ CHEAT_TC = 4 ,
10+ CHEAT_SC = 5 ,
11+ CHEAT_GRIP1 = 6 ,
12+ CHEAT_GRIP2 = 7 ,
13+ BURNOUT = 8 ,
14+ BURNOUT_NON_DRIVEN_WHEEL = 9 ,
15+ INSHALLOWWATER = 10 ,
16+ INDEEPWATER = 11 ,
17+ TYRES_HEAT_UP = 12 ,
18+ ABS_ACTIVE = 13 ,
19+ ABS = 14 ,
20+ ABS_ALT = 15 ,
21+ SQUASHING_PED = 16 ,
22+ REDUCE_GRIP = 17 ,
23+ TELEPORTED_NO_VFX = 18 ,
24+ RESET = 19 ,
25+ BROKEN_OFF = 20 ,
26+ FULL_THROTTLE = 21 ,
27+ SIDE_IMPACT = 22 ,
28+ DUMMY_TRANSITION = 23 ,
29+ DUMMY_TRANSITION_PREV = 24 ,
30+ NO_LATERAL_SPRING = 25 ,
31+ WITHIN_DAMAGE_REGION = 26 ,
32+ WITHIN_HEAVYDAMAGE_REGION = 27 ,
33+ TOUCHING_PAVEMENT = 28 ,
34+ DUMMY = 29 ,
35+ FORCE_NO_SLEEP = 30 ,
36+ SLEEPING_ON_DEBRIS = 31
37+ }
38+
39+ --- @enum eWheelConfigFlags
40+ Enums .eWheelConfigFlags = {
41+ BIKE_WHEEL = 0 ,
42+ LEFTWHEEL = 1 ,
43+ REARWHEEL = 2 ,
44+ STEER = 3 , -- this can be used to immediately render steering when changing steering mode in the handling editor. We need to refactor handling editor to reflect vehicle memory instead of runtime bools
45+ POWERED = 4 ,
46+ TILT_INDEP = 5 ,
47+ TILT_SOLID = 6 ,
48+ BIKE_CONSTRAINED_COLLIDER = 7 ,
49+ BIKE_FALLEN_COLLIDER = 8 ,
50+ INSTANCED = 9 ,
51+ DONT_RENDER_STEER = 10 ,
52+ UPDATE_SUSPENSION = 11 ,
53+ QUAD_WHEEL = 12 ,
54+ HIGH_FRICTION_WHEEL = 13 ,
55+ DONT_REDUCE_GRIP_ON_BURNOUT = 14 ,
56+ IS_PHYSICAL = 15 ,
57+ BICYCLE_WHEEL = 16 ,
58+ TRACKED_WHEEL = 17 ,
59+ PLANE_WHEEL = 18 ,
60+ DONT_RENDER_HUB = 19 ,
61+ SPOILER = 20 , -- vehicle has a spoiler mod (increased grip)
62+ ROTATE_BOUNDS = 21 ,
63+ EXTEND_ON_UPDATE_SUSPENSION = 22 , -- force wheels to extend on suspension update
64+ CENTRE_WHEEL = 23 , -- for three wheeled cars
65+ AMPHIBIOUS_WHEEL = 24 ,
66+ RENDER_WITH_ZERO_COMPRESSION = 25
67+ }
68+
369---- ----------------------------------
470-- Class: CWheel
571---- ----------------------------------
1278--- @field m_offset_from_body pointer<float> //0x020
1379--- @field m_x_offset pointer<float> // 0x030 same as offset from body ?
1480--- @field m_last_ground_pos pointer<vec3> // 0x03C
15- --- @field m_wheel_transform array<pointer<fMatrix44>> // 0x090 - 0x0BC ` rage::fMatrix44`
81+ --- @field m_wheel_transform array<pointer<fMatrix44>> // 0x090 - 0x0BC ` rage::fMatrix44` -- TODO : this is wrong ; fix it
1682--- @field m_unk_flags pointer<uint32_t> //0x0C8
17- --- @field m_tire_radius pointer<float> //0x110
18- --- @field m_tire_width pointer<float> //0x118
19- --- @field m_suspension_compression pointer<float> // 0x168 ` radians`
20- --- @field m_traction_loss pointer<float> // 0x16C
83+ --- @field m_tyre_radius pointer<float> //0xF4
84+ --- @field m_rim_radius pointer<float> //0xF6
85+ --- @field m_old_rim_radius pointer<float> //0xFA
86+ --- @field m_tyre_width pointer<float> //0xFE
87+ --- @field m_handling_data pointer<CHandlingData> //0x102
88+ --- @field m_vehicle pointer<CVehicle> //0x106
89+ --- @field m_suspension_length pointer<float> //0x110
90+ --- @field m_max_suspension_travel pointer<float> //0x114
91+ --- @field m_suspension_forward_offset pointer<float> //0x13C // prefer this to raise /lower individual wheels
92+ --- @field m_suspension_compression pointer<float> // 0x164 ` radians`
93+ --- @field m_suspension_compression_2 pointer<float> // 0x168 ` radians`
94+ --- @field m_wheel_compression pointer<float> // 0x16C
2195--- @field m_rotation_speed pointer // 0x170
2296--- @field m_unk0190 pointer // ?? 0x190
2397--- @field m_unk0194 pointer // ?? 0x194
2498--- @field m_tire_drag_coeff pointer<float> // 0x198
2599--- @field m_top_speed_mult pointer<float> // 0x19C
26100--- @field m_steering_angle pointer<float> // 0x1CC ` radians`
27- --- @field m_brake_pressure pointer<float> // 0x1D0
28- --- @field m_power pointer<float> // 0x1D4
29- --- @field m_health pointer<float> // 0x1E8
30- --- @field m_surface_id pointer<uint16_t> // 0x1EC
31- --- @field unk_flags_1F0 pointer<uint32_t> // 0x1F0
101+ --- @field m_brake_force pointer<float> // 0x1D0
102+ --- @field m_drive_force pointer<float> // 0x1D4
103+ --- @field m_suspension_health pointer<float> // 0x1E8 // 100.0f : car gets slammed (old method of shooting your suspension to stance your car ) // 0.0f : wheel should fall off but doesn ' t. Something else must be set to trigger wheel detachment
104+ --- @field m_tyre_health pointer<float> // 0x1EC // <= 500.0f : flat tyre // 0.0f : no tyre
105+ --- @field m_tyre_wear_mult pointer<float> // 0x1F0 // 0.0f : tyres won ' t burst from long burnout
106+ --- @field m_tyre_wear_unk pointer<float> // 0x1F8 // similar ?
107+ --- @field m_wheel_flags pointer<eWheelFlags> // 0x200
108+ --- @field m_wheel_config_flags pointer<eWheelConfigFlags> // 0x204
109+ --- @field m_unk_u16 pointer<uint16_t> // 0x208
110+ --- @field m_unk_u8 pointer<uint8_t> // 0x20A
111+ --- @field m_tyre_is_burst pointer<bool> // 0x20B
112+ --- @field m_unk_byte pointer<byte> // 0x20C
113+ --- @field m_has_hydraulics pointer<bool> // 0x20D // true for cars with DUNK mod
32114--- @overload fun ( addr : pointer ): CWheel | nil
33115local CWheel = { m_size = 0x1FC }
34116CWheel .__index = CWheel
@@ -45,30 +127,45 @@ function CWheel.new(addr)
45127 return nil
46128 end
47129
48- local instance = setmetatable ({}, CWheel )
49- instance .m_ptr = addr
50- instance .m_y_rotation = addr :add (0x008 )
51- instance .m_y_rotation_inv = addr :add (0x010 )
52- instance .m_offset_from_body = addr :add (0x020 )
53- instance .m_x_offset = addr :add (0x030 )
54- instance .m_last_ground_pos = addr :add (0x03C )
55- instance .m_wheel_transform = { addr :add (0x090 ), addr :add (0x0A0 ), addr :add (0x0B0 ), addr :add (0x0C0 ) }
56- instance .m_unk_flags = addr :add (0x0C8 )
57- instance .m_tire_radius = addr :add (0x110 )
58- instance .m_tire_width = addr :add (0x118 )
59- instance .m_suspension_compression = addr :add (0x168 )
60- instance .m_traction_loss = addr :add (0x16C )
61- instance .m_rotation_speed = addr :add (0x170 )
62- instance .m_unk0190 = addr :add (0x190 )
63- instance .m_unk0194 = addr :add (0x194 )
64- instance .m_tire_drag_coeff = addr :add (0x198 )
65- instance .m_top_speed_mult = addr :add (0x19C )
66- instance .m_steering_angle = addr :add (0x1CC )
67- instance .m_brake_pressure = addr :add (0x1D0 )
68- instance .m_power = addr :add (0x1D4 )
69- instance .m_health = addr :add (0x1E8 )
70- instance .m_surface_id = addr :add (0x1EC )
71- instance .unk_flags_1F0 = addr :add (0x1F0 )
130+ local instance = setmetatable ({}, CWheel )
131+ instance .m_ptr = addr
132+ instance .m_y_rotation = addr :add (0x008 )
133+ instance .m_y_rotation_inv = addr :add (0x010 )
134+ instance .m_offset_from_body = addr :add (0x020 )
135+ instance .m_x_offset = addr :add (0x030 )
136+ instance .m_last_ground_pos = addr :add (0x03C )
137+ instance .m_wheel_transform = { addr :add (0x090 ), addr :add (0x0A0 ), addr :add (0x0B0 ), addr :add (0x0C0 ) }
138+ instance .m_unk_flags = addr :add (0x0C8 )
139+ instance .m_tyre_radius = addr :add (0x0F4 )
140+ instance .m_rim_radius = addr :add (0x0F6 )
141+ instance .m_old_rim_radius = addr :add (0x0FA )
142+ instance .m_tyre_width = addr :add (0x0FE )
143+ instance .m_handling_data = addr :add (0x102 )
144+ instance .m_vehicle = addr :add (0x106 )
145+ instance .m_suspension_length = addr :add (0x110 )
146+ instance .m_max_suspension_travel = addr :add (0x114 )
147+ instance .m_suspension_forward_offset = addr :add (0x13C )
148+ instance .m_suspension_compression_2 = addr :add (0x168 )
149+ instance .m_wheel_compression = addr :add (0x16C )
150+ instance .m_rotation_speed = addr :add (0x170 )
151+ instance .m_unk0190 = addr :add (0x190 )
152+ instance .m_unk0194 = addr :add (0x194 )
153+ instance .m_tire_drag_coeff = addr :add (0x198 )
154+ instance .m_top_speed_mult = addr :add (0x19C )
155+ instance .m_steering_angle = addr :add (0x1CC )
156+ instance .m_brake_force = addr :add (0x1D0 )
157+ instance .m_drive_force = addr :add (0x1D4 )
158+ instance .m_suspension_health = addr :add (0x1E8 )
159+ instance .m_tyre_health = addr :add (0x1EC )
160+ instance .m_tyre_wear_mult = addr :add (0x1F0 )
161+ instance .m_tyre_wear_unk = addr :add (0x1F8 )
162+ instance .m_wheel_flags = addr :add (0x200 )
163+ instance .m_wheel_config_flags = addr :add (0x204 )
164+ instance .m_unk_u16 = addr :add (0x208 )
165+ instance .m_unk_u8 = addr :add (0x20A )
166+ instance .m_tyre_is_burst = addr :add (0x20B )
167+ instance .m_unk_byte = addr :add (0x20C )
168+ instance .m_has_hydraulics = addr :add (0x20D )
72169
73170 return instance
74171end
@@ -136,4 +233,48 @@ function CWheel:GetTiltAngle()
136233 return math.deg (math.acos (dot / mag ))
137234end
138235
236+ --- @param flag eWheelFlags
237+ --- @return boolean
238+ function CWheel :GetWheelFlag (flag )
239+ if (not self :IsValid ()) then
240+ return false
241+ end
242+
243+ return Bit .is_set (self .m_wheel_flags :get_dword (), flag )
244+ end
245+
246+ --- @param flag eWheelConfigFlags
247+ --- @return boolean
248+ function CWheel :GetConfigFlag (flag )
249+ if (not self :IsValid ()) then
250+ return false
251+ end
252+
253+ return Bit .is_set (self .m_wheel_config_flags :get_dword (), flag )
254+ end
255+
256+ --- @param flag eWheelFlags
257+ --- @param toggle boolean
258+ function CWheel :SetWheelFlag (flag , toggle )
259+ if (not self :IsValid ()) then
260+ return
261+ end
262+
263+ local dwFlags = self .m_wheel_flags :get_dword ()
264+ local bitFunc = toggle and Bit .set or Bit .clear
265+ self .m_wheel_flags :set_dword (bitFunc (dwFlags , flag ))
266+ end
267+
268+ --- @param flag eWheelConfigFlags
269+ --- @param toggle boolean
270+ function CWheel :SetConfigFlag (flag , toggle )
271+ if (not self :IsValid ()) then
272+ return
273+ end
274+
275+ local dwFlags = self .m_wheel_config_flags :get_dword ()
276+ local bitFunc = toggle and Bit .set or Bit .clear
277+ self .m_wheel_config_flags :set_dword (bitFunc (dwFlags , flag ))
278+ end
279+
139280return CWheel
0 commit comments