G'day modders !
What is this ?
Scocl is high level script compiler for GTA IV and EFLC . This project is based on the c-like llvm compiler . As you already noticed from the name of the project , compiler allows you to create your own sco scripts , which can be interpreted on GTA IV script virtual machine without any plugins and extensions .
You must extract all archive contents as they are inside of the archive , so folder and file hierarchy must be the same as in the arch
What's the difference from Alice, Script Hook, etc ?
All this utils were just using script functions , scocl allows to create plain sco scripts , like this was done by R*. Using scocl you have no script restrictions , code your scripts like R* developer .
Why so late ?
Not late ! All RAGE games are using almost the same script bytecode , so it would be much easier to add support for new RAGE-based games .
Command line :
<globals version> script version stamp , can be GTAIV or TLAD , or TBOGT , also you can use custom value with 0xHEXVERSION
<filein> script source file
<dirout> compiled script output folder
<options> independent options set - GLOBALSEG , KEEPTEMP, DEBUGOUTPUT
GLOBALSEG - compiling script with global segment , only startup script must be compiled with this key
KEEPTEMP - don't delete temp files after compilation
DEBUGOUTPUT - debug script compilation
scocl.exe GTAIV "c:\gta\scripts\main.c" "c:\gta\scripts\out\" KEEPTEMP DEBUGOUTPUT
scocl.exe TLAD "c:\gta\scripts\startup.c" "c:\gta\scripts\out\" GLOBALSEG
Change log :
First public release
v0.3 ( 15 May 2011 )
First private release
Script writing :
Warning , scocl can't compile any of decompiled scripts , because there is no info inside sufficient for compilation . It's not rly possible to write such decompiler to have all the needed info , so all scripts must be written from scratch .
Decompiled scripts :
While writing new scripts you will need to look into the decompiled scripts anyway. I'm using Total Commander for text search inside of 'em. Note that scocl compiled scripts can't be decompiled using OpenIV or SparkIV becase they are tryn' to find high-level constructions by opcode patterns which were very specified for R* compiler . Scocl is using different pattern set , so you can decompile scocl scripts only to low level , if you will need this use scodcl.exe from the bin folder .
Script files :
All scripts are placed in the script.img and script_network.img archives from <gta dir>\common\data\cdimages dir. We are only interested in the singleplayer. The first script that starts on new game is startup.sco , it loads all ambient scripts and main.sco , main.sco launches initial.sco and switching to the stat and mission control mode . Startup.sco must have global segment inside , all other scripts must not . All scripts in the script.img must have the same globals version (stamp) as startup.sco has .
Script functions :
There are something like ~3000 of natives . Comparing to the scm-engine from previous GTA 3D series , which had one native to one opcode assigned , RAGE has less than 100 opcodes and they look like a real assembler , there is only one opcode for native calling . Native to call is the param of this opcode , this param is a hash of the native name . Before 5th (or something around) patch for GTA IV there was only one hash algorithm , after that patch hash was changed . Compiler is configured for the latest patches , so scocl is using new hash algo . Scripts which were compiled with new hash can't be used with old patches . You can see complete list of the GTA IV and EFLC natives in the inc\natives.h file.
Each script can be marked as "save this one" if it will call THIS_SCRIPT_SHOULD_BE_SAVED() native . By default script wont be saved . If you will change the script without wiping out saves , game will crash while loading the save , so you must delete all saves before you can use changed scripts , the same like it was in with scm.
Special features of the scripts :
1. Script.img must have puzzle.sco inside , game checks this script .
2. If you are using globals you must declare them in the separated *.h file , which you must include in all script projects . Global variable name must begin with G_ , for example G_BASE_X , so local var can't begin with G_ , for good examples look into the zombmod .
3. Only ~2000 of ~3000 natives were used in the original scripts , so some of that ~1000 can be broken , noped or even cause game crashing .
4. Almost all multiplayer related natives are commented , im not sure that someone will ever use them .
5. Script startup.sco can't be paused , cycled or saved .
6. In the original scripts some natives can use 3 float params as one Vector3 structure , so param count in the inc\natives.h can be not the same as in the decompiled code .
7. All data types are multiple of 4 , so for example array of 16 chars will look like int .
You can find script examples in the projects dir . All of 'em are Visual Studio 2010 projects .
Current example solutions :
"stripped" - fully stripped game scripts with "superman" ability
"zombmod" - classic zombie mod base , tested with GTA IV and TLAD , no idea about TBOGT . Here is the gameplay video of this example
Script editor :
Scocl was desgined to be used with IDE from MSVS , this is the best choise for any script coder . Any MSVS C++ version is ok , starting from 2010 . If you have no MSVS you can download C++ express here , thats free , maybe you will be forced to create dev account before downloading , anyway this will be free too . For the script template project use the one from projects\dummy folder .
Script editing in the MSVS looks like this :
You can download scocl and decompiled scripts pack here
Download latest free version of the MSVS