Jump to content

.RRR format explanation (Carrec.img)


Seemann

Recommended Posts

Main Article: wiki:Carrec

The RRR files (R3 files) are stored in the archive carrec.img. These files contain information about predefined paths used in missions of GTA:SA. When a vehicle is assigned to such a path with opcode 05EB or 085E, it is moving along the path without taking into account game physics and environment (traffic cars). Also it does not damage when collided. Opcode 0706 moves the vehicle to the next point along the path. 06FD sets a multiplier for the vehicle’s speed.

The R3 files structure is very simple. It’s a binary file being just a set of structures, without header. Each structure has a size of 32 bytes. A path point structure described below:

(offsets are decimal)

CODE

 

00 dword time
04 word velocity in direction X * 16383.5
06 word velocity in direction Y * 16383.5
08 word velocity in direction Z * 16383.5
10 byte XYZ.right.x * 127.0
11 byte XYZ.right.y * 127.0
12 byte XYZ.right.z * 127.0
13 byte XYZ.top.x * 127.0
14 byte XYZ.top.y * 127.0
15 byte XYZ.top.z * 127.0
16 byte Steering Angle * 20.0
17 byte Gas Pedal Power * 100.0
18 byte Break Pedal Power * 100.0
19 byte Handbrake used flag
20 float XYZ.pos.x
24 float XYZ.pos.y
28 float XYZ.pos.z
32 end

(XYZ is the structure that store information about a 3D-object world position (+0x14 offset)).


There’s a way to create new R3 path and use it in the script. I wrote a CLEO script which allows to record a vehicle movement data in-game and write it to a custom RRR file. This file is need to be added to the carrec.img then using any IMG archive editor and it’s ready to be used.

http://sannybuilder.com/dev/carrec.txt (source)
http://cleo.sannybuilder.com/scripts/carrec.rar (compiled CLEO script)

To get it work, you need to install CLEO 3 Library, put the carrec.cs to the "game\CLEO" folder, and start the game. Take any vehicle, press Shift+R (you should get a message box) to start recording. Then drive you vehicle along the path you want to create. When you finish, press Shift+R again to stop recording. The new RRR path is stored at the data\paths\carrec900.rrr file (by default; it could be changed in script).

The RRR file editor made by Sanchez:
http://sannybuilder.com/files/R3D.rar

Examples of new RRR paths made with the script are downloadable here:
http://sannybuilder.com/dev/temp/carrec900.rrr
http://sannybuilder.com/dev/temp/carrec998.rrr

Pay attention, that the game can only operate maximum with 475 RRR paths. The original installation has 426 of them, so the number of paths to add safely is 49.

Original source:
http://sannybuilder.com/forums/viewtopic.php?id=107

Enjoy.

Edited by Seemann
Link to comment
Share on other sites

  • 4 weeks later...

Wow, that was helpful! Now I understand some of the issues I was having when writing a mod - thank you very much. Worthy of a PIN, IMHO.

 

I look forward to utilizing CLEO and the recorder function! icon14.gif

Link to comment
Share on other sites

  • 1 month later...

Excellent cookie.gifcookie.gifcookie.gif

Thats what we need to let car drives safe on their route

 

Please correct 2 details in your post

 

When a vehicle is assigned to such a path with opcode 05BE or

05BE is 05BE: AS_kill_actor @54

you mean 05EB: assign_car 35@ to_path 706

and the your carrec.sc stores the carrec.rrr in in GTASA\data\Paths

 

I made a exemble script.

press key 11// YES-key, in any state

It teleport the player to SF Airport on motorbike and spawns an actor on motorbike to drive around the airport terminal

 

click to get the necessary carrec.rrr

 

 

004F: create_thread @Drive_1

 

 

