Difference between revisions of "SCM language"

From GTAMods Wiki
Jump to navigation Jump to search
m (Opcode)
(18 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Test link (please, submit changes with "Show preview"): http://www.gtamodding.com/index.php?title=SCM_language&action=edit (login required)
+
<center><span style="color: #CC0000">'''Announcement''': This article is currently being reworked. Check out the progresses by visiting [http://pastebin.com/raw/YfLWLXJw this] link from time to time. Contact [http://www.gtaforums.com/index.php?showuser=172776 Wesser] for any suggestion.</span></center>
 +
{{This|This section deals with the native SCM syntax of GTA 3 series, nothing other than [[GTA 3|III]], [[GTA VC|VC]], [[GTA SA|SA]], [[GTA LCS|LCS]] and [[GTA VCS|VCS]].<br/>
 +
It may contain non-standard SCM definitions as R* hasn't published enough documentation about it yet.}}
 +
{{TocRight}}On the occasion of the ''GTAIII's Tenth Anniversary'', after a long period of darkness where we fell about the real ''SCM'' syntax, R* finally treated us by attaching part of its own original source code into the ''GTAIII Anniversary'' game, available for ''iOS'' and ''Android'' devices. As far back as 2001, a snip of some debugging scripts has been already provided with ''main.sc'' and ''debug.sc'' files. However, many secrets are unrevealed yet, thus some things cannot be documented fully and so they can be only guessed. The ''SCM'' format abbreviation is one of countless proofs of this inconvenience, which may stand for ''Script Multifile''. Other doubts come with source files, whose ''SC'' extension appears to be very close to ''Mission SCript''. Although we have enough information to suppose the currently unknown mysteries of the used language, we still have no safe clue about which was its original denomination. Furthermore, it is a matter of fact that R* developers have been left untouched the ''miss2'' executable name of the ''GTA 3 series'' compiler since the chapter 2. In this connection, we could imagine the new language is a variant or an evolution of the '''GTA2script'''. The ancient documentation by ''DMA'' (at present ''Rockstar North''), mentions GTA2script as a successor to GBHscript - a language used in [[GTA 1]] (''GBH'' was a planned name for GTA). Therefore, the language used in GTA 3 series should've been called '''GTA3script'''. It was influenced by both [[Wikipedia:BASIC|BASIC]] and [[Wikipedia:C_(programming_language)|C]] programming languages.
  
{{This|This section deals with the native script language syntax of GTA 3 series, nothing other than [[GTA 3|III]], [[GTA VC|VC]], [[GTA SA|SA]], [[GTA LCS|LCS]] and [[GTA VCS|VCS]].<br/>
+
 
It may incorporate nonstandard specifications due to the fact R* hasn't published enough documentation about yet.}}
+
<span style="font-size: 14pt">Preliminary remarks</span>
{{TocRight}}On the occasion of the ''Grand Theft Auto III's 10th Anniversary'', after a long period of darkness where we fell about the real scripting language syntax, R* finally treated us (or was it, as it seems, a ''War Drum Studios'' sloppy oversight?) by attaching part of its own original source code into the mobile release, available for ''iOS'' and ''Android'' devices. As far back as 2001, a snip of some debugging scripts has been already provided with ''main.sc'' and ''debug.sc'' files that were allegedly meaningful for a sort of script version checker uncut on debug builds. Nonetheless, many secrets are still unrevealed, thus some things cannot be fully documented and so they can be merely guessed. The .scm format abbreviation is one of countless proofs of this inconvenience, which may stand for '''Script Multifile'''; .scc, in turn, might be the short form of '''Script Compiled''' though we would better predilige the '''Combinedfile''' wording. No doubt come with source files, whose .sc extension is the contraction of '''Mission Script'''. Although we have enough information to suppose the currently unknown mysteries of the used language, we still have no safe clue about what was its original denomination. Furthermore, it is a matter of fact that R* developers have been left untouched the '''miss2''' executable filename of the third generation compiler since the chapter 2. In this connection, we could imagine the newer scripting language is a variant or an evolution of the '''GTA2script''' (sometimes referred to as '''GBHscript'''), which label expressly popped up in the ancient documentation by ''DMA Design Ltd'' (at present ''Rockstar North''). Therefore, we are almost sure to say the language name is most likely '''GTA3script''' (as-is casing). However, it is definitely based on [[Wikipedia:BASIC|BASIC]].
+
----
 +
This article makes use of formatted codes to improve the reading comprehension. Note that:
 +
 
 +
* ''Square brackets'' mean everything inside may be omitted;
 +
* ''Curly brackets'' denote the presence of useful codes but not necessarily needed;
 +
* ''Vertical bars'' divide what can be chosen alternatively.<br/>
  
 
=Fundamentals=
 
=Fundamentals=
  
 
==Comments==
 
==Comments==
Codes are usually self-explanatory for the author but large sources can compromise everyone's management capability, that means some annotation can save much time on the long-term particularly when being stuck trying to understand old stuff which should never happen in the first place, not to mention team mates would certainly blame the original writer on each revision and slow down the completion of cooperative projects. Sometimes, it is also required to temporarily/permanently disable code lines for testing purposes. Fortunately, the language supports the following typologies of comments:
+
''Comments'' are notes left in the code to aid readability or to explain a part of code that may be confusing otherwise. Comments are ignored by the compiler. R*'s compiler supports C++ style comments – single-line comments and multiline comments.
 +
 
 +
A single line comment only affects a single line. They are prefixed with <code>//</code> (two slashes). Anything between these slashes and the end of the line is a comment. Single line comments may appear at the end of a line of code as well as on their own line.
 +
 
 +
<syntaxhighlight>
 +
[...] // This comment is at the end of a line.
 +
 
 +
// This comment is on its own line.
 +
</syntaxhighlight>
 +
 
 +
Multiline comments appear between <code>/*</code> and <code>*/</code>. They do not actually have to span multiple lines, and anything outside of the opening and closing tokens is '''not''' ignored (i.e. these comments may appear with code on either side on the same line).
 +
 
 +
<syntaxhighlight>
 +
[...]
 +
/*
 +
  This comment spans
 +
  multiple lines.
 +
*/
 +
[...]
 +
 
 +
[...] /* This comment is within a line */ [...] /* As is this one */ [...]
 +
</syntaxhighlight>
 +
 
 +
R*'s compiler allows multiline comments to be nested.
 +
 
 +
==Highlighters==
 +
 
 +
''Highlighters'' behaviour sounds trivial, that's to say they simply highlight one or more arguments per [[#Commands|command]] within ''round brackets'', individually or together. In {{icon|3}}, they appear to be used only for '''SETUP_ZONE_PED_INFO''' (in a various order) and ''GXT keys'':
 +
 
 +
SETUP_ZONE_PED_INFO FISHFAC DAY (0) 0 0 0 (0 0 0 0) 0
 +
PRINT_BIG (T4X4_1) 5000 2
 +
 
 +
;Limits
 +
:Opening and closing round brakets are treated as blank spaces;
 +
:An optional ''comma'' can be used as well to distinguish each argument, processed as a space.
 +
 
 +
==Scopes==
 +
 
 +
''Scopes'' are delimited by ''curly brackets'' (or ''multiline brackets'') which act like a [[#Local|local]] [[#Variables|variable]] [[#Scope|scope]]. Essentially, they enclose the code where local variables are used, including [[#Timers|timers]]. They can be opened and closed many times in a [[#Structure|script]]:
 +
 
 +
{
 +
    [...]
 +
}
 +
 
 +
;Limits
 +
:Scopes cannot be nested;
 +
:Opening and closing curly brakets are real commands.
 +
 
 +
==Labels==
 +
 
 +
A ''label'' is a ''sequence of characters'' which identify the reference of a location of the source code useful for ''gotoes''. It can be accessed by any part of the source code. To define a label just append ''':''' (colon) to its name:
 +
 
 +
[...]
 +
 +
{lblname}:
 +
[...]
 +
 
 +
At the compiling time, they are automatically converted into an [[#Offsets|offset]].
 +
 
 +
==Variables==
 +
A ''variable'' is a memory address that is given a name. Variables are used to reference values that are stored in the game's memory and that can change (hence the name "variable"). Instructions may read the variable's memory or write to it. They act in the same way as [[wikipedia:Pointer (computer programming)|pointers]] in other programming languages.
 +
 
 +
There are several words related to variables that are important to know:
 +
* The ''value'' of the variable is the data that lies at the variable's memory address.
 +
* The ''type'' is what kind of value the variable stores.
 +
* The ''scope'' is the region of code in which the variable may be used (and in which it is declared). There are two types:
 +
** The ''global'' scope is shared between all game [[#Structure|scripts]]. Global variables have the same value everywhere. They are declared with the <code>VAR</code> prefix.
 +
** The ''local'' scope is a region of code within a script. Locals are only visible to other code inside the same pair of curly braces. They are declared with the <code>LVAR</code> prefix.
 +
* A ''timer'' is a unique local variable whose value rises automatically. They start counting when the script starts executing, and continue counting indefinitely. There are two such timers, <code>TIMERA</code> and <code>TIMERB</code> which are always defined, so do not need to be declared.
 +
 
 +
===Data types===
 +
----
 +
Among the available data types, some are equivalent to those of the most known programming languages. Their length is up to 4, 8 and 16 bytes. Each type is appended as a suffix in the ''variable declaration''.
 +
 
 +
''For an in-depth description of different data types, see [https://gtamods.com/wiki/SCM_Instruction#Concrete_data_types the SCM instruction page]''.
 +
 
 +
====LABEL====
 +
 
 +
The '''LABEL''' type handles ''variable-length strings''. It can refer to either a ''[[#Labels|label]] name'' or a ''file name''.
 +
 
 +
;Notes
 +
:While inside a script file, R* compiler treats it unambiguously as a label;
 +
:R* compiler allocates 32 bytes per label.
 +
 
 +
;Limit
 +
:'''LABEL''' variables aren't available.
 +
 
 +
====INT====
 +
 
 +
The '''INT''' type handles ''32-bit signed integers''. It is also used to store [[#Value|values]] with less bytes, such as a [[Wikipedia:Primitive_data_type#Booleans|bool]], a [[Wikipedia:Character_(computing)#char|char]] and a [[Wikipedia:Integer_(computer_science)#Short_integer|short int]].
 +
 
 +
====FLOAT====
 +
 
 +
The '''FLOAT''' type handles ''32-bit floating-points''. As it normally does, decimal precision of a [[Wikipedia:Floating_point|float]] is usually stuck to 6-7 digits beyond which it may get lost.
 +
 
 +
;Notes
 +
:R* compiler also accepts ''f'' and ''F'' suffixes for the immediate value.
 +
 
 +
====TEXT_LABEL====
 +
 
 +
The '''TEXT_LABEL''' type handles ''8-byte strings''. Generally, a [[Wikipedia:String_(computer_science)|string]] is an ''array of 1-byte characters''. It requires ''7 characters plus the [[Wikipedia:Null_character|null-terminator]]'' (a blank byte meaning the ''end of the string''). It is used to hold ''GXT keys'' (those of ''town zones'', ''interiors'', ''help textes'' or ''dialogue subtitles'') ''script names'' or any short string. Literal only '''TEXT_LABEL*''' strings are probably marked by ''single quotation marks'' to distinguish them from variable and constant identifiers:
 +
 
 +
PRINT_BIG 'GXT_KEY'
 +
 
 +
;Limit
 +
:'''TEXT_LABEL''' variables are supported in {{icon|sa}} and {{icon|vcs}}.
 +
 
 +
====TEXT_LABEL16====
 +
 
 +
The '''TEXT_LABEL16''' type handles ''16-byte strings''. Like the previous, this type holds ''15 characters plus the null-terminator''. It is used to store ''model and texture names of player clothes'', ''animation names'' or any long string.
 +
 
 +
;Limit
 +
:'''TEXT_LABEL16''' variables and values are supported only in {{icon|sa}}.
 +
 
 +
====TEXT_LABEL32====
 +
 
 +
The '''TEXT_LABEL32''' type handles ''32-byte strings'' or larger, depending on how many continuous parameters of the same type there are, each of which occupies 32 bytes. It can hold up to ''127 characters plus the null-terminator'', after which another '''TEXT_LABEL32''' argument may begin. Strings of such type must be put within ''double quotation marks'':
 +
 
 +
SAVE_STRING_TO_DEBUG_FILE "32B-128B TEXT"
 +
 
 +
;Limits
 +
:'''TEXT_LABEL32''' values are supported since {{icon|vc}};
 +
:'''TEXT_LABEL32''' variables aren't available.
 +
 
 +
====TEXT====
 +
 
 +
The '''TEXT''' type handles ''N-byte strings''. It holds ''N characters plus the null-terminator''. Strings of this type mustn't exceed 255 characters (including the null-byte).
  
* ''Single-line'' comment, prefixed with // (two forward slashes), which extends till the end of the line. Everything is ignored inside: <code>// Some comment.</code>;
+
;Limits
* ''Multi-line'' comment, enclosed with a pair of /* (a slash plus an asterisk) and */ (the other way around), which covers a cricumscribed text area. Several blocks can be nested together: <code>/* Some /* comment */ . */</code>.
+
:'''TEXT''' values are supported since {{icon|sa}};
 +
:'''TEXT''' variables aren't available.
  
==Delimiters==
+
====CONST (pseudo)====
Conventionally, lines can be splitted into various regions in order to enhance the code legibility through bracket-delimited and/or comma-separated elements. As being pure white-spaces, the opening parenthesis delimiter doesn't necessarily need to match the closing counterpart and viceversa. The only tangible use of separators carried out in public sources is related to inline declaration of multiple variables, text keys of print-commands and '''SETUP_ZONE_PED_INFO''' but codes can be organized to one's liking. Here are some demonstrations:
 
  
VAR_INT joeys_buggy, swank_taxi
+
The '''CONST''' type handles ''32-bit signed integers''. It is used only to assign and compare [[#Constants|constants]] to '''INT''' variables regarding ''model [[#Identifiers|identifiers]]'', ''task statuses'', ''ped or audio events'' and such. It is a pseudo type of '''INT'''.
PRINT_NOW (ASUKA) 2000 1
 
SETUP_ZONE_PED_INFO CHINA DAY (30) 350 600 0 (0 0 0 0) 0
 
  
==Integers and Floating-points==
+
;Limit
 +
:The [[#Arithmetic|assignment]] and [[#Comparison|comparison]] of '''CONST''' values are supported since {{icon|vc}}.
  
==Labels, Text labels and Strings==
+
====MULTI (pseudo)====
Thanks to the beneficial code fragmentation, the source is subject to external file inclusions and variegated in-file unconditional branches involving embedded code blocks diversification. Both kinds of partitioning are accomplished respectively through the specification of:
 
  
* ''Filenames'', that is special labels which somehow resemble legit pathnames, starting with any valid pathname character but not containing whitespaces. They are relative to the root path deriving from the .sc extension removal of the main script full path where files are searched in by default: <code>X:\folder\main</code>. Subfolders are scanned as well:
+
The '''MULTI''' type handles a group of few data types acceptable per argument. It is used only for commands featuring optional arguments, those whose type is unpredictable before the compilation. It can be a pseudo type of '''INT''', '''FLOAT''' and '''TEXT_LABEL'''.
** Till the first tree level if inside one of the subdirectories: <code>X:\parent\main\child</code>;
 
** Till the second tree level if inside one of the parent directories: <code>X:\parent</code> or <code>X:\parent\main</code>;
 
** Indefinitely (unlimited recursion till the maximum path length allowed).
 
:The .sc extension at the end of filenames is mandatory else an argument mismatch is warned, by contrast the main script can have any extension to which ''m'' (multifile) or ''c'' (combinedfile) is appended in the target pathname. Due to a [[Cd image]] system limitation, all sorts of filename must be shorter than 20 characters and conventionally they must be free of extra dots for streamed scripts.
 
* ''Label references'', that is unique string identifiers suffixed by a colon which identify a precise location within the common (main script, main extensions and subscripts) or the actual (mission scripts and streamed scripts) script space. Basically, they represent the target position of either goto-like, script starter or function caller commands: <code>my_label_ref:</code> (on a new line). Weirdly enough, label references may begin with any character alike filenames despite they are susceptible to the same restrictions of string identifiers whenever passed as arguments but must not exceed 38 characters, colon excluded, either way. Whereas these are not commands, anything else can follow next to and being inlined so long as a splitting character is inserted.
 
  
That said, labels are essentially user-supplied string identifiers whose existence is verified. Text label identifiers are not fully bound to this rule (except script names) since they are massively employed as main/mission text keys or whatever referring to an internal resource, which the game handles according to a well-defined associative scheme. Notoriously, identifiers length is anything but expensive for readability reasons, in addition they do not even offer the ability to insert white-spaces or other inadmissible characters owing to the by-design absence of delimiting tokens. <incorrect>At this matter, variable-length strings and debugging texts sent as 128-byte string literals are enclosed by " " (double quotes):
+
;Notes
 +
:'''INT''' and '''FLOAT''' can be used interchangeably in {{icon|3}}, {{icon|vc}}, {{icon|sa}}, {{icon|lcs}} and {{icon|vcs}};
 +
:{{icon|vcs}} also admits '''TEXT_LABEL''' arguments.
  
CUSTOM_PLATE_FOR_NEXT_CAR CAR_TAMPA "_FELTCH_"</incorrect>
+
===Declaration===
SAVE_STRING_TO_DEBUG_FILE "CURRENT_WANTED_LIST = "
+
----
 +
''Defining a variable'' means ''assigning a token string to a memory cell'' at the compiling time. Variables must be declared in the following manner:
  
Empty text labels are impracticable, though '''NIL''' compiles a <code>NUL</code>-string in the last Stories chapter<sup>[no source]</sup><s> &ndash; as reported by some indiscreet sources, the rearrangement of crucial commands signals a syntax enhancement the language has undergone which sees delimited strings superseding text labels, lowly probable because string constants are still disallowed for multi-type parameters; as previously assumed, instead, '''DUMMY''' could have been the placeholder keyword but a text key exists actually, while a single _ (underscore) is more Python-oriented (used as a throwaway variable)</s>. It's worth noting string literals and text labels are not interchangeable because of their syntactic differences even if they present semantic similarities, moreover text labels do not ever interfere with command names and string constants. A final quirk to note concerning labels as a whole is they are automatically converted to upper case: this obvious evidence proves identifiers and whatnot are all case insensitive with the exception that 128-byte strings are left as-is for remastered game builds.
+
VAR_* {varname0}[,] [... {varnameN}]
 +
LVAR_* {varname0}[,] [... {varnameN}]
  
==Data types==
+
As mentioned in the sections above, local variables have to be put within curly brackets:
Forasmuch as the language obeys the [[Wikipedia:Strong and weak typing|strong typing]] paradigm, the syntactic elements that denote a value during execution do have fixed data types, most of which are appended as a suffix at variable declaration. Their conspicuous assortment is listed below:
 
  
{|class=wikitable style="text-align: center"
+
{
 +
    VAR_* {varname0}[,] [... {varnameN}]
 +
    LVAR_* {varname0}[,] [... {varnameN}]
 +
 +
    [...]
 +
}
 +
 
 +
''Inline variable declaration'' is allowed, you just have to separate them by ''spaces'' or ''tabulations''. Adding a preceding ''comma'' before these characters is optional.
 +
 
 +
;Limits
 +
:Whereas the ''variable buffer'' is limited, you can declare a certain amount of globals and locals. [[#INT|INT]] and [[#FLOAT|FLOAT]] types take 1 variable, while [[#TEXT_LABEL|TEXT_LABEL]] and [[#TEXT_LABEL16|TEXT_LABEL16]] types occupy respectively 2 and 4 variables to store their data (have a look [[#Variables range|here]] for further details);
 +
:{{icon|vcs}} isn't affected by what said above;
 +
:Global and local variable names must not collide.
 +
 
 +
====Arrays====
 +
 
 +
A ''array'' is a ''collection of variables'' having the same type which can be accessed by an ''index'', an '''INT''' lesser than or equal to the size specified, enclosed by ''square brackets'':
 +
 
 +
{
 +
    VAR_* {varname0}{[arrsize0]}[,] [... {varnameN}{[arrsizeN]}]
 +
    LVAR_* {varname0}{[arrsize0]}[,] [... {varnameN}{[arrsizeN]}]
 +
 +
    [...]
 +
}
 +
 
 +
;Limits
 +
:The usage of arrays is allowed since {{icon|vc}};
 +
:Variable indices are quite buggy in {{icon|vc}} and therefore unrecommended, but they are fully supported since {{icon|sa}};
 +
:The aforesaid indices are one-based, possibly zero-based since {{icon|sa}};
 +
:Multidimensional arrays are not supported.
 +
 
 +
====Handles====
 +
 
 +
A ''handle'' is an univocal identifier assigned to a game entity. It is given by the following statement:
 +
 
 +
<source lang=cpp>short nHandle = (iEntityIndexInPool << 8) | ucEntityFlag;</source>
 +
 
 +
;Note
 +
:R* compiler won't let you assign different entity types to the same variable or using a variable which hasn't been passed to any [[#Commands|command]] designated to the creation of an entity.
 +
 
 +
==Operators==
 +
 
 +
In general, an ''operator'' is a token string that represents a math calculation or an operation of any other kind, in order to make the code understanding clearer at a glance.
 +
 
 +
===Arithmetic===
 +
 
 +
''Arithmetic operators'' compute some of the most common algebric calculations between either a [[#Variables|variable]] and a [[#Value|value]] or two variables. As well as in some programming language happens, [[#CONST (pseudo)|CONST]], [[#TEXT_LABEL|TEXT_LABEL]] and [[#TEXT_LABEL16|TEXT_LABEL16]] types are free from these operators, except for the ''basic assignment''  (see also [[#Operators composition|Operators composition]]):
 +
 
 +
{|class=wikitable
 +
!width=70px|Operator
 +
!width=225px colspan=2|Name
 +
!width=225px|Syntax
 +
!width=550px|Description
 +
|-
 +
!=
 +
|align=center colspan=2|Assignment
 +
|align=center|<code>expr0 '''=''' expr1</code>
 +
|Store ''expr1'' to ''expr0''
 +
|-
 +
!+
 +
|align=center colspan=2|Addition
 +
|align=center|<code>expr0 '''+''' expr1</code>
 +
|Add ''expr1'' to ''expr0''
 +
|-
 +
!-
 +
|align=center colspan=2|Subtraction
 +
|align=center|<code>expr0 '''-''' expr1</code>
 +
|Subtract ''expr1'' from ''expr0''
 +
|-
 +
!*
 +
|align=center colspan=2|Multiplication
 +
|align=center|<code>expr0 '''*''' expr1</code>
 +
|Multiply ''expr0'' by ''expr1''
 +
|-
 +
!/
 +
|align=center colspan=2|Division
 +
|align=center|<code>expr0 '''/''' expr1</code>
 +
|Divide ''expr0'' by ''expr1''
 
|-
 
|-
!style="text-align: left"|Name
+
!+@
!Format
+
|align=center colspan=2|Timed addition
!Size
+
|align=center|<code>expr0 '''+@''' expr1</code>
!Range
+
|Multiply ''expr2'' by delta time and add the result to ''expr1''
!width=64px|Game<br/>support
 
!width=64px|Variable<br/>support
 
!Is<br/>basic
 
 
|-
 
|-
!colspan=7|Single-typed
+
!-@
 +
|align=center colspan=2|Timed subtraction
 +
|align=center|<code>expr0 '''-@''' expr1</code>
 +
|Multiply ''expr2'' by delta time and subtract the result from ''expr1''
 
|-
 
|-
|align=left|'''LABEL'''||String identifier<br/><span style="font-size: 0.75em">(translated to offset/index)</span>||rowspan=2|4||rowspan=2|-2<sup>31</sup> to 2<sup>31</sup>-1||rowspan=2|Since {{icon|3}}||None||
+
!rowspan=2|++
 +
|align=center rowspan=2|Increment
 +
|align=center|Pre{{ref|preinc|[*]}}
 +
|align=center|<code>'''++''' expr0</code>
 +
|rowspan=2|Increment ''expr0'' by 1 and store the result to ''expr0''
 
|-
 
|-
|align=left|'''INT'''||Signed integer||rowspan=3|Since {{icon|3}}||&#x2713;
+
|align=center|Post
 +
|align=center|<code>expr0 '''++'''</code>
 
|-
 
|-
|rowspan=2 align=left|'''FLOAT'''||[[Wikipedia:Q (number format)|Q11.4 fixed-point]]||2||-2<sup>11</sup> to 2<sup>11</sup>-2<sup>-4</sup>||{{icon|3}} only||rowspan=2|&#x2713;
+
!rowspan=2|--
 +
|align=center rowspan=2|Decrement
 +
|align=center|Pre{{ref|preinc|[*]}}
 +
|align=center|<code>'''--''' expr0</code>
 +
|rowspan=2|Decrement ''expr0'' by 1 and store the result to ''expr0''
 
|-
 
|-
|[[Wikipedia:Floating point|IEEE-754 floating-point]]||4||&plusmn;3.4&times;10<sup>&plusmn;38</sup>||Since {{icon|vc}}
+
|align=center|Post
 +
|align=center|<code>expr0 '''--'''</code>
 +
|}
 +
 
 +
;Note
 +
:{{note|preinc}} Pre and post increments have no difference unlike what you would expect.
 +
 
 +
Yet, you can put the ''assignment'' and ''algebric'' operators together inline as follows:
 +
 
 +
{|class=wikitable
 +
!width=70px|Operators
 +
!width=225px|Name
 +
!width=225px|Syntax
 +
!width=550px|Description
 
|-
 
|-
|align=left|'''TEXT_LABEL'''||rowspan=2|UTF-8 null-terminated<br/>[[Wikipedia:String (computer science)|string]] identifier||8||1 to 7||Since {{icon|3}}||{{icon|sa}} and {{icon|vcs}}||&#x2713;
+
!= +
 +
|align=center|Addition and assignment
 +
|align=center|<code>expr0 '''=''' expr1{{ref|expr01|[*]}} '''+''' expr2</code>
 +
|Add ''expr2'' to ''expr1'' and store the result to ''expr0''
 
|-
 
|-
|align=left|'''TEXT_LABEL16'''||16||1 to 15||rowspan=2|{{icon|sa}} only||{{icon|sa}} only||&#x2713;
+
!= -
 +
|align=center|Subtraction and assignment
 +
|align=center|<code>expr0 '''=''' expr1{{ref|expr01|[*]}} '''-''' expr2</code>
 +
|Subtract ''expr2'' from ''expr1'' and store the result to ''expr0''
 
|-
 
|-
|align=left|'''TEXT_LABEL32'''||UTF-8 null-terminated<br/>string identifier<br/><span style="font-size: 0.75em">(4 contiguous blocks)</span>||32&times;4||1 to 127||None||
+
!= *
 +
|align=center|Multiplication and assignment
 +
|align=center|<code>expr0 '''=''' expr1{{ref|expr01|[*]}} '''*''' expr2</code>
 +
|Multiply ''expr1'' by ''expr2'' and store the result to ''expr0''
 +
|-
 +
!= /
 +
|align=center|Division and assignment
 +
|align=center|<code>expr0 '''=''' expr1{{ref|expr01|[*]}} '''/''' expr2</code>
 +
|Divide ''expr1'' by ''expr2'' and store the result to ''expr0''
 +
|-
 +
!= +@
 +
|align=center|Timed addition and assignment
 +
|align=center|<code>expr0 '''=''' expr1{{ref|expr01|[*]}} '''+@''' expr2</code>
 +
|Multiply ''expr2'' by delta time, add the result to ''expr1'' and store everything to ''expr0''
 +
|-
 +
!= -@
 +
|align=center|Timed subtraction and assignment
 +
|align=center|<code>expr0 '''=''' expr1{{ref|expr01|[*]}} '''-@''' expr2</code>
 +
|Multiply ''expr2'' by delta time, subtract the result from ''expr1'' and store everything to ''expr0''
 +
|}
 +
 
 +
;Note
 +
:{{note|expr01}} ''expr1'' can represent ''expr0'' too.
 +
 
 +
;Limit
 +
:Multiple algebric operators per line are not allowed.
 +
 
 +
===Compound assignment===
 +
 
 +
''Compound assignment operators'' store [[#Value|values]] or [[#Variables|variable]] content to other variables having a particular type afterwards the computation of an arithmetic operation, to squeeze the code and clear it up from granted repetitions:
 +
 
 +
{|class=wikitable
 +
!width=70px|Operator
 +
!width=225px|Name
 +
!width=225px|Syntax
 +
!width=550px|Description
 +
|-
 +
!+=
 +
|align=center|Addition assignment
 +
|align=center|<code>expr0 '''+=''' expr1</code>
 +
|Add ''expr1'' to ''expr0'' and store the result to ''expr0''
 +
|-
 +
!-=
 +
|align=center|Subtraction assignment
 +
|align=center|<code>expr0 '''-=''' expr1</code>
 +
|Subtract ''expr1'' from ''expr0'' and store the result to ''expr0''
 +
|-
 +
!*=
 +
|align=center|Multiplication assignment
 +
|align=center|<code>expr0 '''*=''' expr1</code>
 +
|Multiply ''expr0'' by ''expr1'' and store the result to ''expr0''
 +
|-
 +
!/=
 +
|align=center|Division assignment
 +
|align=center|<code>expr0 '''/=''' expr1</code>
 +
|Divide ''expr0'' by ''expr1'' and store the result to ''expr0''
 +
|-
 +
!+=@
 +
|align=center|Timed addition assignment
 +
|align=center|<code>expr0 '''+=@''' expr1</code>
 +
|Multiply ''expr1'' by delta time, add the result to ''expr0'' and store everything to ''expr0''
 +
|-
 +
!-=@
 +
|align=center|Timed subtraction assignment
 +
|align=center|<code>expr0 '''-=@''' expr1</code>
 +
|Multiply ''expr1'' by delta time, subtract the result from ''expr0'' and store everything to ''expr0''
 +
|}
 +
 
 +
===Uncompounded assignment===
 +
 
 +
''Uncompounded assignment operators'' are those on their own, or rather they are neither derivable nor decomposable similarly as those [[#Compound assignment|compounds]]:
 +
 
 +
{|class=wikitable
 +
!width=70px|Operator
 +
!width=225px|Name
 +
!width=225px|Syntax
 +
!width=550px|Description
 +
|-
 +
!=#
 +
|align=center|Cast assignment
 +
|align=center|<code>expr0 '''=#''' expr1</code>
 +
|Cast ''expr1'' to any other type and store the result to ''expr0''
 +
|}
 +
 
 +
;Limit
 +
:Supported conversions are [[#FLOAT|FLOAT]] to [[#INT|INT]] and '''INT''' to '''FLOAT'''.
 +
 
 +
===Logical===
 +
 
 +
''Logical operators'' influence the way conditions are evalueted and enable to test more of them at a time. More than anything, they are built-in statements:
 +
 
 +
{|class=wikitable
 +
!width=70px|Operator
 +
!width=225px|Name
 +
!width=225px|Syntax
 +
!width=550px|Description
 +
|-
 +
!NOT
 +
|align=center|Logical negation
 +
|align=center|<code>IF '''NOT''' condition0</code>
 +
|Test if ''condition0'' is false
 +
|-
 +
!AND
 +
|align=center|Logical conjunction
 +
|align=center|<code>IF condition0<br/>'''AND''' condition8</code>
 +
|Test if both ''condition0'' and ''conditionN'' are true
 +
|-
 +
!OR
 +
|align=center|Logical disjunction
 +
|align=center|<code>IF condition0<br/>'''OR''' condition8</code>
 +
|Test if either ''condition0'' or ''conditionN'' is true
 +
|}
 +
 
 +
===Comparison===
 +
 
 +
''Comparison operators'' test the truth or falsity of the relation between either a [[#Variables|variable]] and a [[#Value|value]], a value and a variable or two variables:
 +
 
 +
{|class=wikitable
 +
!width=70px|Operator
 +
!width=225px|Name
 +
!width=225px|Syntax
 +
!width=550px|Description
 
|-
 
|-
!colspan=7|Multi-typed
+
!=
 +
|align=center|Equal to
 +
|align=center|<code>IF expr0 '''=''' expr1</code>
 +
|Test if ''expr0'' and ''expr1'' are equal
 
|-
 
|-
|rowspan=2 align=left|'''PARAM'''||colspan=3|Same as '''INT''' and '''FLOAT'''||colspan=2|Since {{icon|3}}||rowspan=4|
+
!>
 +
|align=center|Greater than
 +
|align=center|<code>IF expr0 '''>''' expr1</code>
 +
|Test if ''expr0'' is greater than ''expr1''
 
|-
 
|-
|colspan=3|Same as '''TEXT_LABEL'''||colspan=2|Since {{icon|vcs}}
+
!<{{ref|inverr|[*]}}
 +
|align=center|Lesser than
 +
|align=center|<code>IF expr0 '''<''' expr1</code>
 +
|Test if ''expr0'' is lesser than ''expr1''
 
|-
 
|-
|rowspan=2 align=left|'''STRING'''||UTF-8 string<br/><span style="font-size: 0.75em">(non null-terminated)</span>||1..127||1 to N-1||rowspan=2|{{icon|sa}} only||None
+
!>=
 +
|align=center|Greater than or equal to
 +
|align=center|<code>IF expr0 '''>=''' expr1</code>
 +
|Test if ''expr0'' is greater than or equal to ''expr1''
 
|-
 
|-
|colspan=3|Same as '''TEXT_LABEL/16'''<br/><span style="font-size: 0.75em">(variable-only)</span>||{{icon|sa}} only
+
!<={{ref|inverr|[*]}}
 +
|align=center|Lesser than or equal to
 +
|align=center|<code>IF expr0 '''<=''' expr1</code>
 +
|Test if ''expr0'' is lesser than or equal to ''expr1''
 
|}
 
|}
  
Some tiny caveats about immediate numeric fields:
+
;Note
 +
:{{note|inverr}} As a result of a critical bug, R* compiler mistakenly applies the operator inversion.
 +
 
 +
==Commands==
 +
 
 +
A ''command'' is a ''symbolic name'' associated to an [[#Command ID|identifier]] which executes a ''portion of code'' that specifies the operation to be performed by passing ''zero or more arguments''. An ''argument'' is in turn some data given as input to a command. Normally, commands have a defined amount of arguments and those not, such as '''START_NEW_SCRIPT''', can pass as many arguments as the available [[#Local|local]] [[#Variables|variables]] are, except [[#Timers|timers]]. Being a procedure, a command does not return [[#Value|values]] that can be assigned to a variable, even though the boolean flag is kept whenever it is used as a ''condition''. It follows the common programming syntax adopted for ''function calls'':
 +
 
 +
{commandname} [{anyvalue0|varname0} ... {anyvalueN|varnameN}]
 +
 
 +
===Alternators===
 +
An ''alternator'' is an abstract operation that is implemented with a set of commands, each of which takes differently typed arguments.
 +
 
 +
Alternators are used because there are often multiple different combinations of argument types that one might wish to use for an operation. While <code>1 + 2</code> and <code>1 + 2.0</code> are equivalent to a human, they are not to a computer, so they must be implemented differently.
 +
 
 +
Each command has the same [http://en.wikipedia.org/wiki/Arity arity] as the other commands implementing the same operation. They differ only the in combination and order of their parameters' types.
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed">
 +
Common alternators
 +
<div class="mw-collapsible-content">
 +
* {{icon|t}} {{icon|lcs}} {{icon|vcs}}
 +
** '''SET (=)'''
 +
** '''CSET (=#)'''
 +
** '''ADD_THING_TO_THING (+=)'''
 +
** '''SUB_THING_FROM_THING (-=)'''
 +
** '''MULT_THING_BY_THING (*=)'''
 +
** '''DIV_THING_BY_THING (/=)'''
 +
** '''IS_THING_EQUAL_TO_THING (=)'''
 +
** '''IS_THING_NOT_EQUAL_TO_THING (NOT =)'''
 +
** '''IS_THING_GREATER_THAN_THING (>, <=)'''
 +
** '''IS_THING_GREATER_OR_EQUAL_TO_THING (>=, <)'''
 +
** '''ADD_THING_TO_THING_TIMED (+=@)'''
 +
** '''SUB_THING_FROM_THING_TIMED (-=@)'''
 +
** '''ABS'''
 +
* {{icon|sa}}
 +
** '''IS_EMPTY'''
 +
** '''IS_BIT_SET'''
 +
** '''SET_BIT'''
 +
** '''CLEAR_BIT'''
 +
** '''STRING_CAT'''
 +
</div>
 +
</div>
 +
 
 +
{{incomplete}}
 +
 
 +
===Hardcoded===
 +
 
 +
''Hardcoded commands'' are those which have unique characteristics and are handled internally:
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed">
 +
List of hardcoded commands
 +
<div class="mw-collapsible-content">
 +
* {{icon|t}} {{icon|lcs}} {{icon|vcs}}:
 +
** '''GOTO'''
 +
** '''GOTO_IF_FALSE'''
 +
** '''TERMINATE_THIS_SCRIPT'''
 +
** '''START_NEW_SCRIPT'''
 +
** '''VAR_INT'''
 +
** '''VAR_FLOAT'''
 +
** '''LVAR_INT'''
 +
** '''LVAR_FLOAT'''
 +
** '''{'''
 +
** '''}'''
 +
** '''REPEAT'''
 +
** '''ENDREPEAT'''
 +
** '''IF'''
 +
** '''IFNOT'''
 +
** '''ELSE'''
 +
** '''ENDIF'''
 +
** '''WHILE'''
 +
** '''WHILENOT'''
 +
** '''ENDWHILE'''
 +
** '''ANDOR'''
 +
** '''LAUNCH_MISSION'''
 +
** '''SAVE_VAR_INT'''
 +
** '''SAVE_VAR_FLOAT'''
 +
** '''START_CUTSCENE'''{{ref|depcnt|[*]}}
 +
** '''PLAYER_MADE_PROGRESS'''
 +
** '''SET_PROGRESS_TOTAL'''{{ref|thgtot|[*]}}
 +
** '''REGISTER_MISSION_GIVEN'''{{ref|depcnt|[*]}}
 +
** '''REGISTER_MISSION_PASSED'''
 +
** '''SCRIPT_NAME'''
 +
** '''LOAD_AND_LAUNCH_MISSION'''
 +
** '''LOAD_AND_LAUNCH_MISSION_INTERNAL'''
 +
** '''SET_TOTAL_NUMBER_OF_MISSIONS'''{{ref|thgtot|[*]}}
 +
** '''VAR_TEXT_LABEL'''
 +
** '''LVAR_TEXT_LABEL'''
 +
* {{icon|vc}} {{icon|sa}} {{icon|lcs}} {{icon|vcs}}:
 +
** '''REGISTER_ODDJOB_MISSION_PASSED'''
 +
* {{icon|3}} {{icon|lcs}} {{icon|vcs}}:
 +
** '''GOTO_IF_TRUE'''
 +
** '''GOSUB_FILE'''
 +
* {{icon|3}} {{icon|vc}}:
 +
** '''CREATE_COLLECTABLE1'''
 +
** '''SET_COLLECTABLE1_TOTAL'''{{ref|thgtot|[*]}}
 +
* {{icon|vc}} {{icon|sa}}:
 +
** '''LOAD_AND_LAUNCH_MISSION_EXCLUSIVE'''
 +
* {{icon|lcs}} {{icon|vcs}}:
 +
** '''CALL'''
 +
** '''CALLNOT'''
 +
* {{icon|sa}}:
 +
** '''VAR_TEXT_LABEL16'''
 +
** '''LVAR_TEXT_LABEL16'''
 +
** '''SWITCH'''
 +
** '''ENDSWITCH'''
 +
** '''CASE'''
 +
** '''DEFAULT'''
 +
** '''BREAK'''
 +
** '''SWITCH_START'''
 +
** '''SWITCH_CONTINUED'''
 +
* {{icon|vcs}}:
 +
** '''SAVE_VAR_TEXT_LABEL'''{{ref|thgtot|[*]}}
 +
** '''SET_COLLECTABLE2_TOTAL'''
 +
 
 +
;Notes
 +
:{{note|thgtot}} The argument of these commands must be set respectively according to:
 +
:* The sum of '''PLAYER_MADE_PROGRESS''' values;
 +
:* The amount of '''REGISTER_MISSION_PASSED''' (those that don't have an immediate value are excluded) and '''REGISTER_ODDJOB_MISSION_PASSED''';
 +
:* The amount of '''CREATE_COLLECTABLE1'''.
 +
:If the argument of the listed commands differs from what expected, a 0-value must be passed;
 +
:{{note|depcnt}} This command was intended to be counted originally but its counter got deprecated.
 +
 
 +
</div>
 +
</div>
 +
 
 +
{{incomplete}}
 +
 
 +
===WAIT===
 +
 
 +
'''WAIT''' stops the execution of a [[#Structure|script]] according to some milliseconds after which it will resume again. Indeed, it is absolutely necessary into ''infinite loops'' or those that may or may not break after more than one frame, such as the [[#WHILE|WHILE]] control flow. In this case, a [[#INT|INT]] equal to 0 is passed.
 +
 
 +
===GOTO===
 +
 
 +
'''GOTO''' jumps to the [[#Labels|label]] of any location of the source code but conceptually it should never point off the current context. It is also used internally to build the [[#Control flows|control flows]] offered by the scripting language:
 +
 
 +
// File: any.sc
 +
 +
goto_ref0:
 +
GOTO goto_refN
 +
 
 +
// File: any.sc
 +
 +
goto_refN:
 +
GOTO goto_ref0
 +
 
 +
===ANDOR===
 +
 
 +
'''ANDOR''' sets out the way the comparison among more conditions have to occur (see also [[#Compare flag|Compare flag]]).
 +
 
 +
===GOTO_IF_TRUE===
 +
 
 +
'''GOTO_IF_TRUE''' operates in conjunction with [[#ANDOR|ANDOR]] and jumps to a [[#Labels|label]] if the returned boolean flag is true.
 +
 
 +
===GOTO_IF_FALSE===
 +
 
 +
Unlike [[#GOTO_IF_TRUE|GOTO_IF_TRUE]], '''GOTO_IF_FALSE''' jumps to the desired [[#Labels|label]] only if the comparison returns false.
 +
 
 +
===SCRIPT_NAME===
 +
 
 +
'''SCRIPT_NAME''' simply associates an unique name to the current working [[#Structure|script]].
 +
 
 +
;Note
 +
:R* compiler doesn't enable you to associate a name previously used for another script.
 +
 
 +
===SAVE_STRING_TO_DEBUG_FILE===
 +
 
 +
'''SAVE_STRING_TO_DEBUG_FILE''' accepts an argument which can admit up to ''127 characters plus the null-terminator''. In the compiling process, the argument is skipped but its string is copied to a predefined ''128-bytes buffer'', compiled afterwards. Since {{icon|vc}}, these are the seemingly predetermined bytes of a random empty string block which are actually the result of uninitialized data:
 +
 
 +
00 00 41 00 09 2E 00 00 00 00 00 00 '''00''' 00 00 00
 +
09 2E 00 00 00 00 00 00 1C FB 12 00 D8 A8 41 00
 +
00 00 41 00 09 2E 00 00 00 00 00 00 '''01''' 00 00 00
 +
09 2E 00 00 00 00 00 00 1C FB 12 00 D8 A8 41 00
 +
00 00 41 00 09 2E 00 00 00 00 00 00 '''02''' 00 00 00
 +
09 2E 00 00 00 00 00 00 1C FB 12 00 D8 A8 41 00
 +
00 00 41 00 09 2E 00 00 00 00 00 00 '''03''' 00 00 00
 +
09 2E 00 00 00 00 00 00 1C FB 12 00 D8 A8 41 00
 +
 
 +
The split of such bytes into 4 blocks of 32-bytes each is quite noticeable.
 +
 
 +
==Constants==
 +
 
 +
A ''constant'' is a ''symbolic name'' associated to a specific [[#Value|value]]. When compiling, their caption is converted to the assigned value. Since {{icon|vc}}, names and identifiers of objects within [[OBJS]] and [[TOBJ]] blocks are loaded from every ''IDE'' file defined into [[gta.dat|gta_vc.dat]], then those of vehicles and pedestrians within [[PEDS]] and [[CARS]] blocks are retrieved from [[default.ide]]. In {{icon|sa}}, they are listed into ''TXT'' files, whose name follows the [[Wikipedia:CamelCase|Pascal Case]] (eg. ''AudioEvents.txt''). These files respect the syntax below:
 +
 
 +
{constname0} {constvalue0}
 +
 +
{constnameN} {constvalueN}
 +
 
 +
''Constant names and values'' are divided by as many ''spaces'' or ''tabulations'' as you want. ''Constant lines'' are distinguished by two '''\n''' (new line) characters. The ''model names'' which aren't assigned to a constant are still valid (see also [[#Identifiers|Identifiers]]). Keep in mind arguments of some [[#Commands|commands]] having the [[#CONST (pseudo)|CONST]] type accept only ''constant values'' of a single ''namespace''.
 +
 
 +
;Notes
 +
:Constants don't collide even though they belong to different namespaces;
 +
:In {{icon|3}} and {{icon|vc}}, they are hardcoded as everything inside R* compiler;
 +
:In {{icon|sa}}, the subdivision of constant namespaces in files might be just a listing of hardcoded constants useful for developers. The same would apply to {{icon|lcs}} and {{icon|vcs}}.
 +
 
 +
==Formatting==
 +
 
 +
Everything is ''case-insensitive'', that means the uppercase and lowercase letters have no dissimilarities when taken. Usually, the source code is conform to the same formatting according to:
 +
 
 +
* [[#Labels|Labels]] and [[#Variables|variables]] are entirely in lowercase;
 +
* [[#Declaration|Declarations]], [[#Commands|commands]] and [[#Control flows|control flows]] are in uppercase;
 +
* [[#Constants|Constants]] are mostly in uppercase but the lowercase variant can be seen as well.<br/><br/>
 +
=Compiling=
 +
 
 +
==Structure==
  
* String constants are compatible with integer parameters;
+
The source code is split up into several ''SC'' files which comprehend ''main file'', ''foreign gosubs'', ''subscripts'', ''mission scripts'', and ''streamed scripts''. These files can be included more times because they are actually processed once.
* Literals must begin with a number or - (minus sign) or rather . (decimal point, for float values);
 
* Integers allow only the decimal notation;
 
* Floats disallow scientific notation and such;
 
* Integral and fractional parts are singularly omissible;
 
* F or f suffix can be appended next to (quite unused/useless).
 
  
==Immediates and Variables==
+
===Main file===
Data can take the appearance of a few expressions varying from numeric, text label and string literals each of which occupies a certain area of storage with unfixed size. Immediates can also be preserved for later use and therefore reserve space over the private script memory corresponding to a variable. The strongly-typed language property imposes to explicitly declare variables anywhere in the current scope, namely the context inside which they are visible for usage. Sensibly, declarations should figure beforehand but likewise it is allowed for accessing backward declarations. Variables accessible from any location are marked as globals (starting from offset 8, occupying lots of space in the script multifile, up to 64 kibibytes) and their declaration is achieved by prepending the '''VAR''' prefix followed by one of the basic data types (multiple declarations of the same type can be inlined), both separated by an in-between underscore:
+
----
 +
The ''main file'' is the most significant part of the whole source. It can include many script files and/or embedded ''gosubs'', ''scripts'' or ''functions''. Originally, it is characterized by the absence of the [[#Local|local]] [[#Scope|scope]]. It must be put outside the directory, having the same name as the main script file, where all other foreign scripts must be:
  
  VAR_INT player scplayer
+
  <directory>
  VAR_FLOAT x_float, y_float, z_float
+
  | main
  VAR_TEXT_LABEL interior_name
+
  |  | gosub
  VAR_TEXT_LABEL16 shop_item
+
|  |  |- gosub1.sc
 +
|  |  \- gosubN.sc
 +
|  | subscript
 +
|  |  |- subscript1.sc
 +
|  |  \- subscriptN.sc
 +
|  | mission_guy
 +
|  |  |- mission_guy1.sc
 +
|  |  \- mission_guyN.sc
 +
|  |- gosub.sc
 +
|  |- subscript.sc
 +
|  \- mission.sc
 +
  \- main.sc
  
Globals are capable of being selectively marked as saveable using the '''SAVE_VAR''' prefix, in order to restore their value on savegame loading and free generic variables. In Trilogy chapters, if enabled properly in a hacky manner, these are solely common variable declarations with no additional purpose, a plan not gone through. On the other hand, globals declared within the mission context are not visible outside in Stories chapters since they overlap the same space, making a discernment among true and al-most globals. However, there's no exact rule for variable naming apart they must begin with a letter and never end with a colon, just like text labels. It's preferable definitions shall not contain operator tokens to prevent any parsing ambiguity plus, most importantly, they must not conflict with string constants and local timers. Nevertheless, text labels and variable names semantics may collide: in this case, the formers have priority over the latters unless a preceding dollar sign) is added:
+
;Note
 +
:R* compiler will scan subfolders too.
  
PRINT_BIG TEXTKEY 5000 2  // Compiles a text label literal.
+
===Foreign gosubs===
PRINT_BIG $textkey 5000 2 // Compiles a text label variable.
+
----
 +
''Foreign gosubs'' (also called ''subroutines'') are ''main extension files''. They are called using the '''GOSUB_FILE''' [[#Commands|command]] which jumps to a specific [[#Labels|label]] and executes some code that returns back to the place where it has been called with '''RETURN'''. You are able to specify the gosub label to start jumping at as well:
  
Despite variables are freed and zero-initialized at runtime on new/load game or script allocation in broad terms, statistical information are still gathered whenever they are read before being written, besides if they are never read or never written (passing a variable as reference has no effect onto the content). Furthermore, if a variable is set to hold an entity handle (alias unique index) returned by a specific create-command it cannot be assigned to any other entity-command of different kind or none, including the forseeable assignment operations. This restriction propagates on script and function callings as well: starting/streaming the same script or calling the same function multiple times with variables of dissimilar entity types is forbidden if triggers are encountered prior the script or function local scope is fetched, in which case entities are explicitly initialized in the form of unreachable code:
+
// File: main.sc
 +
 +
GOSUB_FILE gosub_ref foreign_gosub.sc
  
 +
// File: foreign_gosub.sc
 +
 +
gosub_ref:
 
  {
 
  {
     LVAR_INT test_char sanity
+
     [...]
 +
}
 +
RETURN
 +
 
 +
;Limit
 +
:Foreign gosubs were introduced since {{icon|3}}. They were unused in {{icon|vc}} and got removed in {{icon|sa}}, but then they were reimplemented in {{icon|lcs}} and {{icon|vcs}}.
 +
 
 +
====Gosubs====
 +
 
 +
As mentioned, ''gosubs'' are also embedded in any script file. They follow almost the same rules, except they are called by '''GOSUB''' and can actually inehrit the [[#Local|local]] [[#Scope|scope]] of the parent script:
 +
 
 +
// File: any.sc
 
   
 
   
    sanity = 0
+
GOSUB gosub_ref
     IF sanity = -1
+
 
        CREATE_CHAR PEDTYPE_CIVMALE male01 0.0 0.0 0.0 test_char
+
// File: any.sc
    ENDIF
+
 +
gosub_ref:
 +
{
 +
     [...]
 
  }
 
  }
 +
RETURN
  
==Local scope==
+
;Note
Once a script is started/streamed or a subscript/mission is launched, a local variable space of 72 (16+2 &times; 4, III/Vice City), 136 (32+2 &times; 4, San Andreas) or 424 (96+8+2 &times; 4, Stories) bytes is also reserved. As opposed to global variables, locals have visibility only inside a particular region of the source code and are preceded by the '''LVAR''' prefix at declaration within an unnestable block embraced by curly brackets:
+
:R* compiler doesn't take care if the code within a scope jumps to a gosub inside which another scope is declared. It is strongly recommended to pay attention at this issue or you will fall down into an irreparable local [[#Variables|variable]] mismatch.
  
 +
===Subscripts===
 +
----
 +
''Subscripts'' are code blocks which take part of a ''queue of other scripts'' and are allocated over the memory by '''LAUNCH_MISSION'''. They are denoted by the presence of '''MISSION_START''' at the very top of the mission file. As long as they aren't ended with '''MISSION_END''', their execution never expires till the end of the game process. Each one works independently, even though they are able to share [[#Global|global]] [[#Variables|variables]]:
 +
 +
// File: main.sc
 +
 +
LAUNCH_MISSION subscript.sc
 +
 +
// File: subscript.sc
 +
 +
MISSION_START
 +
 +
[VAR_* {varname0}[,] [... {varnameN}]]
 +
 +
SCRIPT_NAME main
 +
 +
subscript_loop:
 
  {
 
  {
     LVAR_INT pickup message_num
+
     [LVAR_* {varname0}[,] [... {varnameN}]]
 +
 +
    [...]
 
  }
 
  }
 +
//GOTO subscript_loop
 +
MISSION_END
  
Local names do not override global definitions, they must not collide together otherwise a warn is issued. In the last Trilogy chapter, locals are mainly static variables whose space (having a size of 4096 bytes, 1024&times;4) is shared among each mission thus they are reasonably more abundant in this context. Beyond user-defined locals, predefined '''TIMERA''' and '''TIMERB''' variables are provided: these timers measures the playing time milliseconds passed since the script beginning but they can be reset just fine. As deducible, any script file inclusion within a local scope does inherit no local variable even for the unassuming foreign gosub.
+
;Notes
 +
:'''MISSION_START''' is a special and fake directive that isn't assigned to any [[#Commands|command]]. R* compiler will notify an error if it isn't placed at the first line of a subscript or a [[#Mission scripts|mission script]];
 +
:'''MISSION_END''' is an alias of '''TERMINATE_THIS_SCRIPT'''.
  
==Arrays==
+
====Scripts====
Since the last Trilogy chapter, instead of declaring multiple scalar variables of same type, an unidimensional, numeric (unassociative) array can be defined. Each element is accessed through either a positive, zero-based<sup>[no source]</sup>, 8-bit unsigned number or a variable index embraced by a pair of square brackets on assignment or argument passing. On declaration, the said brackets enclose the array size which mustn't be bigger than 255 units:
 
  
VAR_INT prop_assets[32]
+
As for [[#Gosubs|gosubs]], ''scripts'' can be embedded everywhere in a script file. They are started by '''START_NEW_SCRIPT''' which has an undefined amount of arguments, whose type must match with those of each [[#Local|local]] variable of the starting script in order to be passed, else the compilation will interrupt. Unlike subscripts, they get terminated by '''TERMINATE_THIS_SCRIPT''' or '''TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME''' (elsewhere in another script):
CREATE_FORSALE_PROPERTY_PICKUP -1969.27 282.47 34.6 50000 PROP_3 prop_assets[0]
 
  
In sooth, one-based arrays were already supported in the second Trilogy chapter but they missed the intrinsic data type, giving no reference point on how to interpret the compiled operands, producing corrupted intermediate code because of fall-through reading. There is no precedent to safely assert that arrays became zero-based later on the language evolution but what is certain is this sort of indexing lines up immediate with variable indices. Oddly, as a result of the unidimensionality constraint implementation, a complementary yet nonfactual identifier can follow the closing bracket immediately afterwards with no redundancy notice (i.e. <code>prop_assets[0]anything</code>). Moreover, scalar variables have an implicit array size of one element which is needlessly accessible and plus the index part of the first element of an array is in turn omissible, everything notwithstanding the misleading declaration. Granted that brackets do not encompass any separator character, array indices reject string constants but admit local timers.
+
// File: any.sc
 +
 +
START_NEW_SCRIPT script [{anyvalue0|varname0} ... {anyvalueN|varnameN}]
  
==String constants==
+
// File: any.sc
Very often, numeric literals express arbitrary values which are far from being self-documenting without descriptive labels belonging to a list of predefined names. These strings or enumerations are guaranteed to store an immutable constant and must forcibly pertain to the required namespace if passed as arguments unless, if and only if no namespace is set, the default constants '''TRUE'''/'''FALSE''', '''ON'''/'''OFF''', '''DAY'''/'''NIGHT''' or '''KILLFRENZY''' statuses are supplied:
+
 +
script:
 +
{
 +
    SCRIPT_NAME script
 +
 +
script_loop:
 +
 +
    [LVAR_* {varname0}[,] [... {varnameN}]]
 +
 +
    [...]
 +
 +
    //GOTO script_loop
 +
    TERMINATE_THIS_SCRIPT
 +
}
  
CHANGE_BLIP_DISPLAY blip1_jm1 BLIP_ONLY
+
;Notes
flag_car_blip_displayed_jm1 = TRUE
+
:Scripts must have a local [[#Scope|scope]];
 +
:Script commands must be inserted within or after the local scope;
 +
:Since {{icon|vc}}, the ''opening curly bracket'' must be put before the script [[#Labels|label]] when more arguments are passed.
  
Assignments and comparisons do not suffer such a restriction and, what's more, in case of too long lines (wider than 255 characters) immediates can safely replace string constants to shorten the exceeding length and fall within the limits. During the development stage, the game's map experiences lots of continuous changes that make the management of objects, as a result of having a fixed indexing, pretty awkward without taking into account their bulk amount. In this respect, parameters expecting level objects are able to define the used objects (no more longer than 23 characters) under the hood, bringing them together in a sorted array whose criteria depends on the order of their appearance, something other than the default models which are hardcoded (for peds, cars, weapons, wheels, cutscene objects and the like). A blank, unavailable object is always reserved, shifting ahead each next negated position becoming one-based. Negative indices assure models fit in the used objects array, according to which the runtime matches the right index through a lookup table:
+
====Functions====
  
REQUEST_MODEL bridgefuka // First use ever. It compiles -1 from now on.
+
{{incomplete}}
REQUEST_MODEL bridgefukb // First use again. This time it compiles -2.
 
LOAD_ALL_MODELS_NOW
 
CREATE_OBJECT_NO_OFFSET bridgefuka 715.746 -937.908 40.194 damagea
 
CREATE_OBJECT_NO_OFFSET bridgefukb 787.835 -939.24 38.971 damageb
 
  
The lack of error-checking requires a meticulous handwriting to avoid script deadlocks at runtime, the reason why both default models and level objects are loaded straight from [[Item Definition|IDE]] files for Vice City's remastered build. Nonetheless, iterating among several objects can be very expensive for a poorly optimised, rough compiler even on fast machines, not to mention namespaced constants are likely to collide without specializing prefixes (i.e. '''SNIPER''' camera mode and weapon name, formerly '''WEAPON_SNIPER'''), enough to revert back thereafter. Assignments and comparisons have no clue about used objects and are therefore not designed to accommodate or implicitly define one on their own, because they are supposed to be strict with the identifier existence as being more prone to work out with variables. This concept somehow extends to those parameters not featuring used objects as a general rule. If an unusual application needs to take place, making use of non-inlined '''CONSTANT_INT''' declarations would hint the compiler to treat unequivocally the specified string constants as used objects, truly defining a new one on the first practical usage wherever it occurs and not yielding an undefined variable error:
+
===Mission scripts===
 +
----
 +
''Mission scripts'' are those [[#Subscripts|subscripts]] which are responsible for the presence of a storyline in the game. When they are launched with '''LOAD_AND_LAUNCH_MISSION''', the mission is loaded in the mission block, allocated over the memory and the script pointer is moved to the corresponding mission [[#Offsets|offset]]. Do not forget to begin a mission script with '''MISSION_START''' and end it with '''MISSION_END''':
  
  CONSTANT_INT cj_pizza_1
+
  // File: main.sc
CONSTANT_INT cj_pizza_2
 
VAR_INT test_model1 test_model2
 
 
   
 
   
  REQUEST_MODEL pizzahigh  // -1
+
  LOAD_AND_LAUNCH_MISSION mission.sc
test_model1 = cj_pizza_1 // -2
 
test_model2 = cj_pizza_2 // -3
 
REQUEST_MODEL test_model1
 
REQUEST_MODEL test_model2
 
  
Any string constant passed in place of an object model compiles a used object indiscriminately assuming no '''CONSTANT_INT''' declaration, preventing redefinitions (whether default or namespaced), does exist. Messing around with frequent compiler tool recompilations can be tedious solely to establish broad, same-indexed or math-related string constants but fortunately, in the last Trilogy chapter, the language offers the opportunity to settle user-supplied default constants for numeric literals using '''CONST'''-prefixed declarations which, alike for variables and '''CONSTANT_INT'''s, are backward accessible:
+
// File: mission.sc
 +
 +
MISSION_START
 +
 +
GOSUB mission_start
 +
 +
IF HAS_DEATHARREST_BEEN_EXECUTED
 +
    GOSUB mission_failed
 +
ENDIF
 +
 +
GOSUB mission_cleanup
 +
 +
MISSION_END
 +
 +
[VAR_* {varname0}[,] [... {varnameN}]]
 +
 +
mission_start:
 +
 +
REGISTER_MISSION_GIVEN
 +
SCRIPT_NAME mission
 +
 +
// Variables initialization
 +
 +
{
 +
    [LVAR_* {varname0}[,] [... {varnameN}]]
 +
 +
    [...]
 +
}
 +
GOTO mission_passed
 +
 +
mission_failed:
 +
[...]
 +
RETURN
 +
 +
mission_passed:
 +
REGISTER_MISSION_PASSED mission
 +
//PLAYER_MADE_PROGRESS 1
 +
[...]
 +
RETURN
 +
 +
// Mark everything as no longer needed
 +
 +
mission_cleanup:
 +
//MISSION_HAS_FINISHED
 +
[...]
 +
RETURN
 +
 
 +
Some missions doesn't need to be executed multiple times because they may just initialize some [[#Global|global]] [[#Variables|variables]] defined in the [[#Main file|main]] script or launch the intro mission. For this matter, here comes the usage of '''LOAD_AND_LAUNCH_MISSION_EXCLUSIVE''':
  
  CONST_INT gf_date_active 1
+
  // File: main.sc
CONST_FLOAT math_pi 3.1415927
 
 
   
 
   
  SET_BIT gf_date_flags gf_date_active
+
  LOAD_AND_LAUNCH_MISSION_EXCLUSIVE initial.sc
  rad_angle = deg_angle * math_pi
+
  LOAD_AND_LAUNCH_MISSION_EXCLUSIVE intro.sc
rad_angle /= 180.0
+
 
 +
;Note
 +
:Exclusive missions are never launched in the source code. It's likely, it was an idea not came to the end successfully or rather they were useful for debugging purposes.
 +
 
 +
;Limits
 +
:'''LOAD_AND_LAUNCH_MISSION_EXCLUSIVE''' is available only in {{icon|vc}} and {{icon|sa}};
 +
:Only 2 exclusive missions in {{icon|vc}} and 3 in {{icon|sa}} are handled, plus they must be launched before any of the counterpart.
 +
 
 +
===Streamed scripts===
 +
----
 +
{{incomplete}}
 +
 
 +
==Control flow==
 +
 
 +
As usual, the evolution of something implies its development over the years. Alongside, the ''control flows'' implementation has been distributed equally into every chapter. Their definitions are similar to those used in ''pseudocodes'' resulting in a ''raw source code''. However, you are still able to build your own control flows:
 +
 
 +
ANDOR {value}
 +
    [NOT] {condition0}
 +
    [[NOT] {condition8}]
 +
GOTO_IF_FALSE ELSE
 +
    {consequence}
 +
    [GOTO ENDIF]
 +
ELSE:
 +
    [{alternative}
 +
ENDIF:]
 +
 
 +
;Note
 +
:It's likely, user-made control flows weren't intended to be usable because R* compiler cannot recognize an [[#Comparison|equal to]] rather than an [[#Arithmetic|assignment]] operator.
 +
 
 +
===If===
 +
<code>IF</code> is the most common conditional statement. It executes one block of code if a boolean condition is <code>true</code>, and (optionally) another if the condition is <code>false</code>. The condition may be made of multiple conditions combined using the [[#Logical|logical operators]] <code>AND</code> or <code>OR</code>, or it may just be a single condition. <code>AND</code> makes the final condition <code>true</code> only if ''all'' of the input conditions are <code>true</code>, whereas <code>OR</code> only requires ''one'' input condition to be <code>true</code>. The condition may be inverted with <code>NOT</code>, another logical operator. Syntax:
 +
 
 +
<syntaxhighlight>
 +
IF [NOT] {condition0}
 +
[AND|OR [NOT] {condition8}]
 +
    {consequence}
 +
[ELSE
 +
    {alternative}]
 +
ENDIF
 +
</syntaxhighlight>
 +
 
 +
;Limitations
 +
*There is a maximum of '''8 conditions'''.
 +
 
 +
===If-not===
 +
<code>IFNOT</code> works in the same way as <code>IF</code> except that the condition is always inverted.
 +
 
 +
<syntaxhighlight>
 +
IFNOT [NOT] {condition0}
 +
[AND|OR [NOT] {condition8}]
 +
    {consequence}
 +
[ELSE
 +
    {alternative}]
 +
ENDIF
 +
</syntaxhighlight>
 +
 
 +
;Limitations
 +
*<code>IFNOT</code> is only supported in games that have <code>GOTO_IF_TRUE</code>: {{icon|3}}, {{icon|lcs}} and {{icon|vcs}}.
 +
 
 +
===While===
 +
<code>WHILE</code> is similar to <code>IF</code>, but it continues executing the body until the condition is <code>false</code>.
 +
 
 +
<syntaxhighlight>
 +
WHILE [NOT] {condition0}
 +
[AND|OR [NOT] {condition8}]
 +
    {consequence}
 +
ENDWHILE
 +
</syntaxhighlight>
 +
 
 +
===While-not===
 +
<code>WHILENOT</code> is to <code>WHILE</code> as <code>IFNOT</code> is to <code>IF</code>: it loops until the condition is <code>true</code>.
 +
 
 +
<syntaxhighlight>
 +
WHILENOT [NOT] {condition0}
 +
[AND|OR [NOT] {condition8}]
 +
    {consequence}
 +
ENDWHILE
 +
</syntaxhighlight>
 +
 
 +
;Limitations
 +
*Like <code>IFNOT</code>, <code>WHILENOT</code> is only supported in games that have <code>GOTO_IF_TRUE</code>: {{icon|3}}, {{icon|lcs}} and {{icon|vcs}}.
 +
 
 +
===Repeat===
 +
<code>REPEAT</code> acts as a range-based loop (generally a ''for-loop'' in modern programming languages). It executes the body and increments a certain [[#Variables|variable]] until it reaches a target value, at which point the loop stops.
 +
 
 +
<syntaxhighlight>
 +
REPEAT {target} {varname}
 +
    {consequence}
 +
ENDREPEAT
 +
</syntaxhighlight>
 +
 
 +
;Limitations
 +
*<code>REPEAT</code> is supported in games from {{icon|vc}};
 +
*The target value must be positive;
 +
*The body will be read at least once in any case.
 +
 
 +
===Switch===
 +
A <code>SWITCH</code> statement is functionally equivalent to multiple nested <code>IF...ELSE</code> statements. It takes a single value and executes a block of code that is specific to that value (a <code>CASE</code>) until it finds a <code>BREAK</code>, which moves execution to the end of the construct. If no matching case is found, the <code>DEFAULT</code> clause is executed.
 +
 
 +
<syntaxhighlight>
 +
SWITCH {varname}
 +
    CASE {value0}
 +
        {consequence}
 +
        BREAK
 +
    [CASE {valueN}
 +
        {consequence}
 +
        BREAK]
 +
    [DEFAULT
 +
        {alternative}
 +
        BREAK]
 +
ENDSWITCH
 +
</syntaxhighlight>
 +
 
 +
;Limitations
 +
*It is supported from {{icon|sa}};
 +
*<code>CASE</code> allows the use of [[#INT|INT]] and [[#CONST (pseudo)|CONST]] values only;
 +
*In {{icon|sa}}, the <code>CASE</code> values should be sorted (R*'s compiler should do it implicitly);
 +
*Every <code>CASE</code>, including <code>DEFAULT</code>, must end with a <code>BREAK</code>.
 +
 
 +
=Decompiling=
 +
 
 +
==Structure==
  
Given that default models are also default constants in Stories chapters<sup>[no source]</sup>, default constants and used objects count as pseudoconstants: contrary to what namespaced constants entail, generic alternatives are favoured on assignment or comparison command pairing. It should be pointed out that, due to a critical compiler bug, the high 16 bits of the value held by a namespaced constant are unexpectedly discarded on assignment or comparison and that, if set, the 16th bit yields a nonexistent variable error (i.e. '''THREAT_GANG9''' flag) prior Stories chapters, where a default constant is compiled only if the low 16 bits represent a value lesser than -1<sup>[no source]</sup>:
+
For further information about the SCM file format, read [[Mission_Scripting (Overview)|this]] article. Take into account the compiling order of each ''SC'' file is [[#Main file|main file]] » [[#Foreign gosubs|foreign gosubs]] » [[#Subscripts|subscripts]] » [[#Mission scripts|mission scripts]] apart from the reading order of the commands used to include them. [[#Streamed scripts|Streamed scripts]] are compiled individually into the ''script.img'' file. On the other hand, [[#Functions|functions]] are compiled like [[#Gosubs|gosubs]].
  
{|style="table-layout: fixed; margin-bottom: -8px" width=100% cellspacing=0 cellpadding=0
+
==Identifiers==
|width=50%|'''Mission script'''
 
|width=16px rowspan=2|
 
|width=50%|'''Script multifile'''
 
|-
 
|<pre style="white-space: pre; overflow-x: scroll">
 
SET_CHAR_THREAT_SEARCH test_char THREAT_GANG_GOLFER
 
SET_CHAR_THREAT_SEARCH test_char THREAT_GANG9
 
SET_CHAR_THREAT_SEARCH test_char THREAT_EMERGENCY
 
threat_flag = THREAT_GANG_GOLFER
 
threat_flag = THREAT_GANG9 // Ill-formed in Trilogy.
 
threat_flag = THREAT_EMERGENCY
 
</pre>
 
|<pre style="white-space: pre; overflow-x: scroll">
 
SET_CHAR_THREAT_SEARCH test_char 16384
 
SET_CHAR_THREAT_SEARCH test_char 32768
 
SET_CHAR_THREAT_SEARCH test_char 65536
 
SET_VAR_INT_TO_CONSTANT threat_flag 16384
 
SET_VAR_INT threat_flag 32768
 
SET_VAR_INT_TO_CONSTANT threat_flag 0
 
</pre>
 
|}
 
  
This inconvenient unwittingly affects real code in Liberty City Stories in one circumstance. On a final note, string constants are incompatible with optional arguments and thus taking advantage of a temporary variable would overcome this syntactic limitation.
+
''Undefined [[#Constants|constants]]'' of model identifiers, whose name refers to a [[DFF]] which is presumably archived into any of the [[IMG]]<nowiki>s</nowiki>, loaded by the game, are overwritten by a decrementing value in the order they get compiled. These ''model names'' are then put into the second segment of the ''SCM header''. Those of [[#Mission scripts|mission scripts]] and [[#Streamed scripts|streamed scripts]] respect the same rule except the fact they are turned into a zero-based growing identifier, while exclusive mission scripts are launched by a negative identifier resulting from the bits inversion (bitwise complement).
  
==Operators==
+
==Offsets==
As soon as a numeric or text label variable is declared, it can be subjected to algebric operations and/or logical comparisons by virtue of several operators. Their support is sadly very primitive, in fact the ability to establish complex expressions with parentheses and such is not featured albeit one and only binary operation is enabled to follow the basic assignment. In this regard, the variable being assigned to the lvalue cannot be the same as the outer rvalue for non-commutative operations: <code>VAR1 = THING - VAR1</code>, <code>VAR1 = THING / VAR1</code>, <code>VAR1 = THING +@ VAR1</code> and <code>VAR1 = THING -@ VAR1</code> are all ill-formed. This issue arises because the explicit usage of a temporary variable is needed which would be harmful for the compiler to waste by itself under the hood, thus here expressions are necessarily made up of distinct two-operand instructions, that is the lvalue content is initialized prior encoding any supplementary rvalue arithmetic:
 
  
//VAR1 = 1 - VAR1 // Invalid, cause VAR1 = 1; VAR1 -= VAR1 doesn't make sense. It would perform 1 - 1 = 0.
+
An ''offset'' is a ''32-bit signed integer'' which points to a location of the script file. Those within the [[#Main file|main file]], [[#Foreign gosubs|foreign gosubs]] and [[#Subscripts|subscripts]] are ''absolute offsets'' that start from the beginning of the main script, while the ones inside [[#Mission scripts|mission scripts]] and [[#Streamed scripts|streamed scripts]] are ''relative and negative offsets'' starting from their beginning. The offset is related to [[#Global|global]] [[#Variables|variables]] as well, whose interval goes from ''8'' and ends to ''65532'' (''0xFFFC''), each one is aligned to the nearest 4 bytes.
VAR1 = 1 - VAR2  // Valid, cause VAR1 = 1; VAR1 -= VAR2 doesn't null itself like above.
 
VAR1 = 1 + VAR1  // Valid, addition (as well as multiplication) is commutative so this is compiled to VAR1 += 1.
 
  
The subtraction of positive or negative rvalues necessitates a splitting character in order to discern the infix operator unambiguously, which would be treated as part of the literal or a variable decrement otherwise (i.e. <code>VAR1 = VAR1 -1</code> or <code>VAR1 = VAR1 --1</code>). Typically, string constants are not suitable for math calculations because of the lack of pairable command alternatives but even so they are semantically contemplated as long as a namespaced constant is provided as the inner rvalue of a compound assignment or a default constant is passed to any rvalue. Another clear limitation is prefix and postfix operators do not apply onto arguments, hence there's no concrete differentiation. However, the language introduces the timed addition/subtraction to looply update a variable in a frame-rate independent way, the cast assignment to do a mutual conversion between integers and floats but it doesn't give support for the modulo operation as its predecessor. The inequality comparison was planned but quickly gone obsolete<sup>[no source]</sup> &ndash; availing of the negated form of the equality operator would have sounded more intuitive but one should be aware the not-flag is not bundled with the command index when pairing command alternatives. Due to a programmers' negligence, the local-global in/equality comparison between integer or float variables is not feasible except in the last chapter of Trilogy and Stories series.
+
==Variables range==
  
<span style="display: block; margin: 1em 0; font-size: 1.17em; color: black">'''Arithmetic operators'''</span>
+
The following table shows the [[#Variables|variables]] range of the [[#Local|local]] [[#Scope|scope]] for each game version:
  
{|class=wikitable
+
{|class=wikitable style=text-align:center
 +
!Context
 +
!width=50px|{{icon|3}}
 +
!width=50px|{{icon|vc}}
 +
!width=50px|{{icon|sa}}
 +
!width=50px|{{icon|lcs}}
 +
!width=50px|{{icon|vcs}}
 +
|-
 +
|align=left|[[#Foreign gosubs|Foreign gosub]]/[[#Gosubs|Gosub]]||0-15||0-15||n/a||0-95||0-95
 +
|-
 +
|align=left|[[#Subscripts|Subscript]]/[[#Scripts|Script]]||0-15||0-15||0-31||0-95||0-95
 +
|-
 +
|align=left|[[#Mission scripts|Mission script]]||0-15||0-15||0-1023||0-95||0-95
 +
|-
 +
|align=left|[[#Streamed scripts|Streamed script]]||n/a||n/a||0-31||n/a||n/a
 
|-
 
|-
!colspan=2 width=192px style="text-align: left"|Name
+
|align=left|[[#Functions|Function]]||n/a||n/a||n/a||0-95||0-95
!width=148px|Syntax
 
!width=112px|INT
 
!width=112px|FLOAT
 
!width=112px|TEXT_LABEL/16
 
 
|-
 
|-
|colspan=2|Basic assignment||align=center|<pre style="margin: 0">VAR = THING</pre>||align=center|&#x2713;||align=center|&#x2713;||align=center|&#x2713;
+
!colspan=6|
 
|-
 
|-
|colspan=2|Addition||align=center|<pre style="margin: 0">THING + THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
|align=left|[[#Timers|Timer]]||16-17||16-17||32-33||t0-t1||t0-t1
 +
|}
 +
 
 +
==Compiled operators==
 +
As in most compiled programming languages, SCM's [[#Operators|operators]] are always compiled with two operands, regardless of how they appear within the source code.
 +
 
 +
This means that operators that seem to have only one operand will have two, and operators that seem to have more than two are actually compiled as multiple instructions.
 +
 
 +
{|class="mw-collapsible wikitable"
 +
!width=70px|Operator
 +
!width=200px colspan=2|Name
 +
!width=200px|Written
 +
!width=180px|Compiled
 
|-
 
|-
|colspan=2|Subtraction||align=center|<pre style="margin: 0">THING - THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
!rowspan=2|<code>++</code>
 +
|align=center rowspan=2|Increment
 +
|align=center|Pre
 +
|align=center|<code>++a</code>
 +
|align=center rowspan=2|<code>a += 1</code>
 
|-
 
|-
|colspan=2|Multiplication||align=center|<pre style="margin: 0">THING * THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
|align=center|Post
 +
|align=center|<code>a++</code>
 
|-
 
|-
|colspan=2|Division||align=center|<pre style="margin: 0">THING / THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
!rowspan=2|<code>--</code>
 +
|align=center rowspan=2|Decrement
 +
|align=center|Pre
 +
|align=center|<code>--a</code>
 +
|align=center rowspan=2|<code>a -= 1</code>
 
|-
 
|-
|colspan=2|Timed addition||align=center|<pre style="margin: 0">THING +@ THING</pre>||||align=center|&#x2713;||
+
|align=center|Post
 +
|align=center|<code>a--</code>
 
|-
 
|-
|colspan=2|Timed subtraction||align=center|<pre style="margin: 0">THING -@ THING</pre>||||align=center|&#x2713;||
+
!<code>+=</code>
 +
|align=center colspan=2|Addition and assignment
 +
|align=center|<code>a = b + c</code>
 +
|align=center|<code>a = b</code><br/><code>a += c</code>
 
|-
 
|-
|rowspan=2|Increment||Prefix||align=center|<pre style="margin: 0">++ VAR</pre>||rowspan=2 align=center|&#x2713;||rowspan=2|
+
!<code>-=</code>
|rowspan=2|
+
|align=center colspan=2|Subtraction and assignment
 +
|align=center|<code>a = b - c</code>
 +
|align=center|<code>a = b</code><br/><code>a -= c</code>
 
|-
 
|-
|Postfix||align=center|<pre style="margin: 0">VAR ++</pre>
+
!<code>*=</code>
 +
|align=center colspan=2|Multiplication and assignment
 +
|align=center|<code>a = b * c</code>
 +
|align=center|<code>a = b</code><br/><code>a *= c</code>
 
|-
 
|-
|rowspan=2|Decrement||Prefix||align=center|<pre style="margin: 0">-- VAR</pre>||rowspan=2 align=center|&#x2713;||rowspan=2|
+
!<code>/=</code>
|rowspan=2|
+
|align=center colspan=2|Division and assignment
 +
|align=center|<code>a = b / c</code>
 +
|align=center|<code>a = b</code><br/><code>a /= c</code>
 
|-
 
|-
|Postfix||align=center|<pre style="margin: 0">VAR --</pre>
+
!<code>+=@</code>
 +
|align=center colspan=2|Timed addition and assignment
 +
|align=center|<code>a = b +@ c</code>
 +
|align=center|<code>a = b</code><br/><code>a +=@ c</code>
 +
|-
 +
!<code>-=@</code>
 +
|align=center colspan=2|Timed subtraction and assignment
 +
|align=center|<code>a = b -@ c</code>
 +
|align=center|<code>a = b</code><br/><code>a -=@ c</code>
 
|}
 
|}
  
<span style="display: block; margin: 1em 0; font-size: 1.17em; color: black">'''Compound assignment operators'''</span>
+
==Opcode==
 +
A command's ''opcode'' is a ''16-bit signed integer'' identifier which the game uses to find the implementation for the command. The maximum number of opcodes possible is 32,767 (<code>0x7FFF</code>), because the most significant bit (<code>0x8000</code>) is the ''sign bit'', which is only set when the associated command's return value is inverted (e.g. <code>not x()</code>).
 +
 
 +
There are no commands with negative opcodes; the game takes the absolute value (<code>|opcode|</code>) before finding the implementation, after noting whether it is inverted.
 +
 
 +
==Command arguments==
 +
 
 +
The limitation of the amount of arguments a [http://en.wikipedia.org/wiki/Variadic_function variadic] command can pass is game specific:
 +
 
 +
* 16 for {{icon|3}} and {{icon|vc}};
 +
* 32 for {{icon|sa}};
 +
* 96 for {{icon|lcs}} and {{icon|vcs}}.
 +
 
 +
==Managed commands==
 +
 
 +
Here is the list of all managed [[#Commands|commands]] and their relative specifications:
 +
 
 +
'''Legend:'''
 +
 
 +
* '''Prefix:'''
 +
** V, [[#Global|VAR]];
 +
** L, [[#Local|LVAR]];
 +
** A, ANY ([[#Value|VALUE]], VAR, LVAR).
  
{|class=wikitable
+
* '''Specifier:'''
 +
** R, [[#LABEL|LABEL]];
 +
** I, [[#INT|INT]];
 +
** F, [[#FLOAT|FLOAT]];
 +
** T, [[#TEXT_LABEL|TEXT_LABEL]];
 +
** T16, [[#TEXT_LABEL16|TEXT_LABEL16]];
 +
** T32, [[#TEXT_LABEL32|TEXT_LABEL32]];
 +
** T[N], [[#TEXT|TEXT]];
 +
** C, [[#CONST (pseudo)|CONST]];
 +
** M, [[#MULTI (pseudo)|MULTI]].
 +
 
 +
* '''Suffix:'''
 +
** O, OPTIONAL.
 +
 
 +
'''List:'''
 +
 
 +
Be aware, the argument data types of the commands below are just informative:
 +
 
 +
<div width=100% style="overflow: auto; margin: -8px auto 8px">
 +
{|class="mw-collapsible mw-collapsed wikitable" style=text-align:center
 +
|-
 +
!rowspan=3 colspan=2|Command
 +
!rowspan=3|ID
 +
!colspan=9|Arguments
 +
|-
 +
!width=45px rowspan=2|#
 +
!width=45px rowspan=2|1
 +
!width=45px rowspan=2|2
 +
!width=45px rowspan=2|3
 +
!width=45px rowspan=2|4
 +
!width=45px rowspan=2|...
 +
!width=45px rowspan=2|18
 +
!width=45px rowspan=2|...
 +
!width=45px|n+l
 +
|-
 +
!n+i+o
 +
|-
 +
|colspan=12|{{icon|t}} {{icon|lcs}} {{icon|vcs}}
 +
|-
 +
!colspan=2|MISSION_START{{ref|misdef|[*]}}
 +
|
 +
!0
 +
|colspan=8|
 +
|-
 +
!colspan=2|GOTO{{ref|statem|[*]}}
 +
|[[0002|2]]
 +
!1
 +
|R||colspan=7|
 +
|-
 +
|colspan=12|{{icon|t}} {{icon|lcs}}
 +
|-
 +
!rowspan=12|=<br/>SET!!SET_VAR_INT
 +
|[[0004|4]]
 +
!rowspan=12|2
 +
|VI||I||colspan=6|
 +
|-
 +
!SET_VAR_FLOAT
 +
|[[0005|5]]||VF||F||colspan=6|
 +
|-
 +
!SET_LVAR_INT
 +
|[[0006|6]]||LI||I||colspan=6|
 +
|-
 +
!SET_LVAR_FLOAT
 +
|[[0007|7]]||LF||F||colspan=6|
 +
|-
 +
!SET_VAR_INT_TO_VAR_INT
 +
|[[0084|132]]||VI||VI||colspan=6|
 +
|-
 +
!SET_LVAR_INT_TO_LVAR_INT
 +
|[[0085|133]]||LI||LI||colspan=6|
 +
|-
 +
!SET_VAR_FLOAT_TO_VAR_FLOAT
 +
|[[0086|134]]||VF||VF||colspan=6|
 +
|-
 +
!SET_LVAR_FLOAT_TO_LVAR_FLOAT
 +
|[[0087|135]]||LF||LF||colspan=6|
 +
|-
 +
!SET_VAR_FLOAT_TO_LVAR_FLOAT
 +
|[[0088|136]]||VF||LF||colspan=6|
 +
|-
 +
!SET_LVAR_FLOAT_TO_VAR_FLOAT
 +
|[[0089|137]]||LF||VF||colspan=6|
 +
|-
 +
!SET_VAR_INT_TO_LVAR_INT
 +
|[[008A|138]]||VI||LI||colspan=6|
 +
|-
 +
!SET_LVAR_INT_TO_VAR_INT
 +
|[[008B|139]]||LI||VI||colspan=6|
 +
|-
 +
!rowspan=12|+=<br/>+<br/>ADD_THING_TO_THING!!ADD_VAL_TO_INT_VAR
 +
|[[0008|8]]
 +
!rowspan=12|2
 +
|VI||I||colspan=6|
 +
|-
 +
!ADD_VAL_TO_FLOAT_VAR
 +
|[[0009|9]]||VF||F||colspan=6|
 +
|-
 +
!ADD_VAL_TO_INT_LVAR
 +
|[[000A|10]]||LI||I||colspan=6|
 +
|-
 +
!ADD_VAL_TO_FLOAT_LVAR
 +
|[[000B|11]]||LF||F||colspan=6|
 +
|-
 +
!ADD_INT_VAR_TO_INT_VAR
 +
|[[0058|88]]||VI||VI||colspan=6|
 +
|-
 +
!ADD_FLOAT_VAR_TO_FLOAT_VAR
 +
|[[0059|89]]||VF||VF||colspan=6|
 +
|-
 +
!ADD_INT_LVAR_TO_INT_LVAR
 +
|[[005A|90]]||LI||LI||colspan=6|
 +
|-
 +
!ADD_FLOAT_LVAR_TO_FLOAT_LVAR
 +
|[[005B|91]]||LF||LF||colspan=6|
 +
|-
 +
!ADD_INT_VAR_TO_INT_LVAR
 +
|[[005C|92]]||LI||VI||colspan=6|
 +
|-
 +
!ADD_FLOAT_VAR_TO_FLOAT_LVAR
 +
|[[005D|93]]||LF||VF||colspan=6|
 +
|-
 +
!ADD_INT_LVAR_TO_INT_VAR
 +
|[[005E|94]]||VI||LI||colspan=6|
 +
|-
 +
!ADD_FLOAT_LVAR_TO_FLOAT_VAR
 +
|[[005F|95]]||VF||LF||colspan=6|
 +
|-
 +
!rowspan=12|-=<br/>-<br/>SUB_THING_FROM_THING!!SUB_VAL_FROM_INT_VAR
 +
|[[000C|12]]
 +
!rowspan=12|2
 +
|VI||I||colspan=6|
 +
|-
 +
!SUB_VAL_FROM_FLOAT_VAR
 +
|[[000D|13]]||VF||F||colspan=6|
 +
|-
 +
!SUB_VAL_FROM_INT_LVAR
 +
|[[000E|14]]||LI||I||colspan=6|
 +
|-
 +
!SUB_VAL_FROM_FLOAT_LVAR
 +
|[[000F|15]]||LF||F||colspan=6|
 +
|-
 +
!SUB_INT_VAR_FROM_INT_VAR
 +
|[[0060|96]]||VI||VI||colspan=6|
 +
|-
 +
!SUB_FLOAT_VAR_FROM_FLOAT_VAR
 +
|[[0061|97]]||VF||VF||colspan=6|
 +
|-
 +
!SUB_INT_LVAR_FROM_INT_LVAR
 +
|[[0062|98]]||LI||LI||colspan=6|
 +
|-
 +
!SUB_FLOAT_LVAR_FROM_FLOAT_LVAR
 +
|[[0063|99]]||LF||LF||colspan=6|
 +
|-
 +
!SUB_INT_VAR_FROM_INT_LVAR
 +
|[[0064|100]]||LI||VI||colspan=6|
 +
|-
 +
!SUB_FLOAT_VAR_FROM_FLOAT_LVAR
 +
|[[0065|101]]||LF||VF||colspan=6|
 +
|-
 +
!SUB_INT_LVAR_FROM_INT_VAR
 +
|[[0066|102]]||VI||LI||colspan=6|
 +
|-
 +
!SUB_FLOAT_LVAR_FROM_FLOAT_VAR
 +
|[[0067|103]]||VF||LF||colspan=6|
 +
|-
 +
!rowspan=12|*=<br/>*<br/>MULT_THING_BY_THING!!MULT_INT_VAR_BY_VAL
 +
|[[0010|16]]
 +
!rowspan=12|2
 +
|VI||I||colspan=6|
 +
|-
 +
!MULT_FLOAT_VAR_BY_VAL
 +
|[[0011|17]]||VF||F||colspan=6|
 +
|-
 +
!MULT_INT_LVAR_BY_VAL
 +
|[[0012|18]]||LI||I||colspan=6|
 +
|-
 +
!MULT_FLOAT_LVAR_BY_VAL
 +
|[[0013|19]]||LF||F||colspan=6|
 +
|-
 +
!MULT_INT_VAR_BY_INT_VAR
 +
|[[0068|104]]||VI||VI||colspan=6|
 +
|-
 +
!MULT_FLOAT_VAR_BY_FLOAT_VAR
 +
|[[0069|105]]||VF||VF||colspan=6|
 +
|-
 +
!MULT_INT_LVAR_BY_INT_LVAR
 +
|[[006A|106]]||LI||LI||colspan=6|
 +
|-
 +
!MULT_FLOAT_LVAR_BY_FLOAT_LVAR
 +
|[[006B|107]]||LF||LF||colspan=6|
 +
|-
 +
!MULT_INT_VAR_BY_INT_LVAR
 +
|[[006C|108]]||VI||LI||colspan=6|
 +
|-
 +
!MULT_FLOAT_VAR_BY_FLOAT_LVAR
 +
|[[006D|109]]||VF||LF||colspan=6|
 +
|-
 +
!MULT_INT_LVAR_BY_INT_VAR
 +
|[[006E|110]]||LI||VI||colspan=6|
 +
|-
 +
!MULT_FLOAT_LVAR_BY_FLOAT_VAR
 +
|[[006F|111]]||LF||VF||colspan=6|
 +
|-
 +
!rowspan=12|/=<br/>/<br/>DIV_THING_BY_THING!!DIV_INT_BY_VAL
 +
|[[0014|20]]
 +
!rowspan=12|2
 +
|VI||I||colspan=6|
 +
|-
 +
!DIV_FLOAT_VAR_BY_VAL
 +
|[[0015|21]]||VF||F||colspan=6|
 +
|-
 +
!DIV_INT_LVAR_BY_VAL
 +
|[[0016|22]]||LI||I||colspan=6|
 +
|-
 +
!DIV_FLOAT_LVAR_BY_VAL
 +
|[[0017|23]]||LF||F||colspan=6|
 +
|-
 +
!DIV_INT_VAR_BY_INT_VAR
 +
|[[0070|112]]||VI||VI||colspan=6|
 +
|-
 +
!DIV_FLOAT_VAR_BY_FLOAT_VAR
 +
|[[0071|113]]||VF||VF||colspan=6|
 +
|-
 +
!DIV_INT_LVAR_BY_INT_LVAR
 +
|[[0072|114]]||LI||LI||colspan=6|
 +
|-
 +
!DIV_FLOAT_LVAR_BY_FLOAT_LVAR
 +
|[[0073|115]]||LF||LF||colspan=6|
 +
|-
 +
!DIV_INT_VAR_BY_INT_LVAR
 +
|[[0074|116]]||VI||LI||colspan=6|
 +
|-
 +
!DIV_FLOAT_VAR_BY_FLOAT_LVAR
 +
|[[0075|117]]||VF||LF||colspan=6|
 +
|-
 +
!DIV_INT_LVAR_BY_INT_VAR
 +
|[[0076|118]]||LI||VI||colspan=6|
 +
|-
 +
!DIV_FLOAT_LVAR_BY_FLOAT_VAR
 +
|[[0077|119]]||LF||VF||colspan=6|
 +
|-
 +
!rowspan=16|><br/><=<br/>IS_THING_GREATER_THAN_THING!!IS_INT_VAR_GREATER_THAN_NUMBER
 +
|[[0018|24]]
 +
!rowspan=16|2
 +
|VI||I||colspan=6|
 +
|-
 +
!IS_INT_LVAR_GREATER_THAN_NUMBER
 +
|[[0019|25]]||LI||I||colspan=6|
 +
|-
 +
!IS_NUMBER_GREATER_THAN_INT_VAR
 +
|[[001A|26]]||I||VI||colspan=6|
 +
|-
 +
!IS_NUMBER_GREATER_THAN_INT_LVAR
 +
|[[001B|27]]||I||LI||colspan=6|
 +
|-
 +
!IS_INT_VAR_GREATER_THAN_INT_VAR
 +
|[[001C|28]]||VI||VI||colspan=6|
 +
|-
 +
!IS_INT_LVAR_GREATER_THAN_INT_LVAR
 +
|[[001D|29]]||LI||LI||colspan=6|
 +
|-
 +
!IS_INT_VAR_GREATER_THAN_INT_LVAR
 +
|[[001E|30]]||VI||LI||colspan=6|
 +
|-
 +
!IS_INT_LVAR_GREATER_THAN_INT_VAR
 +
|[[001F|31]]||LI||VI||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_GREATER_THAN_NUMBER
 +
|[[0020|32]]||VF||F||colspan=6|
 +
|-
 +
!IS_FLOAT_LVAR_GREATER_THAN_NUMBER
 +
|[[0021|33]]||LF||F||colspan=6|
 +
|-
 +
!IS_NUMBER_GREATER_THAN_FLOAT_VAR
 +
|[[0022|34]]||F||VF||colspan=6|
 +
|-
 +
!IS_NUMBER_GREATER_THAN_FLOAT_LVAR
 +
|[[0023|35]]||F||LF||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_GREATER_THAN_FLOAT_VAR
 +
|[[0024|36]]||VF||VF||colspan=6|
 +
|-
 +
!IS_FLOAT_LVAR_GREATER_THAN_FLOAT_LVAR
 +
|[[0025|37]]||LF||LF||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_GREATER_THAN_FLOAT_LVAR
 +
|[[0026|38]]||VF||LF||colspan=6|
 +
|-
 +
!IS_FLOAT_LVAR_GREATER_THAN_FLOAT_VAR
 +
|[[0027|39]]||LF||VF||colspan=6|
 +
|-
 +
!rowspan=16|>=<br/><<br/>IS_THING_GREATER_OR_EQUAL_TO_THING!!IS_INT_VAR_GREATER_OR_EQUAL_TO_NUMBER
 +
|[[0028|40]]
 +
!rowspan=16|2
 +
|VI||I||colspan=6|
 +
|-
 +
!IS_INT_LVAR_GREATER_OR_EQUAL_TO_NUMBER
 +
|[[0029|41]]||LI||I||colspan=6|
 +
|-
 +
!IS_NUMBER_GREATER_OR_EQUAL_TO_INT_VAR
 +
|[[002A|42]]||I||VI||colspan=6|
 +
|-
 +
!IS_NUMBER_GREATER_OR_EQUAL_TO_INT_LVAR
 +
|[[002B|43]]||I||LI||colspan=6|
 +
|-
 +
!IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_VAR
 +
|[[002C|44]]||VI||VI||colspan=6|
 +
|-
 +
!IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_LVAR
 +
|[[002D|45]]||LI||LI||colspan=6|
 +
|-
 +
!IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_LVAR
 +
|[[002E|46]]||VI||LI||colspan=6|
 +
|-
 +
!IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_VAR
 +
|[[002F|47]]||LI||VI||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_NUMBER
 +
|[[0030|48]]||VF||F||colspan=6|
 +
|-
 +
!IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_NUMBER
 +
|[[0031|49]]||LF||F||colspan=6|
 +
|-
 +
!IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_VAR
 +
|[[0032|50]]||F||VF||colspan=6|
 +
|-
 +
!IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_LVAR
 +
|[[0033|51]]||F||LF||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_VAR
 +
|[[0034|52]]||VF||VF||colspan=6|
 +
|-
 +
!IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR
 +
|[[0035|53]]||LF||LF||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR
 +
|[[0036|54]]||VF||LF||colspan=6|
 +
|-
 +
!IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_VAR
 +
|[[0037|55]]||LF||VF||colspan=6|
 +
|-
 +
!rowspan=10|=<br/>IS_THING_EQUAL_TO_THING!!IS_INT_VAR_EQUAL_TO_NUMBER
 +
|[[0038|56]]
 +
!rowspan=10|2
 +
|VI||I||colspan=6|
 +
|-
 +
!IS_INT_LVAR_EQUAL_TO_NUMBER
 +
|[[0039|57]]||LI||I||colspan=6|
 +
|-
 +
!IS_INT_VAR_EQUAL_TO_INT_VAR
 +
|[[003A|58]]||VI||VI||colspan=6|
 +
|-
 +
!IS_INT_LVAR_EQUAL_TO_INT_LVAR
 +
|[[003B|59]]||LI||LI||colspan=6|
 +
|-
 +
!IS_INT_VAR_EQUAL_TO_INT_LVAR
 +
|[[003C|60]]||VI||LI||colspan=6|
 
|-
 
|-
!width=192px style="text-align: left"|Name
+
!IS_FLOAT_VAR_EQUAL_TO_NUMBER
!width=148px|Syntax
+
|[[0042|66]]||VF||F||colspan=6|
!Meaning
 
!width=112px|INT
 
!width=112px|FLOAT
 
 
|-
 
|-
|Addition assignment||align=center|<pre style="margin: 0">VAR += THING</pre>||align=center|<pre style="margin: 0">VAR1 = VAR1 + THING</pre>||align=center|&#x2713;||align=center|&#x2713;
+
!IS_FLOAT_LVAR_EQUAL_TO_NUMBER
 +
|[[0043|67]]||LF||F||colspan=6|
 
|-
 
|-
|Subtraction assignment||align=center|<pre style="margin: 0">VAR -= THING</pre>||align=center|<pre style="margin: 0">VAR1 = VAR1 - THING</pre>||align=center|&#x2713;||align=center|&#x2713;
+
!IS_FLOAT_VAR_EQUAL_TO_FLOAT_VAR
 +
|[[0044|68]]||VF||VF||colspan=6|
 
|-
 
|-
|Multiplication assignment||align=center|<pre style="margin: 0">VAR *= THING</pre>||align=center|<pre style="margin: 0">VAR1 = VAR1 * THING</pre>||align=center|&#x2713;||align=center|&#x2713;
+
!IS_FLOAT_LVAR_EQUAL_TO_FLOAT_LVAR
 +
|[[0045|69]]||LF||LF||colspan=6|
 
|-
 
|-
|Division assignment||align=center|<pre style="margin: 0">VAR /= THING</pre>||align=center|<pre style="margin: 0">VAR1 = VAR1 / THING</pre>||align=center|&#x2713;||align=center|&#x2713;
+
!IS_FLOAT_VAR_EQUAL_TO_FLOAT_LVAR
 +
|[[0046|70]]||VF||LF||colspan=6|
 
|-
 
|-
|Timed addition assignment||align=center|<pre style="margin: 0">VAR +=@ THING</pre>||align=center|<pre style="margin: 0">VAR1 = VAR1 +@ THING</pre>||align=center|&nbsp;||align=center|&#x2713;
+
!rowspan=10|NOT =<br/>IS_THING_NOT_EQUAL_TO_THING!!IS_INT_VAR_NOT_EQUAL_TO_NUMBER
 +
|[[003D|61]]
 +
!rowspan=10|2
 +
|VI||I||colspan=6|
 
|-
 
|-
|Timed subtraction assignment||align=center|<pre style="margin: 0">VAR -=@ THING</pre>||align=center|<pre style="margin: 0">VAR1 = VAR1 -@ THING</pre>||||align=center|&#x2713;
+
!IS_INT_LVAR_NOT_EQUAL_TO_NUMBER
 +
|[[003E|62]]||LI||I||colspan=6|
 
|-
 
|-
|Cast assignment||align=center|<pre style="margin: 0">VAR =# THING</pre>||align=center|AS IS||align=center|&#x2713;||align=center|&#x2713;
+
!IS_INT_VAR_NOT_EQUAL_TO_INT_VAR
|}
+
|[[003F|63]]||VI||VI||colspan=6|
  
<span style="display: block; margin: 1em 0; font-size: 1.17em; color: black">'''Comparison operators/relational operators'''</span>
 
 
{|class=wikitable
 
 
|-
 
|-
!width=192px style="text-align: left"|Name
+
!IS_INT_LVAR_NOT_EQUAL_TO_INT_LVAR
!width=148px|Syntax
+
|[[0040|64]]||LI||LI||colspan=6|
!width=112px|INT
+
|-
!width=112px|FLOAT
+
!IS_INT_VAR_NOT_EQUAL_TO_INT_LVAR
!width=112px|TEXT_LABEL/16
+
|[[0041|65]]||VI||LI||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_NOT_EQUAL_TO_NUMBER
 +
|[[0047|71]]||VF||F||colspan=6|
 +
|-
 +
!IS_FLOAT_LVAR_NOT_EQUAL_TO_NUMBER
 +
|[[0048|72]]||LF||F||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_VAR
 +
|[[0049|73]]||VF||VF||colspan=6|
 +
|-
 +
!IS_FLOAT_LVAR_NOT_EQUAL_TO_FLOAT_LVAR
 +
|[[004A|74]]||LF||LF||colspan=6|
 +
|-
 +
!IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_LVAR
 +
|[[004B|75]]||VF||LF||colspan=6|
 +
|-
 +
!colspan=2|GOTO_IF_FALSE{{ref|statem|[*]}}
 +
|[[004D|77]]
 +
!1
 +
|R||colspan=7|
 +
|-
 +
!colspan=2|TERMINATE_THIS_SCRIPT
 +
|rowspan=2|[[004E|78]]
 +
!rowspan=2|0
 +
|rowspan=2 colspan=8|
 +
|-
 +
!colspan=2|MISSION_END
 +
|-
 +
!colspan=2|START_NEW_SCRIPT{{ref|undarg|[*]}}
 +
|[[004F|79]]
 +
!1+l
 +
|R||colspan=7|AM
 +
|-
 +
|colspan=2|GOSUB
 +
|[[0050|80]]
 +
!1
 +
|R||colspan=7|
 +
|-
 +
|colspan=2|RETURN
 +
|[[0051|81]]
 +
!0
 +
|colspan=8|
 +
|-
 +
!rowspan=6|+=@<br/>+@<br/>ADD_THING_TO_THING_TIMED!!ADD_TIMED_VAL_TO_FLOAT_VAR
 +
|[[0078|120]]
 +
!rowspan=6|2
 +
|VF||F||colspan=6|
 +
|-
 +
!ADD_TIMED_VAL_TO_FLOAT_LVAR
 +
|[[0079|121]]||LF||F||colspan=6|
 +
|-
 +
!ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR
 +
|[[007A|122]]||VF||VF||colspan=6|
 +
|-
 +
!ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR
 +
|[[007B|123]]||LF||LF||colspan=6|
 +
|-
 +
!ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR
 +
|[[007C|124]]||LF||VF||colspan=6|
 +
|-
 +
!ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR
 +
|[[007D|125]]||VF||LF||colspan=6|
 +
|-
 +
!rowspan=6|-=@<br/>-@<br/>SUB_THING_FROM_THING_TIMED!!SUB_TIMED_VAL_FROM_FLOAT_VAR
 +
|[[007E|126]]
 +
!rowspan=6|2
 +
|VF||F||colspan=6|
 +
|-
 +
!SUB_TIMED_VAL_FROM_FLOAT_LVAR
 +
|[[007F|127]]||LF||F||colspan=6|
 
|-
 
|-
|Equal to||align=center|<pre style="margin: 0">VAR = THING</pre>||align=center|&#x2713;||align=center|&#x2713;||align=center|&#x2713;
+
!SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR
 +
|[[0080|128]]||VF||VF||colspan=6|
 
|-
 
|-
|Not equal to||align=center|<pre style="margin: 0">VAR <> THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
!SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_LVAR
 +
|[[0081|129]]||LF||LF||colspan=6|
 
|-
 
|-
|Greater than||align=center|<pre style="margin: 0">THING > THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
!SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR
 +
|[[0082|130]]||LF||VF||colspan=6|
 
|-
 
|-
|Less than||align=center|<pre style="margin: 0">THING < THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
!SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR
 +
|[[0083|131]]||VF||LF||colspan=6|
 
|-
 
|-
|Greater than or equal to||align=center|<pre style="margin: 0">THING >= THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
!rowspan=8|=#<br/>CSET<br/>!!CSET_VAR_INT_TO_VAR_FLOAT
 +
|[[008C|140]]
 +
!rowspan=8|2
 +
|VI||VF||colspan=6|
 
|-
 
|-
|Less than or equal to||align=center|<pre style="margin: 0">THING <= THING</pre>||align=center|&#x2713;||align=center|&#x2713;||
+
!CSET_VAR_FLOAT_TO_VAR_INT
|}
+
|[[008D|141]]||VF||VI||colspan=6|
 
 
<span style="display: block; margin: 1em 0; font-size: 1.17em; color: black">'''Logical operators'''</span>
 
 
 
{|class=wikitable
 
 
|-
 
|-
!width=192px style="text-align: left"|Name
+
!CSET_LVAR_INT_TO_VAR_FLOAT
!width=148px|Syntax
+
|[[008E|142]]||LI||VF||colspan=6|
 
|-
 
|-
|Logical negation||align=center|<pre style="margin: 0">NOT</pre>
+
!CSET_LVAR_FLOAT_TO_VAR_INT
 +
|[[008F|143]]||LF||VI||colspan=6|
 
|-
 
|-
|Logical conjunction||align=center|<pre style="margin: 0">AND</pre>
+
!CSET_VAR_INT_TO_LVAR_FLOAT
 +
|[[0090|144]]||VI||LF||colspan=6|
 
|-
 
|-
|Logical disjunction||align=center|<pre style="margin: 0">OR</pre>
+
!CSET_VAR_FLOAT_TO_LVAR_INT
|}
+
|[[0091|145]]||VF||LI||colspan=6|
 
 
==Commands==
 
The [[Wikipedia:Imperative programming|imperative programming]] paradigm provides for a conglomerate of commands the script is filled up of and structured in, which are seen as orders to instruct the execution of the relative built-in portion of game code at runtime. Their invocation is faithful to [[Wikipedia:Functional programming|procedure]] calls: they may feature zero or more parameters of any type or indefinite, depending on whether or not qualified as optional, and receive as much as arguments either by-value or by-reference affecting the read/written access accordingly (do note a pure reference does not initialize anything). Alike procedures, no assignable result is returned but a boolean state is catched anyway on conditional evaluation. One major peculiarity is command names are usually identified by a verb in its imperative form:
 
 
 
GIVE_WEAPON_TO_CHAR mafia_1X WEAPONTYPE_UZI 999
 
 
 
Historically, complex commands stand out over the simple counterpart in the way they are implemented compiler-wise:
 
 
 
* Variable and local scope declarators are true, non-compilable commands;
 
* File includers assemble multiple files in a single source and require the rightmost argument to be a filename if inside the main script or main extension, otherwise '''START_NEW_SCRIPT''' is expected (this behaviour is originally buggy);
 
* Script starters/streamers and function callers involve a type-checking of the optional parameters passed basing on the variables declared in the local scope, whose opening brace must precede the script label reference even few lines earlier since the second Trilogy chapter (the first one needs it right after instead but it's likely it is merely due to good style programming);
 
* '''SCRIPT_NAME''' defines an univocal script name immune to redefinitions but not among mission scripts because they can only run one at a time;
 
* '''SKIP_CUTSCENE_START''' and '''SKIP_CUTSCENE_END''' mark a specific region of code (mostly inside mission scripts). Several blocks cannot be nested together;
 
* Dynamic counters expect one argument to be a zero-value which gets updated automatically/internally on compilation, keeping track of the times few commands are used (unless, if applicable, the only acceptable argument is a variable, then the command is not taken into account) or the total sum of the first argument values (of course, non-immediates are discarded):
 
 
 
:{|class=wikitable style="text-align: left"
 
 
|-
 
|-
!Initializer
+
!CSET_LVAR_INT_TO_LVAR_FLOAT
!Dependency/ies
+
|[[0092|146]]||LI||LF||colspan=6|
!width=50px|Check<br/>arg.
 
!width=50px|Is<br/>addend
 
 
|-
 
|-
|'''SET_COLLECTABLE1_TOTAL'''||'''CREATE_COLLECTABLE1'''||||
+
!CSET_LVAR_FLOAT_TO_LVAR_INT
 +
|[[0093|147]]||LF||LI||colspan=6|
 
|-
 
|-
|'''SET_PROGRESS_TOTAL'''||'''PLAYER_MADE_PROGRESS'''||align=center|&#x2713;||align=center|&#x2713;
+
!rowspan=4|ABS!!ABS_VAR_INT
 +
|[[0094|148]]
 +
!rowspan=4|1
 +
|VI||colspan=7|
 
|-
 
|-
|rowspan=2|'''SET_TOTAL_NUMBER_OF_MISSIONS'''||'''REGISTER_MISSION_PASSED'''||align=center|&#x2713;||
+
!ABS_LVAR_INT
 +
|[[0095|149]]||LI||colspan=7|
 
|-
 
|-
|'''REGISTER_ODDJOB_MISSION_PASSED'''||||
+
!ABS_VAR_FLOAT
 +
|[[0096|150]]||VF||colspan=7|
 
|-
 
|-
|'''SET_MISSION_RESPECT_TOTAL'''||'''AWARD_PLAYER_MISSION_RESPECT'''||align=center|&#x2713;||align=center|&#x2713;
+
!ABS_LVAR_FLOAT
|}
+
|[[0097|151]]||LF||colspan=7|
 
 
A third category consisting of special commands or command pairs, is able to look for the matching signature into a list of akin commands on the basis of the data type of the passed arguments and choose, accordingly, the equivalent alternative in a direct and effortless way. Although the alternative commands are also accessible by and can share the same definition, the selection process is not entirely conform to [[Wikipedia:Function overloading|function overloading]] because these still maintain their own unique name, they are just smartly resolved through common aliases. The complete lists are reported below:
 
 
 
{|width=100% cellspacing=0 cellpadding=0
 
 
|-
 
|-
|width=50%|<span style="display: block; margin: 0; font-size: 1.17em; color: black">'''Trilogy and first Stories chapters'''</span>||width=50%|<span style="display: block; margin: 0; font-size: 1.17em; color: black">'''Second Stories chapter'''</span>
+
!colspan=2|VAR_INT{{ref|defvar|[*]}}
 +
|[[00C7|199]]
 +
!n
 +
|VI||colspan=7|VIO
 
|-
 
|-
|valign=top|<div style="overflow: auto; float: left" width=auto>
+
!colspan=2|VAR_FLOAT{{ref|defvar|[*]}}
{|class="wikitable" style="margin-bottom: 0" width=100%
+
|[[00C8|200]]
 +
!n
 +
|VF||colspan=7|VFO
 
|-
 
|-
!colspan=2 style="text-align: left"|Command
+
!colspan=2|LVAR_INT{{ref|defvar|[*]}}
!rowspan=2 width=64px|Game<br/>support
+
|[[00C9|201]]
 +
!n
 +
|LI||colspan=7|LIO
 
|-
 
|-
|width=20px|
+
!colspan=2|LVAR_FLOAT{{ref|defvar|[*]}}
!style="text-align: left"|Alternative
+
|[[00CA|202]]
|}
+
!n
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
|LF||colspan=7|LFO
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|SET (<code>=</code>)
+
!colspan=2|{{{ref|embdsc|[*]}}
|width=64px align=center|Since {{icon|3}}
+
|[[00CB|203]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|rowspan=18 width=20px|
+
!colspan=2|}{{ref|embdsc|[*]}}
|'''SET_VAR_INT'''||rowspan=12|
+
|[[00CC|204]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_VAR_FLOAT'''
+
!colspan=2|IF{{ref|statem|[*]}}
 +
|[[00CF|207]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SET_LVAR_INT'''
+
!colspan=2|ELSE{{ref|statem|[*]}}
 +
|[[00D1|209]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_LVAR_FLOAT'''
+
!colspan=2|ENDIF{{ref|statem|[*]}}
 +
|[[00D2|210]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_VAR_INT_TO_VAR_INT'''
+
!colspan=2|WHILE{{ref|statem|[*]}}
 +
|[[00D3|211]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SET_LVAR_INT_TO_LVAR_INT'''
+
!colspan=2|ENDWHILE{{ref|statem|[*]}}
 +
|[[00D5|213]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_VAR_FLOAT_TO_VAR_FLOAT'''
+
|colspan=12|{{icon|t}}
 
|-
 
|-
|'''SET_LVAR_FLOAT_TO_LVAR_FLOAT'''
+
!colspan=2|ANDOR{{ref|statem|[*]}}
 +
|[[00D6|214]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SET_VAR_FLOAT_TO_LVAR_FLOAT'''
+
!colspan=2|LAUNCH_MISSION
 +
|[[00D7|215]]
 +
!1
 +
|R||colspan=7|
 
|-
 
|-
|'''SET_LVAR_FLOAT_TO_VAR_FLOAT'''
+
|colspan=2|START_CUTSCENE
 +
|[[02E7|743]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_VAR_INT_TO_LVAR_INT'''
+
!colspan=2|PLAYER_MADE_PROGRESS
 +
|[[030C|780]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SET_LVAR_INT_TO_VAR_INT'''
+
!colspan=2|SET_PROGRESS_TOTAL
 +
|[[030D|781]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SET_VAR_INT_TO_CONSTANT'''||rowspan=2 align=center|Since {{icon|vc}}
+
|colspan=2|REGISTER_MISSION_GIVEN
 +
|[[0317|791]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_LVAR_INT_TO_CONSTANT'''
+
!colspan=2|REGISTER_MISSION_PASSED
 +
|[[0318|792]]
 +
!1
 +
|T||colspan=7|
 
|-
 
|-
|'''SET_VAR_TEXT_LABEL'''||rowspan=4 align=center|{{icon|sa}} only
+
!colspan=2|SCRIPT_NAME
 +
|[[03A4|932]]
 +
!1
 +
|T||colspan=7|
 
|-
 
|-
|'''SET_LVAR_TEXT_LABEL'''
+
!colspan=2|LOAD_AND_LAUNCH_MISSION
 +
|[[0416|1046]]
 +
!1
 +
|R||colspan=7|
 
|-
 
|-
|'''SET_VAR_TEXT_LABEL16'''
+
!colspan=2|LOAD_AND_LAUNCH_MISSION_INTERNAL
 +
|[[0417|1047]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SET_LVAR_TEXT_LABEL16'''
+
!colspan=2|SET_TOTAL_NUMBER_OF_MISSIONS
|}
+
|[[042C|1068]]
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!1
 +
|I||colspan=7|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|CSET (<code>=#</code>)
+
!colspan=2|REGISTER_ODDJOB_MISSION_PASSED
|width=64px align=center|Since {{icon|3}}
+
|[[0595|1429]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|rowspan=8 width=20px|
+
|colspan=12|{{icon|vc}} {{icon|sa}} {{icon|lcs}}
|'''CSET_VAR_INT_TO_VAR_FLOAT||rowspan=8|
 
 
|-
 
|-
|'''CSET_VAR_FLOAT_TO_VAR_INT
+
!colspan=2|REPEAT{{ref|statem|[*]}}
 +
|[[00CD|205]]
 +
!2
 +
|I||VLI||colspan=6|
 
|-
 
|-
|'''CSET_LVAR_INT_TO_VAR_FLOAT
+
!colspan=2|ENDREPEAT{{ref|statem|[*]}}
 +
|[[00CE|206]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''CSET_LVAR_FLOAT_TO_VAR_INT
+
|colspan=12|{{icon|3}} {{icon|vc}}
 
|-
 
|-
|'''CSET_VAR_INT_TO_LVAR_FLOAT
+
!colspan=2|CREATE_COLLECTABLE1
 +
|[[02EC|748]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''CSET_VAR_FLOAT_TO_LVAR_INT
+
!colspan=2|SET_COLLECTABLE1_TOTAL
 +
|[[02ED|749]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''CSET_LVAR_INT_TO_LVAR_FLOAT
+
|colspan=12|{{icon|3}} {{icon|lcs}}
 
|-
 
|-
|'''CSET_LVAR_FLOAT_TO_LVAR_INT
+
!colspan=2|GOTO_IF_TRUE{{ref|statem|[*]}}
|}
+
|[[004C|76]]
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!1
 +
|R||colspan=7|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|ADD_THING_TO_THING (<code>+=</code>)
+
|colspan=12|{{icon|vc}} {{icon|sa}}
|width=64px align=center|Since {{icon|3}}
 
 
|-
 
|-
|rowspan=12 width=20px|
+
!rowspan=2|=<br/>IS_THING_EQUAL_TO_THING!!IS_INT_VAR_EQUAL_TO_CONSTANT
|'''ADD_VAL_TO_INT_VAR'''||rowspan=12|
+
|[[04A3|1187]]
 +
!rowspan=2|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''ADD_VAL_TO_FLOAT_VAR'''
+
!IS_INT_LVAR_EQUAL_TO_CONSTANT
 +
|[[04A4|1188]]||LI||C||colspan=6|
 
|-
 
|-
|'''ADD_VAL_TO_INT_LVAR'''
+
!rowspan=2|=<br/>SET!!SET_VAR_INT_TO_CONSTANT
 +
|[[04AE|1198]]
 +
!rowspan=2|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''ADD_VAL_TO_FLOAT_LVAR'''
+
!SET_LVAR_INT_TO_CONSTANT
 +
|[[04AF|1199]]||LI||C||colspan=6|
 
|-
 
|-
|'''ADD_INT_VAR_TO_INT_VAR'''
+
!rowspan=4|><br/><=<br/>IS_THING_GREATER_THAN_THING!!IS_INT_VAR_GREATER_THAN_CONSTANT
 +
|[[04B0|1200]]
 +
!rowspan=4|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''ADD_FLOAT_VAR_TO_FLOAT_VAR'''
+
!IS_INT_LVAR_GREATER_THAN_CONSTANT
 +
|[[04B1|1201]]||LI||C||colspan=6|
 
|-
 
|-
|'''ADD_INT_LVAR_TO_INT_LVAR'''
+
!IS_CONSTANT_GREATER_THAN_INT_VAR
 +
|[[04B2|1202]]||C||VI||colspan=6|
 
|-
 
|-
|'''ADD_FLOAT_LVAR_TO_FLOAT_LVAR'''
+
!IS_CONSTANT_GREATER_THAN_INT_LVAR
 +
|[[04B3|1203]]||C||LI||colspan=6|
 
|-
 
|-
|'''ADD_INT_VAR_TO_INT_LVAR'''
+
!rowspan=4|>=<br/><<br/>IS_THING_GREATER_OR_EQUAL_TO_THING!!IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT
 +
|[[04B4|1204]]
 +
!rowspan=4|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''ADD_FLOAT_VAR_TO_FLOAT_LVAR'''
+
!IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT
 +
|[[04B5|1205]]||LI||C||colspan=6|
 
|-
 
|-
|'''ADD_INT_LVAR_TO_INT_VAR'''
+
!IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR
 +
|[[04B6|1206]]||C||VI||colspan=6|
 
|-
 
|-
|'''ADD_FLOAT_LVAR_TO_FLOAT_VAR'''
+
!IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR
|}
+
|[[04B7|1207]]||C||LI||colspan=6|
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|SUB_THING_FROM_THING (<code>-=</code>)
+
!colspan=2|LOAD_AND_LAUNCH_MISSION_EXCLUSIVE
|width=64px align=center|Since {{icon|3}}
+
|[[0515|1301]]
 +
!1
 +
|R||colspan=7|
 
|-
 
|-
|rowspan=12 width=20px|
+
|colspan=12|{{icon|3}}
|'''SUB_VAL_FROM_INT_VAR'''||rowspan=12|
 
 
|-
 
|-
|'''SUB_VAL_FROM_FLOAT_VAR'''
+
!colspan=2|IFNOT{{ref|statem|[*]}}
 +
|[[00D0|208]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SUB_VAL_FROM_INT_LVAR'''
+
!colspan=2|WHILENOT{{ref|statem|[*]}}
 +
|[[00D4|212]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SUB_VAL_FROM_FLOAT_LVAR'''
+
!colspan=2|GOSUB_FILE
 +
|[[02CD|717]]
 +
!2
 +
|R||R||colspan=6|
 
|-
 
|-
|'''SUB_INT_VAR_FROM_INT_VAR'''
+
|colspan=12|{{icon|sa}}
 
|-
 
|-
|'''SUB_FLOAT_VAR_FROM_FLOAT_VAR'''
+
!rowspan=2|=<br/>SET!!SET_VAR_TEXT_LABEL
 +
|[[05A9|1449]]
 +
!rowspan=2|2
 +
|VT||AT||colspan=6|
 
|-
 
|-
|'''SUB_INT_LVAR_FROM_INT_LVAR'''
+
!SET_LVAR_TEXT_LABEL
 +
|[[05AA|1450]]||LT||AT||colspan=6|
 
|-
 
|-
|'''SUB_FLOAT_LVAR_FROM_FLOAT_LVAR'''
+
!colspan=2|VAR_TEXT_LABEL{{ref|defvar|[*]}}
 +
|[[05AB|1451]]
 +
!n
 +
|VT||colspan=7|VTO
 
|-
 
|-
|'''SUB_INT_VAR_FROM_INT_LVAR'''
+
!colspan=2|LVAR_TEXT_LABEL{{ref|defvar|[*]}}
 +
|[[05AC|1452]]
 +
!n
 +
|LT||colspan=7|LTO
 
|-
 
|-
|'''SUB_FLOAT_VAR_FROM_FLOAT_LVAR'''
+
!rowspan=2|=<br/>IS_THING_EQUAL_TO_THING!!IS_VAR_TEXT_LABEL_EQUAL_TO_TEXT_LABEL
 +
|[[05AD|1453]]
 +
!rowspan=2|2
 +
|VT||AT||colspan=6|
 
|-
 
|-
|'''SUB_INT_LVAR_FROM_INT_VAR'''
+
!IS_LVAR_TEXT_LABEL_EQUAL_TO_TEXT_LABEL
 +
|[[05AE|1454]]||LT||AT||colspan=6|
 
|-
 
|-
|'''SUB_FLOAT_LVAR_FROM_FLOAT_VAR'''
+
!rowspan=2|=<br/>SET!!SET_VAR_TEXT_LABEL16
|}
+
|[[06D1|1745]]
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!rowspan=2|2
 +
|VT16||AT16||colspan=6|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|MULT_THING_BY_THING (<code>*=</code>)
+
!SET_LVAR_TEXT_LABEL16
|width=64px align=center|Since {{icon|3}}
+
|[[06D2|1476]]||LT16||AT16||colspan=6|
 
|-
 
|-
|rowspan=12 width=20px|
+
!colspan=2|VAR_TEXT_LABEL16{{ref|defvar|[*]}}
|'''MULT_INT_VAR_BY_VAL'''||rowspan=12|
+
|[[06D3|1477]]
 +
!n
 +
|VT16||colspan=7|VT16O
 
|-
 
|-
|'''MULT_FLOAT_VAR_BY_VAL'''
+
!colspan=2|LVAR_TEXT_LABEL16{{ref|defvar|[*]}}
 +
|[[06D4|1478]]
 +
!n
 +
|LT16||colspan=7|LT16O
 
|-
 
|-
|'''MULT_INT_LVAR_BY_VAL'''
+
!rowspan=2|=<br/>IS_THING_EQUAL_TO_THING!!IS_INT_LVAR_EQUAL_TO_INT_VAR
 +
|[[07D6|2006]]
 +
!rowspan=2|2
 +
|LI||VI||colspan=6|
 
|-
 
|-
|'''MULT_FLOAT_LVAR_BY_VAL'''
+
!IS_FLOAT_LVAR_EQUAL_TO_FLOAT_VAR
 +
|[[07D7|2007]]||LF||VF||colspan=6|
 
|-
 
|-
|'''MULT_INT_VAR_BY_INT_VAR'''
+
!rowspan=4|IS_EMPTY{{ref|likely|[*]}}!!IS_VAR_TEXT_LABEL_EMPTY
 +
|[[0844|2116]]
 +
!rowspan=4|1
 +
|VT||colspan=7|
 
|-
 
|-
|'''MULT_FLOAT_VAR_BY_FLOAT_VAR'''
+
!IS_LVAR_TEXT_LABEL_EMPTY
 +
|[[0845|2117]]||LT||colspan=7|
 
|-
 
|-
|'''MULT_INT_LVAR_BY_INT_LVAR'''
+
!IS_VAR_TEXT_LABEL16_EMPTY
 +
|[[0846|2118]]||VT16||colspan=7|
 
|-
 
|-
|'''MULT_FLOAT_LVAR_BY_FLOAT_LVAR'''
+
!IS_LVAR_TEXT_LABEL16_EMPTY
 +
|[[0847|2119]]||LT16||colspan=7|
 
|-
 
|-
|'''MULT_INT_VAR_BY_INT_LVAR'''
+
!colspan=2|SWITCH{{ref|statem|[*]}}
 +
|[[0848|2120]]
 +
!1
 +
|VLI||colspan=7|
 
|-
 
|-
|'''MULT_FLOAT_VAR_BY_FLOAT_LVAR'''
+
!colspan=2|ENDSWITCH{{ref|statem|[*]}}
 +
|[[0849|2121]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''MULT_INT_LVAR_BY_INT_VAR'''
+
!colspan=2|CASE{{ref|statem|[*]}}
 +
|[[084A|2122]]
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''MULT_FLOAT_LVAR_BY_FLOAT_VAR'''
+
!colspan=2|DEFAULT{{ref|statem|[*]}}
|}
+
|[[084B|2123]]
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!0
 +
|colspan=8|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|DIV_THING_BY_THING (<code>/=</code>)
+
!colspan=2|BREAK{{ref|statem|[*]}}
|width=64px align=center|Since {{icon|3}}
+
|[[084C|2124]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|rowspan=12 width=20px|
+
!rowspan=4 colspan=2|SWITCH_START{{ref|statem|[*]}}
|'''DIV_INT_VAR_BY_VAL'''||rowspan=12|
+
|rowspan=4|[[0871|2161]]
 +
!rowspan=4|18
 +
|rowspan=2|VI
 +
|rowspan=2|I
 +
|rowspan=2|I
 +
|rowspan=2|R
 +
|colspan=2|I||colspan=2|
 
|-
 
|-
|'''DIV_FLOAT_VAR_BY_VAL'''
+
|colspan=2|R||colspan=2|
 
|-
 
|-
|'''DIV_INT_LVAR_BY_VAL'''
+
|rowspan=2|LI
 +
|rowspan=2|I
 +
|rowspan=2|I
 +
|rowspan=2|R
 +
|colspan=2|I||colspan=2|
 
|-
 
|-
|'''DIV_FLOAT_LVAR_BY_VAL'''
+
|colspan=2|R||colspan=2|
 
|-
 
|-
|'''DIV_INT_VAR_BY_INT_VAR'''
+
!rowspan=2 colspan=2|SWITCH_CONTINUED{{ref|statem|[*]}}
 +
|rowspan=2|[[0872|2162]]
 +
!rowspan=2|18
 +
|colspan=6|I
 +
|colspan=2|
 
|-
 
|-
|'''DIV_FLOAT_VAR_BY_FLOAT_VAR'''
+
|colspan=6|R
 +
|colspan=2|
 
|-
 
|-
|'''DIV_INT_LVAR_BY_INT_LVAR'''
+
!rowspan=6|IS_BIT_SET{{ref|likely|[*]}}!!IS_GLOBAL_VAR_BIT_SET_CONST
 +
|[[08B4|2228]]
 +
!rowspan=6|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''DIV_FLOAT_LVAR_BY_FLOAT_LVAR'''
+
!IS_GLOBAL_VAR_BIT_SET_VAR
 +
|[[08B5|2229]]||VI||VI||colspan=6|
 
|-
 
|-
|'''DIV_INT_VAR_BY_INT_LVAR'''
+
!IS_GLOBAL_VAR_BIT_SET_LVAR
 +
|[[08B6|2230]]||VI||LI||colspan=6|
 
|-
 
|-
|'''DIV_FLOAT_VAR_BY_FLOAT_LVAR'''
+
!IS_LOCAL_VAR_BIT_SET_CONST
 +
|[[08B7|2231]]||LI||C||colspan=6|
 
|-
 
|-
|'''DIV_INT_LVAR_BY_INT_VAR'''
+
!IS_LOCAL_VAR_BIT_SET_VAR
 +
|[[08B8|2232]]||LI||VI||colspan=6|
 
|-
 
|-
|'''DIV_FLOAT_LVAR_BY_FLOAT_VAR'''
+
!IS_LOCAL_VAR_BIT_SET_LVAR
|}
+
|[[08B9|2233]]||LI||LI||colspan=6|
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_THING_EQUAL_TO_THING (<code>=</code>)
+
!rowspan=6|SET_BIT{{ref|likely|[*]}}!!SET_GLOBAL_VAR_BIT_CONST
|width=64px align=center|Since {{icon|3}}
+
|[[08BA|2234]]
 +
!rowspan=6|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|rowspan=18 width=20px|
+
!SET_GLOBAL_VAR_BIT_VAR
|'''IS_INT_VAR_EQUAL_TO_NUMBER'''||rowspan=5|
+
|[[08BB|2235]]||VI||VI||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_EQUAL_TO_NUMBER'''
+
!SET_GLOBAL_VAR_BIT_LVAR
 +
|[[08BC|2236]]||VI||LI||colspan=6|
 
|-
 
|-
|'''IS_INT_VAR_EQUAL_TO_INT_VAR'''
+
!SET_LOCAL_VAR_BIT_CONST
 +
|[[08BD|2237]]||LI||C||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_EQUAL_TO_INT_LVAR'''
+
!SET_LOCAL_VAR_BIT_VAR
 +
|[[08BE|2238]]||LI||VI||colspan=6|
 
|-
 
|-
|'''IS_INT_VAR_EQUAL_TO_INT_LVAR'''
+
!SET_LOCAL_VAR_BIT_LVAR
 +
|[[08BF|2239]]||LI||LI||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_EQUAL_TO_INT_VAR'''||align=center|{{icon|sa}} only
+
!rowspan=6|CLEAR_BIT{{ref|likely|[*]}}!!CLEAR_GLOBAL_VAR_BIT_CONST
 +
|[[08C0|2240]]
 +
!rowspan=6|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_EQUAL_TO_NUMBER'''||rowspan=5|
+
!CLEAR_GLOBAL_VAR_BIT_VAR
 +
|[[08C1|2241]]||VI||VI||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_EQUAL_TO_NUMBER'''
+
!CLEAR_GLOBAL_VAR_BIT_LVAR
 +
|[[08C2|2242]]||VI||LI||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_EQUAL_TO_FLOAT_VAR'''
+
!CLEAR_LOCAL_VAR_BIT_CONST
 +
|[[08C3|2243]]||LI||C||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_EQUAL_TO_FLOAT_LVAR'''
+
!CLEAR_LOCAL_VAR_BIT_VAR
 +
|[[08C4|2244]]||LI||VI||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_EQUAL_TO_FLOAT_LVAR'''
+
!CLEAR_LOCAL_VAR_BIT_LVAR
 +
|[[08C5|2245]]||LI||LI||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_EQUAL_TO_FLOAT_VAR'''||align=center|{{icon|sa}} only
+
!rowspan=2|=<br/>IS_THING_EQUAL_TO_THING!!IS_VAR_TEXT_LABEL16_EQUAL_TO_TEXT_LABEL
 +
|[[08F9|2297]]
 +
!rowspan=2|2
 +
|VT16||AT16||colspan=6|
 
|-
 
|-
|'''IS_INT_VAR_EQUAL_TO_CONSTANT'''||rowspan=2 align=center|Since {{icon|vc}}
+
!IS_LVAR_TEXT_LABEL16_EQUAL_TO_TEXT_LABEL
 +
|[[08FA|2298]]||LT16||AT16||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_EQUAL_TO_CONSTANT'''
+
!rowspan=2|STRING_CAT{{ref|likely|[*]}}!!STRING_CAT16
 +
|[[098B|2443]]
 +
!rowspan=2|3
 +
|VT16||VT16||VT16||colspan=5|
 
|-
 
|-
|'''IS_VAR_TEXT_LABEL_EQUAL_TO_TEXT_LABEL'''||rowspan=4 align=center|{{icon|sa}} only
+
!STRING_CAT8
 +
|[[098C|2444]]||VT||VT||VT||colspan=5|
 
|-
 
|-
|'''IS_LVAR_TEXT_LABEL_EQUAL_TO_TEXT_LABEL'''
+
|colspan=12|{{icon|lcs}}
 
|-
 
|-
|'''IS_VAR_TEXT_LABEL16_EQUAL_TO_TEXT_LABEL'''
+
|colspan=2|RETURN_TRUE
 +
|[[00C5|197]]
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''IS_LVAR_TEXT_LABEL16_EQUAL_TO_TEXT_LABEL'''
+
|colspan=2|RETURN_FALSE
|}
+
|[[00C6|198]]
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!0
 +
|colspan=8|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_THING_NOT_EQUAL_TO_THING (<code><></code>)
+
!colspan=2|SWITCH{{ref|statem|[*]}}{{ref|posngs|[*]}}
|width=64px align=center|Since {{icon|3}}
+
|214
 +
!1
 +
|VLI||colspan=7|
 
|-
 
|-
|rowspan=12 width=20px|
+
!colspan=2|ENDSWITCH{{ref|statem|[*]}}{{ref|posngs|[*]}}
|'''IS_INT_VAR_NOT_EQUAL_TO_NUMBER'''||rowspan=5|
+
|215
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''IS_INT_LVAR_NOT_EQUAL_TO_NUMBER'''
+
!colspan=2|CASE{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|216
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''IS_INT_VAR_NOT_EQUAL_TO_INT_VAR'''
+
!colspan=2|DEFAULT{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|217
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''IS_INT_LVAR_NOT_EQUAL_TO_INT_LVAR'''
+
!colspan=2|BREAK{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|218
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''IS_INT_VAR_NOT_EQUAL_TO_INT_LVAR'''
+
!colspan=2|ANDOR{{ref|statem|[*]}}
 +
|219
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''IS_INT_LVAR_NOT_EQUAL_TO_INT_VAR'''||align=center|{{icon|sa}} only
+
!colspan=2|LAUNCH_MISSION
 +
|220
 +
!1
 +
|R||colspan=7|
 
|-
 
|-
|'''IS_FLOAT_VAR_NOT_EQUAL_TO_NUMBER'''||rowspan=5|
+
!colspan=2|SAVE_VAR_INT{{ref|defvar|[*]}}
 +
|502
 +
!l
 +
|VI||colspan=7|VIO
 
|-
 
|-
|'''IS_FLOAT_LVAR_NOT_EQUAL_TO_NUMBER'''
+
!colspan=2|SAVE_VAR_FLOAT{{ref|defvar|[*]}}
 +
|503
 +
!l
 +
|VF||colspan=7|VFO
 
|-
 
|-
|'''IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_VAR'''
+
!colspan=2|GOSUB_FILE
 +
|722
 +
!2
 +
|R||R||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_NOT_EQUAL_TO_FLOAT_LVAR'''
+
|colspan=2|START_CUTSCENE
 +
|748
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_LVAR'''
+
!colspan=2|PLAYER_MADE_PROGRESS
 +
|785
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''IS_FLOAT_LVAR_NOT_EQUAL_TO_FLOAT_VAR'''||align=center|{{icon|sa}} only
+
!colspan=2|SET_PROGRESS_TOTAL
|}
+
|786
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!1
 +
|I||colspan=7|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_THING_GREATER_THAN_THING (<code>></code>, <code><=</code>)
+
|colspan=2|REGISTER_MISSION_GIVEN
|width=64px align=center|Since {{icon|3}}
+
|796
 +
!0
 +
|colspan=8|
 
|-
 
|-
|rowspan=20 width=20px|
+
!colspan=2|REGISTER_MISSION_PASSED
|'''IS_INT_VAR_GREATER_THAN_NUMBER'''||rowspan=16|
+
|797
 +
!1
 +
|T||colspan=7|
 
|-
 
|-
|'''IS_INT_LVAR_GREATER_THAN_NUMBER'''
+
!colspan=2|SCRIPT_NAME
 +
|937
 +
!1
 +
|T||colspan=7|
 
|-
 
|-
|'''IS_NUMBER_GREATER_THAN_INT_VAR'''
+
!colspan=2|LOAD_AND_LAUNCH_MISSION
 +
|1051
 +
!1
 +
|R||colspan=7|
 
|-
 
|-
|'''IS_NUMBER_GREATER_THAN_INT_LVAR'''
+
!colspan=2|LOAD_AND_LAUNCH_MISSION_INTERNAL
 +
|1052
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''IS_INT_VAR_GREATER_THAN_INT_VAR'''
+
!colspan=2|SET_TOTAL_NUMBER_OF_MISSIONS
 +
|1073
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''IS_INT_LVAR_GREATER_THAN_INT_LVAR'''
+
!rowspan=2|=<br/>IS_THING_EQUAL_TO_THING!!IS_INT_VAR_EQUAL_TO_CONSTANT
 +
|1192
 +
!rowspan=2|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''IS_INT_VAR_GREATER_THAN_INT_LVAR'''
+
!IS_INT_LVAR_EQUAL_TO_CONSTANT
 +
|1193||LI||C||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_GREATER_THAN_INT_VAR'''
+
!rowspan=2|=<br/>SET!!SET_VAR_INT_TO_CONSTANT
 +
|1203
 +
!rowspan=2|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_THAN_NUMBER'''
+
!SET_LVAR_INT_TO_CONSTANT
 +
|1204||LI||C||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_GREATER_THAN_NUMBER'''
+
!rowspan=4|><br/><=<br/>IS_THING_GREATER_THAN_THING!!IS_INT_VAR_GREATER_THAN_CONSTANT
 +
|1205
 +
!rowspan=4|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''IS_NUMBER_GREATER_THAN_FLOAT_VAR'''
+
!IS_INT_LVAR_GREATER_THAN_CONSTANT
 +
|1206||LI||C||colspan=6|
 
|-
 
|-
|'''IS_NUMBER_GREATER_THAN_FLOAT_LVAR'''
+
!IS_CONSTANT_GREATER_THAN_INT_VAR
 +
|1207||C||VI||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_THAN_FLOAT_VAR'''
+
!IS_CONSTANT_GREATER_THAN_INT_LVAR
 +
|1208||C||LI||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_GREATER_THAN_FLOAT_LVAR'''
+
!rowspan=4|>=<br/><<br/>IS_THING_GREATER_OR_EQUAL_TO_THING!!IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT
 +
|1209
 +
!rowspan=4|2
 +
|VI||C||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_THAN_FLOAT_LVAR'''
+
!IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT
 +
|1210||LI||C||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_GREATER_THAN_FLOAT_VAR'''
+
!IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR
 +
|1211||C||VI||colspan=6|
 
|-
 
|-
|'''IS_INT_VAR_GREATER_THAN_CONSTANT'''||rowspan=4 align=center|Since {{icon|vc}}
+
!IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR
 +
|1212||C||LI||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_GREATER_THAN_CONSTANT'''
+
!colspan=2|REGISTER_ODDJOB_MISSION_PASSED
 +
|1434
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''IS_CONSTANT_GREATER_THAN_INT_VAR'''
+
!rowspan=2 colspan=2|CALL{{ref|undarg|[*]}}{{ref|argvar|[*]}}{{ref|likely|[*]}}
 +
|rowspan=2|1454
 +
!rowspan=2|1+i+o
 +
|rowspan=2|R
 +
|colspan=7|AM
 
|-
 
|-
|'''IS_CONSTANT_GREATER_THAN_INT_LVAR'''
+
|colspan=7|VLM
|}
 
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_THING_GREATER_OR_EQUAL_TO_THING (<code>>=</code>, <code><</code>)
+
!rowspan=2 colspan=2|CALLNOT{{ref|undarg|[*]}}{{ref|argvar|[*]}}{{ref|likely|[*]}}
|width=64px align=center|Since {{icon|3}}
+
|rowspan=2|1455
 +
!rowspan=2|1+i+o
 +
|rowspan=2|R
 +
|colspan=7|AM
 
|-
 
|-
|rowspan=20 width=20px|
+
|colspan=7|VLM
|'''IS_INT_VAR_GREATER_OR_EQUAL_TO_NUMBER'''||rowspan=16|
 
 
|-
 
|-
|'''IS_INT_LVAR_GREATER_OR_EQUAL_TO_NUMBER'''
+
|colspan=12|{{icon|vcs}}
 
|-
 
|-
|'''IS_NUMBER_GREATER_OR_EQUAL_TO_INT_VAR'''
+
!rowspan=7|=<br/>SET!!SET_INT{{ref|likely|[*]}}
 +
|4
 +
 
 +
!rowspan=7|2
 +
|VLI||I||colspan=6|
 
|-
 
|-
|'''IS_NUMBER_GREATER_OR_EQUAL_TO_INT_LVAR'''
+
!SET_FLOAT{{ref|likely|[*]}}
 +
|5||VLF||F||colspan=6|
 
|-
 
|-
|'''IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_VAR'''
+
!SET_TEXT_LABEL{{ref|likely|[*]}}
 +
|6||VLT||T||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_LVAR'''
+
!SET_INT_TO_INT{{ref|likely|[*]}}
 +
|53||VLI||VLI||colspan=6|
 
|-
 
|-
|'''IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_LVAR'''
+
!SET_FLOAT_TO_FLOAT{{ref|likely|[*]}}
 +
|54||VLF||VLF||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_VAR'''
+
!SET_TEXT_LABEL_TO_TEXT_LABEL{{ref|likely|[*]}}
 +
|55||VLT||VLT||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_NUMBER'''
+
!SET_INT_TO_CONSTANT{{ref|likely|[*]}}
 +
|738||VLI||C||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_NUMBER'''
+
!rowspan=4|+=<br/>+<br/>ADD_THING_TO_THING!!ADD_VAL_TO_INT{{ref|likely|[*]}}
 +
|7
 +
!rowspan=4|2
 +
|VLI||I||colspan=6|
 
|-
 
|-
|'''IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_VAR'''
+
!ADD_VAL_TO_FLOAT{{ref|likely|[*]}}
 +
|8||VLF||F||colspan=6|
 
|-
 
|-
|'''IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_LVAR'''
+
!ADD_INT_TO_INT{{ref|likely|[*]}}
 +
|41||VLI||VLI||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_VAR'''
+
!ADD_FLOAT_TO_FLOAT{{ref|likely|[*]}}
 +
|42||VLF||VLF||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR'''
+
!rowspan=4|-=<br/>-<br/>SUB_THING_FROM_THING!!SUB_VAL_FROM_INT{{ref|likely|[*]}}
 +
|9
 +
!rowspan=4|2
 +
|VLI||I||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR'''
+
!SUB_VAL_FROM_FLOAT{{ref|likely|[*]}}
 +
|10||VLF||F||colspan=6|
 
|-
 
|-
|'''IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_VAR'''
+
!SUB_INT_FROM_INT{{ref|likely|[*]}}
 +
|43||VLI||VLI||colspan=6|
 
|-
 
|-
|'''IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT'''||rowspan=4 align=center|Since {{icon|vc}}
+
!SUB_FLOAT_FROM_FLOAT{{ref|likely|[*]}}
 +
|44||VLF||VLF||colspan=6|
 
|-
 
|-
|'''IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT'''
+
!rowspan=4|*=<br/>*<br/>MULT_THING_BY_THING!!MULT_INT_BY_VAL{{ref|likely|[*]}}
 +
|11
 +
!rowspan=4|2
 +
|VLI||I||colspan=6|
 
|-
 
|-
|'''IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR'''
+
!MULT_FLOAT_BY_VAL{{ref|likely|[*]}}
 +
|12||VLF||F||colspan=6|
 
|-
 
|-
|'''IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR'''
+
!MULT_INT_BY_INT{{ref|likely|[*]}}
|}
+
|45||VLI||VLI||colspan=6|
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
|-
 +
!|MULT_FLOAT_BY_FLOAT{{ref|likely|[*]}}
 +
|46||VLF||VLF||colspan=6|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|ADD_THING_TO_THING_TIMED (<code>+=@</code>)
+
!rowspan=4|/=<br/>/<br/>DIV_THING_BY_THING!!DIV_INT_BY_VAL{{ref|likely|[*]}}
|width=64px align=center|Since {{icon|3}}
+
|13
 +
!rowspan=4|2
 +
|VLI||I||colspan=6|
 
|-
 
|-
|rowspan=6 width=20px|
+
!DIV_FLOAT_BY_VAL{{ref|likely|[*]}}
|'''ADD_TIMED_VAL_TO_FLOAT_VAR'''||rowspan=6|
+
|14||VLF||F||colspan=6|
 
|-
 
|-
|'''ADD_TIMED_VAL_TO_FLOAT_LVAR'''
+
!DIV_INT_BY_INT{{ref|likely|[*]}}
 +
|47||VLI||VLI||colspan=6|
 
|-
 
|-
|'''ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR'''
+
!DIV_FLOAT_BY_FLOAT{{ref|likely|[*]}}
 +
|48||VLF||VLF||colspan=6|
 
|-
 
|-
|'''ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR'''
+
!rowspan=8|><br/><=<br/>IS_THING_GREATER_THAN_THING!!IS_INT_GREATER_THAN_NUMBER{{ref|likely|[*]}}
 +
|15
 +
!rowspan=8|2
 +
|VLI||I||colspan=6|
 
|-
 
|-
|'''ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR'''
+
!IS_NUMBER_GREATER_THAN_INT{{ref|likely|[*]}}
 +
|16||I||VLI||colspan=6|
 
|-
 
|-
|'''ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR'''
+
!IS_INT_GREATER_THAN_INT{{ref|likely|[*]}}
|}
+
|17||VLI||VLI||colspan=6|
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|SUB_THING_FROM_THING_TIMED (<code>-=@</code>)
+
!IS_FLOAT_GREATER_THAN_NUMBER{{ref|likely|[*]}}
|width=64px align=center|Since {{icon|3}}
+
|18||VLF||F||colspan=6|
 
|-
 
|-
|rowspan=6 width=20px|
+
!IS_NUMBER_GREATER_THAN_FLOAT{{ref|likely|[*]}}
|'''SUB_TIMED_VAL_FROM_FLOAT_VAR'''||rowspan=6|
+
|19||F||VLF||colspan=6|
 
|-
 
|-
|'''SUB_TIMED_VAL_FROM_FLOAT_LVAR'''
+
!IS_FLOAT_GREATER_THAN_FLOAT{{ref|likely|[*]}}
 +
|20||VLF||VLF||colspan=6|
 
|-
 
|-
|'''SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR'''
+
!IS_INT_GREATER_THAN_CONSTANT{{ref|likely|[*]}}
 +
|739||VLI||C||colspan=6|
 
|-
 
|-
|'''SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_LVAR'''
+
!IS_CONSTANT_GREATER_THAN_INT{{ref|likely|[*]}}
 +
|740||C||VLI||colspan=6|
 
|-
 
|-
|'''SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR'''
+
!rowspan=8|>=<br/><<br/>IS_THING_GREATER_OR_EQUAL_TO_THING!!IS_INT_GREATER_OR_EQUAL_TO_NUMBER{{ref|likely|[*]}}
 +
|21
 +
!rowspan=8|2
 +
|VLI||I||colspan=6|
 
|-
 
|-
|'''SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR'''
+
!IS_NUMBER_GREATER_OR_EQUAL_TO_INT{{ref|likely|[*]}}
|}
+
|22||I||VLI||colspan=6|
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|ABS
+
!IS_INT_GREATER_OR_EQUAL_TO_INT{{ref|likely|[*]}}
|width=64px align=center|Since {{icon|3}}
+
|23||VLI||VLI||colspan=6|
 
|-
 
|-
|rowspan=4 width=20px|
+
!IS_FLOAT_GREATER_OR_EQUAL_TO_NUMBER{{ref|likely|[*]}}
|'''ABS_VAR_INT'''||rowspan=4|
+
|24||VLF||F||colspan=6|
 
|-
 
|-
|'''ABS_LVAR_INT'''
+
!IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT{{ref|likely|[*]}}
 +
|25||F||VLF||colspan=6|
 
|-
 
|-
|'''ABS_VAR_FLOAT'''
+
!IS_FLOAT_GREATER_OR_EQUAL_TO_FLOAT{{ref|likely|[*]}}
 +
|26||VLF||VLF||colspan=6|
 
|-
 
|-
|'''ABS_LVAR_FLOAT'''
+
!IS_INT_GREATER_OR_EQUAL_TO_CONSTANT{{ref|likely|[*]}}
|}
+
|741||VLI||C||colspan=6|
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_EMPTY
+
!IS_CONSTANT_GREATER_OR_EQUAL_TO_INT{{ref|likely|[*]}}
|width=64px align=center|{{icon|sa}} only
+
|742||C||VLI||colspan=6|
 
|-
 
|-
|rowspan=4 width=20px|
+
!rowspan=7|=<br/>IS_THING_EQUAL_TO_THING!!IS_INT_EQUAL_TO_NUMBER{{ref|likely|[*]}}
|'''IS_VAR_TEXT_LABEL_EMPTY'''||rowspan=4|
+
|27
 +
!rowspan=7|2
 +
|VLI||I||colspan=6|
 
|-
 
|-
|'''IS_LVAR_TEXT_LABEL_EMPTY'''
+
!IS_INT_EQUAL_TO_INT{{ref|likely|[*]}}
 +
|28||VLI||VLI||colspan=6|
 
|-
 
|-
|'''IS_VAR_TEXT_LABEL16_EMPTY'''
+
!IS_FLOAT_EQUAL_TO_NUMBER{{ref|likely|[*]}}
 +
|29||VLF||F||colspan=6|
 
|-
 
|-
|'''IS_LVAR_TEXT_LABEL16_EMPTY'''
+
!IS_FLOAT_EQUAL_TO_FLOAT{{ref|likely|[*]}}
|}
+
|30||VLF||VLF||colspan=6|
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_BIT_SET
+
!IS_TEXT_LABEL_EQUAL_TO_STRING{{ref|likely|[*]}}
|width=64px align=center|{{icon|sa}} only
+
|31||VLT||T||colspan=6|
 
|-
 
|-
|rowspan=6 width=20px|
+
!IS_TEXT_LABEL_EQUAL_TO_TEXT_LABEL{{ref|likely|[*]}}
|'''IS_GLOBAL_VAR_BIT_SET_CONST'''||rowspan=6|
+
|32||VLT||VLT||colspan=6|
 
|-
 
|-
|'''IS_GLOBAL_VAR_BIT_SET_VAR'''
+
!IS_INT_EQUAL_TO_CONSTANT{{ref|likely|[*]}}
 +
|731||VLI||C||colspan=6|
 
|-
 
|-
|'''IS_GLOBAL_VAR_BIT_SET_LVAR'''
+
!colspan=2|GOTO_IF_TRUE{{ref|statem|[*]}}
 +
|33
 +
!1
 +
|R||colspan=7|
 
|-
 
|-
|'''IS_LOCAL_VAR_BIT_SET_CONST'''
+
!colspan=2|GOTO_IF_FALSE{{ref|statem|[*]}}
 +
|34
 +
!1
 +
|R||colspan=7|
 
|-
 
|-
|'''IS_LOCAL_VAR_BIT_SET_VAR'''
+
!colspan=2|TERMINATE_THIS_SCRIPT
 +
|rowspan=2|35
 +
!rowspan=2|0
 +
|rowspan=2 colspan=8|
 
|-
 
|-
|'''IS_LOCAL_VAR_BIT_SET_LVAR'''
+
!colspan=2|MISSION_END
|}
 
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|SET_BIT
+
!colspan=2|START_NEW_SCRIPT{{ref|undarg|[*]}}
|width=64px align=center|{{icon|sa}} only
+
|36
 +
!1+l
 +
|R||colspan=7|AM
 
|-
 
|-
|rowspan=6 width=20px|
+
|colspan=2|GOSUB
|'''SET_GLOBAL_VAR_BIT_CONST'''||rowspan=6|
+
|37
 +
!1
 +
|R||colspan=7|
 
|-
 
|-
|'''SET_GLOBAL_VAR_BIT_VAR'''
+
|colspan=2|RETURN
 +
|38
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_GLOBAL_VAR_BIT_LVAR'''
+
!rowspan=2|+=@<br/>+@<br/>ADD_THING_TO_THING_TIMED!!ADD_TIMED_VAL_TO_FLOAT{{ref|likely|[*]}}
 +
|49
 +
!rowspan=2|2
 +
|VLF||F||colspan=6|
 
|-
 
|-
|'''SET_LOCAL_VAR_BIT_CONST'''
+
!ADD_TIMED_FLOAT_TO_FLOAT{{ref|likely|[*]}}
 +
|50||VLF||VLF||colspan=6|
 
|-
 
|-
|'''SET_LOCAL_VAR_BIT_VAR'''
+
!rowspan=2|-=@<br/>-@<br/>SUB_THING_FROM_THING_TIMED!!SUB_TIMED_VAL_FROM_FLOAT{{ref|likely|[*]}}
 +
|51
 +
!rowspan=2|2
 +
|VLF||F||colspan=6|
 
|-
 
|-
|'''SET_LOCAL_VAR_BIT_LVAR'''
+
!SUB_TIMED_FLOAT_FROM_FLOAT{{ref|likely|[*]}}
|}
+
|52||VLF||VLF||colspan=6|
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|CLEAR_BIT
+
!rowspan=2|=#<br/>CSET!!CSET_INT_TO_FLOAT{{ref|likely|[*]}}
|width=64px align=center|{{icon|sa}} only
+
|56
 +
!rowspan=2|2
 +
|VLI||VLF||colspan=6|
 
|-
 
|-
|rowspan=6 width=20px|
+
!CSET_FLOAT_TO_INT{{ref|likely|[*]}}
|'''CLEAR_GLOBAL_VAR_BIT_CONST'''||rowspan=6|
+
|57||VLF||VLI||colspan=6|
 
|-
 
|-
|'''CLEAR_GLOBAL_VAR_BIT_VAR'''
+
!rowspan=2|ABS!!ABS_INT{{ref|likely|[*]}}
 +
|58
 +
!rowspan=2|1
 +
|VLI||colspan=7|
 
|-
 
|-
|'''CLEAR_GLOBAL_VAR_BIT_LVAR'''
+
!ABS_FLOAT{{ref|likely|[*]}}
 +
|59||VLF||colspan=7|
 
|-
 
|-
|'''CLEAR_LOCAL_VAR_BIT_CONST'''
+
|colspan=2|RETURN_TRUE
 +
|94
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''CLEAR_LOCAL_VAR_BIT_VAR'''
+
|colspan=2|RETURN_FALSE
 +
|95
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''CLEAR_LOCAL_VAR_BIT_LVAR'''
+
!colspan=2|VAR_INT{{ref|defvar|[*]}}{{ref|posngs|[*]}}
|}
+
|96
</div>
+
!n
|valign=top|<div style="overflow: auto; float: left" width=auto>
+
|VI||colspan=7|VIO
{|class="wikitable" style="margin-bottom: 0" width=100%
 
 
|-
 
|-
!colspan=2 style="text-align: left"|Command
+
!colspan=2|VAR_FLOAT{{ref|defvar|[*]}}{{ref|posngs|[*]}}
 +
|97
 +
!n
 +
|VF||colspan=7|VFO
 
|-
 
|-
|width=20px|
+
!colspan=2|LVAR_INT{{ref|defvar|[*]}}{{ref|posngs|[*]}}
!style="text-align: left"|Alternative
+
|98
|}
+
!n
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
|LI||colspan=7|LIO
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|SET (<code>=</code>)
+
!colspan=2|LVAR_FLOAT{{ref|defvar|[*]}}{{ref|posngs|[*]}}
 +
|99
 +
!n
 +
|LF||colspan=7|LFO
 
|-
 
|-
|rowspan=7 width=20px|
+
!colspan=2|VAR_TEXT_LABEL{{ref|defvar|[*]}}{{ref|posngs|[*]}}
|'''SET_VAR_INT'''
+
|100
 +
!n
 +
|VT||colspan=7|VTO
 
|-
 
|-
|'''SET_VAR_FLOAT'''
+
!colspan=2|LVAR_TEXT_LABEL{{ref|defvar|[*]}}{{ref|posngs|[*]}}
 +
|101
 +
!n
 +
|LT||colspan=7|LTO
 
|-
 
|-
|'''SET_VAR_TEXT_LABEL'''
+
!colspan=2|{{{ref|embdsc|[*]}}{{ref|posngs|[*]}}
 +
|102
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_VAR_INT_TO_VAR_INT'''
+
!colspan=2|}{{ref|embdsc|[*]}}{{ref|posngs|[*]}}
 +
|103
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SET_VAR_FLOAT_TO_VAR_FLOAT'''
+
!colspan=2|IF{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|104
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SET_VAR_TEXT_LABEL_TO_VAR_TEXT_LABEL'''
+
!colspan=2|IFNOT{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|105
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SET_VAR_INT_TO_CONSTANT'''
+
!colspan=2|ELSE{{ref|statem|[*]}}{{ref|posngs|[*]}}
|}
+
|106
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!0
 +
|colspan=8|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|CSET (<code>=#</code>)
+
!colspan=2|ENDIF{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|107
 +
!0
 +
|colspan=8|
 
|-
 
|-
|rowspan=2 width=20px|
+
!colspan=2|WHILE{{ref|statem|[*]}}{{ref|posngs|[*]}}
|'''CSET_VAR_INT_TO_VAR_FLOAT'''
+
|108
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''CSET_VAR_FLOAT_TO_VAR_INT'''
+
!colspan=2|WHILENOT{{ref|statem|[*]}}{{ref|posngs|[*]}}
|}
+
|109
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!1
 +
|I||colspan=7|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|ADD_THING_TO_THING (<code>+=</code>)
+
!colspan=2|ENDWHILE{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|110
 +
!0
 +
|colspan=8|
 
|-
 
|-
|rowspan=4 width=20px|
+
!colspan=2|REPEAT{{ref|statem|[*]}}{{ref|posngs|[*]}}
|'''ADD_VAL_TO_INT_VAR'''
+
|111
 +
!2
 +
|I||VLI||colspan=6|
 
|-
 
|-
|'''ADD_VAL_TO_FLOAT_VAR'''
+
!colspan=2|ENDREPEAT{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|112
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''ADD_INT_VAR_TO_INT_VAR'''
+
!colspan=2|SWITCH{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|113
 +
!1
 +
|VLI||colspan=7|
 
|-
 
|-
|'''ADD_FLOAT_VAR_TO_FLOAT_VAR'''
+
!colspan=2|ENDSWITCH{{ref|statem|[*]}}{{ref|posngs|[*]}}
|}
+
|114
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!0
 +
|colspan=8|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|SUB_THING_FROM_THING (<code>-=</code>)
+
!colspan=2|CASE{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|115
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|rowspan=4 width=20px|
+
!colspan=2|DEFAULT{{ref|statem|[*]}}{{ref|posngs|[*]}}
|'''SUB_VAL_FROM_INT_VAR'''
+
|116
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SUB_VAL_FROM_FLOAT_VAR'''
+
!colspan=2|BREAK{{ref|statem|[*]}}{{ref|posngs|[*]}}
 +
|117
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''SUB_INT_VAR_FROM_INT_VAR'''
+
!colspan=2|ANDOR{{ref|statem|[*]}}
 +
|120
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''SUB_FLOAT_VAR_FROM_FLOAT_VAR'''
+
!colspan=2|LAUNCH_MISSION
|}
+
|121
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!1
 +
|R||colspan=7|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|MULT_THING_BY_THING (<code>*=</code>)
+
!colspan=2|SAVE_VAR_INT{{ref|defvar|[*]}}
 +
|297
 +
!l
 +
|VI||colspan=7|VIO
 
|-
 
|-
|rowspan=4 width=20px|
+
!colspan=2|SAVE_VAR_FLOAT{{ref|defvar|[*]}}
|'''MULT_INT_VAR_BY_VAL'''
+
|298
 +
!l
 +
|VF||colspan=7|VFO
 
|-
 
|-
|'''MULT_FLOAT_VAR_BY_VAL'''
+
!colspan=2|SAVE_VAR_TEXT_LABEL{{ref|defvar|[*]}}
 +
|299
 +
!l
 +
|VT||colspan=7|VTO
 
|-
 
|-
|'''MULT_INT_VAR_BY_INT_VAR'''
+
!colspan=2|GOSUB_FILE
 +
|442
 +
!2
 +
|R||R||colspan=6|
 
|-
 
|-
|'''MULT_FLOAT_VAR_BY_FLOAT_VAR'''
+
!colspan=2|PLAYER_MADE_PROGRESS
|}
+
|479
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!1
 +
|I||colspan=7|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|DIV_THING_BY_THING (<code>/=</code>)
+
!colspan=2|SET_PROGRESS_TOTAL
 +
|480
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|rowspan=4 width=20px|
+
|colspan=2|REGISTER_MISSION_GIVEN
|'''DIV_INT_VAR_BY_VAL'''
+
|490
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''DIV_FLOAT_VAR_BY_VAL'''
+
!colspan=2|REGISTER_MISSION_PASSED
 +
|491
 +
!1
 +
|T||colspan=7|
 
|-
 
|-
|'''DIV_INT_VAR_BY_INT_VAR'''
+
!colspan=2|SCRIPT_NAME
 +
|568
 +
!1
 +
|T||colspan=7|
 
|-
 
|-
|'''DIV_FLOAT_VAR_BY_FLOAT_VAR'''
+
!colspan=2|LOAD_AND_LAUNCH_MISSION
|}
+
|648
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
!1
 +
|R||colspan=7|
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_THING_EQUAL_TO_THING (<code>=</code>)
+
!colspan=2|LOAD_AND_LAUNCH_MISSION_INTERNAL
 +
|649
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|rowspan=7 width=20px|
+
!colspan=2|SET_TOTAL_NUMBER_OF_MISSIONS
|'''IS_INT_VAR_EQUAL_TO_NUMBER'''
+
|662
 +
!1
 +
|I||colspan=7|
 
|-
 
|-
|'''IS_INT_VAR_EQUAL_TO_INT_VAR'''
+
!colspan=2|REGISTER_ODDJOB_MISSION_PASSED
 +
|874
 +
!0
 +
|colspan=8|
 
|-
 
|-
|'''IS_FLOAT_VAR_EQUAL_TO_NUMBER'''
+
!rowspan=2 colspan=2|CALL{{ref|undarg|[*]}}{{ref|argvar|[*]}}{{ref|likely|[*]}}
 +
|rowspan=2|890
 +
!rowspan=2|1+i+o
 +
|rowspan=2|R
 +
|colspan=7|AM
 
|-
 
|-
|'''IS_FLOAT_VAR_EQUAL_TO_FLOAT_VAR'''
+
|colspan=7|VLM
 
|-
 
|-
|'''IS_TEXT_LABEL_VAR_EQUAL_TO_TEXT_LABEL'''
+
!rowspan=2 colspan=2|CALLNOT{{ref|undarg|[*]}}{{ref|argvar|[*]}}{{ref|likely|[*]}}
 +
|rowspan=2|891
 +
!rowspan=2|1+i+o
 +
|rowspan=2|R
 +
|colspan=7|AM
 
|-
 
|-
|'''IS_TEXT_LABEL_VAR_EQUAL_TO_TEXT_LABEL_VAR'''
+
|colspan=7|VLM
 
|-
 
|-
|'''IS_INT_VAR_EQUAL_TO_CONSTANT'''
+
!colspan=2|SET_COLLECTABLE2_TOTAL
 +
|1242
 +
!1
 +
|I||colspan=7|
 
|}
 
|}
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
</div>
 +
 
 +
;Notes
 +
:{{note|misdef}} A special [[#Mission scripts|mission]] directive which is never compiled;
 +
:{{note|statem}} It is used to build the various [[#Control flows|control flows]] internally;
 +
:{{note|defvar}} It is used to declare one or more variables;
 +
:{{note|embdsc}} It embeds a variable scope;
 +
:{{note|undarg}} It has an undefined amount of arguments;
 +
:{{note|likely}} It is a likely definition of the standard command;
 +
:{{note|posngs}} It should exist but its position is purely guessed;
 +
:{{note|argvar}} Arguments amount varies when compiling.
 +
 
 +
{{incomplete}}
 +
 
 +
==Uncommon values==
 +
 
 +
Arguments of some commands keep uncommon [[#Value|values]] which look familiar after encoding:
 +
 
 +
<div width=100% style="overflow: auto; margin: -8px auto 8px">
 +
{|class="mw-collapsible mw-collapsed wikitable" style=text-align:center
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_THING_GREATER_THAN_THING (<code>></code>, <code><=</code>)
+
!rowspan=2|Command
 +
!rowspan=2|Arg.<br/>ID
 +
!rowspan=2|Value
 +
!colspan=4|Encoded
 
|-
 
|-
|rowspan=8 width=20px|
+
!Command!!Arg.<br/>ID!!Value!!Type
|'''IS_INT_VAR_GREATER_THAN_NUMBER'''
 
 
|-
 
|-
|'''IS_NUMBER_GREATER_THAN_INT_VAR'''
+
|colspan=7|{{icon|t}} {{icon|lcs}} {{icon|vcs}}
 
|-
 
|-
|'''IS_INT_VAR_GREATER_THAN_INT_VAR'''
+
!GOTO
 +
|1||Generic [[#Labels|label]]
 +
!GOTO
 +
|1||Positive/Negative [[#Offsets|offset]]||INT
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_THAN_NUMBER'''
+
!GOTO_IF_FALSE
 +
|1||Generic label
 +
!GOTO_IF_FALSE
 +
|1||Positive/Negative offset||INT
 
|-
 
|-
|'''IS_NUMBER_GREATER_THAN_FLOAT_VAR'''
+
!GOSUB
 +
|1||[[#Gosubs|Gosub]] label
 +
!GOSUB
 +
|1||Positive/Negative offset||INT
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_THAN_FLOAT_VAR'''
+
!rowspan=4|GOSUB_FILE
 +
|1||Gosub label
 +
!rowspan=4|GOSUB_FILE
 +
|1||rowspan=2|Zero-based offset||rowspan=4|INT
 
|-
 
|-
|'''IS_INT_VAR_GREATER_THAN_CONSTANT'''
+
|2||[[#Foreign gosubs|Foreign gosub]] file||2
 
|-
 
|-
|'''IS_CONSTANT_GREATER_THAN_INT_VAR'''
+
|1||Gosub label||1||rowspan=2|Positive/Negative offset
|}
+
|-
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
+
|2||Foreign gosub label||2
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|IS_THING_GREATER_OR_EQUAL_TO_THING (<code>>=</code>, <code><</code>)
+
!rowspan=2|START_NEW_SCRIPT
 +
|1||[[#Scripts|Script]] label
 +
!rowspan=2|START_NEW_SCRIPT
 +
|1||Positive/Negative offset||INT
 
|-
 
|-
|rowspan=8 width=20px|
+
|l||Passed [[#Local|locals]]||l||Passed locals||ANY_MULTI
|'''IS_INT_VAR_GREATER_OR_EQUAL_TO_NUMBER'''
 
 
|-
 
|-
|'''IS_NUMBER_GREATER_OR_EQUAL_TO_INT_VAR'''
+
!rowspan=2|LAUNCH_MISSION
 +
|rowspan=2|1||[[#Subscripts|Subscript]] file
 +
!rowspan=2|LAUNCH_MISSION
 +
|rowspan=2|1||Zero-based offset||rowspan=2|INT
 
|-
 
|-
|'''IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_VAR'''
+
|Subscript label||Positive/Negative offset
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_NUMBER'''
+
!rowspan=2|LOAD_AND_LAUNCH_MISSION
 +
|rowspan=2|1||[[#Mission scripts|Mission script]] file
 +
!LOAD_AND_LAUNCH_MISSION_INTERNAL
 +
|rowspan=2|1||Mission [[#Identifiers|identifier]]||rowspan=2|INT
 
|-
 
|-
|'''IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_VAR'''
+
|Mission script label
 +
!LOAD_AND_LAUNCH_MISSION
 +
|Positive/Negative offset
 
|-
 
|-
|'''IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_VAR'''
+
|colspan=7|{{icon|3}} {{icon|lcs}} {{icon|vcs}}
 
|-
 
|-
|'''IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT'''
+
!GOTO_IF_TRUE
 +
|1||Generic label
 +
!GOTO_IF_TRUE
 +
|1||Positive/Negative offset||INT
 
|-
 
|-
|'''IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR'''
+
|colspan=7|{{icon|vc}} {{icon|sa}}
|}
 
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|ADD_THING_TO_THING_TIMED (<code>+=@</code>)
+
!rowspan=2|LOAD_AND_LAUNCH_MISSION_EXCLUSIVE
 +
|rowspan=2|1||Mission script file
 +
!LOAD_AND_LAUNCH_MISSION_INTERNAL
 +
|rowspan=2|1||Negative mission identifier||rowspan=2|INT
 
|-
 
|-
|rowspan=2 width=20px|
+
|Mission script label
|'''ADD_TIMED_VAL_TO_FLOAT_VAR'''
+
!LOAD_AND_LAUNCH_MISSION_EXCLUSIVE
 +
|Positive/Negative offset
 
|-
 
|-
|'''ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR'''
+
|colspan=7|{{icon|lcs}} {{icon|vcs}}
|}
 
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|SUB_THING_FROM_THING_TIMED (<code>-=@</code>)
+
!rowspan=6|CALL<br/>CALLNOT
 +
|rowspan=4|1||rowspan=4|[[#Functions|Function]] label
 +
!rowspan=6|CALL<br/>CALLNOT
 +
|1||# of input arguments||rowspan=4|INT
 
|-
 
|-
|rowspan=2 width=20px|
+
|2||# of output arguments
|'''SUB_TIMED_VAL_FROM_FLOAT_VAR'''
 
 
|-
 
|-
|'''SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR'''
+
|3||# of script locals
|}
 
{|class="wikitable collapsible collapsed" style="margin: -1px auto 0" width=100%
 
 
|-
 
|-
!colspan=2 style="background-color: inherit; text-align: left"|ABS
+
|4||Positive/Negative offset
 
|-
 
|-
|rowspan=2 width=20px|
+
|i||Input arguments||i||Input arguments||ANY_MULTI
|'''ABS_VAR_INT'''
 
 
|-
 
|-
|'''ABS_VAR_FLOAT'''
+
|o||Output arguments||o||Output arguments||HOLD_MULTI
 
|}
 
|}
 
</div>
 
</div>
 +
 +
{{incomplete}}
 +
 +
==Compare flag==
 +
 +
The ''compare flag'' is an internal script-dependent flag which makes conditional '''GOTO'''s such as [[#GOTO_IF_TRUE|GOTO_IF_TRUE]] (unavailable in {{icon|t}}) and [[#GOTO_IF_FALSE|GOTO_IF_FALSE]] deciding whether to jump otherwise. It can handle up to ''8 checks'' per conditional statement and indicates you are verifying a single condition (0, see also [[#Optimization|Optimization]]) or multiple conditions with either '''AND''' (1 to 8) or '''OR''' (21 to 28) [[#Logical|logical operators]] (see also [[#ANDOR|ANDOR]]).
 +
 +
==Control flows analysis==
 +
 +
As an overview of the compiled source, [[#Control flows|control flows]] are literally nested meaning that the code is unoptimized. Furthermore, the jump of an embedded construct doesn't get merged with that of the construct itself, which consists of a benefit for the code parsing.
 +
 +
===IF===
 +
 +
As regards the [[#IF|IF]] control flow, if the whole check is true the ''consequence'' is performed and the code jumps to the end of the construct, otherwise it skips to the ''alternative'' (see also [[#Compare flag|Compare flag]]):
 +
 +
{|width=100%
 +
!width=50%|Decompiled
 +
!width=1px|{{icon|t}}
 +
!width=1px|{{icon|lcs}}
 +
!width=1px|{{icon|vcs}}
 +
!Compiled
 +
|-
 +
|
 +
IF [NOT] {condition0}
 +
[AND|OR [NOT] {condition8}]
 +
    {consequence}
 +
[ELSE
 +
    {alternative}]
 +
ENDIF
 +
|
 +
{..214}
 +
{.....}
 +
{.....}
 +
{...77}
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
  -----
 +
|
 +
{..219}
 +
{.....}
 +
{.....}
 +
{...77}
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
  -----
 +
|
 +
{..120}
 +
{.....}
 +
{.....}
 +
{...34}
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
  -----
 +
|
 +
ANDOR {value}
 +
    [NOT] {condition0}
 +
    [[NOT] {condition8}]
 +
GOTO_IF_FALSE ELSE
 +
    {consequence}
 +
    [GOTO ENDIF]
 +
ELSE:
 +
    [{alternative}
 +
ENDIF:]
 
|}
 
|}
  
==Control flows==
+
===IFNOT===
Insofar as subprograms, scripts are organized in a systematic arrangement through which goto branches, subroutine branches, function calls and returns are executed to form control flow statements and structures. These alter the [[Wikipedia:Program Counter|program counter]] most of the time affecting the top-down order all commands are fetched by. Facing off code duplication is quite recurring especially when the tasks to perform vary only in the input data, the case where a piece of code or subroutine, built once in the source, is invoked many times from various different places and returns back, as if the '''GOSUB''' statement is substituted in-place by the subroutine's body without '''RETURN''' during the control transferring, shrinking long codes and reducing the script overall size. The flow of execution can also be broken up conditionally by means of:
 
  
* Decision-making structures ('''IF''', '''IFNOT''', '''SWITCH'''), which evaluate the result of one or more conditions and choose what path to follow based off the trueness or falseness of the check being tested. Been deemed the most basic tool of [[Wikipedia:Structured programming|structured programming]], '''IF''' is a bidirectional statement that proceeds with the execution of the underneath code only if the test carried out evaluates to true otherwise it transfers the control next to '''ENDIF''', unless a preceding and optional '''ELSE''' clause, establishing an alternative path, is specified. In the first Trilogy and both Stories chapters where '''GOTO_IF_TRUE''' is handled by game code, the barely used '''IFNOT''' can be deployed as a placeholder to easily invert the compare-flag, a boolean state which is set or cleared as a result of the bitwise [[Wikipedia:Bitwise operation#AND|conjunction]] or [[Wikipedia:Bitwise operation#OR|disjunction]] with the true/false state caught by a condition, applying the inversion according to the presence of the not-flag before updating. Logical operators make possible the connection among multiple conditions via the '''AND''' [[Wikipedia:Logical conjunction|conjunction]] and '''OR''' [[Wikipedia:Logical disjunction|disjunction]] giving the chance to verify if conditions are all true or if just one of them is satisfied bearing in mind that the '''NOT''' [[Wikipedia:Logical negation|negation]], inverting the boolean state of a single condition, may be supplied. Connectivity information are held by '''ANDOR''', whose argument depicts a value in the range <code>[1,8)</code> or <code>[21,28)</code> for logical conjunction and disjunction respectively, limiting the amount of total conditions to provide to a maximum of 8 per check (the prominent intervals discrepancy also suggests '''NAND''' and '''NOR''' operators might have been a plan). A value of 0 does nothing relevant functional-wise at runtime, what led programmers to not compile said command in such a situation for Stories chapters. The inability to create subexpressions enforces to not combine '''AND''' with '''OR''' in a check, plus evaluations are eager and therefore not short-circuited meaning all conditions are executed prior potentially branching through '''GOTO_IF_FALSE''' in the common case after the compare-flag gets processed. Nesting lots of '''IF-ELSE-ENDIF''' structures of one-condition checks testing the equality of the same variable against a few integer literals or string constants can add a ridiculous code redundancy and performance overhead, sorted out in the last Trilogy chapter thanks to the introduction of the '''SWITCH''' statement, a multiway statement either branching to the switch section labelled by fall-through '''CASE''' statements of which one passses a value that shall match the variable content to compare or optionally branching to '''DEFAULT''' in the worst-case scenario, each ending with a nonmandatory '''BREAK''' statement goto-ing past '''ENDSWITCH'''. On compilation, the implementation somehow mimics the pattern of a [[Wikipedia:Jump table|jump table]] sorting case label references by value to fulfil the runtime's [[Wikipedia:Binary search|binary search]] among at least 1 of 75 entries (default case aside);
+
Not that much to say more than the preceding construct, the [[#IFNOT|IFNOT]] control flow is built nearly in the same way. In fact, the '''ELSE''' clause points to the ''alternative'', whereas the [[#GOTO|GOTO]] jumps to its end. The substantial difference consists in the substitution of [[#GOTO_IF_FALSE|GOTO_IF_FALSE]] with [[#GOTO_IF_TRUE|GOTO_IF_TRUE]]:
* Looping structures ('''REPEAT''', '''WHILE''', '''WHILENOT'''), which repeatedly execute a block of code certain number of times (count-controlled) or by constantly and successfully evaluating a check (condition-controlled).
 
  
IF/IFNOT-ELSE-ENDIF
+
{|width=100%
SWITCH-CASE/DEFAULT-BREAK-ENDSWITCH
+
!width=50%|Decompiled
 +
!width=1px|{{icon|3}}
 +
!width=1px|{{icon|lcs}}
 +
!width=1px|{{icon|vcs}}
 +
!Compiled
 +
|-
 +
|
 +
IFNOT [NOT] {condition0}
 +
[AND|OR [NOT] {condition8}]
 +
    {consequence}
 +
[ELSE
 +
    {alternative}]
 +
ENDIF
 +
|
 +
{..214}
 +
{.....}
 +
{.....}
 +
{...76}
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
  -----
 +
|
 +
{..219}
 +
{.....}
 +
{.....}
 +
{...76}
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
  -----
 +
|
 +
{..120}
 +
{.....}
 +
{.....}
 +
{...33}
 +
{.....}
 +
{....2}
 +
  -----  
 +
{.....}
 +
  -----
 +
|
 +
ANDOR {value}
 +
    [NOT] {condition0}
 +
    [[NOT] {condition8}]
 +
GOTO_IF_TRUE ELSE
 +
    {consequence}
 +
    [GOTO ENDIF]
 +
ELSE:
 +
    [{alternative}
 +
ENDIF:]
 +
|}
  
WHILE/WHILENOT-ENDWHILE
+
===WHILE===
REPEAT-ENDREPEAT
 
  
=Code layout=
+
The [[#WHILE|WHILE]] control flow is built pretty much similarly to the previous, even though when the ''consequence'' is read the code is moved to the beginning of the construct:
  
==Main script and Main extensions==
+
{|width=100%
 +
!width=50%|Decompiled
 +
!width=1px|{{icon|t}}
 +
!width=1px|{{icon|lcs}}
 +
!width=1px|{{icon|vcs}}
 +
!Compiled
 +
|-
 +
|
 +
WHILE [NOT] {condition0}
 +
[AND|OR [NOT] {condition8}]
 +
    {consequence}
 +
ENDWHILE
 +
|
 +
  -----
 +
{..214}
 +
{.....}
 +
{.....}
 +
{...77}
 +
{.....}
 +
{....2}
 +
  -----
 +
|
 +
  -----
 +
{..219}
 +
{.....}
 +
{.....}
 +
{...77}
 +
{.....}
 +
{....2}
 +
  -----
 +
|
 +
  -----
 +
{..120}
 +
{.....}
 +
{.....}
 +
{...34}
 +
{.....}
 +
{....2}
 +
  -----
 +
|
 +
WHILE:
 +
ANDOR {value}
 +
    [NOT] {condition0}
 +
    [[NOT] {condition8}]
 +
GOTO_IF_FALSE ENDWHILE
 +
    {consequence}
 +
    GOTO WHILE
 +
ENDWHILE:
 +
|}
  
==Scripts and Streamed scripts==
+
===WHILENOT===
  
==Subscripts and Mission scripts==
+
To say the least, [[#WHILENOT|WHILENOT]] control flow follows the same constitution of both [[#WHILE|WHILE]] and [[#IFNOT|IFNOT]] constructs, by exchanging [[#GOTO_IF_FALSE|GOTO_IF_FALSE]] with [[#GOTO_IF_TRUE|GOTO_IF_TRUE]]:
  
[...] The so-called official compiler is custom by ''War Drum Studios''.
+
{|width=100%
 +
!width=50%|Decompiled
 +
!width=1px|{{icon|3}}
 +
!width=1px|{{icon|lcs}}
 +
!width=1px|{{icon|vcs}}
 +
!Compiled
 +
|-
 +
|
 +
WHILENOT [NOT] {condition0}
 +
[AND|OR [NOT] {condition8}]
 +
    {consequence}
 +
ENDWHILE
 +
|
 +
  -----
 +
{..214}
 +
{.....}
 +
{.....}
 +
{...76}
 +
{.....}
 +
{....2}
 +
  -----
 +
|
 +
  -----
 +
{..219}
 +
{.....}
 +
{.....}
 +
{...76}
 +
{.....}
 +
{....2}
 +
  -----
 +
|
 +
  -----  
 +
{..120}
 +
{.....}
 +
{.....}
 +
{...33}
 +
{.....}
 +
{....2}
 +
  -----
 +
|
 +
WHILENOT:
 +
ANDOR {value}
 +
    [NOT] {condition0}
 +
    [[NOT] {condition8}]
 +
GOTO_IF_TRUE ENDWHILE
 +
    {consequence}
 +
    GOTO WHILENOT
 +
ENDWHILE:
 +
|}
  
<del>[...] '''LOAD_SPRITE''' expects a variable-length text label of 14 characters but then the game code enforces an useless uppercase conversion of a fixed-length 15 character identifier, incorrectly including the null-terminator at 15th position during the process.</del>
+
===REPEAT===
[...] Variable and text label identifiers are limited to 40 characters, the reason why 4 '''TEXT_LABEL32''' parameters are needed to store 128-byte strings. They can be passed individually as 32-byte aligned blocks but the first character is trimmed out.
 
[...] In the last Trilogy and Stories chapter, text labels must begin with an alphanumeric character or an underscore, provided that they aren't valid integer or floating-point literals.
 
[...] It is prohibited to fetch or handle a long text label using a variable of shorter length but this one is rather passable to those text label parameters also permitting long-lengthed literals.
 
[...] Variable-length text labels are kind of Pascal strings. Reference: https://en.wikipedia.org/wiki/String_(computer_science)#Length-prefixed.
 
  
[...] In the last Trilogy chapter, local variables start at index 34 in mission scripts so local timers are also ignored.
+
Seemingly, the [[#REPEAT|REPEAT]] control flow is the first construct ever optimized as a result of a possible R* compiler fault. Moreover, it sounds ambiguous as it loops at least once. This was probably the intention of R* programmers, that is iterating at least once else the construct is useless. However, there are few chance they decide to use such structure to avoid some conflict with some other constructs:
  
[...] Some commands have non-typified arguments which are referred to as parameters.
+
{|width=100%
 +
!width=50%|Decompiled
 +
!colspan=2|G/L {{icon|vc}} {{icon|sa}} {{icon|lcs}}
 +
!width=1px|G/L {{icon|vcs}}
 +
!Compiled
 +
|-
 +
|
 +
REPEAT {times} {varname}
 +
    {consequence}
 +
ENDREPEAT
 +
|width=1px|
 +
{....4}
 +
  -----
 +
{.....}
 +
{....8}
 +
{...40}
 +
{...77}
 +
|width=1px|
 +
{....5}
 +
  -----
 +
{.....}
 +
{....9}
 +
{...41}
 +
{...77}
 +
|
 +
{....4}
 +
  -----
 +
{.....}
 +
{....7}
 +
{...21}
 +
{...34}
 +
|
 +
{varname} = {value0}
 +
LOOP:
 +
{consequence}
 +
++ {varname}
 +
    {varname} >= {valueN}
 +
GOTO_IF_FALSE LOOP
 +
|}
  
[*] No more than 8 conditions are allowed per check
+
===SWITCH===
[*] Checks are not short-circuited at runtime meaning all conditions are executed before branching
 
[*] NAND and NOR might have been planned considering ANDOR values (0, 1 to 7, 21 to 27). Hint: mention the compare flag.
 
[*] ANDOR is not compiled in Stories games for one condition checks
 
[*] IFNOT and WHILENOT are not supported in VC and SA because GOTO_IF_TRUE is not handled by game code there.
 
[*] REPEAT is supported since VC
 
[*] REPEAT cycles at least one-time
 
[*] REPEAT wrongly accepts a value lesser than 1 for the times argument
 
[*] SWITCH is supported only in SA
 
[*] SWITCH allows fall-through CASEs so BREAK is not mandatory
 
[*] SWITCH handles up to 75 CASEs chosen as a result of a binary search which requires CASEs to be sorted on compilation
 
[*] In contrast to scope-free subroutines which feature no argument...
 
[*] Boolean-valued gosub and function
 
[*] Recursion is allegedly not supported albeit gosubs and functions have 8 global levels of nesting in Trilogy chapters and 16 in Stories'.
 
[*] Decision-making statement (IF, IFNOT, SWITCH)
 
[*] Count-controlled loop (REPEAT)
 
[*] Condition-controlled loop (WHILE, WHILENOT)
 
[*] An unconditional branch, despite considered harmful in the programming literature, is the only way to go for breaking loops prematurely and enhance the simplistic code logic.
 
[*] Infinite loops are achieved by means of a backward GOTO
 
  
[...] Although it is able to infer nothing regarding the aim exclusive mission scripts were planned for which swings among testing, mission pack and multiplayer purposes, there are bunch of irrefutable evidences implementation-wise. The functionality is analoguous to usual mission scripts but, on the other hand, the opposing kind of them is totally superseded and completely overlooked during the compilation phase. Their coexistence is perfectly legal, though leftover launchers are bad style and dangerous in so far as noncompilable unless an exclusive variation is also provided. Additionally, they are a lot limited in quantity: the first Trilogy chapter expects in theory only an intro mission ('''INTRO''', shame not at runtime), the second chapter an auxiliary initialization mission ('''INITIAL'''), the third one an extra initialization mission ('''INITIL2''') and whereas Stories chapters have game provision for such feature along the lines of Vice City, their compilers have allegedly no support because of deprecation (the trigger command is still there, however the too many initialization missions seen in the script binary might speak from themselves). Hints: one's complement
+
In {{icon|sa}}, the [[#SWITCH|SWITCH]] control flow is more complex and efficient because the game uses internally a [[Wikipedia:Binary_search_algorithm|binary search algorithm]] to jump at the [[#Labels|label]] that matches with the value of a particular case. This method requires a known amount of cases which is up to 75. When a case is true, a ''consequence'' is executed and the code jumps to the end of the construct, otherwise the ''alternative'' may be performed. As the code is unoptimized, the [[#GOTO|GOTO]] of the last case is still compiled even though its label points right after the command mentioned earlier:
  
[...] Early in development, '''STREAM_SCRIPT''' was compiled to '''STREAM_SCRIPT_INTERNAL'''.
+
{|width=100%
 +
!width=20%|Decompiled
 +
!width=1px|{{icon|sa}}
 +
!Compiled
 +
|-
 +
|
 +
SWITCH {varname}
 +
    CASE {value0}
 +
        {consequence}
 +
        BREAK
 +
    [CASE {valueN}
 +
        {consequence}
 +
        BREAK]
 +
    [DEFAULT
 +
        {alternative}
 +
        BREAK]
 +
ENDSWITCH
 +
|
 +
{.2161}
 +
{.2162}
 +
  -----
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
{....2}
 +
  -----
 +
|
 +
SWITCH_START {varname} {numcases} {isdefault} DEFAULT {value0} CASE0 ...
 +
[SWITCH_CONTINUED ... {valueN} CASEN [-1 ENDSWITCH]]
 +
CASE0:
 +
    {consequence}
 +
    GOTO ENDSWITCH
 +
[CASEN:
 +
    {consequence}
 +
    GOTO ENDSWITCH]
 +
[DEFAULT:
 +
    {alternative}
 +
    GOTO ENDSWITCH]
 +
ENDSWITCH:
 +
|}
 +
 
 +
In {{icon|lcs}} and {{icon|vcs}}, such control flow is a set of nested [[#IF|IF]] constructs which causes a very slight loss of performance by considering that [[#ANDOR|ANDOR]] isn't compiled:
 +
 
 +
{|width=100%
 +
!width=50%|Decompiled
 +
!colspan=2|G/L {{icon|lcs}}
 +
!width=1px|G/L {{icon|vcs}}
 +
!Compiled
 +
|-
 +
|
 +
SWITCH {varname}
 +
    CASE {value0}
 +
        {consequence}
 +
        BREAK]
 +
    [CASE {valueN}
 +
        {consequence}
 +
        BREAK]
 +
    [DEFAULT
 +
        {alternative}
 +
        BREAK]
 +
ENDSWITCH
 +
|width=1px|
 +
  -----
 +
{...56}
 +
{...77}
 +
{.....}
 +
{....2}
 +
  -----
 +
{...56}
 +
{...77}
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
  -----
 +
  -----
 +
|width=1px|
 +
  -----
 +
{...57}
 +
{...77}
 +
{.....}
 +
{....2}
 +
  -----
 +
{...57}
 +
{...77}
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
  -----
 +
  -----
 +
|
 +
  -----
 +
{...27}
 +
{...34}
 +
{.....}
 +
{....2}
 +
  -----
 +
{...27}
 +
{...34}
 +
{.....}
 +
{....2}
 +
  -----
 +
{.....}
 +
  -----
 +
  -----
 +
|
 +
CASE0:
 +
    {varname} = {value0}
 +
GOTO_IF_FALSE CASEN
 +
    {consequence}
 +
    GOTO ENDSWITCH0
 +
CASEN:
 +
        [{varname} = {valueN}
 +
    GOTO_IF_FALSE DEFAULT
 +
        {consequence}
 +
        GOTO ENDSWITCHN
 +
    DEFAULT:
 +
        [{alternative}
 +
    ENDSWITCHN:]]
 +
ENDSWITCH0:
 +
|}
 +
 
 +
==Optimization==
 +
 
 +
In {{icon|lcs}} and {{icon|vcs}}, whenever a ''single condition'' is checked [[#ANDOR|ANDOR]] doesn't get compiled cause no [[#Logical|logical operator]] ('''AND''', '''OR''') is used and so they become really useless. Its lack increases the script efficiency a lot. However, the jump of the '''ELSE''' clause of an [[#IF|IF]] statement which points to the end of the construct is still compiled after a [[#GOTO|GOTO]]. Furthermore, ''Stories Games'' come with an improved data type managing which causes a considerable decrease of the compiled file size.
 +
 
 +
=Tools=
 +
 
 +
* [[SCRambl]] - an open-source tool provided by {{U|Deji}}
 +
* [[Mission Scripting Tools]]
  
Despite streamed scripts may receive an entity handle as input parameter, they are not necessarily callable and so an on-top, unreachable, explicit entity's creation is due:
+
=See also=
 +
* [[SCM language III/VC definitions]]
  
{
+
=External links=
    VAR_INT test_char sanity
+
 
+
*{{icon|2}} [http://gtamp.com/GTA2/gta2script.7z DMA's official GTA2script Compiler V9.6], [http://projectcerbera.com/gta/2/tutorials/scripting DMA's official GTA2script information] - found into the game copy
    sanity = 0
+
*{{icon|3}} [https://www.dropbox.com/s/bwxqe33c8ownfc8/gta3ta_source.rar GTA III 10th Anniversary source] - found into the ''iOS'' game copy
    IF sanity = -1
+
*{{icon|3}} [http://pastebin.com/Pfwscpeh GTA III unofficial main.sc] - Reconstruction of main.sc, missing from the iOS source code, by {{U|Link2012}}
        CREATE_CHAR PEDTYPE_CIVMALE male01 0.0 0.0 0.0 test_char
+
*{{icon|3}} {{icon|vc}} [http://pastebin.com/raw.php?i=T73rCdDd GTA III/VC unavailable script commands (possibly NOP'd)] - some sort of information by {{U|Wesser}} as a result of the reverse-engineering applied to the [http://www.rockstargames.com/ Rockstar Games]' official '''GTA3 Script Compiler V413'''
    ENDIF
+
*{{icon|3}} {{icon|vc}} [https://www.dropbox.com/s/7xgvqo8b9u1qw02/gta3sc_v413.rar Official GTA3 Script Compiler V413] - found into the ''GTA VC 10th Anniversary'' copy
}
+
*{{icon|3}} {{icon|vc}} [http://pastebin.com/raw.php?i=Pjb0Ezkx GTA3 Script Compiler V413 Compilation Strings] - a list by {{U|Wesser}} of all the error messages the compiler can throw and more
 +
*{{icon|sa}} [http://pastebin.com/raw.php?i=Ra9JLLeN GTA SA PC/PS2/XBOX script commands], [http://pastebin.com/raw.php?i=kCwS6rdG GTA SA Mobile script commands] - taken directly from the ''Android'' application and rearranged by {{U|Wesser}}
 +
*{{GTAF|441362|Reconstructing the III .sc language}} &ndash; a post by {{U|NTAuthority}}
  
This scenario also extends to any embedded script or script file
+
{{N|SA|VC|3}}
  
Originally, explicit entity creations are conventionally put on top of any sort of script by mean of unreachable code to confer specific entity types to declared variables for better error-checking:
+
[[Category:Mission Script]]

Revision as of 11:34, 3 October 2020

Announcement: This article is currently being reworked. Check out the progresses by visiting this link from time to time. Contact Wesser for any suggestion.
This section deals with the native SCM syntax of GTA 3 series, nothing other than III, VC, SA, LCS and VCS.
It may contain non-standard SCM definitions as R* hasn't published enough documentation about it yet.

On the occasion of the GTAIII's Tenth Anniversary, after a long period of darkness where we fell about the real SCM syntax, R* finally treated us by attaching part of its own original source code into the GTAIII Anniversary game, available for iOS and Android devices. As far back as 2001, a snip of some debugging scripts has been already provided with main.sc and debug.sc files. However, many secrets are unrevealed yet, thus some things cannot be documented fully and so they can be only guessed. The SCM format abbreviation is one of countless proofs of this inconvenience, which may stand for Script Multifile. Other doubts come with source files, whose SC extension appears to be very close to Mission SCript. Although we have enough information to suppose the currently unknown mysteries of the used language, we still have no safe clue about which was its original denomination. Furthermore, it is a matter of fact that R* developers have been left untouched the miss2 executable name of the GTA 3 series compiler since the chapter 2. In this connection, we could imagine the new language is a variant or an evolution of the GTA2script. The ancient documentation by DMA (at present Rockstar North), mentions GTA2script as a successor to GBHscript - a language used in GTA 1 (GBH was a planned name for GTA). Therefore, the language used in GTA 3 series should've been called GTA3script. It was influenced by both BASIC and C programming languages.


Preliminary remarks


This article makes use of formatted codes to improve the reading comprehension. Note that:

  • Square brackets mean everything inside may be omitted;
  • Curly brackets denote the presence of useful codes but not necessarily needed;
  • Vertical bars divide what can be chosen alternatively.

Fundamentals

Comments

Comments are notes left in the code to aid readability or to explain a part of code that may be confusing otherwise. Comments are ignored by the compiler. R*'s compiler supports C++ style comments – single-line comments and multiline comments.

A single line comment only affects a single line. They are prefixed with // (two slashes). Anything between these slashes and the end of the line is a comment. Single line comments may appear at the end of a line of code as well as on their own line.

[...] // This comment is at the end of a line.

// This comment is on its own line.

Multiline comments appear between /* and */. They do not actually have to span multiple lines, and anything outside of the opening and closing tokens is not ignored (i.e. these comments may appear with code on either side on the same line).

[...]
/*
  This comment spans
  multiple lines.
*/
[...]

[...] /* This comment is within a line */ [...] /* As is this one */ [...]

R*'s compiler allows multiline comments to be nested.

Highlighters

Highlighters behaviour sounds trivial, that's to say they simply highlight one or more arguments per command within round brackets, individually or together. In GTA III, they appear to be used only for SETUP_ZONE_PED_INFO (in a various order) and GXT keys:

SETUP_ZONE_PED_INFO FISHFAC DAY (0) 0 0 0 (0 0 0 0) 0
PRINT_BIG (T4X4_1) 5000 2
Limits
Opening and closing round brakets are treated as blank spaces;
An optional comma can be used as well to distinguish each argument, processed as a space.

Scopes

Scopes are delimited by curly brackets (or multiline brackets) which act like a local variable scope. Essentially, they enclose the code where local variables are used, including timers. They can be opened and closed many times in a script:

{
    [...]
}
Limits
Scopes cannot be nested;
Opening and closing curly brakets are real commands.

Labels

A label is a sequence of characters which identify the reference of a location of the source code useful for gotoes. It can be accessed by any part of the source code. To define a label just append : (colon) to its name:

[...]

{lblname}:
[...]

At the compiling time, they are automatically converted into an offset.

Variables

A variable is a memory address that is given a name. Variables are used to reference values that are stored in the game's memory and that can change (hence the name "variable"). Instructions may read the variable's memory or write to it. They act in the same way as pointers in other programming languages.

There are several words related to variables that are important to know:

  • The value of the variable is the data that lies at the variable's memory address.
  • The type is what kind of value the variable stores.
  • The scope is the region of code in which the variable may be used (and in which it is declared). There are two types:
    • The global scope is shared between all game scripts. Global variables have the same value everywhere. They are declared with the VAR prefix.
    • The local scope is a region of code within a script. Locals are only visible to other code inside the same pair of curly braces. They are declared with the LVAR prefix.
  • A timer is a unique local variable whose value rises automatically. They start counting when the script starts executing, and continue counting indefinitely. There are two such timers, TIMERA and TIMERB which are always defined, so do not need to be declared.

Data types


Among the available data types, some are equivalent to those of the most known programming languages. Their length is up to 4, 8 and 16 bytes. Each type is appended as a suffix in the variable declaration.

For an in-depth description of different data types, see the SCM instruction page.

LABEL

The LABEL type handles variable-length strings. It can refer to either a label name or a file name.

Notes
While inside a script file, R* compiler treats it unambiguously as a label;
R* compiler allocates 32 bytes per label.
Limit
LABEL variables aren't available.

INT

The INT type handles 32-bit signed integers. It is also used to store values with less bytes, such as a bool, a char and a short int.

FLOAT

The FLOAT type handles 32-bit floating-points. As it normally does, decimal precision of a float is usually stuck to 6-7 digits beyond which it may get lost.

Notes
R* compiler also accepts f and F suffixes for the immediate value.

TEXT_LABEL

The TEXT_LABEL type handles 8-byte strings. Generally, a string is an array of 1-byte characters. It requires 7 characters plus the null-terminator (a blank byte meaning the end of the string). It is used to hold GXT keys (those of town zones, interiors, help textes or dialogue subtitles) script names or any short string. Literal only TEXT_LABEL* strings are probably marked by single quotation marks to distinguish them from variable and constant identifiers:

PRINT_BIG 'GXT_KEY'
Limit
TEXT_LABEL variables are supported in San Andreas and Vice City Stories.

TEXT_LABEL16

The TEXT_LABEL16 type handles 16-byte strings. Like the previous, this type holds 15 characters plus the null-terminator. It is used to store model and texture names of player clothes, animation names or any long string.

Limit
TEXT_LABEL16 variables and values are supported only in San Andreas.

TEXT_LABEL32

The TEXT_LABEL32 type handles 32-byte strings or larger, depending on how many continuous parameters of the same type there are, each of which occupies 32 bytes. It can hold up to 127 characters plus the null-terminator, after which another TEXT_LABEL32 argument may begin. Strings of such type must be put within double quotation marks:

SAVE_STRING_TO_DEBUG_FILE "32B-128B TEXT"
Limits
TEXT_LABEL32 values are supported since Vice City;
TEXT_LABEL32 variables aren't available.

TEXT

The TEXT type handles N-byte strings. It holds N characters plus the null-terminator. Strings of this type mustn't exceed 255 characters (including the null-byte).

Limits
TEXT values are supported since San Andreas;
TEXT variables aren't available.

CONST (pseudo)

The CONST type handles 32-bit signed integers. It is used only to assign and compare constants to INT variables regarding model identifiers, task statuses, ped or audio events and such. It is a pseudo type of INT.

Limit
The assignment and comparison of CONST values are supported since Vice City.

MULTI (pseudo)

The MULTI type handles a group of few data types acceptable per argument. It is used only for commands featuring optional arguments, those whose type is unpredictable before the compilation. It can be a pseudo type of INT, FLOAT and TEXT_LABEL.

Notes
INT and FLOAT can be used interchangeably in GTA III, Vice City, San Andreas, Liberty City Stories and Vice City Stories;
Vice City Stories also admits TEXT_LABEL arguments.

Declaration


Defining a variable means assigning a token string to a memory cell at the compiling time. Variables must be declared in the following manner:

VAR_* {varname0}[,] [... {varnameN}]
LVAR_* {varname0}[,] [... {varnameN}]

As mentioned in the sections above, local variables have to be put within curly brackets:

{
    VAR_* {varname0}[,] [... {varnameN}]
    LVAR_* {varname0}[,] [... {varnameN}]

    [...]
}

Inline variable declaration is allowed, you just have to separate them by spaces or tabulations. Adding a preceding comma before these characters is optional.

Limits
Whereas the variable buffer is limited, you can declare a certain amount of globals and locals. INT and FLOAT types take 1 variable, while TEXT_LABEL and TEXT_LABEL16 types occupy respectively 2 and 4 variables to store their data (have a look here for further details);
Vice City Stories isn't affected by what said above;
Global and local variable names must not collide.

Arrays

A array is a collection of variables having the same type which can be accessed by an index, an INT lesser than or equal to the size specified, enclosed by square brackets:

{
    VAR_* {varname0}{[arrsize0]}[,] [... {varnameN}{[arrsizeN]}]
    LVAR_* {varname0}{[arrsize0]}[,] [... {varnameN}{[arrsizeN]}]

    [...]
}
Limits
The usage of arrays is allowed since Vice City;
Variable indices are quite buggy in Vice City and therefore unrecommended, but they are fully supported since San Andreas;
The aforesaid indices are one-based, possibly zero-based since San Andreas;
Multidimensional arrays are not supported.

Handles

A handle is an univocal identifier assigned to a game entity. It is given by the following statement:

short nHandle = (iEntityIndexInPool << 8) | ucEntityFlag;
Note
R* compiler won't let you assign different entity types to the same variable or using a variable which hasn't been passed to any command designated to the creation of an entity.

Operators

In general, an operator is a token string that represents a math calculation or an operation of any other kind, in order to make the code understanding clearer at a glance.

Arithmetic

Arithmetic operators compute some of the most common algebric calculations between either a variable and a value or two variables. As well as in some programming language happens, CONST, TEXT_LABEL and TEXT_LABEL16 types are free from these operators, except for the basic assignment (see also Operators composition):

Operator Name Syntax Description
= Assignment expr0 = expr1 Store expr1 to expr0
+ Addition expr0 + expr1 Add expr1 to expr0
- Subtraction expr0 - expr1 Subtract expr1 from expr0
* Multiplication expr0 * expr1 Multiply expr0 by expr1
/ Division expr0 / expr1 Divide expr0 by expr1
+@ Timed addition expr0 +@ expr1 Multiply expr2 by delta time and add the result to expr1
-@ Timed subtraction expr0 -@ expr1 Multiply expr2 by delta time and subtract the result from expr1
++ Increment Pre[*] ++ expr0 Increment expr0 by 1 and store the result to expr0
Post expr0 ++
-- Decrement Pre[*] -- expr0 Decrement expr0 by 1 and store the result to expr0
Post expr0 --
Note
^ Pre and post increments have no difference unlike what you would expect.

Yet, you can put the assignment and algebric operators together inline as follows:

Operators Name Syntax Description
= + Addition and assignment expr0 = expr1[*] + expr2 Add expr2 to expr1 and store the result to expr0
= - Subtraction and assignment expr0 = expr1[*] - expr2 Subtract expr2 from expr1 and store the result to expr0
= * Multiplication and assignment expr0 = expr1[*] * expr2 Multiply expr1 by expr2 and store the result to expr0
= / Division and assignment expr0 = expr1[*] / expr2 Divide expr1 by expr2 and store the result to expr0
= +@ Timed addition and assignment expr0 = expr1[*] +@ expr2 Multiply expr2 by delta time, add the result to expr1 and store everything to expr0
= -@ Timed subtraction and assignment expr0 = expr1[*] -@ expr2 Multiply expr2 by delta time, subtract the result from expr1 and store everything to expr0
Note
^ expr1 can represent expr0 too.
Limit
Multiple algebric operators per line are not allowed.

Compound assignment

Compound assignment operators store values or variable content to other variables having a particular type afterwards the computation of an arithmetic operation, to squeeze the code and clear it up from granted repetitions:

Operator Name Syntax Description
+= Addition assignment expr0 += expr1 Add expr1 to expr0 and store the result to expr0
-= Subtraction assignment expr0 -= expr1 Subtract expr1 from expr0 and store the result to expr0
*= Multiplication assignment expr0 *= expr1 Multiply expr0 by expr1 and store the result to expr0
/= Division assignment expr0 /= expr1 Divide expr0 by expr1 and store the result to expr0
+=@ Timed addition assignment expr0 +=@ expr1 Multiply expr1 by delta time, add the result to expr0 and store everything to expr0
-=@ Timed subtraction assignment expr0 -=@ expr1 Multiply expr1 by delta time, subtract the result from expr0 and store everything to expr0

Uncompounded assignment

Uncompounded assignment operators are those on their own, or rather they are neither derivable nor decomposable similarly as those compounds:

Operator Name Syntax Description
=# Cast assignment expr0 =# expr1 Cast expr1 to any other type and store the result to expr0
Limit
Supported conversions are FLOAT to INT and INT to FLOAT.

Logical

Logical operators influence the way conditions are evalueted and enable to test more of them at a time. More than anything, they are built-in statements:

Operator Name Syntax Description
NOT Logical negation IF NOT condition0 Test if condition0 is false
AND Logical conjunction IF condition0
AND condition8
Test if both condition0 and conditionN are true
OR Logical disjunction IF condition0
OR condition8
Test if either condition0 or conditionN is true

Comparison

Comparison operators test the truth or falsity of the relation between either a variable and a value, a value and a variable or two variables:

Operator Name Syntax Description
= Equal to IF expr0 = expr1 Test if expr0 and expr1 are equal
> Greater than IF expr0 > expr1 Test if expr0 is greater than expr1
<[*] Lesser than IF expr0 < expr1 Test if expr0 is lesser than expr1
>= Greater than or equal to IF expr0 >= expr1 Test if expr0 is greater than or equal to expr1
<=[*] Lesser than or equal to IF expr0 <= expr1 Test if expr0 is lesser than or equal to expr1
Note
^ As a result of a critical bug, R* compiler mistakenly applies the operator inversion.

Commands

A command is a symbolic name associated to an identifier which executes a portion of code that specifies the operation to be performed by passing zero or more arguments. An argument is in turn some data given as input to a command. Normally, commands have a defined amount of arguments and those not, such as START_NEW_SCRIPT, can pass as many arguments as the available local variables are, except timers. Being a procedure, a command does not return values that can be assigned to a variable, even though the boolean flag is kept whenever it is used as a condition. It follows the common programming syntax adopted for function calls:

{commandname} [{anyvalue0|varname0} ... {anyvalueN|varnameN}]

Alternators

An alternator is an abstract operation that is implemented with a set of commands, each of which takes differently typed arguments.

Alternators are used because there are often multiple different combinations of argument types that one might wish to use for an operation. While 1 + 2 and 1 + 2.0 are equivalent to a human, they are not to a computer, so they must be implemented differently.

Each command has the same arity as the other commands implementing the same operation. They differ only the in combination and order of their parameters' types.

Common alternators

  • GTA III Vice City San Andreas Liberty City Stories Vice City Stories
    • SET (=)
    • CSET (=#)
    • ADD_THING_TO_THING (+=)
    • SUB_THING_FROM_THING (-=)
    • MULT_THING_BY_THING (*=)
    • DIV_THING_BY_THING (/=)
    • IS_THING_EQUAL_TO_THING (=)
    • IS_THING_NOT_EQUAL_TO_THING (NOT =)
    • IS_THING_GREATER_THAN_THING (>, <=)
    • IS_THING_GREATER_OR_EQUAL_TO_THING (>=, <)
    • ADD_THING_TO_THING_TIMED (+=@)
    • SUB_THING_FROM_THING_TIMED (-=@)
    • ABS
  • San Andreas
    • IS_EMPTY
    • IS_BIT_SET
    • SET_BIT
    • CLEAR_BIT
    • STRING_CAT

This section is incomplete. You can help by fixing and expanding it.

Hardcoded

Hardcoded commands are those which have unique characteristics and are handled internally:

List of hardcoded commands

  • GTA III Vice City San Andreas Liberty City Stories Vice City Stories:
    • GOTO
    • GOTO_IF_FALSE
    • TERMINATE_THIS_SCRIPT
    • START_NEW_SCRIPT
    • VAR_INT
    • VAR_FLOAT
    • LVAR_INT
    • LVAR_FLOAT
    • {
    • }
    • REPEAT
    • ENDREPEAT
    • IF
    • IFNOT
    • ELSE
    • ENDIF
    • WHILE
    • WHILENOT
    • ENDWHILE
    • ANDOR
    • LAUNCH_MISSION
    • SAVE_VAR_INT
    • SAVE_VAR_FLOAT
    • START_CUTSCENE[*]
    • PLAYER_MADE_PROGRESS
    • SET_PROGRESS_TOTAL[*]
    • REGISTER_MISSION_GIVEN[*]
    • REGISTER_MISSION_PASSED
    • SCRIPT_NAME
    • LOAD_AND_LAUNCH_MISSION
    • LOAD_AND_LAUNCH_MISSION_INTERNAL
    • SET_TOTAL_NUMBER_OF_MISSIONS[*]
    • VAR_TEXT_LABEL
    • LVAR_TEXT_LABEL
  • Vice City San Andreas Liberty City Stories Vice City Stories:
    • REGISTER_ODDJOB_MISSION_PASSED
  • GTA III Liberty City Stories Vice City Stories:
    • GOTO_IF_TRUE
    • GOSUB_FILE
  • GTA III Vice City:
    • CREATE_COLLECTABLE1
    • SET_COLLECTABLE1_TOTAL[*]
  • Vice City San Andreas:
    • LOAD_AND_LAUNCH_MISSION_EXCLUSIVE
  • Liberty City Stories Vice City Stories:
    • CALL
    • CALLNOT
  • San Andreas:
    • VAR_TEXT_LABEL16
    • LVAR_TEXT_LABEL16
    • SWITCH
    • ENDSWITCH
    • CASE
    • DEFAULT
    • BREAK
    • SWITCH_START
    • SWITCH_CONTINUED
  • Vice City Stories:
    • SAVE_VAR_TEXT_LABEL[*]
    • SET_COLLECTABLE2_TOTAL
Notes
^ The argument of these commands must be set respectively according to:
  • The sum of PLAYER_MADE_PROGRESS values;
  • The amount of REGISTER_MISSION_PASSED (those that don't have an immediate value are excluded) and REGISTER_ODDJOB_MISSION_PASSED;
  • The amount of CREATE_COLLECTABLE1.
If the argument of the listed commands differs from what expected, a 0-value must be passed;
^ This command was intended to be counted originally but its counter got deprecated.

This section is incomplete. You can help by fixing and expanding it.

WAIT

WAIT stops the execution of a script according to some milliseconds after which it will resume again. Indeed, it is absolutely necessary into infinite loops or those that may or may not break after more than one frame, such as the WHILE control flow. In this case, a INT equal to 0 is passed.

GOTO

GOTO jumps to the label of any location of the source code but conceptually it should never point off the current context. It is also used internally to build the control flows offered by the scripting language:

// File: any.sc

goto_ref0:
GOTO goto_refN
// File: any.sc

goto_refN:
GOTO goto_ref0

ANDOR

ANDOR sets out the way the comparison among more conditions have to occur (see also Compare flag).

GOTO_IF_TRUE

GOTO_IF_TRUE operates in conjunction with ANDOR and jumps to a label if the returned boolean flag is true.

GOTO_IF_FALSE

Unlike GOTO_IF_TRUE, GOTO_IF_FALSE jumps to the desired label only if the comparison returns false.

SCRIPT_NAME

SCRIPT_NAME simply associates an unique name to the current working script.

Note
R* compiler doesn't enable you to associate a name previously used for another script.

SAVE_STRING_TO_DEBUG_FILE

SAVE_STRING_TO_DEBUG_FILE accepts an argument which can admit up to 127 characters plus the null-terminator. In the compiling process, the argument is skipped but its string is copied to a predefined 128-bytes buffer, compiled afterwards. Since Vice City, these are the seemingly predetermined bytes of a random empty string block which are actually the result of uninitialized data:

00 00 41 00 09 2E 00 00 00 00 00 00 00 00 00 00 
09 2E 00 00 00 00 00 00 1C FB 12 00 D8 A8 41 00
00 00 41 00 09 2E 00 00 00 00 00 00 01 00 00 00 
09 2E 00 00 00 00 00 00 1C FB 12 00 D8 A8 41 00
00 00 41 00 09 2E 00 00 00 00 00 00 02 00 00 00 
09 2E 00 00 00 00 00 00 1C FB 12 00 D8 A8 41 00
00 00 41 00 09 2E 00 00 00 00 00 00 03 00 00 00 
09 2E 00 00 00 00 00 00 1C FB 12 00 D8 A8 41 00

The split of such bytes into 4 blocks of 32-bytes each is quite noticeable.

Constants

A constant is a symbolic name associated to a specific value. When compiling, their caption is converted to the assigned value. Since Vice City, names and identifiers of objects within OBJS and TOBJ blocks are loaded from every IDE file defined into gta_vc.dat, then those of vehicles and pedestrians within PEDS and CARS blocks are retrieved from default.ide. In San Andreas, they are listed into TXT files, whose name follows the Pascal Case (eg. AudioEvents.txt). These files respect the syntax below:

{constname0} {constvalue0}

{constnameN} {constvalueN}

Constant names and values are divided by as many spaces or tabulations as you want. Constant lines are distinguished by two \n (new line) characters. The model names which aren't assigned to a constant are still valid (see also Identifiers). Keep in mind arguments of some commands having the CONST type accept only constant values of a single namespace.

Notes
Constants don't collide even though they belong to different namespaces;
In GTA III and Vice City, they are hardcoded as everything inside R* compiler;
In San Andreas, the subdivision of constant namespaces in files might be just a listing of hardcoded constants useful for developers. The same would apply to Liberty City Stories and Vice City Stories.

Formatting

Everything is case-insensitive, that means the uppercase and lowercase letters have no dissimilarities when taken. Usually, the source code is conform to the same formatting according to:

Compiling

Structure

The source code is split up into several SC files which comprehend main file, foreign gosubs, subscripts, mission scripts, and streamed scripts. These files can be included more times because they are actually processed once.

Main file


The main file is the most significant part of the whole source. It can include many script files and/or embedded gosubs, scripts or functions. Originally, it is characterized by the absence of the local scope. It must be put outside the directory, having the same name as the main script file, where all other foreign scripts must be:

<directory>
| main
|  | gosub
|  |  |- gosub1.sc
|  |  \- gosubN.sc
|  | subscript
|  |  |- subscript1.sc
|  |  \- subscriptN.sc
|  | mission_guy
|  |  |- mission_guy1.sc
|  |  \- mission_guyN.sc
|  |- gosub.sc
|  |- subscript.sc
|  \- mission.sc
\- main.sc
Note
R* compiler will scan subfolders too.

Foreign gosubs


Foreign gosubs (also called subroutines) are main extension files. They are called using the GOSUB_FILE command which jumps to a specific label and executes some code that returns back to the place where it has been called with RETURN. You are able to specify the gosub label to start jumping at as well:

// File: main.sc

GOSUB_FILE gosub_ref foreign_gosub.sc
// File: foreign_gosub.sc

gosub_ref:
{
    [...]
}
RETURN
Limit
Foreign gosubs were introduced since GTA III. They were unused in Vice City and got removed in San Andreas, but then they were reimplemented in Liberty City Stories and Vice City Stories.

Gosubs

As mentioned, gosubs are also embedded in any script file. They follow almost the same rules, except they are called by GOSUB and can actually inehrit the local scope of the parent script:

// File: any.sc

GOSUB gosub_ref
// File: any.sc

gosub_ref:
{
    [...]
}
RETURN
Note
R* compiler doesn't take care if the code within a scope jumps to a gosub inside which another scope is declared. It is strongly recommended to pay attention at this issue or you will fall down into an irreparable local variable mismatch.

Subscripts


Subscripts are code blocks which take part of a queue of other scripts and are allocated over the memory by LAUNCH_MISSION. They are denoted by the presence of MISSION_START at the very top of the mission file. As long as they aren't ended with MISSION_END, their execution never expires till the end of the game process. Each one works independently, even though they are able to share global variables:

// File: main.sc

LAUNCH_MISSION subscript.sc
// File: subscript.sc

MISSION_START

[VAR_* {varname0}[,] [... {varnameN}]]

SCRIPT_NAME main

subscript_loop:
{
    [LVAR_* {varname0}[,] [... {varnameN}]]

    [...]
}
//GOTO subscript_loop
MISSION_END
Notes
MISSION_START is a special and fake directive that isn't assigned to any command. R* compiler will notify an error if it isn't placed at the first line of a subscript or a mission script;
MISSION_END is an alias of TERMINATE_THIS_SCRIPT.

Scripts

As for gosubs, scripts can be embedded everywhere in a script file. They are started by START_NEW_SCRIPT which has an undefined amount of arguments, whose type must match with those of each local variable of the starting script in order to be passed, else the compilation will interrupt. Unlike subscripts, they get terminated by TERMINATE_THIS_SCRIPT or TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME (elsewhere in another script):

// File: any.sc

START_NEW_SCRIPT script [{anyvalue0|varname0} ... {anyvalueN|varnameN}]
// File: any.sc

script:
{
    SCRIPT_NAME script

script_loop:

    [LVAR_* {varname0}[,] [... {varnameN}]]

    [...]

    //GOTO script_loop
    TERMINATE_THIS_SCRIPT
}
Notes
Scripts must have a local scope;
Script commands must be inserted within or after the local scope;
Since Vice City, the opening curly bracket must be put before the script label when more arguments are passed.

Functions

This section is incomplete. You can help by fixing and expanding it.

Mission scripts


Mission scripts are those subscripts which are responsible for the presence of a storyline in the game. When they are launched with LOAD_AND_LAUNCH_MISSION, the mission is loaded in the mission block, allocated over the memory and the script pointer is moved to the corresponding mission offset. Do not forget to begin a mission script with MISSION_START and end it with MISSION_END:

// File: main.sc

LOAD_AND_LAUNCH_MISSION mission.sc
// File: mission.sc

MISSION_START

GOSUB mission_start

IF HAS_DEATHARREST_BEEN_EXECUTED
    GOSUB mission_failed
ENDIF

GOSUB mission_cleanup

MISSION_END

[VAR_* {varname0}[,] [... {varnameN}]]

mission_start:

REGISTER_MISSION_GIVEN
SCRIPT_NAME mission

// Variables initialization

{
    [LVAR_* {varname0}[,] [... {varnameN}]]

    [...]
}
GOTO mission_passed

mission_failed:
[...]
RETURN

mission_passed:
REGISTER_MISSION_PASSED mission
//PLAYER_MADE_PROGRESS 1
[...]
RETURN

// Mark everything as no longer needed

mission_cleanup:
//MISSION_HAS_FINISHED
[...]
RETURN

Some missions doesn't need to be executed multiple times because they may just initialize some global variables defined in the main script or launch the intro mission. For this matter, here comes the usage of LOAD_AND_LAUNCH_MISSION_EXCLUSIVE:

// File: main.sc

LOAD_AND_LAUNCH_MISSION_EXCLUSIVE initial.sc
LOAD_AND_LAUNCH_MISSION_EXCLUSIVE intro.sc
Note
Exclusive missions are never launched in the source code. It's likely, it was an idea not came to the end successfully or rather they were useful for debugging purposes.
Limits
LOAD_AND_LAUNCH_MISSION_EXCLUSIVE is available only in Vice City and San Andreas;
Only 2 exclusive missions in Vice City and 3 in San Andreas are handled, plus they must be launched before any of the counterpart.

Streamed scripts


This section is incomplete. You can help by fixing and expanding it.

Control flow

As usual, the evolution of something implies its development over the years. Alongside, the control flows implementation has been distributed equally into every chapter. Their definitions are similar to those used in pseudocodes resulting in a raw source code. However, you are still able to build your own control flows:

ANDOR {value}
    [NOT] {condition0}
    [[NOT] {condition8}]
GOTO_IF_FALSE ELSE
    {consequence}
    [GOTO ENDIF]
ELSE:
    [{alternative}
ENDIF:]
Note
It's likely, user-made control flows weren't intended to be usable because R* compiler cannot recognize an equal to rather than an assignment operator.

If

IF is the most common conditional statement. It executes one block of code if a boolean condition is true, and (optionally) another if the condition is false. The condition may be made of multiple conditions combined using the logical operators AND or OR, or it may just be a single condition. AND makes the final condition true only if all of the input conditions are true, whereas OR only requires one input condition to be true. The condition may be inverted with NOT, another logical operator. Syntax:

IF [NOT] {condition0}
[AND|OR [NOT] {condition8}]
    {consequence}
[ELSE
    {alternative}]
ENDIF
Limitations
  • There is a maximum of 8 conditions.

If-not

IFNOT works in the same way as IF except that the condition is always inverted.

IFNOT [NOT] {condition0}
[AND|OR [NOT] {condition8}]
    {consequence}
[ELSE
    {alternative}]
ENDIF
Limitations
  • IFNOT is only supported in games that have GOTO_IF_TRUE: GTA III, Liberty City Stories and Vice City Stories.

While

WHILE is similar to IF, but it continues executing the body until the condition is false.

WHILE [NOT] {condition0}
[AND|OR [NOT] {condition8}]
    {consequence}
ENDWHILE

While-not

WHILENOT is to WHILE as IFNOT is to IF: it loops until the condition is true.

WHILENOT [NOT] {condition0}
[AND|OR [NOT] {condition8}]
    {consequence}
ENDWHILE
Limitations
  • Like IFNOT, WHILENOT is only supported in games that have GOTO_IF_TRUE: GTA III, Liberty City Stories and Vice City Stories.

Repeat

REPEAT acts as a range-based loop (generally a for-loop in modern programming languages). It executes the body and increments a certain variable until it reaches a target value, at which point the loop stops.

REPEAT {target} {varname}
    {consequence}
ENDREPEAT
Limitations
  • REPEAT is supported in games from Vice City;
  • The target value must be positive;
  • The body will be read at least once in any case.

Switch

A SWITCH statement is functionally equivalent to multiple nested IF...ELSE statements. It takes a single value and executes a block of code that is specific to that value (a CASE) until it finds a BREAK, which moves execution to the end of the construct. If no matching case is found, the DEFAULT clause is executed.

SWITCH {varname}
    CASE {value0}
        {consequence}
        BREAK
    [CASE {valueN}
        {consequence}
        BREAK]
    [DEFAULT
        {alternative}
        BREAK]
ENDSWITCH
Limitations
  • It is supported from San Andreas;
  • CASE allows the use of INT and CONST values only;
  • In San Andreas, the CASE values should be sorted (R*'s compiler should do it implicitly);
  • Every CASE, including DEFAULT, must end with a BREAK.

Decompiling

Structure

For further information about the SCM file format, read this article. Take into account the compiling order of each SC file is main file » foreign gosubs » subscripts » mission scripts apart from the reading order of the commands used to include them. Streamed scripts are compiled individually into the script.img file. On the other hand, functions are compiled like gosubs.

Identifiers

Undefined constants of model identifiers, whose name refers to a DFF which is presumably archived into any of the IMGs, loaded by the game, are overwritten by a decrementing value in the order they get compiled. These model names are then put into the second segment of the SCM header. Those of mission scripts and streamed scripts respect the same rule except the fact they are turned into a zero-based growing identifier, while exclusive mission scripts are launched by a negative identifier resulting from the bits inversion (bitwise complement).

Offsets

An offset is a 32-bit signed integer which points to a location of the script file. Those within the main file, foreign gosubs and subscripts are absolute offsets that start from the beginning of the main script, while the ones inside mission scripts and streamed scripts are relative and negative offsets starting from their beginning. The offset is related to global variables as well, whose interval goes from 8 and ends to 65532 (0xFFFC), each one is aligned to the nearest 4 bytes.

Variables range

The following table shows the variables range of the local scope for each game version:

Context GTA III Vice City San Andreas Liberty City Stories Vice City Stories
Foreign gosub/Gosub 0-15 0-15 n/a 0-95 0-95
Subscript/Script 0-15 0-15 0-31 0-95 0-95
Mission script 0-15 0-15 0-1023 0-95 0-95
Streamed script n/a n/a 0-31 n/a n/a
Function n/a n/a n/a 0-95 0-95
Timer 16-17 16-17 32-33 t0-t1 t0-t1

Compiled operators

As in most compiled programming languages, SCM's operators are always compiled with two operands, regardless of how they appear within the source code.

This means that operators that seem to have only one operand will have two, and operators that seem to have more than two are actually compiled as multiple instructions.

Operator Name Written Compiled
++ Increment Pre ++a a += 1
Post a++
-- Decrement Pre --a a -= 1
Post a--
+= Addition and assignment a = b + c a = b
a += c
-= Subtraction and assignment a = b - c a = b
a -= c
*= Multiplication and assignment a = b * c a = b
a *= c
/= Division and assignment a = b / c a = b
a /= c
+=@ Timed addition and assignment a = b +@ c a = b
a +=@ c
-=@ Timed subtraction and assignment a = b -@ c a = b
a -=@ c

Opcode

A command's opcode is a 16-bit signed integer identifier which the game uses to find the implementation for the command. The maximum number of opcodes possible is 32,767 (0x7FFF), because the most significant bit (0x8000) is the sign bit, which is only set when the associated command's return value is inverted (e.g. not x()).

There are no commands with negative opcodes; the game takes the absolute value (|opcode|) before finding the implementation, after noting whether it is inverted.

Command arguments

The limitation of the amount of arguments a variadic command can pass is game specific:

  • 16 for GTA III and Vice City;
  • 32 for San Andreas;
  • 96 for Liberty City Stories and Vice City Stories.

Managed commands

Here is the list of all managed commands and their relative specifications:

Legend:

  • Suffix:
    • O, OPTIONAL.

List:

Be aware, the argument data types of the commands below are just informative:

Command ID Arguments
# 1 2 3 4 ... 18 ... n+l
n+i+o
GTA III Vice City San Andreas Liberty City Stories Vice City Stories
MISSION_START[*] 0
GOTO[*] 2 1 R
GTA III Vice City San Andreas Liberty City Stories
=
SET
SET_VAR_INT 4 2 VI I
SET_VAR_FLOAT 5 VF F
SET_LVAR_INT 6 LI I
SET_LVAR_FLOAT 7 LF F
SET_VAR_INT_TO_VAR_INT 132 VI VI
SET_LVAR_INT_TO_LVAR_INT 133 LI LI
SET_VAR_FLOAT_TO_VAR_FLOAT 134 VF VF
SET_LVAR_FLOAT_TO_LVAR_FLOAT 135 LF LF
SET_VAR_FLOAT_TO_LVAR_FLOAT 136 VF LF
SET_LVAR_FLOAT_TO_VAR_FLOAT 137 LF VF
SET_VAR_INT_TO_LVAR_INT 138 VI LI
SET_LVAR_INT_TO_VAR_INT 139 LI VI
+=
+
ADD_THING_TO_THING
ADD_VAL_TO_INT_VAR 8 2 VI I
ADD_VAL_TO_FLOAT_VAR 9 VF F
ADD_VAL_TO_INT_LVAR 10 LI I
ADD_VAL_TO_FLOAT_LVAR 11 LF F
ADD_INT_VAR_TO_INT_VAR 88 VI VI
ADD_FLOAT_VAR_TO_FLOAT_VAR 89 VF VF
ADD_INT_LVAR_TO_INT_LVAR 90 LI LI
ADD_FLOAT_LVAR_TO_FLOAT_LVAR 91 LF LF
ADD_INT_VAR_TO_INT_LVAR 92 LI VI
ADD_FLOAT_VAR_TO_FLOAT_LVAR 93 LF VF
ADD_INT_LVAR_TO_INT_VAR 94 VI LI
ADD_FLOAT_LVAR_TO_FLOAT_VAR 95 VF LF
-=
-
SUB_THING_FROM_THING
SUB_VAL_FROM_INT_VAR 12 2 VI I
SUB_VAL_FROM_FLOAT_VAR 13 VF F
SUB_VAL_FROM_INT_LVAR 14 LI I
SUB_VAL_FROM_FLOAT_LVAR 15 LF F
SUB_INT_VAR_FROM_INT_VAR 96 VI VI
SUB_FLOAT_VAR_FROM_FLOAT_VAR 97 VF VF
SUB_INT_LVAR_FROM_INT_LVAR 98 LI LI
SUB_FLOAT_LVAR_FROM_FLOAT_LVAR 99 LF LF
SUB_INT_VAR_FROM_INT_LVAR 100 LI VI
SUB_FLOAT_VAR_FROM_FLOAT_LVAR 101 LF VF
SUB_INT_LVAR_FROM_INT_VAR 102 VI LI
SUB_FLOAT_LVAR_FROM_FLOAT_VAR 103 VF LF
*=
*
MULT_THING_BY_THING
MULT_INT_VAR_BY_VAL 16 2 VI I
MULT_FLOAT_VAR_BY_VAL 17 VF F
MULT_INT_LVAR_BY_VAL 18 LI I
MULT_FLOAT_LVAR_BY_VAL 19 LF F
MULT_INT_VAR_BY_INT_VAR 104 VI VI
MULT_FLOAT_VAR_BY_FLOAT_VAR 105 VF VF
MULT_INT_LVAR_BY_INT_LVAR 106 LI LI
MULT_FLOAT_LVAR_BY_FLOAT_LVAR 107 LF LF
MULT_INT_VAR_BY_INT_LVAR 108 VI LI
MULT_FLOAT_VAR_BY_FLOAT_LVAR 109 VF LF
MULT_INT_LVAR_BY_INT_VAR 110 LI VI
MULT_FLOAT_LVAR_BY_FLOAT_VAR 111 LF VF
/=
/
DIV_THING_BY_THING
DIV_INT_BY_VAL 20 2 VI I
DIV_FLOAT_VAR_BY_VAL 21 VF F
DIV_INT_LVAR_BY_VAL 22 LI I
DIV_FLOAT_LVAR_BY_VAL 23 LF F
DIV_INT_VAR_BY_INT_VAR 112 VI VI
DIV_FLOAT_VAR_BY_FLOAT_VAR 113 VF VF
DIV_INT_LVAR_BY_INT_LVAR 114 LI LI
DIV_FLOAT_LVAR_BY_FLOAT_LVAR 115 LF LF
DIV_INT_VAR_BY_INT_LVAR 116 VI LI
DIV_FLOAT_VAR_BY_FLOAT_LVAR 117 VF LF
DIV_INT_LVAR_BY_INT_VAR 118 LI VI
DIV_FLOAT_LVAR_BY_FLOAT_VAR 119 LF VF
>
<=
IS_THING_GREATER_THAN_THING
IS_INT_VAR_GREATER_THAN_NUMBER 24 2 VI I
IS_INT_LVAR_GREATER_THAN_NUMBER 25 LI I
IS_NUMBER_GREATER_THAN_INT_VAR 26 I VI
IS_NUMBER_GREATER_THAN_INT_LVAR 27 I LI
IS_INT_VAR_GREATER_THAN_INT_VAR 28 VI VI
IS_INT_LVAR_GREATER_THAN_INT_LVAR 29 LI LI
IS_INT_VAR_GREATER_THAN_INT_LVAR 30 VI LI
IS_INT_LVAR_GREATER_THAN_INT_VAR 31 LI VI
IS_FLOAT_VAR_GREATER_THAN_NUMBER 32 VF F
IS_FLOAT_LVAR_GREATER_THAN_NUMBER 33 LF F
IS_NUMBER_GREATER_THAN_FLOAT_VAR 34 F VF
IS_NUMBER_GREATER_THAN_FLOAT_LVAR 35 F LF
IS_FLOAT_VAR_GREATER_THAN_FLOAT_VAR 36 VF VF
IS_FLOAT_LVAR_GREATER_THAN_FLOAT_LVAR 37 LF LF
IS_FLOAT_VAR_GREATER_THAN_FLOAT_LVAR 38 VF LF
IS_FLOAT_LVAR_GREATER_THAN_FLOAT_VAR 39 LF VF
>=
<
IS_THING_GREATER_OR_EQUAL_TO_THING
IS_INT_VAR_GREATER_OR_EQUAL_TO_NUMBER 40 2 VI I
IS_INT_LVAR_GREATER_OR_EQUAL_TO_NUMBER 41 LI I
IS_NUMBER_GREATER_OR_EQUAL_TO_INT_VAR 42 I VI
IS_NUMBER_GREATER_OR_EQUAL_TO_INT_LVAR 43 I LI
IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_VAR 44 VI VI
IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_LVAR 45 LI LI
IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_LVAR 46 VI LI
IS_INT_LVAR_GREATER_OR_EQUAL_TO_INT_VAR 47 LI VI
IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_NUMBER 48 VF F
IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_NUMBER 49 LF F
IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_VAR 50 F VF
IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_LVAR 51 F LF
IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_VAR 52 VF VF
IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR 53 LF LF
IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_LVAR 54 VF LF
IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_FLOAT_VAR 55 LF VF
=
IS_THING_EQUAL_TO_THING
IS_INT_VAR_EQUAL_TO_NUMBER 56 2 VI I
IS_INT_LVAR_EQUAL_TO_NUMBER 57 LI I
IS_INT_VAR_EQUAL_TO_INT_VAR 58 VI VI
IS_INT_LVAR_EQUAL_TO_INT_LVAR 59 LI LI
IS_INT_VAR_EQUAL_TO_INT_LVAR 60 VI LI
IS_FLOAT_VAR_EQUAL_TO_NUMBER 66 VF F
IS_FLOAT_LVAR_EQUAL_TO_NUMBER 67 LF F
IS_FLOAT_VAR_EQUAL_TO_FLOAT_VAR 68 VF VF
IS_FLOAT_LVAR_EQUAL_TO_FLOAT_LVAR 69 LF LF
IS_FLOAT_VAR_EQUAL_TO_FLOAT_LVAR 70 VF LF
NOT =
IS_THING_NOT_EQUAL_TO_THING
IS_INT_VAR_NOT_EQUAL_TO_NUMBER 61 2 VI I
IS_INT_LVAR_NOT_EQUAL_TO_NUMBER 62 LI I
IS_INT_VAR_NOT_EQUAL_TO_INT_VAR 63 VI VI
IS_INT_LVAR_NOT_EQUAL_TO_INT_LVAR 64 LI LI
IS_INT_VAR_NOT_EQUAL_TO_INT_LVAR 65 VI LI
IS_FLOAT_VAR_NOT_EQUAL_TO_NUMBER 71 VF F
IS_FLOAT_LVAR_NOT_EQUAL_TO_NUMBER 72 LF F
IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_VAR 73 VF VF
IS_FLOAT_LVAR_NOT_EQUAL_TO_FLOAT_LVAR 74 LF LF
IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_LVAR 75 VF LF
GOTO_IF_FALSE[*] 77 1 R
TERMINATE_THIS_SCRIPT 78 0
MISSION_END
START_NEW_SCRIPT[*] 79 1+l R AM
GOSUB 80 1 R
RETURN 81 0
+=@
+@
ADD_THING_TO_THING_TIMED
ADD_TIMED_VAL_TO_FLOAT_VAR 120 2 VF F
ADD_TIMED_VAL_TO_FLOAT_LVAR 121 LF F
ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR 122 VF VF
ADD_TIMED_FLOAT_LVAR_TO_FLOAT_LVAR 123 LF LF
ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR 124 LF VF
ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR 125 VF LF
-=@
-@
SUB_THING_FROM_THING_TIMED
SUB_TIMED_VAL_FROM_FLOAT_VAR 126 2 VF F
SUB_TIMED_VAL_FROM_FLOAT_LVAR 127 LF F
SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR 128 VF VF
SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_LVAR 129 LF LF
SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR 130 LF VF
SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR 131 VF LF
=#
CSET
CSET_VAR_INT_TO_VAR_FLOAT 140 2 VI VF
CSET_VAR_FLOAT_TO_VAR_INT 141 VF VI
CSET_LVAR_INT_TO_VAR_FLOAT 142 LI VF
CSET_LVAR_FLOAT_TO_VAR_INT 143 LF VI
CSET_VAR_INT_TO_LVAR_FLOAT 144 VI LF
CSET_VAR_FLOAT_TO_LVAR_INT 145 VF LI
CSET_LVAR_INT_TO_LVAR_FLOAT 146 LI LF
CSET_LVAR_FLOAT_TO_LVAR_INT 147 LF LI
ABS ABS_VAR_INT 148 1 VI
ABS_LVAR_INT 149 LI
ABS_VAR_FLOAT 150 VF
ABS_LVAR_FLOAT 151 LF
VAR_INT[*] 199 n VI VIO
VAR_FLOAT[*] 200 n VF VFO
LVAR_INT[*] 201 n LI LIO
LVAR_FLOAT[*] 202 n LF LFO
{[*] 203 0
}[*] 204 0
IF[*] 207 1 I
ELSE[*] 209 0
ENDIF[*] 210 0
WHILE[*] 211 1 I
ENDWHILE[*] 213 0
GTA III Vice City San Andreas
ANDOR[*] 214 1 I
LAUNCH_MISSION 215 1 R
START_CUTSCENE 743 0
PLAYER_MADE_PROGRESS 780 1 I
SET_PROGRESS_TOTAL 781 1 I
REGISTER_MISSION_GIVEN 791 0
REGISTER_MISSION_PASSED 792 1 T
SCRIPT_NAME 932 1 T
LOAD_AND_LAUNCH_MISSION 1046 1 R
LOAD_AND_LAUNCH_MISSION_INTERNAL 1047 1 I
SET_TOTAL_NUMBER_OF_MISSIONS 1068 1 I
REGISTER_ODDJOB_MISSION_PASSED 1429 0
Vice City San Andreas Liberty City Stories
REPEAT[*] 205 2 I VLI
ENDREPEAT[*] 206 0
GTA III Vice City
CREATE_COLLECTABLE1 748 1 I
SET_COLLECTABLE1_TOTAL 749 1 I
GTA III Liberty City Stories
GOTO_IF_TRUE[*] 76 1 R
Vice City San Andreas
=
IS_THING_EQUAL_TO_THING
IS_INT_VAR_EQUAL_TO_CONSTANT 1187 2 VI C
IS_INT_LVAR_EQUAL_TO_CONSTANT 1188 LI C
=
SET
SET_VAR_INT_TO_CONSTANT 1198 2 VI C
SET_LVAR_INT_TO_CONSTANT 1199 LI C
>
<=
IS_THING_GREATER_THAN_THING
IS_INT_VAR_GREATER_THAN_CONSTANT 1200 2 VI C
IS_INT_LVAR_GREATER_THAN_CONSTANT 1201 LI C
IS_CONSTANT_GREATER_THAN_INT_VAR 1202 C VI
IS_CONSTANT_GREATER_THAN_INT_LVAR 1203 C LI
>=
<
IS_THING_GREATER_OR_EQUAL_TO_THING
IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT 1204 2 VI C
IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT 1205 LI C
IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR 1206 C VI
IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR 1207 C LI
LOAD_AND_LAUNCH_MISSION_EXCLUSIVE 1301 1 R
GTA III
IFNOT[*] 208 1 I
WHILENOT[*] 212 1 I
GOSUB_FILE 717 2 R R
San Andreas
=
SET
SET_VAR_TEXT_LABEL 1449 2 VT AT
SET_LVAR_TEXT_LABEL 1450 LT AT
VAR_TEXT_LABEL[*] 1451 n VT VTO
LVAR_TEXT_LABEL[*] 1452 n LT LTO
=
IS_THING_EQUAL_TO_THING
IS_VAR_TEXT_LABEL_EQUAL_TO_TEXT_LABEL 1453 2 VT AT
IS_LVAR_TEXT_LABEL_EQUAL_TO_TEXT_LABEL 1454 LT AT
=
SET
SET_VAR_TEXT_LABEL16 1745 2 VT16 AT16
SET_LVAR_TEXT_LABEL16 1476 LT16 AT16
VAR_TEXT_LABEL16[*] 1477 n VT16 VT16O
LVAR_TEXT_LABEL16[*] 1478 n LT16 LT16O
=
IS_THING_EQUAL_TO_THING
IS_INT_LVAR_EQUAL_TO_INT_VAR 2006 2 LI VI
IS_FLOAT_LVAR_EQUAL_TO_FLOAT_VAR 2007 LF VF
IS_EMPTY[*] IS_VAR_TEXT_LABEL_EMPTY 2116 1 VT
IS_LVAR_TEXT_LABEL_EMPTY 2117 LT
IS_VAR_TEXT_LABEL16_EMPTY 2118 VT16
IS_LVAR_TEXT_LABEL16_EMPTY 2119 LT16
SWITCH[*] 2120 1 VLI
ENDSWITCH[*] 2121 0
CASE[*] 2122 1 I
DEFAULT[*] 2123 0
BREAK[*] 2124 0
SWITCH_START[*] 2161 18 VI I I R I
R
LI I I R I
R
SWITCH_CONTINUED[*] 2162 18 I
R
IS_BIT_SET[*] IS_GLOBAL_VAR_BIT_SET_CONST 2228 2 VI C
IS_GLOBAL_VAR_BIT_SET_VAR 2229 VI VI
IS_GLOBAL_VAR_BIT_SET_LVAR 2230 VI LI
IS_LOCAL_VAR_BIT_SET_CONST 2231 LI C
IS_LOCAL_VAR_BIT_SET_VAR 2232 LI VI
IS_LOCAL_VAR_BIT_SET_LVAR 2233 LI LI
SET_BIT[*] SET_GLOBAL_VAR_BIT_CONST 2234 2 VI C
SET_GLOBAL_VAR_BIT_VAR 2235 VI VI
SET_GLOBAL_VAR_BIT_LVAR 2236 VI LI
SET_LOCAL_VAR_BIT_CONST 2237 LI C
SET_LOCAL_VAR_BIT_VAR 2238 LI VI
SET_LOCAL_VAR_BIT_LVAR 2239 LI LI
CLEAR_BIT[*] CLEAR_GLOBAL_VAR_BIT_CONST 2240 2 VI C
CLEAR_GLOBAL_VAR_BIT_VAR 2241 VI VI
CLEAR_GLOBAL_VAR_BIT_LVAR 2242 VI LI
CLEAR_LOCAL_VAR_BIT_CONST 2243 LI C
CLEAR_LOCAL_VAR_BIT_VAR 2244 LI VI
CLEAR_LOCAL_VAR_BIT_LVAR 2245 LI LI
=
IS_THING_EQUAL_TO_THING
IS_VAR_TEXT_LABEL16_EQUAL_TO_TEXT_LABEL 2297 2 VT16 AT16
IS_LVAR_TEXT_LABEL16_EQUAL_TO_TEXT_LABEL 2298 LT16 AT16
STRING_CAT[*] STRING_CAT16 2443 3 VT16 VT16 VT16
STRING_CAT8 2444 VT VT VT
Liberty City Stories
RETURN_TRUE 197 0
RETURN_FALSE 198 0
SWITCH[*][*] 214 1 VLI
ENDSWITCH[*][*] 215 0
CASE[*][*] 216 1 I
DEFAULT[*][*] 217 0
BREAK[*][*] 218 0
ANDOR[*] 219 1 I
LAUNCH_MISSION 220 1 R
SAVE_VAR_INT[*] 502 l VI VIO
SAVE_VAR_FLOAT[*] 503 l VF VFO
GOSUB_FILE 722 2 R R
START_CUTSCENE 748 0
PLAYER_MADE_PROGRESS 785 1 I
SET_PROGRESS_TOTAL 786 1 I
REGISTER_MISSION_GIVEN 796 0
REGISTER_MISSION_PASSED 797 1 T
SCRIPT_NAME 937 1 T
LOAD_AND_LAUNCH_MISSION 1051 1 R
LOAD_AND_LAUNCH_MISSION_INTERNAL 1052 1 I
SET_TOTAL_NUMBER_OF_MISSIONS 1073 1 I
=
IS_THING_EQUAL_TO_THING
IS_INT_VAR_EQUAL_TO_CONSTANT 1192 2 VI C
IS_INT_LVAR_EQUAL_TO_CONSTANT 1193 LI C
=
SET
SET_VAR_INT_TO_CONSTANT 1203 2 VI C
SET_LVAR_INT_TO_CONSTANT 1204 LI C
>
<=
IS_THING_GREATER_THAN_THING
IS_INT_VAR_GREATER_THAN_CONSTANT 1205 2 VI C
IS_INT_LVAR_GREATER_THAN_CONSTANT 1206 LI C
IS_CONSTANT_GREATER_THAN_INT_VAR 1207 C VI
IS_CONSTANT_GREATER_THAN_INT_LVAR 1208 C LI
>=
<
IS_THING_GREATER_OR_EQUAL_TO_THING
IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT 1209 2 VI C
IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT 1210 LI C
IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR 1211 C VI
IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR 1212 C LI
REGISTER_ODDJOB_MISSION_PASSED 1434 0
CALL[*][*][*] 1454 1+i+o R AM
VLM
CALLNOT[*][*][*] 1455 1+i+o R AM
VLM
Vice City Stories
=
SET
SET_INT[*] 4 2 VLI I
SET_FLOAT[*] 5 VLF F
SET_TEXT_LABEL[*] 6 VLT T
SET_INT_TO_INT[*] 53 VLI VLI
SET_FLOAT_TO_FLOAT[*] 54 VLF VLF
SET_TEXT_LABEL_TO_TEXT_LABEL[*] 55 VLT VLT
SET_INT_TO_CONSTANT[*] 738 VLI C
+=
+
ADD_THING_TO_THING
ADD_VAL_TO_INT[*] 7 2 VLI I
ADD_VAL_TO_FLOAT[*] 8 VLF F
ADD_INT_TO_INT[*] 41 VLI VLI
ADD_FLOAT_TO_FLOAT[*] 42 VLF VLF
-=
-
SUB_THING_FROM_THING
SUB_VAL_FROM_INT[*] 9 2 VLI I
SUB_VAL_FROM_FLOAT[*] 10 VLF F
SUB_INT_FROM_INT[*] 43 VLI VLI
SUB_FLOAT_FROM_FLOAT[*] 44 VLF VLF
*=
*
MULT_THING_BY_THING
MULT_INT_BY_VAL[*] 11 2 VLI I
MULT_FLOAT_BY_VAL[*] 12 VLF F
MULT_INT_BY_INT[*] 45 VLI VLI
MULT_FLOAT_BY_FLOAT[*] 46 VLF VLF
/=
/
DIV_THING_BY_THING
DIV_INT_BY_VAL[*] 13 2 VLI I
DIV_FLOAT_BY_VAL[*] 14 VLF F
DIV_INT_BY_INT[*] 47 VLI VLI
DIV_FLOAT_BY_FLOAT[*] 48 VLF VLF
>
<=
IS_THING_GREATER_THAN_THING
IS_INT_GREATER_THAN_NUMBER[*] 15 2 VLI I
IS_NUMBER_GREATER_THAN_INT[*] 16 I VLI
IS_INT_GREATER_THAN_INT[*] 17 VLI VLI
IS_FLOAT_GREATER_THAN_NUMBER[*] 18 VLF F
IS_NUMBER_GREATER_THAN_FLOAT[*] 19 F VLF
IS_FLOAT_GREATER_THAN_FLOAT[*] 20 VLF VLF
IS_INT_GREATER_THAN_CONSTANT[*] 739 VLI C
IS_CONSTANT_GREATER_THAN_INT[*] 740 C VLI
>=
<
IS_THING_GREATER_OR_EQUAL_TO_THING
IS_INT_GREATER_OR_EQUAL_TO_NUMBER[*] 21 2 VLI I
IS_NUMBER_GREATER_OR_EQUAL_TO_INT[*] 22 I VLI
IS_INT_GREATER_OR_EQUAL_TO_INT[*] 23 VLI VLI
IS_FLOAT_GREATER_OR_EQUAL_TO_NUMBER[*] 24 VLF F
IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT[*] 25 F VLF
IS_FLOAT_GREATER_OR_EQUAL_TO_FLOAT[*] 26 VLF VLF
IS_INT_GREATER_OR_EQUAL_TO_CONSTANT[*] 741 VLI C
IS_CONSTANT_GREATER_OR_EQUAL_TO_INT[*] 742 C VLI
=
IS_THING_EQUAL_TO_THING
IS_INT_EQUAL_TO_NUMBER[*] 27 2 VLI I
IS_INT_EQUAL_TO_INT[*] 28 VLI VLI
IS_FLOAT_EQUAL_TO_NUMBER[*] 29 VLF F
IS_FLOAT_EQUAL_TO_FLOAT[*] 30 VLF VLF
IS_TEXT_LABEL_EQUAL_TO_STRING[*] 31 VLT T
IS_TEXT_LABEL_EQUAL_TO_TEXT_LABEL[*] 32 VLT VLT
IS_INT_EQUAL_TO_CONSTANT[*] 731 VLI C
GOTO_IF_TRUE[*] 33 1 R
GOTO_IF_FALSE[*] 34 1 R
TERMINATE_THIS_SCRIPT 35 0
MISSION_END
START_NEW_SCRIPT[*] 36 1+l R AM
GOSUB 37 1 R
RETURN 38 0
+=@
+@
ADD_THING_TO_THING_TIMED
ADD_TIMED_VAL_TO_FLOAT[*] 49 2 VLF F
ADD_TIMED_FLOAT_TO_FLOAT[*] 50 VLF VLF
-=@
-@
SUB_THING_FROM_THING_TIMED
SUB_TIMED_VAL_FROM_FLOAT[*] 51 2 VLF F
SUB_TIMED_FLOAT_FROM_FLOAT[*] 52 VLF VLF
=#
CSET
CSET_INT_TO_FLOAT[*] 56 2 VLI VLF
CSET_FLOAT_TO_INT[*] 57 VLF VLI
ABS ABS_INT[*] 58 1 VLI
ABS_FLOAT[*] 59 VLF
RETURN_TRUE 94 0
RETURN_FALSE 95 0
VAR_INT[*][*] 96 n VI VIO
VAR_FLOAT[*][*] 97 n VF VFO
LVAR_INT[*][*] 98 n LI LIO
LVAR_FLOAT[*][*] 99 n LF LFO
VAR_TEXT_LABEL[*][*] 100 n VT VTO
LVAR_TEXT_LABEL[*][*] 101 n LT LTO
{[*][*] 102 0
}[*][*] 103 0
IF[*][*] 104 1 I
IFNOT[*][*] 105 1 I
ELSE[*][*] 106 0
ENDIF[*][*] 107 0
WHILE[*][*] 108 1 I
WHILENOT[*][*] 109 1 I
ENDWHILE[*][*] 110 0
REPEAT[*][*] 111 2 I VLI
ENDREPEAT[*][*] 112 0
SWITCH[*][*] 113 1 VLI
ENDSWITCH[*][*] 114 0
CASE[*][*] 115 1 I
DEFAULT[*][*] 116 0
BREAK[*][*] 117 0
ANDOR[*] 120 1 I
LAUNCH_MISSION 121 1 R
SAVE_VAR_INT[*] 297 l VI VIO
SAVE_VAR_FLOAT[*] 298 l VF VFO
SAVE_VAR_TEXT_LABEL[*] 299 l VT VTO
GOSUB_FILE 442 2 R R
PLAYER_MADE_PROGRESS 479 1 I
SET_PROGRESS_TOTAL 480 1 I
REGISTER_MISSION_GIVEN 490 0
REGISTER_MISSION_PASSED 491 1 T
SCRIPT_NAME 568 1 T
LOAD_AND_LAUNCH_MISSION 648 1 R
LOAD_AND_LAUNCH_MISSION_INTERNAL 649 1 I
SET_TOTAL_NUMBER_OF_MISSIONS 662 1 I
REGISTER_ODDJOB_MISSION_PASSED 874 0
CALL[*][*][*] 890 1+i+o R AM
VLM
CALLNOT[*][*][*] 891 1+i+o R AM
VLM
SET_COLLECTABLE2_TOTAL 1242 1 I
Notes
^ A special mission directive which is never compiled;
^ It is used to build the various control flows internally;
^ It is used to declare one or more variables;
^ It embeds a variable scope;
^ It has an undefined amount of arguments;
^ It is a likely definition of the standard command;
^ It should exist but its position is purely guessed;
^ Arguments amount varies when compiling.

This section is incomplete. You can help by fixing and expanding it.

Uncommon values

Arguments of some commands keep uncommon values which look familiar after encoding:

Command Arg.
ID
Value Encoded
Command Arg.
ID
Value Type
GTA III Vice City San Andreas Liberty City Stories Vice City Stories
GOTO 1 Generic label GOTO 1 Positive/Negative offset INT
GOTO_IF_FALSE 1 Generic label GOTO_IF_FALSE 1 Positive/Negative offset INT
GOSUB 1 Gosub label GOSUB 1 Positive/Negative offset INT
GOSUB_FILE 1 Gosub label GOSUB_FILE 1 Zero-based offset INT
2 Foreign gosub file 2
1 Gosub label 1 Positive/Negative offset
2 Foreign gosub label 2
START_NEW_SCRIPT 1 Script label START_NEW_SCRIPT 1 Positive/Negative offset INT
l Passed locals l Passed locals ANY_MULTI
LAUNCH_MISSION 1 Subscript file LAUNCH_MISSION 1 Zero-based offset INT
Subscript label Positive/Negative offset
LOAD_AND_LAUNCH_MISSION 1 Mission script file LOAD_AND_LAUNCH_MISSION_INTERNAL 1 Mission identifier INT
Mission script label LOAD_AND_LAUNCH_MISSION Positive/Negative offset
GTA III Liberty City Stories Vice City Stories
GOTO_IF_TRUE 1 Generic label GOTO_IF_TRUE 1 Positive/Negative offset INT
Vice City San Andreas
LOAD_AND_LAUNCH_MISSION_EXCLUSIVE 1 Mission script file LOAD_AND_LAUNCH_MISSION_INTERNAL 1 Negative mission identifier INT
Mission script label LOAD_AND_LAUNCH_MISSION_EXCLUSIVE Positive/Negative offset
Liberty City Stories Vice City Stories
CALL
CALLNOT
1 Function label CALL
CALLNOT
1 # of input arguments INT
2 # of output arguments
3 # of script locals
4 Positive/Negative offset
i Input arguments i Input arguments ANY_MULTI
o Output arguments o Output arguments HOLD_MULTI

This section is incomplete. You can help by fixing and expanding it.

Compare flag

The compare flag is an internal script-dependent flag which makes conditional GOTOs such as GOTO_IF_TRUE (unavailable in GTA III Vice City San Andreas) and GOTO_IF_FALSE deciding whether to jump otherwise. It can handle up to 8 checks per conditional statement and indicates you are verifying a single condition (0, see also Optimization) or multiple conditions with either AND (1 to 8) or OR (21 to 28) logical operators (see also ANDOR).

Control flows analysis

As an overview of the compiled source, control flows are literally nested meaning that the code is unoptimized. Furthermore, the jump of an embedded construct doesn't get merged with that of the construct itself, which consists of a benefit for the code parsing.

IF

As regards the IF control flow, if the whole check is true the consequence is performed and the code jumps to the end of the construct, otherwise it skips to the alternative (see also Compare flag):

Decompiled GTA III Vice City San Andreas Liberty City Stories Vice City Stories Compiled
IF [NOT] {condition0}
[AND|OR [NOT] {condition8}]
    {consequence}
[ELSE
    {alternative}]
ENDIF
{..214}
{.....}
{.....}
{...77}
{.....}
{....2}
 ----- 
{.....}
 ----- 
{..219}
{.....}
{.....}
{...77}
{.....}
{....2}
 ----- 
{.....}
 ----- 
{..120}
{.....}
{.....}
{...34}
{.....}
{....2}
 ----- 
{.....}
 ----- 
ANDOR {value}
    [NOT] {condition0}
    [[NOT] {condition8}]
GOTO_IF_FALSE ELSE
    {consequence}
    [GOTO ENDIF]
ELSE:
    [{alternative}
ENDIF:]

IFNOT

Not that much to say more than the preceding construct, the IFNOT control flow is built nearly in the same way. In fact, the ELSE clause points to the alternative, whereas the GOTO jumps to its end. The substantial difference consists in the substitution of GOTO_IF_FALSE with GOTO_IF_TRUE:

Decompiled GTA III Liberty City Stories Vice City Stories Compiled
IFNOT [NOT] {condition0}
[AND|OR [NOT] {condition8}]
    {consequence}
[ELSE
    {alternative}]
ENDIF
{..214}
{.....}
{.....}
{...76}
{.....}
{....2}
 ----- 
{.....}
 ----- 
{..219}
{.....}
{.....}
{...76}
{.....}
{....2}
 ----- 
{.....}
 ----- 
{..120}
{.....}
{.....}
{...33}
{.....}
{....2}
 ----- 
{.....}
 ----- 
ANDOR {value}
    [NOT] {condition0}
    [[NOT] {condition8}]
GOTO_IF_TRUE ELSE
    {consequence}
    [GOTO ENDIF]
ELSE:
    [{alternative}
ENDIF:]

WHILE

The WHILE control flow is built pretty much similarly to the previous, even though when the consequence is read the code is moved to the beginning of the construct:

Decompiled GTA III Vice City San Andreas Liberty City Stories Vice City Stories Compiled
WHILE [NOT] {condition0}
[AND|OR [NOT] {condition8}]
    {consequence}
ENDWHILE
 ----- 
{..214}
{.....}
{.....}
{...77}
{.....}
{....2}
 ----- 
 ----- 
{..219}
{.....}
{.....}
{...77}
{.....}
{....2}
 ----- 
 ----- 
{..120}
{.....}
{.....}
{...34}
{.....}
{....2}
 ----- 
WHILE:
ANDOR {value}
    [NOT] {condition0}
    [[NOT] {condition8}]
GOTO_IF_FALSE ENDWHILE
    {consequence}
    GOTO WHILE
ENDWHILE:

WHILENOT

To say the least, WHILENOT control flow follows the same constitution of both WHILE and IFNOT constructs, by exchanging GOTO_IF_FALSE with GOTO_IF_TRUE:

Decompiled GTA III Liberty City Stories Vice City Stories Compiled
WHILENOT [NOT] {condition0}
[AND|OR [NOT] {condition8}]
    {consequence}
ENDWHILE
 ----- 
{..214}
{.....}
{.....}
{...76}
{.....}
{....2}
 ----- 
 ----- 
{..219}
{.....}
{.....}
{...76}
{.....}
{....2}
 ----- 
 ----- 
{..120}
{.....}
{.....}
{...33}
{.....}
{....2}
 ----- 
WHILENOT:
ANDOR {value}
    [NOT] {condition0}
    [[NOT] {condition8}]
GOTO_IF_TRUE ENDWHILE
    {consequence}
    GOTO WHILENOT
ENDWHILE:

REPEAT

Seemingly, the REPEAT control flow is the first construct ever optimized as a result of a possible R* compiler fault. Moreover, it sounds ambiguous as it loops at least once. This was probably the intention of R* programmers, that is iterating at least once else the construct is useless. However, there are few chance they decide to use such structure to avoid some conflict with some other constructs:

Decompiled G/L Vice City San Andreas Liberty City Stories G/L Vice City Stories Compiled
REPEAT {times} {varname}
    {consequence}
ENDREPEAT
{....4}
 ----- 
{.....}
{....8}
{...40}
{...77}
{....5}
 ----- 
{.....}
{....9}
{...41}
{...77}
{....4}
 ----- 
{.....}
{....7}
{...21}
{...34}
{varname} = {value0}
LOOP:
{consequence}
++ {varname}
    {varname} >= {valueN}
GOTO_IF_FALSE LOOP

SWITCH

In San Andreas, the SWITCH control flow is more complex and efficient because the game uses internally a binary search algorithm to jump at the label that matches with the value of a particular case. This method requires a known amount of cases which is up to 75. When a case is true, a consequence is executed and the code jumps to the end of the construct, otherwise the alternative may be performed. As the code is unoptimized, the GOTO of the last case is still compiled even though its label points right after the command mentioned earlier:

Decompiled San Andreas Compiled
SWITCH {varname}
    CASE {value0}
        {consequence}
        BREAK
    [CASE {valueN}
        {consequence}
        BREAK]
    [DEFAULT
        {alternative}
        BREAK]
ENDSWITCH
{.2161}
{.2162}
 ----- 
{.....}
{....2}
 ----- 
{.....}
{....2}
 ----- 
{.....}
{....2}
 ----- 
SWITCH_START {varname} {numcases} {isdefault} DEFAULT {value0} CASE0 ...
[SWITCH_CONTINUED ... {valueN} CASEN [-1 ENDSWITCH]]
CASE0:
    {consequence}
    GOTO ENDSWITCH
[CASEN:
    {consequence}
    GOTO ENDSWITCH]
[DEFAULT:
    {alternative}
    GOTO ENDSWITCH]
ENDSWITCH:

In Liberty City Stories and Vice City Stories, such control flow is a set of nested IF constructs which causes a very slight loss of performance by considering that ANDOR isn't compiled:

Decompiled G/L Liberty City Stories G/L Vice City Stories Compiled
SWITCH {varname}
    CASE {value0}
        {consequence}
        BREAK]
    [CASE {valueN}
        {consequence}
        BREAK]
    [DEFAULT
        {alternative}
        BREAK]
ENDSWITCH
 ----- 
{...56}
{...77}
{.....}
{....2}
 ----- 
{...56}
{...77}
{.....}
{....2}
 ----- 
{.....}
 ----- 
 ----- 
 ----- 
{...57}
{...77}
{.....}
{....2}
 ----- 
{...57}
{...77}
{.....}
{....2}
 ----- 
{.....}
 ----- 
 ----- 
 ----- 
{...27}
{...34}
{.....}
{....2}
 ----- 
{...27}
{...34}
{.....}
{....2}
 ----- 
{.....}
 ----- 
 ----- 
CASE0:
    {varname} = {value0}
GOTO_IF_FALSE CASEN
    {consequence}
    GOTO ENDSWITCH0
CASEN:
        [{varname} = {valueN}
    GOTO_IF_FALSE DEFAULT
        {consequence}
        GOTO ENDSWITCHN
    DEFAULT:
        [{alternative}
    ENDSWITCHN:]]
ENDSWITCH0:

Optimization

In Liberty City Stories and Vice City Stories, whenever a single condition is checked ANDOR doesn't get compiled cause no logical operator (AND, OR) is used and so they become really useless. Its lack increases the script efficiency a lot. However, the jump of the ELSE clause of an IF statement which points to the end of the construct is still compiled after a GOTO. Furthermore, Stories Games come with an improved data type managing which causes a considerable decrease of the compiled file size.

Tools

See also

External links