Talk:SCM language

From GTAMods Wiki
Jump to navigation Jump to search

More leaked scripts

So this time we got the entire GTA III, GTA VC and GTA SA script sources!

So we ('sup Wesser) guessed lots of things wrong (streamed scripts, some text label stuff, CONSTANT_*), but we were right about CONST_*. I'm really glad we are able to finally see what these scripts were really like. Link2012 (talk) 02:33, 12 November 2021 (UTC)

Cool but... lots of things? This is an unfair overstatement for us at a first glance:
  • The filename of streamed scripts seemingly becomes a string constant on registration (we had no more talk since ages and I did change my view like that in the meantime :p);
  • MISSION_START and MISSION_END indeed are also used as directives of streamed scripts, or better yet streamed sub-scripts (something we could have thought ourselves, dammit);
  • Text label literals oftenly come with an unpredictable ampersand;
  • CONSTANT_INT is nowhere found.
Actually, I feel so much proud of what's been discovered, imagined and reconstructed without a single piece of evidence about certain stuff. – Wesser (talk) 02:14, 14 November 2021 (UTC)
They also leaked the San Andreas Script Compiler so we now have enough information to specify the language with precision up to San Andreas :-). Link2012 (talk) 14:12, 14 November 2021 (UTC)

Rework ETA?

It seems pointless to edit the page on the wiki while the rework is going on, since the reworked page will presumably completely replace the current one entirely (correct me if I am wrong on that). Is there any ETA for the rework? Additionally, would it be possible for the rework to be done entirely on the wiki – section by section maybe – so that people can actively contribute to the page during the rework? – Squ1dd13 (talk) 11:39, 3 September 2020 (UTC)

If you are willing to help, send me a modified version of the work-in-progress article privately on GTAF. I will then pick up myself what's worth and discard the rest. – Wesser (talk) 19:37, 3 September 2020 (UTC)
Ok, I'm a bit busy at the moment but I'll probably do that at some point. Cheers. – Squ1dd13 (talk) 18:08, 4 September 2020 (UTC)
Hey. Nice to see another member of the community interested in the language after so long. Thanks for the updates. Let me express some disagreements: Command is an element of the language, opcode an element of the runtime environment (i.e. CRunningScript). The name of a operation should be command, since that is what Rockstar's miss2.exe strings call them (never mentioning something as an opcode). The language and the runtime should be treated as separate entities (e.g. Python can target CPython, PyPy, JVM, CLR and even native code) due to the separation of programming languages and compiler fields in computer science. b) Alternators shouldn't be called overloads IMO, because that's probably not how Rockstar called them. This language is quite exotic, and that's something to get used to. The leaked compiler always refer to it as an "alternative". Plus, when one describes it formally, it's not as easy to parallel it with function overloading (can talk further if necessary). Anyway, since you are here, you might be interested in something I've been working for the past few years. It's still unfinished therefore I have not yet acquired feedback from other community members, but it may provide insights onto the design of the language: It's pretty formal, but that's what it is supposed to be. Best regards. Link2012 (talk) 19:57, 28 September 2020 (UTC)
I never really liked the "alternator" term, I opt for "multicommand" which is consistent with the native lexicon. – Wesser (talk) 16:29, 29 September 2020 (UTC)
I recall your disagreement on the term, as we additionally opted for "command set" or "command selector". "Multicommand" seems fine to me since it's not to be confused with another PL term. Link2012 (talk) 17:23, 29 September 2020 (UTC)
I disagree with your point that the idea of alternators is different to function overloading (in this case, operator overloading), but given that I'm new here and have less experience with both this wiki and the SCM language, I'll change the section back to 'alternators'. Regarding the point about "command" vs. "opcode", I'm not really sure what you're picking up on there? I don't see any obvious instances where I've used one where the other would be more suitable (I try to use "opcode" when referring to the number, and "command" when referring to the operation that has that number), but I'll look out for any mistakes I've made with that. Thanks for the advice! – Squ1dd13 (talk) 11:28, 3 October 2020 (UTC)
My mistake on the point about opcodes, I thought you renamed the Commands section to Opcodes when I saw the diffs. Sorry for that. Regarding overloading, my disagreement comes from a) The commands themselves are not overloaded. There's not multiple commands named SET, but a name that maps to other commands that are independent from said name. b) The semantics for the arguments of a command and an alternator are different. For example, let's say we have the alternator AAA = {BBB INPUT_INT}. Since BBB INPUT_INT accepts integers and variables, I'd assume AAA 1 or AAA somevar would work, but neither does, breaking my expectations about "overloading". And you are more than welcome! You did good on expressing your disagreement about my disagreement, such that I can share and question my own knowledge about the subject. Language design is something to be toughly discussed, or otherwise we risk breaking compilers or languages themselves forever. Link2012 (talk) 16:14, 3 October 2020 (UTC)
I see your point about the alternators now, and it makes sense. Thanks for the explanation, it worked well! – Squ1dd13 (talk) 15:51, 5 October 2020 (UTC)
Let me also take this opportunity to share something I've seen recently. The following is an interview that Rockstar North developers gave to GameSpot back in 2006: This interview confirms that arrays were only introduced in GTA SA, confirms the terms "main script", "mission script" and others, and introduces a new term, "ambient script", which are the non-main and non-mission scripts. Link2012 (talk) 21:40, 28 September 2020 (UTC)
Thanks for sharing. A hidden gem, even though it unveils little unknown details, it's still pleasant to get something from a trusted source. Seemann (talk) 02:40, 29 September 2020 (UTC)