:Drive_1////------------------sannybuilder code03A4: name_thread 'DRIV' :DRIV_110001: wait 0 ms 00D6: if 0256:   player $PLAYER_CHAR defined 004D: jump_if_false @DRIV_11 077E: get_active_interior_to $ACTIVE_INTERIOR 00D6: if and0038:   $ACTIVE_INTERIOR == 0 00E1:   player 0 pressed_key 11//<<<<<-------------press YES-key in any state 004D: jump_if_false @DRIV_11 016A: fade 0 time 250 0001: wait 250 ms 01B4: set_player $PLAYER_CHAR can_move 0 0362: remove_actor $PLAYER_ACTOR from_car_and_place_at -1338.5 -408.1 14.1 0173: set_actor $PLAYER_ACTOR Z_angle_to 90.8 0001: wait 500 ms 0247: load_model #NRG500 0247: load_model #MAFFA 07C0: load_path 840 :DRIV_1280001: wait 0 ms 00D6: if and0248:   model #NRG500 available 0248:   model #MAFFA available 07C1:   path 840 available 004D: jump_if_false @DRIV_128 00A5: 1@ = create_car #NRG500 at -1333.5 -408.1 14.1 0175: set_car 1@ Z_angle_to 280.0 0224: set_car 1@ health_to 2000 00A5: 7@ = create_car #NRG500 at -1354.5 -419.1 14.1 0175: set_car 7@ Z_angle_to 280.0 0224: set_car 7@ health_to 2000 020A: set_car 7@ door_status_to 4 02AC: set_car 7@ immunities BP 1 FP 1 EP 1 CP 1 MP 1 01EC: make_car 7@ very_heavy 1 0129: 9@ = create_actor_pedtype 24 model #MAFFA in_car 7@ driverseat 0223: set_actor 9@ health_to 3000 04E4: unknown_refresh_game_renderer_at -1333.5 -408.1 03CB: set_rendering_origin_at -1333.5 -408.1 14.1 029B: 23@ = init_object #AD_JUMP at -1576.02 -202.34 13.76 0177: set_object 23@ Z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 23@ 0382: set_object 23@ collision_detection 1 029B: 24@ = init_object #AD_JUMP at -1597.9 -506.5 21.7 0177: set_object 24@ Z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 24@ 0382: set_object 24@ collision_detection 1 029B: 25@ = init_object #AD_JUMP at -1375.9 -581.5 13.69 0177: set_object 25@ Z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 25@ 0382: set_object 25@ collision_detection 1 029B: 26@ = init_object #AD_JUMP at -1374.9 -585.5 13.69 0177: set_object 26@ Z_angle_to 270.0 01C7: remove_object_from_mission_cleanup_list 26@ 0382: set_object 26@ collision_detection 1 0177: set_object 23@ Z_angle_to 135.0 0177: set_object 24@ Z_angle_to 225.0 0177: set_object 25@ Z_angle_to 280.0 0177: set_object 26@ Z_angle_to 280.0 0249: release_model #NRG500 0249: release_model #MAFFA 0001: wait 250 ms 036A: put_actor $PLAYER_ACTOR in_car 1@ 0001: wait 250 ms 016A: fade 1 time 1000 0001: wait 1000 ms 0373: set_camera_directly_behind_player 02EB: restore_camera_with_jumpcut 01B4: set_player $PLAYER_CHAR can_move 1 085E: assign_car 7@ to_looped_path 840//<<---vehicle repeat the course again and again//0705: car 7@ assign_to_path 840 and_drive_normal//<<---vehicle stops after one round06FD: set_car 7@ speed_on_path_to 0.95 :DRIV_6010001: wait 0 ms 00D6: if 0256:   player $PLAYER_CHAR defined 004D: jump_if_false @DRIV_601 00D6: if and8119:   not car 1@ wrecked 8119:   not car 7@ wrecked 8118:   not actor 9@ dead 004D: jump_if_false @DRIV_601 00D6: if 00FE:   actor $PLAYER_ACTOR sphere 0 in_sphere -1333.5 -408.1 14.1 radius 650.5 650.5 50.5 004D: jump_if_false @DRIV_702 0002: jump @DRIV_601 :DRIV_7020873: release_path 840 01C3: remove_references_to_car 1@ // Like turning a car into any random car 01C3: remove_references_to_car 7@ // Like turning a car into any random car 01C2: remove_references_to_actor 9@ // Like turning an actor into a random pedestrian 0108: destroy_object 23@ 0108: destroy_object 24@ 0108: destroy_object 25@ 0108: destroy_object 26@ 0002: jump @DRIV_11

 

  • Like 1
Link to comment
Share on other sites

  • 7 months later...
  • 5 months later...

 

Main Article: wiki:Carrec

 

The RRR files (R3 files) are stored in the archive carrec.img. These files contain information about predefined paths used in missions of GTA:SA. When a vehicle is assigned to such a path with opcode 05EB or 085E, it is moving along the path without taking into account game physics and environment (traffic cars). Also it does not damage when collided. Opcode 0706 moves the vehicle to the next point along the path. 06FD sets a multiplier for the vehicle’s speed.

 

