Script Path

From GTAMods Wiki
Revision as of 03:24, 4 September 2017 by Spaceeinstein (talk | contribs)
Jump to navigation Jump to search
Vice City's spath0.dat map

A Script Path (also named Object Path) lets the script in Vice City attach objects to a path and control their movement along it. The path data are stored in a plain text file located in .\data\paths\spath0.dat, which is used by Cortez's yacht in the mission "All Hands On Deck!" The game can support two additional script path files in the same directory: spath1.dat and spath2.dat. Script paths are based on flight paths used for airborne NPC vehicles.

Format for spath*.dat

NumNodes
X Y Z
Vice City Identifier Type Description
Section 1: Number of path nodes
A NumNodes integer The number of lines that are to be read from the file.
Section 2: Path nodes
A,B,C X, Y, Z float[3] X, Y, Z coordinates, each line linked to create a path
Repeat up to the number of path nodes

Undefined lines of coordinates will use the center of the world (0, 0, 0) as the point for the path.

Mission script

The following example explains how these files are used in the original script in Sanny Builder's format to move Cortez's yacht. First, the script path is initialized using opcode 049C.

049C: 0@ = scripted_path_file 0 width 90.0

Next, objects need to be created using opcode 029B (opcode 0107 can also be used to create them).

029B: 1@ = init_object #YT_MAIN_BODY at -375.499 -1322.31 9.81124
029B: 2@ = init_object #YT_MAIN_BODY2 at -375.499 -1322.31 9.81124
029B: 3@ = init_object #YT_DOORS14 at -375.499 -1322.31 9.81124
029B: 4@ = init_object #YT_TMP_BOAT at -375.499 -1322.31 9.81124
029B: 5@ = init_object #LODMAIN_BODY at -375.499 -1322.31 9.81124

These objects are attached to the path using opcode 049D.

049D: attach_scripted_file 0@ with_object 1@
049D: attach_scripted_file 0@ with_object 2@
049D: attach_scripted_file 0@ with_object 3@
049D: attach_scripted_file 0@ with_object 4@
049D: attach_scripted_file 0@ with_object 5@

Lastly, opcode 049E is used to prevent the yacht from moving along the path.

049E: set_scripted_file 0@ speed_to 0.0

During the mission, the yacht's speed varies and is warped along the path in two occasions using opcode 049F.

049E: set_scripted_file 0@ speed_to 5.0
// ...
049F: set_scripted_file 0@ distance_along_path_to 2700.0

When you fail the mission, the yacht is reset back to the beginning.

049F: set_scripted_file 0@ distance_along_path_to 0.0 
049E: set_scripted_file 0@ speed_to 0.0

When you pass the mission, the objects and path are no longer needed so they are removed from the game using opcodes 0108 and 04A1 respectively.

0108: destroy_object 1@
0108: destroy_object 2@
0108: destroy_object 3@
0108: destroy_object 4@
0108: destroy_object 5@
04A1: release_scripted_file 0@

Note that if a script path is actively moving objects, replays will be disabled. All of these attributes are saved in the block 17 of the save file.

See also