Bloodriver the Conqueror
Active member
Hi! I Want To Check If The Car Is Drifting And Check If The Wheel Has Left A Trace.
{$CLEO}
0000: drifting detector by ajom.
Const
DRIFTINGSENSITIVITY = 10.0 // change this value until the drifting detection becomes more accurate.
MYCAR = 31@
End
While true
Wait 0
If 00DF: actor $PLAYER_ACTOR driving
Then
03C0: MYCAR = actor $PLAYER_ACTOR car
0AB1: @GetVehicleRelativeRotationVelocityPerSecond 1 _OfVehicleHandle MYCAR _StoreRotationVelocityXYZ 2@ 1@ 0@
0@ *= 57.2957795131 // convert to degrees
3@ = DRIFTINGSENSITIVITY
3@ *= -1.0
If 002D: 3@ >= 0@ // drifting left
Then 0AD1: show_formatted_text_highpriority "Drifting Left: %f" time 100 0@
Else
If 0@ >= DRIFTINGSENSITIVITY // drifting right
Then 0AD1: show_formatted_text_highpriority "Drifting Right: %f" time 100 0@
End
End
End
End
:GetVehicleRelativeRotationVelocityPerSecond // 0AB1: @GetVehicleRelativeRotationVelocityPerSecond 1 _OfVehicleHandle 0@ _StoreRotationVelocityXYZ 29@ 30@ 31@
00AA: store_car 0@ position_to 29@ 30@ 31@
// Per Frame to Per Second Converter
0A8D: 28@ = readMem 0xB7CB5C size 4 vp 0 // gta frame time, use in order to be consistent with FPS
if 28@ == 0.0
then 28@ = 1.0
else 28@ /= 50.0
end
//
0A97: 27@ = vehicle 0@ struct
27@ += 80 // X (NS) Spin
0A8D: 26@ = read_memory 27@ size 4 virtual_protect 0
0073: 26@ /= 28@ // normalize RV to Per Second
005B: 29@ += 26@ // X Origin to our Vehicle Position
27@ += 4 // Y (EW) Spin
0A8D: 26@ = read_memory 27@ size 4 virtual_protect 0
0073: 26@ /= 28@ // normalize RV to Per Second
005B: 30@ += 26@ // Y Origin to our Vehicle Position
27@ += 4 // Z (NW) Spin
0A8D: 26@ = read_memory 27@ size 4 virtual_protect 0
0073: 26@ /= 28@ // normalize RV to Per Second
005B: 31@ += 26@ // Z Origin to our Vehicle Position
27@ -= 88
0AB1: @worldCoordsToEntityOffsets 4 _entity 27@ _coords_XYZ 29@ 30@ 31@ _store_to 29@ 30@ 31@
ret 3 29@ 30@ 31@
:worldCoordsToEntityOffsets
{
By Wesser modernized by ajom
Description: Convert world coordinates to entity's relative offsets.
Passed: 0@ - entity pointer 1@ - position X 2@ - position Y 3@ - position Z
Result: 7@ - relative offset X 8@ - relative offset Y 9@ - relative offset Z
Example: 0AB1: @worldCoordsToEntityOffsets 4 _entity 0x00000000 _coords_XYZ 0.0 0.0 0.0 _storeoffsets_XYZ 1@ 2@ 3@
}
0@ += 0x14 // CEntity.m_clPlaceable.m_pclMatrix
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
0A8E: 4@ = 0@ + 0x30 // CMatrix.m_clOrigin
0AA5: call 0x40FE60 num_params 3 pop 3 pclVectorB 4@ pclVectorA 1@v pclOffset 1@v // vectorSub
0AA5: call 0x59C810 num_params 3 pop 3 pclMatrix 0@ pclAbsOffset 1@v pclRelOffset 7@v // absToRelOffset
0AB2: ret 3 offsetX 7@ offsetY 8@ offsetZ 9@
Dude Thanks For Helping.I don't know how the wheel tracks are processed in gtasa memory(or where it can be found). Maybe someone else can help you.
You might also try checking the vehicle's Yaw Rotation Velocity:
PHP:{$CLEO} 0000: drifting detector by ajom. Const DRIFTINGSENSITIVITY = 10.0 // change this value until the drifting detection becomes more accurate. MYCAR = 31@ End While true Wait 0 If 00DF: actor $PLAYER_ACTOR driving Then 03C0: MYCAR = actor $PLAYER_ACTOR car 0AB1: @GetVehicleRelativeRotationVelocityPerSecond 1 _OfVehicleHandle MYCAR _StoreRotationVelocityXYZ 2@ 1@ 0@ 0@ *= 57.2957795131 // convert to degrees 3@ = DRIFTINGSENSITIVITY 3@ *= -1.0 If 002D: 3@ >= 0@ // drifting left Then 0AD1: show_formatted_text_highpriority "Drifting Left: %f" time 100 0@ Else If 0@ >= DRIFTINGSENSITIVITY // drifting right Then 0AD1: show_formatted_text_highpriority "Drifting Right: %f" time 100 0@ End End End End :GetVehicleRelativeRotationVelocityPerSecond // 0AB1: @GetVehicleRelativeRotationVelocityPerSecond 1 _OfVehicleHandle 0@ _StoreRotationVelocityXYZ 29@ 30@ 31@ 00AA: store_car 0@ position_to 29@ 30@ 31@ // Per Frame to Per Second Converter 0A8D: 28@ = readMem 0xB7CB5C size 4 vp 0 // gta frame time, use in order to be consistent with FPS if 28@ == 0.0 then 28@ = 1.0 else 28@ /= 50.0 end // 0A97: 27@ = vehicle 0@ struct 27@ += 80 // X (NS) Spin 0A8D: 26@ = read_memory 27@ size 4 virtual_protect 0 0073: 26@ /= 28@ // normalize RV to Per Second 005B: 29@ += 26@ // X Origin to our Vehicle Position 27@ += 4 // Y (EW) Spin 0A8D: 26@ = read_memory 27@ size 4 virtual_protect 0 0073: 26@ /= 28@ // normalize RV to Per Second 005B: 30@ += 26@ // Y Origin to our Vehicle Position 27@ += 4 // Z (NW) Spin 0A8D: 26@ = read_memory 27@ size 4 virtual_protect 0 0073: 26@ /= 28@ // normalize RV to Per Second 005B: 31@ += 26@ // Z Origin to our Vehicle Position 27@ -= 88 0AB1: @worldCoordsToEntityOffsets 4 _entity 27@ _coords_XYZ 29@ 30@ 31@ _store_to 29@ 30@ 31@ ret 3 29@ 30@ 31@ :worldCoordsToEntityOffsets { By Wesser modernized by ajom Description: Convert world coordinates to entity's relative offsets. Passed: 0@ - entity pointer 1@ - position X 2@ - position Y 3@ - position Z Result: 7@ - relative offset X 8@ - relative offset Y 9@ - relative offset Z Example: 0AB1: @worldCoordsToEntityOffsets 4 _entity 0x00000000 _coords_XYZ 0.0 0.0 0.0 _storeoffsets_XYZ 1@ 2@ 3@ } 0@ += 0x14 // CEntity.m_clPlaceable.m_pclMatrix 0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0 0A8E: 4@ = 0@ + 0x30 // CMatrix.m_clOrigin 0AA5: call 0x40FE60 num_params 3 pop 3 pclVectorB 4@ pclVectorA 1@v pclOffset 1@v // vectorSub 0AA5: call 0x59C810 num_params 3 pop 3 pclMatrix 0@ pclAbsOffset 1@v pclRelOffset 7@v // absToRelOffset 0AB2: ret 3 offsetX 7@ offsetY 8@ offsetZ 9@
The script above is untested. I gave you the idea on what I think you can do without furtherly Reading the game memory of terrain.