The R3 files structure is very simple. It’s a binary file being just a set of structures, without header. Each structure has a size of 32 bytes. A path point structure described below:

 

(offsets are decimal)

 

00  dword    time 04  word     velocity in direction X * 16383.5 06  word     velocity in direction Y * 16383.5 08  word     velocity in direction Z * 16383.5 10  byte     XYZ.right.x * 127.0 11  byte     XYZ.right.y * 127.0 12  byte     XYZ.right.z * 127.0 13  byte     XYZ.top.x * 127.0 14  byte     XYZ.top.y * 127.0 15  byte     XYZ.top.z * 127.0 16  byte     Steering Angle * 20.0 17  byte     Gas Pedal Power * 100.0 18  byte     Break Pedal Power * 100.0 19  byte     Handbrake used flag 20  float    XYZ.pos.x 24  float    XYZ.pos.y 28  float    XYZ.pos.z 32  end

 

 

(XYZ is the structure that store information about a 3D-object world position (+0x14 offset)).

 

 

There’s a way to create new R3 path and use it in the script. I wrote a CLEO script which allows to record a vehicle movement data in-game and write it to a custom RRR file. This file is need to be added to the carrec.img then using any IMG archive editor and it’s ready to be used.

 

http://sannybuilder.com/dev/carrec.txt (source)

http://cleo.sannybuilder.com/scripts/carrec.rar (compiled CLEO script)

 

To get it work, you need to install CLEO 3 Library, put the carrec.cs to the "game\CLEO" folder, and start the game. Take any vehicle, press Shift+R (you should get a message box) to start recording. Then drive you vehicle along the path you want to create. When you finish, press Shift+R again to stop recording. The new RRR path is stored at the data\paths\carrec900.rrr file (by default; it could be changed in script).

 

The RRR file editor made by Sanchez (updated):

http://foolroot.nm.ru/R3D.rar

 

Examples of new RRR paths made with the script are downloadable here:

http://sannybuilder.com/dev/temp/carrec900.rrr

http://sannybuilder.com/dev/temp/carrec998.rrr

 

Pay attention, that the game can only operate maximum with 475 RRR paths. The original installation has 426 of them, so the number of paths to add safely is 49.

 

Original source:

http://sannybuilder.com/forums/viewtopic.php?id=107

 

Enjoy.

With what opcode can i move the vehicle along the path but to have the game physics and environment like the other cars and damage as well.

Edited by dtd mods
Suction Testicle Ban
Link to comment
Share on other sites

  • 1 month later...
PLEASE PLEASE PLEASE How can i create my own cleo script??????

Read tutorials about SA Coding. Dont ask offtopic questions please.

  • Like 1
Yl8KS.jpg
Link to comment
Share on other sites

  • 1 year later...

Hi,

I found a bug in the R3D tool, I cuts up the number of path point if it has more than 3 character, like here:

 

user posted image

 

I tried to expand this column, but it doesn´t work.

Is there any solution?

Link to comment
Share on other sites

  • 4 months later...

Will the car stop at the stops if I stop and stand near the bus stop 10 seconds.

 

or need to write code "...car stopped at point... radius 10 10 10 ?

Link to comment
Share on other sites

Will the car stop at the stops if I stop and stand near the bus stop 10 seconds.

 

or need to write code "...car stopped at point... radius 10 10 10 ?

The car will do the exact same thing you did. If you stopped it will stop, if you did not it wont.

Yl8KS.jpg
Link to comment
Share on other sites

  • 5 years later...
ThePlayaJam765

I know I am extremely late to the party but Here's a short script i wrote that will playback rrr paths that you've made. Just change 381 into the number of your path then press TAB+P in-game while in the appropiate vehicle type to watch it.

{$CLEO .cs}//-------------MAIN---------------thread 'CARPATH':CARPATH_01wait 0if and0AB0:   key_pressed 90AB0:   key_pressed 80Actor.Driving($PLAYER_ACTOR)else_jump @CARPATH_01jump @CARPATH_02:CARPATH_0207C0: load_path 3810@ = Actor.CurrentCar($PLAYER_ACTOR)jump @CARPATH_03:CARPATH_03wait 1000if860E:   not car 0@ assigned_to_pathelse_jump @CARPATH_0105EB: assign_car 0@ to path 38106FD: set_car 0@ speed_on_path_to 1.0jump @CARPATH_01
Edited by ThePlayaJam765
Link to comment
Share on other sites

  • 4 months later...
  • 8 months later...

