Quantcast

Jump to content

» «
Photo

[GTA IV|EFLC|REL] Scocl

166 replies to this topic
Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006

#1

Posted 07 November 2011 - 05:36 PM Edited by Alexander Blade, 31 October 2013 - 04:58 PM.

G'day modders ! biggrin.gif

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 .

Installing :
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 :

CODE scocl.exe <globals version> <filein> <dirout> <options>

<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

Examples :

CODE scocl.exe GTAIV "c:\gta\scripts\main.c" "c:\gta\scripts\out\"
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 :

CODE v0.8 ( 7 Nov 2011 )
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.

Saves :
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[4] .

Examples :
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 :

29796986.th.jpg 13773207.th.jpg

Links :
You can download scocl and decompiled scripts pack here
http://dev-c.com/gtaiv/scocl

Download latest free version of the MSVS
http://www.microsoft...express/Windows

  • Gforce and Frank.s like this

GTARandom
  • GTARandom

    Unfortunate piece of meat

  • Members
  • Joined: 15 Jun 2009

#2

Posted 07 November 2011 - 08:18 PM

Wow, keep it up.

I was just working on setting up the TV for a custom safehouse the other day, could you help me a bit with it , seeing as you have tools ready almost?

It seems to be located in the script ambtv.sco but relies on other main scripts, it won't trigger until a certain mission is passed.

terreur69
  • terreur69

    C2C - Down The Road

  • Members
  • Joined: 27 Dec 2010

#3

Posted 07 November 2011 - 09:09 PM

awesom work !!
this will be greatly advance the modding, great work, for cons, a little tutorial would be possible colgate.gif ?

ikt
  • ikt

     

  • Members
  • Joined: 02 Oct 2006

#4

Posted 07 November 2011 - 10:00 PM Edited by ikt, 07 November 2011 - 10:37 PM.

Amazing work, great for gameplay-replacing mods instead of additional mods. One thing though, how is the performance compared to ScriptHook? If I make a very long script in Scripthook which executes every tick, the game starts to lag. And is this like SA their SCM, modifying it makes you start a new game?

@ Alexander Blade below:

Thanks for the info. Heh, so it's all up to the scripter. Good to know smile.gif

Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006

#5

Posted 07 November 2011 - 10:27 PM

GTARandom
Try to find out what stats and globals ambtv is using

terreur69
Im planning to do the tutorial in the nearest future

ikt
Yep , if any script was modified new game must be started , anyway with cleo iv everything will be okay with saves and additional mods . Btw there is always a way to rewrite script to make it less laggy biggrin.gif Performance is a bit less than native code , anyway like i said , optimization can be done almost for every script .

terreur69
  • terreur69

    C2C - Down The Road

  • Members
  • Joined: 27 Dec 2010

#6

Posted 08 November 2011 - 04:15 PM

I try to compile the startup zombmod(no modify ), and what does not work ,, ther is a floder "out " with startup.s feel anything .
and i can not see if there is an error, the command disappears on confused.gif

Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006

#7

Posted 08 November 2011 - 07:22 PM Edited by Alexander Blade, 08 November 2011 - 07:27 PM.

r u using MSVC ide ?
it's ok with command line too
CODE
Microsoft Windows XP [Версия 5.1.2600]
(С) Корпорация Майкрософт, 1985-2001.

C:\Documents and Settings\Alexander>"C:\Documents and Settings\0.8\bin\scocl.exe" GTAIV D:\Dev\Gta\s
cocl\release\0.8\projects\zombmod\startup.c D:\Dev\Gta\scocl\release\0.8\projects\zombmod\
"C:\Documents and Settings\0.8\bin\scocl.exe" GTAIV D:\Dev\Gta\scocl\release\0.8\projects\zombmod\st
artup.c D:\Dev\Gta\scocl\release\0.8\projects\zombmod\
startup.c compile started
startup.c compile finished, elapsed time 1234 ms

C:\Documents and Settings\Alexander>"C:\Documents and Settings\0.8\bin\scocl.exe" GTAIV D:\Dev\Gta\s
cocl\release\0.8\projects\zombmod\startup.c D:\Dev\Gta\scocl\release\0.8\projects\zombmod\ KEEPTEMP
"C:\Documents and Settings\0.8\bin\scocl.exe" GTAIV D:\Dev\Gta\scocl\release\0.8\projects\zombmod\st
artup.c D:\Dev\Gta\scocl\release\0.8\projects\zombmod\ KEEPTEMP
startup.c compile started
startup.c compile finished, elapsed time 687 ms

