Difference between revisions of "Script Path"

From GTAMods Wiki
Jump to navigation Jump to search
(Format)
(yacht example)
Line 1: Line 1:
 
[[File:VCSpath.jpg|thumb|right|250px|Vice City's <code>spath0.dat</code> map]]
 
[[File:VCSpath.jpg|thumb|right|250px|Vice City's <code>spath0.dat</code> map]]
'''Spath'''*.dat files are plain text '''script path''' files used only in [[Vice City]] to attach and move map objects along a path. These files are located in the <code>{{dir|vc}}\data\paths</code> folder in the Vice City directory. These files, which mainly contain coordinates, can be controlled by the <code>[[main.scm]]</code> script file. By default, Vice City has only one script path file, <code>spath0.dat</code>, which controls Cortez's yacht in the mission "All Hands On Deck!" Additional script path files can be created by incrementing the number at the end of the file name by one, i.e., <code>spath1.dat</code>, <code>spath2.dat</code>, etc.
+
'''spath'''*.dat files are plain text '''script path''' files used only in [[Vice City]] to attach and move map objects along a path. These files are located in the <code>{{dir|vc}}\data\paths</code> folder in the Vice City directory. These files, which mainly contain coordinates, can be controlled by the <code>[[main.scm]]</code> script file. By default, Vice City has only one script path file, <code>spath0.dat</code>, which controls Cortez's yacht in the mission "All Hands On Deck!" Additional script path files can be created by incrementing the number at the end of the file name by one, i.e., <code>spath1.dat</code>, <code>spath2.dat</code>, etc.
  
 
The concept of script paths were preceded by binary <code>[[chase.dat|chase*.dat]]</code> files from [[GTA III]] and are succeeded by the binary [[Carrec|R3]] file format in [[San Andreas]] and [[GTA IV]].
 
The concept of script paths were preceded by binary <code>[[chase.dat|chase*.dat]]</code> files from [[GTA III]] and are succeeded by the binary [[Carrec|R3]] file format in [[San Andreas]] and [[GTA IV]].
  
 
== Format ==
 
== Format ==
{|{{Prettytable}}
+
{|class="wikitable center-col-1"
! width="36px"| {{Icon|VC}}
+
! style="width: 3em;"| {{Icon|VC}}
! width="100px"| Type
+
! style="width: 6em;" | Type
 
! Description
 
! Description
 
|-
 
|-
 
! colspan="3" | Section 1
 
! colspan="3" | Section 1
 
|-
 
|-
| <center>A</center> || integer || The number of lines that are to be read from the file.
+
| A || integer || The number of lines that are to be read from the file.
 
|-
 
|-
 
! colspan="3" | Section 2
 
! colspan="3" | Section 2
 
|-
 
|-
| <center>A,B,C</center> || float[3] || X, Y, Z coordinates, each line linked to create a path
+
| A,B,C || float[3] || X, Y, Z coordinates, each line linked to create a path
 
|}
 
|}
Undefined lines of coordinates will use the center of the game (0, 0, 0) for the path.
+
Undefined lines of coordinates will use the center of the world (0, 0, 0) as the point for the path.
  
== Scripting ==
+
== Mission script ==
The following information uses [[Sanny Builder]] to explain how to use these files through the <code>main.scm</code> file. First, the script path files needs to be defined in the script file using opcode [[049C]].
+
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: <span style="color:blue">0@</span> = scripted_path_file 0 width 5.0
+
<syntaxhighlight lang="scm">049C: 0@ = scripted_path_file 0 width 90.0</syntaxhighlight>
Next, objects need to be created either by opcode [[0107]] or [[029B]]. These objects need to be attached to the path using opcode [[049D]].
+
Next, objects need to be created using opcode [[029B]] (opcode [[0107]] can also be used to create them).
049D: attach_scripted_file <span style="color:blue">0@</span> with_object <span style="color:blue">1@</span>
+
<syntaxhighlight lang="scm">029B: 1@ = init_object #YT_MAIN_BODY at -375.499 -1322.31 9.81124
Lastly, the attached objects can start moving along the path using opcode [[049E]].
+
029B: 2@ = init_object #YT_MAIN_BODY2 at -375.499 -1322.31 9.81124
049E: set_scripted_file <span style="color:blue">0@</span> speed_to 5.0
+
029B: 3@ = init_object #YT_DOORS14 at -375.499 -1322.31 9.81124
Note that if a script path is actively moving objects, replays will be disabled. Additional opcodes related to script paths include [[049F]], which warps the objects along the path instead of moving it, and opcode [[04A1]], which removes all references of the specified script path from the game. All of these attributes are saved in the [[Saves (GTA VC)#Block 17: Script Paths|block 17 of the save file]] so that you don't have to reapply the attributes again.
+
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</syntaxhighlight>
 +
These objects are attached to the path using opcode [[049D]].
 +
<syntaxhighlight lang="scm">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@</syntaxhighlight>
 +
Lastly, opcode [[049E]] is used to prevent the yacht from moving along the path.
 +
<syntaxhighlight lang="scm">049E: set_scripted_file 0@ speed_to 0.0</syntaxhighlight>
 +
During the mission, the yacht's speed varies and is warped along the path in two occasions using opcode [[049F]].
 +
<syntaxhighlight lang="scm">049E: set_scripted_file 0@ speed_to 5.0
 +
// ...
 +
049F: set_scripted_file 0@ distance_along_path_to 2700.0</syntaxhighlight>
 +
When you fail the mission, the yacht is reset back to the beginning.
 +
<syntaxhighlight lang="scm">049F: set_scripted_file 0@ distance_along_path_to 0.0
 +
049E: set_scripted_file 0@ speed_to 0.0</syntaxhighlight>
 +
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.
 +
<syntaxhighlight lang="scm">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@</syntaxhighlight>
 +
Note that if a script path is actively moving objects, replays will be disabled. All of these attributes are saved in the [[Saves (GTA VC)#Block 17: Script Paths|block 17 of the save file]].
  
 
== See also ==
 
== See also ==
Line 35: Line 59:
 
{{VC-navi}}
 
{{VC-navi}}
  
[[Category:Map Formats]][[Category:Mission_Script]]
+
[[Category:Map Formats]][[Category:Mission Script]]

Revision as of 03:04, 23 July 2015

Vice City's spath0.dat map

spath*.dat files are plain text script path files used only in Vice City to attach and move map objects along a path. These files are located in the .\data\paths folder in the Vice City directory. These files, which mainly contain coordinates, can be controlled by the main.scm script file. By default, Vice City has only one script path file, spath0.dat, which controls Cortez's yacht in the mission "All Hands On Deck!" Additional script path files can be created by incrementing the number at the end of the file name by one, i.e., spath1.dat, spath2.dat, etc.

The concept of script paths were preceded by binary chase*.dat files from GTA III and are succeeded by the binary R3 file format in San Andreas and GTA IV.

Format

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

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