it's sucks that i have to completely close the game when I add it carrec.img,

if the game runs, it won't let me open or save, with carrec.rrr902 by itself, the car just teleport to san ferrio's car practice area

 

then I record the path and I got it working but the car is invisible and driving up-side then blows up, it glitchly

Link to comment
Share on other sites

it's sucks that i have to completely close the game when I add it carrec.img,

if the game runs, it won't let me open or save, with carrec.rrr902 by itself, the car just teleport to san ferrio's car practice area

 

then I record the path and I got it working but the car is invisible and driving up-side then blows up, it glitchly

Sorry, but you can't replace anything in the games original .IMG without closing the game. That's pretty obvious.

 

Also, make sure to run your IMG editor in Administrator mode because the same happened to me. You have to make sure you actually import the car path. It's not glitchy at all. You're just bad at coding.

Link to comment
Share on other sites

Path recorder works fine, although It doesn't show Started Recording/Ended recording(?). But, I recorded the path, put it into IMG and when I try to run it in SAMP, my game just freezes. Anyone knows how to fix this or It just doesn't work in SAMP?

  • Bruh 1
Link to comment
Share on other sites

  • 6 years later...
On 12/26/2023 at 9:53 PM, Gabriel GBR said:

Does anyone still has the record script for me to use?the links seem to be down

Yes

 

Seemanns carrec.cs, decompiled and modified (key_press only) by me, press BACKSPACE key to record path


{$CLEO .cs}

//-------------MAIN---------------
0006: 0@ = 0 
0006: 33@ = 500 
0006: 1@ = 0 

:NONAME_22
0001: wait 0 ms 
0050: gosub @NONAME_143 
00D6: if 
0039:   0@ == 1 
004D: jump_if_false @NONAME_111 
00D6: if 
0039:   1@ == 0 
004D: jump_if_false @NONAME_97 
0050: gosub @NONAME_331 
0006: 32@ = 0 
0006: 5@ = 0 
0006: 4@ = 0 

:NONAME_97
0050: gosub @NONAME_413 
0002: jump @NONAME_136 

:NONAME_111
00D6: if 
0039:   1@ == 1 
004D: jump_if_false @NONAME_136 
0050: gosub @NONAME_399 

:NONAME_136
0002: jump @NONAME_22 

:NONAME_143
00D6: if 
0256:   player $PLAYER_CHAR defined 
004D: jump_if_false @NONAME_286 
00D6: if 
00DF:   actor $PLAYER_ACTOR driving 
004D: jump_if_false @NONAME_286 
00D6: if and
0AB0:   key_pressed 8 
0029:   33@ >= 500 
004D: jump_if_false @NONAME_284 
00D6: if 
0039:   0@ == 1 
004D: jump_if_false @NONAME_252 
0006: 0@ = 0 
0006: 1@ = 1 
03E5: show_text_box 'CARREC2'  // Car record OFF
0002: jump @NONAME_277 

:NONAME_252
0006: 0@ = 1 
0006: 1@ = 0 
03E5: show_text_box 'CARREC1'  // Car record ON

:NONAME_277
0006: 33@ = 0 

:NONAME_284
0051: return 

:NONAME_286
00D6: if 
0039:   0@ == 1 
004D: jump_if_false @NONAME_329 
0006: 0@ = 0 
0006: 1@ = 1 
03E5: show_text_box 'CARREC2'  // Car record OFF

:NONAME_329
0051: return 

:NONAME_331
00D6: if 
0A9A: 2@ = openfile "data\Paths\carrec900.rrr" mode 25207 // IF and SET 
004D: jump_if_false @NONAME_390 
0006: 1@ = 1 
0002: jump @NONAME_397 

:NONAME_390
0006: 0@ = 0 

:NONAME_397
0051: return 

:NONAME_399
0A9B: closefile 2@ 
0006: 1@ = 0 
0051: return 