C:\Documents and Settings\Alexander>"C:\Documents and Settings\0.8\bin\scocl.exe" GTAIV D:\Dev\Gta\s
cocl\release\0.8\projects\zombmod\startup.c D:\Dev\Gta\scocl\release\0.8\projects\zombmod\ GLOBALSEG

"C:\Documents and Settings\0.8\bin\scocl.exe" GTAIV D:\Dev\Gta\scocl\release\0.8\projects\zombmod\st
artup.c D:\Dev\Gta\scocl\release\0.8\projects\zombmod\ GLOBALSEG
startup.c compile started
startup.c compile finished, elapsed time 766 ms

C:\Documents and Settings\Alexander>

terreur69
  • terreur69

    C2C - Down The Road

  • Members
  • Joined: 27 Dec 2010

#8

Posted 08 November 2011 - 07:55 PM

tell me what is wrong : http://www.mediafire...b2qexkr055d1jpn

Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006

#9

Posted 08 November 2011 - 08:15 PM

you must extract the whole archive into one dir without changing any paths etc

terreur69
  • terreur69

    C2C - Down The Road

  • Members
  • Joined: 27 Dec 2010

#10

Posted 08 November 2011 - 09:00 PM Edited by terreur69, 08 November 2011 - 09:15 PM.

QUOTE (Alexander Blade @ Tuesday, Nov 8 2011, 22:15)
you must extract the whole archive into one dir without changing any paths etc

inlove.gif inlove.gif inlove.gif inlove.gif work perfectly !!! big thanks man !

and is that one can do the opposite .sco > .c ???

Seemann
  • Seemann

    Ruhe

  • Members
  • Joined: 03 Sep 2004
  • Russia

#11

Posted 09 November 2011 - 01:39 AM

Good work. As always.

Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006

#12

Posted 09 November 2011 - 09:12 AM

QUOTE (terreur69 @ Tuesday, Nov 8 2011, 21:00)
QUOTE (Alexander Blade @ Tuesday, Nov 8 2011, 22:15)
you must extract the whole archive into one dir without changing any paths etc

inlove.gif inlove.gif inlove.gif inlove.gif work perfectly !!! big thanks man !

and is that one can do the opposite .sco > .c ???

Nope , as i wrote in the documentaion - decompilation is impossible

thaCURSEDpie
  • thaCURSEDpie

    GTA:IV scripter

  • Members
  • Joined: 01 Jul 2007

#13

Posted 10 November 2011 - 01:11 PM

Awesome work!

What are the advantages of this over scripthook modding? In scripthook you can do a lot of additional stuff, such as detecting keypresses, playing sounds and displaying graphics / menus.

terreur69
  • terreur69

    C2C - Down The Road

  • Members
  • Joined: 27 Dec 2010

#14

Posted 10 November 2011 - 07:08 PM

my games crash to every faith that i place the sco, even those had zombmod confused.gif and even removing the savegames

MajesticNL
  • MajesticNL

    Big Homie

  • Members
  • Joined: 16 Oct 2005
  • Netherlands

#15

Posted 10 November 2011 - 10:31 PM

Another professional russian, good job.

VcSaJen
  • VcSaJen

    Player Hater

  • Members
  • Joined: 24 Jan 2011

#16

Posted 11 November 2011 - 03:09 AM

Awesome!

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009

#17

Posted 11 November 2011 - 03:14 AM

WOW, welcome back! biggrin.gif
Nice work but I'm looking forward to CLEO IV icon14.gif

Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006

#18

Posted 12 November 2011 - 01:03 PM

Thx guyz smile.gif

terreur69
Whats the patch ? Are u deleting all scripts from the script.img and then adding all 11 scripts from the sco folder ?

Rapier
  • Rapier

    Retired scripter

  • Members
  • Joined: 14 Aug 2005

#19

Posted 12 November 2011 - 01:33 PM

Hello Alexander, I think you was dead... tounge.gif

I have very little knowledge of C++, could you do to be compiled with Delphi???

Off topic
You will no longer update the plugin ALICE to be used with the latest versions of GTAIV?

terreur69
  • terreur69

    C2C - Down The Road

  • Members
  • Joined: 27 Dec 2010

#20

Posted 12 November 2011 - 02:52 PM

QUOTE (Alexander Blade @ Saturday, Nov 12 2011, 15:03)
Thx guyz smile.gif

terreur69
Whats the patch ? Are u deleting all scripts from the script.img and then adding all 11 scripts from the sco folder ?

i have the GTAIV 1.0.4.0 ( patch 4 ) , and yes i remove the all sco , and i placed the sco zombmod on script.img , the game crash to loading .

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009

#21

Posted 12 November 2011 - 05:00 PM

Good work Alexander!

I will surely try it out.

Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006