I'm not going to update the article by myself because I'm not good with words, my english is not so good... I'm going to left informations here to fix the article... All information here is based on the reverse engineering of the SCM compiler left on Vice City 10th Anniversary, I will refer to this compiler here only by miss2 (Yeah, the name is the same as GTA 2 Script Compiler)

About the 'SCM' meaning

SCM may stand for "Script Multifile", since the button to compile a scm is named "Run MultiFile parser", we have also the button "Run Parser" that produces a .scc file, it's unknown about the usage of that .scc Somewhere in the compiler code we have something like

    strcat(OutputFilename, "m")
    strcat(OutputFilename, "c")


One mistake on the article about comments, the article say:

   Multiline comments cannot be nested. 

But actually multiline comments CAN BE nested.

Round brackets

They are replaced by ' ' in the first compilation step, so probably they are really for reading or highlighting purposes. ',' is also replaced with ' '



There is not VAR_CONST, but actually 04AE (and others) are used to assign a constant value into a VAR_INT, example:

a = PAD2


04AE: $303 = 1
004E: end_thread


The 8 byte string variable is called VAR_TEXT_LABEL


No trace about that variable type in miss2, but I can guess it was called VAR_STRING


The article is right about how arrays are declared (VAR_INT array[size]), but we have a strange behaviour around arrays... The index seem to start from 1 instead of 0, very strange, let's see a example

VAR_INT a[4]
a[0] = 0
a[1] = 1
a[2] = 2
a[3] = 3
a[4] = 4


0004: $303 = 0
0004: $303 = 1
0004: $304 = 2
0004: $305 = 3
0004: $306 = 4
004E: end_thread 

The array support on miss2 is not good since Vice City don't have arrays, using array[var] would output a messed file, so we can't say much about it.


Time Step operator

The time step operator is not =- or =+, but [email protected] or [email protected], example:

a [email protected] 1.0
a [email protected] 1.0
a = 1.0 [email protected] 2.0
a = a [email protected] 3.0


0078: $303 += time_step * 1.0
007E: $303 -= time_step * 1.0
0005: $303 = 1.0
0078: $303 += time_step * 2.0
007E: $303 -= time_step * 3.0
004E: end_thread 

Compare String

No COMPARE_STRING, string comparision is done with the comparision operator (at least for VAR_TEXT_LABEL)


Constants are hardcoded (as everything in the compiler). Maybe they changed this on the SA Compiler or maybe AudioEvents.txt is a constant dump file.

The script files

File gosubs

They are called "main extension files" and "foreign gosubs" and are called using GOSUB_FILE Example:

GOSUB_FILE sub_label


START_NEW_SCRIPT is 004F, LAUNCH_MISSION is 00D7 and LOAD_AND_LAUNCH_MISSION is 0417 Okay, you may say: "Somewhere in GTA III Script files we have a commented block where LAUNCH_MISSION is launching a mission (0417)...", Yes, but this has probably been changed during the time, look again at that commented part and look the final code in sanny, the code is different.

There's also LOAD_AND_LAUNCH_MISSION_EXCLUSIVE, I don't know the purposes of it, okay.

LAUNCH_MISSION scripts are called Subscripts

The START_NEW_SCRIPT target label MUST be inside a scope block... The compiler also checks for the variables in that scope block to see if the START_NEW_SCRIPT extra params can be accept by the variables in the script scope block.

The foreign scripts MUST be inside a folder with the same name as the main script file, inside another folder or not. Example:

Usage Example:

LAUNCH_MISSION // launch a subscript
LOAD_AND_LAUNCH_MISSION // launch a mission

LVAR_INT number_1


There's no DO..WHILE_TRUE and probably there's no FOR..ENDFOR too But we have a new statement over here, REPEAT..ENDREPEAT

REPEAT num_times var
  // code here

This is like a FOR (for that reason I said there's no FOR...ENDFOR), will repeat the code num_times, using the var as the counter variable.


 k *= 10


0004: $303 = 0 

0010: $304 *= 10
0008: $303 += 1
0028:   $303 >= 4 
004D: jump_if_false @Noname_7 
004E: end_thread 

128 Byte Strings

128 bytes strings are enclosed in quotation marks, example:


Models constant

They are read from the IDE files in maps folder... Actually miss2 read default.ide and gta_vc.dat, after parsing gta_vc.dat, miss2 will read all listed IDE files.

Entity Variables

miss2 doesn't permit you to assign more than one entity to a specific variable, for example:

CREATE_CAR 400 0.0 0.0 0.0 var
CREATE_CHAR 4 1 0.0 0.0 0.0 var   // error: Variable has already been used to create a entity of a different type

Link2012 (talk) 12 December 2012 (UTC)