:NONAME_413
00D6: if 
0039:   0@ == 1 
004D: jump_if_false @NONAME_489 
00D6: if 
002D:   32@ >= 4@ // (int) 
004D: jump_if_false @NONAME_489 
0006: 32@ = 0 
005A: 5@ += 4@ // (int) 
0050: gosub @NONAME_491 
0209: 4@ = random_int_in_ranges 0 50 
000A: 4@ += 225 

:NONAME_489
0051: return 

:NONAME_491
0A9E: writefile 2@ size 4 from 5@ 
03C0: 6@ = actor $PLAYER_ACTOR car 
0A97: 6@ = car 6@ struct 
0A8E: 23@ = 6@ + 68 // int 
0A8D: 23@ = read_memory 23@ size 4 virtual_protect 0 
0013: 23@ *= 16383.5 
008E: 23@ = float 23@ to_integer 
0A9E: writefile 2@ size 2 from 23@ 
0A8E: 23@ = 6@ + 72 // int 
0A8D: 23@ = read_memory 23@ size 4 virtual_protect 0 
0013: 23@ *= 16383.5 
008E: 23@ = float 23@ to_integer 
0A9E: writefile 2@ size 2 from 23@ 
0A8E: 23@ = 6@ + 76 // int 
0A8D: 23@ = read_memory 23@ size 4 virtual_protect 0 
0013: 23@ *= 16383.5 
008E: 23@ = float 23@ to_integer 
0A9E: writefile 2@ size 2 from 23@ 
0A8E: 23@ = 6@ + 20 // int 
0A8D: 23@ = read_memory 23@ size 4 virtual_protect 0 
0050: gosub @NONAME_969 
000A: 23@ += 16 
0050: gosub @NONAME_969 
0A8E: 23@ = 6@ + 1172 // int 
0A8D: 23@ = read_memory 23@ size 4 virtual_protect 0 
0013: 23@ *= 20.0 
008E: 23@ = float 23@ to_integer 
0A9E: writefile 2@ size 1 from 23@ 
0A8E: 23@ = 6@ + 1180 // int 
0A8D: 23@ = read_memory 23@ size 4 virtual_protect 0 
0013: 23@ *= 100.0 
008E: 23@ = float 23@ to_integer 
0A9E: writefile 2@ size 1 from 23@ 
0A8E: 23@ = 6@ + 1184 // int 
0A8D: 23@ = read_memory 23@ size 4 virtual_protect 0 
0013: 23@ *= 100.0 
008E: 23@ = float 23@ to_integer 
0A9E: writefile 2@ size 1 from 23@ 
0A8E: 23@ = 6@ + 1064 // int 
0A8D: 23@ = read_memory 23@ size 1 virtual_protect 0 
00D6: if 
08B7:   test 23@ bit 5 
004D: jump_if_false @NONAME_918 
0006: 23@ = 1 
0002: jump @NONAME_925 

:NONAME_918
0006: 23@ = 0 

:NONAME_925
0A9E: writefile 2@ size 1 from 23@ 
03C0: 6@ = actor $PLAYER_ACTOR car 
00AA: store_car 6@ position_to 20@ 21@ 22@ 
0A9E: writefile 2@ size 12 from 20@ 
0051: return 

:NONAME_969
0A8E: 24@ = 23@ + 0 // int 
0A8D: 24@ = read_memory 24@ size 4 virtual_protect 0 
0013: 24@ *= 127.0 
008E: 24@ = float 24@ to_integer 
0A9E: writefile 2@ size 1 from 24@ 
0A8E: 24@ = 23@ + 4 // int 
0A8D: 24@ = read_memory 24@ size 4 virtual_protect 0 
0013: 24@ *= 127.0 
008E: 24@ = float 24@ to_integer 
0A9E: writefile 2@ size 1 from 24@ 
0A8E: 24@ = 23@ + 8 // int 
0A8D: 24@ = read_memory 24@ size 4 virtual_protect 0 
0013: 24@ *= 127.0 
008E: 24@ = float 24@ to_integer 
0A9E: writefile 2@ size 1 from 24@ 
0051: return 

 

Edited by ZAZ
Link to comment
Share on other sites

Gabriel GBR
On 1/2/2024 at 9:09 AM, ZAZ said:

Yes

 

Seemanns carrec.cs, decompiled and modified (key_press only) by me, press BACKSPACE key to record path

 

Oh,hey,i already compiled it,i didnt see there was a source code 😑,but thanks anyways

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.