#22

Posted 12 November 2011 - 08:39 PM

terreur69
Oh , u cant use this with 1040 , cuz 1040 is using old native hashes , only newest patches biggrin.gif I'll do the update for the scocl soon .

Rapier
Im not sure if ill do an update for the Alice , cuz almost noone used it . And about delphi - no , i can't rewrite the whole compiler , C-like syntax is easy to learn anyway .

terreur69
  • terreur69

    C2C - Down The Road

  • Members
  • Joined: 27 Dec 2010

#23

Posted 13 November 2011 - 10:04 AM

ok cool , and can give 0xHEXVERSION each version of gta IV and EFLC please colgate.gif , thanx!

Rapier
  • Rapier

    Retired scripter

  • Members
  • Joined: 14 Aug 2005

#24

Posted 13 November 2011 - 12:58 PM

QUOTE (Alexander Blade @ Saturday, Nov 12 2011, 18:39)
...And about delphi - no , i can't rewrite the whole compiler , C-like syntax is easy to learn anyway .

OK... cryani.gif suicidal.gif

I have another question: In Alice you can't use all commands (E.g. CAM_RESTORE), with Scocl will be possible to use all commands?

Performer
  • Performer

    I'M RICH, BIATCH!

  • Members
  • Joined: 15 May 2010
  • Germany

#25

Posted 13 November 2011 - 04:09 PM

YEAAAAAHHHHHHHH!!!!! Now its my part in IV:SAČ to try to convert missions smile.gif

gtasadude
  • gtasadude

    Stunter

  • Members
  • Joined: 29 Oct 2005

#26

Posted 14 November 2011 - 04:19 AM

I can't write scripts but I have to say big thanks for making this tool, incredible work. The amount of progress that's been made with IV in a year is just great, RAGE is really beginning to shape up as an engine for modders now smile.gif

GTA5Videos
  • GTA5Videos

    Rat

  • Members
  • Joined: 06 Nov 2011

#27

Posted 14 November 2011 - 02:36 PM

wow nice! 2 questions:
does this work for xbox?
and
"stripped" - fully stripped game scripts with "superman" ability

is that a superman mod or what?

thanks smile.gif and oh if its superman is it controllable?

Frank.s
  • Frank.s

  • The Yardies
  • Joined: 15 Apr 2008

#28

Posted 14 November 2011 - 04:00 PM Edited by Frank.s, 14 November 2011 - 04:04 PM.

Incredible work Alexander. cookie.gif cookie.gif

QUOTE (GTA5Videos @ Monday, Nov 14 2011, 14:36)
is that a superman mod or what?

No flying ability, it actually gives infinite ammo on all guns and infinite health.

Fantaseb
  • Fantaseb

    One Nation, One Love, But Who? ;)

  • BUSTED!
  • Joined: 17 Oct 2011

#29

Posted 14 November 2011 - 05:50 PM

QUOTE (Alexander Blade @ Monday, Nov 7 2011, 17:36)
G'day modders ! biggrin.gif

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 .

Installing :
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 :
CODE
scocl.exe <globals version> <filein> <dirout> <options>


<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

Examples :
CODE
scocl.exe GTAIV "c:\gta\scripts\main.c" "c:\gta\scripts\out\"
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 :
CODE
v0.8 ( 7 Nov 2011 )
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 , so i had uploaded the pack of the OpenIV decompiled scripts from GTA IV , TLAD and TBOGT . 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.

Saves :
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[4] .

Examples :
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 :
user posted image user posted image user posted image

Links :
Download scocl http://Alexander.San...es/IV.Scocl.zip
Download decompiled scripts pack http://Alexander.San....tlad.tbogt.zip
Download latest free version of the MSVS http://www.microsoft...express/Windows


Plans for this week :
CLEO IV . The same thing as was for SA . Project is already started and it works fine with my EFLC , im planning to add support of all patches and publish cleo . Cleo IV suports script saving , like it was in Cleo 3 for SA , also the most incredible thing is that u can create ur own cleo missions without affecting original scripts and saves ! smile.gif

Okay well I have a question, how do I use this? I have extracted all of the files from Script_Network.img into the same folder as the program and I can even edit them .Sco files in this program, you need to make a tut. Thanks

Alexander Blade
  • Alexander Blade

    Come As You Are

  • Members
  • Joined: 05 Nov 2006

#30

Posted 14 November 2011 - 09:45 PM

the point is that everyone who can actually code scripts can handle everything regarding scocl by himself cuz all needed info for such people is already available in the *.chm
scripts of gta iv is a lot more than sa and all previous versions , u need to have C coding skillz anyway to use this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users