Re: New GTA2 Script Compiler Preview v0.1
Posted: 02 Jul 2012, 20:29
by B-$hep
T.M. wrote:...
Yes i know my friend. I apologize, but as i said, i was very very tired when i uploaded this stuff.
I was awake whole night and i wasn't even thinking clearly. I forgot to mention many things, not only you but about compiler also. But anyway, i will create a source pack for you and will send PM soon.
I fixed my mistake.
Elypter or anybody, who downloaded the 7zip pack here:
1) Did you tried to compile the script?
2) Did you executed it with GTA2?
3) Did it work for you? I mean IDE and GTA2MISS.exe?
4) Any errors (error messages anywhere)?
I forgot to mention that this script was designed for ste.gmp map, that ships with GTA2.
It has a parking lot near church, and the cars and bus supposed to be there and parked.
I use GTA2 Power Manager to quickly test maps and script. It makes it very easy and quick. I love it.
Just make sure to check "Skip Frontend"
Re: New GTA2 Script Compiler Preview v0.1
Posted: 12 Mar 2013, 21:40
by B-$hep
Just want you to know that i still work on this thing. It's going very nicely.
I take it with small steps. And i want this thing to be binary compatible with original scr files except of course the junk data at the end of the .scr files. Everything else must be exactly same.
Otherwise it will crash even without that, GTA2 .scripting is unstable enough.
So far i have pretty much worked on "interesting" things like, cars, players, generators things.
So for ex script like this compiles and works fine and is 99% match with miss2 binaries, except junk data, because it's not needed:
[MIS]/* VENERIC ISLE
created by Jozodezokokotar
ICQ: 319-945-345
DECLARE PLAYERS & VARIABLES */
PLAYER_PED PLAYER_1 = ( 115.0 , 128.5 , 3.0 ) 0 180
PLAYER_PED PLAYER_2 = ( 115.0 , 113.5 , 3.0 ) 2 0
PLAYER_PED PLAYER_3 = ( 122.0 , 121.0 , 3.0 ) 4 270
PLAYER_PED PLAYER_4 = ( 108.0 , 121.0 , 3.0 ) 3 90
PLAYER_PED PLAYER_5 = ( 124.6 , 110.5 , 4.0 ) 13 90
PLAYER_PED PLAYER_6 = ( 104.0 , 132.0 , 4.0 ) 12 315
CHAR_DATA pl1_helfer
CHAR_DATA pl2_helfer
CHAR_DATA pl3_helfer
CHAR_DATA pl4_helfer
CHAR_DATA pl5_helfer
CHAR_DATA pl6_helfer
DECLARE_POLICELEVEL ( 1 )
DECLARE_FINISH_SCORE ( 0 )
DECLARE_TOTAL_MISSIONS ( 0 )
DECLARE_TOTAL_SECRETS ( 0 )
// DECLARE CARS
PARKED_CAR_DATA swatvan1 = ( 116.9 , 131.8 , 3.0 ) -1 315 SWATVAN
PARKED_CAR_DATA miara = ( 115.2 , 131.6 , 3.0 ) 9 45 MIURA
PARKED_CAR_DATA meteor = ( 114.1 , 131.6 , 3.0 ) 10 45 STRATOSB
PARKED_CAR_DATA michelli = ( 112.8 , 131.6 , 3.0 ) 34 45 T2000GT
PARKED_CAR_DATA swatvan2 = ( 117.1 , 110.1 , 3.0 ) -1 225 SWATVAN
PARKED_CAR_DATA stinger = ( 115.2 , 110.3 , 3.0 ) 30 135 STINGRAY
PARKED_CAR_DATA wellard = ( 114.1 , 110.3 , 3.0 ) 13 135 ALLARD
PARKED_CAR_DATA atype = ( 112.8 , 110.3 , 3.0 ) 34 135 RTYPE
PARKED_CAR_DATA furore = ( 122.6 , 122.6 , 3.0 ) 33 135 ZCX5
PARKED_CAR_DATA ztype = ( 107.4 , 119.4 , 3.0 ) 11 315 VTYPE
PARKED_CAR_DATA rumbler = ( 106.0 , 123.5 , 3.0 ) 21 260 WBTWIN
PARKED_CAR_DATA jeffry = ( 124.5 , 119.2 , 3.0 ) 5 45 JEFFREY
PARKED_CAR_DATA garbaget = ( 90.8 , 121.5 , 3.0 ) 29 45 GTRUCK
PARKED_CAR_DATA apc = ( 86.0 , 119.0 , 3.0 ) -1 170 APC
PARKED_CAR_DATA blackvan = ( 120.5 , 141.7 , 3.0 ) 2 315 VAN
PARKED_CAR_DATA karmabus = ( 123.1 , 98.0 , 3.0 ) -1 225 KRSNABUS
PARKED_CAR_DATA copcar1 = ( 107.5 , 139.4 , 3.0 ) -1 180 COPCAR
PARKED_CAR_DATA copcar2 = ( 122.5 , 102.6 , 3.0 ) -1 0 COPCAR
PARKED_CAR_DATA parked_trailer1 = ( 124.1 , 142.0 , 3.0 ) 16 315 truktrns
PARKED_CAR_DATA parked_trailer2 = ( 91.0 , 118.0 , 3.0 ) 21 45 truktrns
PARKED_CAR_DATA parked_trailer3 = ( 137.9 , 117.0 , 3.0 ) 29 45 truktrns
PARKED_CAR_DATA truckcabsx = ( 125.5 , 95.6 , 3.0 ) 32 315 TRUKCAB2
PARKED_CAR_DATA armyjeep = ( 118.0 , 142.0 , 3.0 ) -1 0 GUNJEEP
PARKED_CAR_DATA oiljeep = ( 135.8 , 116.8 , 3.0 ) -1 45 JEEP
PARKED_CAR_DATA fbicar = ( 90.5 , 119.5 , 3.0 ) -1 45 EDSELFBI
PARKED_CAR_DATA firetruck1 = ( 108.5 , 139.7 , 3.0 ) -1 180 FIRETRUK
PARKED_CAR_DATA firetruck2 = ( 121.5 , 102.3 , 3.0 ) -1 0 FIRETRUK
PARKED_CAR_DATA dummy1 = ( 105.0 , 106.5 , 3.0 ) -1 45 JEEP
PARKED_CAR_DATA dummy2 = ( 96.8 , 120.9 , 3.0 ) -1 90 SWATVAN
PARKED_CAR_DATA dummy3 = ( 133.0 , 121.0 , 3.0 ) -1 270 APC
PARKED_CAR_DATA car_pl1 = ( 112.2 , 129.2 , 3.0 ) 31 135 GT24640
PARKED_CAR_DATA car_pl2 = ( 118.6 , 113.6 , 3.0 ) 28 315 GT24640
PARKED_CAR_DATA car_pl3 = ( 124.6 , 120.5 , 3.0 ) 20 90 GT24640
PARKED_CAR_DATA car_pl4 = ( 105.4 , 120.5 , 3.0 ) 35 270 GT24640
PARKED_CAR_DATA car_pl5 = ( 127.5 , 111.5 , 3.0 ) 27 45 GT24640
PARKED_CAR_DATA car_pl6 = ( 104.8 , 134.5 , 3.0 ) 34 80 GT24640
// DECLARE WEAPONS
GENERATOR machine_gun1 = ( 113.0 , 126.0 , 3.0 ) 0 COLLECT_01 200 800 10
GENERATOR machine_gun2 = ( 117.0 , 116.0 , 3.0 ) 0 COLLECT_01 200 800 10
GENERATOR machine_gun3 = ( 134.5 , 126.6 , 4.0 ) 0 COLLECT_01 600 800 15
GENERATOR machine_gun4 = ( 121.0 , 127.0 , 4.0 ) 0 COLLECT_01 200 800 10
GENERATOR machine_gun5 = ( 104.0 , 111.2 , 4.0 ) 0 COLLECT_01 200 800 10
GENERATOR silenced_machine1 = ( 120.0 , 123.0 , 3.0 ) 0 COLLECT_09 200 800 10
GENERATOR silenced_machine2 = ( 110.0 , 119.0 , 3.0 ) 0 COLLECT_09 200 800 10
GENERATOR silenced_machine3 = ( 104.6 , 133.6 , 4.0 ) 0 COLLECT_09 600 800 15
GENERATOR silenced_machine4 = ( 119.5 , 102.5 , 3.0 ) 0 COLLECT_09 600 800 15
GENERATOR silenced_machine5 = ( 95.5 , 115.4 , 4.0 ) 0 COLLECT_09 600 800 15
GENERATOR shotgun1 = ( 117.0 , 126.0 , 3.0 ) 0 COLLECT_06 200 800 16
GENERATOR shotgun2 = ( 120.0 , 119.0 , 3.0 ) 0 COLLECT_06 200 800 16
GENERATOR shotgun3 = ( 113.0 , 116.0 , 3.0 ) 0 COLLECT_06 200 800 16
GENERATOR shotgun4 = ( 110.0 , 123.0 , 3.0 ) 0 COLLECT_06 200 800 16
GENERATOR dual_pistol1 = ( 126.0 , 132.4 , 4.0 ) 0 COLLECT_10 200 800 32
GENERATOR dual_pistol2 = ( 126.0 , 109.0 , 4.0 ) 0 COLLECT_10 200 800 32
GENERATOR dual_pistol3 = ( 104.0 , 109.8 , 4.0 ) 0 COLLECT_10 200 800 32
GENERATOR dual_pistol4 = ( 109.0 , 127.0 , 4.0 ) 0 COLLECT_10 200 800 32
GENERATOR flamethrower = ( 109.5 , 111.5 , 5.0 ) 0 COLLECT_08 1200 3600 5
GENERATOR electro_gun = ( 120.5 , 130.5 , 5.0 ) 0 COLLECT_03 1200 3600 5
GENERATOR rocket_launcher1 = ( 124.5 , 115.5 , 5.0 ) 0 COLLECT_02 1200 3600 2
GENERATOR rocket_launcher2 = ( 105.5 , 126.5 , 5.0 ) 0 COLLECT_02 1200 3600 2
GENERATOR rocket_launcher3 = ( 120.6 , 92.5 , 3.0 ) 0 COLLECT_02 1200 3600 2
GENERATOR invisibility = ( 115.0 , 121.0 , 3.0 ) 0 COLLECT_39 9800 9900
GENERATOR pistol1 = ( 102.4 , 131.4 , 4.0 ) 0 COLLECT_00 200 800 99
GENERATOR pistol2 = ( 126.0 , 111.0 , 4.0 ) 0 COLLECT_00 200 800 99
GENERATOR molotov1 = ( 102.5 , 116.5 , 4.0 ) 0 COLLECT_04 600 800 6
GENERATOR molotov2 = ( 134.4 , 123.6 , 3.0 ) 0 COLLECT_04 600 800 6
GENERATOR molotov3 = ( 104.0 , 139.0 , 3.0 ) 0 COLLECT_04 600 800 6
GENERATOR grenade1 = ( 117.5 , 102.5 , 3.0 ) 0 COLLECT_05 600 800 8
GENERATOR grenade2 = ( 126.8 , 122.2 , 3.0 ) 0 COLLECT_05 600 800 8
GENERATOR grenade3 = ( 95.5 , 118.5 , 3.0 ) 0 COLLECT_05 600 800 8
GENERATOR armour1 = ( 104.0 , 110.5 , 4.0 ) 0 COLLECT_31 600 1200
GENERATOR armour2 = ( 126.0 , 131.6 , 4.0 ) 0 COLLECT_31 600 1200
GENERATOR health1 = ( 120.5 , 111.5 , 5.0 ) 0 COLLECT_30 600 1200
GENERATOR health2 = ( 109.5 , 130.5 , 5.0 ) 0 COLLECT_30 600 1200
GENERATOR double_damage = ( 126.0 , 110.0 , 4.0 ) 0 COLLECT_35 6400 7200
GENERATOR double_fire_rate = ( 102.4 , 133.6 , 4.0 ) 0 COLLECT_36 6400 7200
GENERATOR cop_bribe = ( 100.0 , 106.0 , 3.0 ) 0 COLLECT_33 600 800
GENERATOR gang_powerup = ( 130.0 , 136.0 , 3.0 ) 0 COLLECT_40 3800 4200
GENERATOR electrofingers = ( 100.0 , 136.0 , 3.0 ) 0 COLLECT_37 600 1200
GENERATOR car_oil = ( 105.5 , 115.5 , 5.0 ) 0 COLLECT_16 3800 4200 5
GENERATOR car_bomb = ( 130.0 , 106.0 , 3.0 ) 0 COLLECT_15 3800 4200
GENERATOR instant_bomb = ( 124.5 , 126.5 , 5.0 ) 0 COLLECT_23 3800 4200
LEVELSTART
// WEAPONS RESPAWN pt.2
SWITCH_GENERATOR ( flamethrower , ON )
SWITCH_GENERATOR ( electro_gun , ON )
SWITCH_GENERATOR ( rocket_launcher1 , ON )
SWITCH_GENERATOR ( rocket_launcher2 , ON )
SWITCH_GENERATOR ( rocket_launcher3 , ON )
SWITCH_GENERATOR ( invisibility , ON )
SWITCH_GENERATOR ( molotov1 , ON )
SWITCH_GENERATOR ( molotov2 , ON )
SWITCH_GENERATOR ( molotov3 , ON )
SWITCH_GENERATOR ( grenade1 , ON )
SWITCH_GENERATOR ( grenade2 , ON )
SWITCH_GENERATOR ( grenade3 , ON )
SWITCH_GENERATOR ( armour1 , ON )
SWITCH_GENERATOR ( armour2 , ON )
SWITCH_GENERATOR ( health1 , ON )
SWITCH_GENERATOR ( health2 , ON )
SWITCH_GENERATOR ( cop_bribe , ON )
SWITCH_GENERATOR ( gang_powerup , ON )
SWITCH_GENERATOR ( electrofingers , ON )
SWITCH_GENERATOR ( car_oil , ON )
SWITCH_GENERATOR ( car_bomb , ON )
SWITCH_GENERATOR ( instant_bomb , ON )
LEVELEND
[/mis]
I really want to try out IF..THEN & WHILE's soon.
It would be very exciting.
REQUEST
If anybody here has bunch of scripts (.mis files) on your hard drive, any script, it doesn't matter short or big, please make a pack with them and upload to somewhere.
I need example .mis files as much as possible. To test different kinds of syntax and commands.
It would help alot.
So far i got bunch of them from Elypter packs, but i want more.
Currently 263 .mis files in my C:\Scripts folder.
I need more
Re: New GTA2 Script Compiler Preview v0.1
Posted: 13 Mar 2013, 10:16
by B-$hep
Hi T.M.
Thanks for the scripts.
Yes, i have looked into if-then's some time ago, just to see how they are done / used etc.
Just small sneak peak to this thing.
About finishing the compiler i want to tell you one thing.
It will be like with decompiler, i slowly worked on it, it was fun and then you came and basically finished the job with "1 day". But i asked you to not to code it and finish it. Even you said you don't have time. But you did it. OK what's done that's done. Im not mad or anything. I know there are better coders, like you. I wanted to try to finish the if-thens, while in your decompiler, but the source is not easy to understand. If i figure them out then i can only give you the stuff i figured out and you must add this to decompiler by yourself.
And i think same will be with compiler. You will make it in 1-2 days maybe and that's it.
But im bored atm and it's interesting to code and fun to run GTA2 to see if it crashes or something or doing a binary compare on .scr files after compile, etc.
If you will finish it withing few days, i don't have anything to do again.
Don't understand me wrong, im not mad at you because of this nor i will be, but im just telling you how it will go.
And im still very very thankful to your help and sources you gave out.
Of course i will give out the source fully, but i don't know when.
Im just afraid i will be out of job again.
EDIT:
You really should use more #ifdef #endif in your headers to avoid multiple declarations errors.
Or just #pragma once
It's very good practice. I got a bunch of errors from VC++ and wondered why. And then i discovered that you don't have these commands at the beginning of the header files.
I added and errors went away.
I know that scr decompiler dll compiles but when using stuff in other projects you (users) will have problems.
Re: New GTA2 Script Compiler Preview v0.1
Posted: 13 Mar 2013, 11:18
by T.M.
B-$hep wrote:About finishing the compiler i want to tell you one thing.
It will be like with decompiler, i slowly worked on it, it was fun and then you came and basically finished the job with "1 day". But i asked you to not to code it and finish it. Even you said you don't have time. But you did it.
Yeah. If you shared the code on the first place, i probably wouldnt have finished it myself. You know, when you tell a kid "no", he wants it even more.
Currently i really dont have any time, so no worries.
B-$hep wrote:I wanted to try to finish the if-thens, while in your decompiler, but the source is not easy to understand.
You probably have to rewrite some parts of the code anyways. It doesnt get linear anymore when the If's and While's are added. Currently it just outputs each command for each line. if/whiles need more trickier formatting and parsing logic.
Basically the decompiler just reads one command at a time, parses the values for each parameter, executes some custom functions for some of them (to keep track of stuff), and then outputs the line. I have added a lot of comments there, so it should be possible to understand the logic. If you read it all and still dont understand, i can explain more.
B-$hep wrote:If i figure them out then i can only give you the stuff i figured out and you must add this to decompiler by yourself.
Its best if you just make own decompiler from scratch, and then just parse the if/whiles, and forget about the CREATE_CAR etc other commands (you can just ignore them, or replace them with a simple DO_NOWT command. Though, that is trickier to add in the IF's like IF(delay(5)) or something. But in my decompiler source code you can find all those commands which are "boolean" so they return a bool value, which means they are used in if-structures. You can find them with these keywords in the scr_functions.h: TWO_PARAMS_LAYOUT_BOOL, FOUR_PARAMS_LAYOUT_BOOL, CUSTOM_STRUCT_LAYOUT_BOOL, ZERO_PARAMS_LAYOUT_BOOL.
B-$hep wrote:And i think same will be with compiler. You will make it in 1-2 days maybe and that's it.
I wont. I have other stuff to be busy with. Honestly.
B-$hep wrote:You really should use more #ifdef #endif in your headers to avoid multiple declarations errors.
Or just #pragma once
It's very good practice. I got a bunch of errors from VC++ and wondered why. And then i discovered that you don't have these commands at the beginning of the header files.
I added and errors went away.
I know that scr decompiler dll compiles but when using stuff in other projects you (users) will have problems.
Yeah the code is shitty, didnt really think how to make it "good", just wanted to make it easy as possible. Didnt really care either, since i knew nobody will use it anyways.
Here is something i figured from the IF's before:
[cpp]struct SCR_IF_JUMP {
SCR_CMD_FORMAT(
Uint16 logical_operator; // seems to be 0 for AND command and 1 for OR command.
Uint16 else_jump; // where will it jump if check was false.
);
};
string read_IF_JUMP(FPStruct ¶ms){
get_data(SCR_IF_JUMP, data);
if(params.header->return_value == 0 && data.logical_operator == 0){ // not sure about this.
return sprintf_str("ENDIF %s", hexdump(params,0).c_str());
}else{
return sprintf_str("%s", hexdump(params,1).c_str());
}
}[/cpp]
(taken from scr_functions.h end of file)
Re: New GTA2 Script Compiler Preview v0.1
Posted: 17 Mar 2013, 10:56
by B-$hep
Last night i messed with some commands, specially the CAR_DATA command.
And noticed that miss2 either forgot to initialize some of the stuff to 0 or it does something more.
Also T.M, if you are reading this...
Code: Select all
struct SCR_CAR_DATA_DEC {
SCR_CMD_FORMAT(
Uint16 varname;
What's the purpose of "varname". Is it even used?
Currently i init this to 0 and GTA2 still works fine.
Also the trailer model thingy, you said in sources that 0xFFFE is mini_car.
miss2 puts a 0x0000 instead of it.
In my compiler i write 0xFFFE if trailer is mini_car. GTA2 shows mini version of car although i don't know the purpose of it, i can't enter the car and control it. Probably for remote only.
There are some things that miss2 does differently, to be exact, it saves some "odd" looking stuff / values that i don't understand. And because of these values some bytes are different in compiled .scr. I mean odd stuff for CAR_DATA specifically.
If you see some missing "h" letters in my posts, im sorry, my keyboard is dying here.
Re: New GTA2 Script Compiler Preview v0.1
Posted: 18 Mar 2013, 14:55
by T.M.
B-$hep wrote:Last night i messed with some commands, specially the CAR_DATA command.
And noticed that miss2 either forgot to initialize some of the stuff to 0 or it does something more.
Also T.M, if you are reading this...
Code: Select all
struct SCR_CAR_DATA_DEC {
SCR_CMD_FORMAT(
Uint16 varname;
What's the purpose of "varname". Is it even used?
Currently i init this to 0 and GTA2 still works fine.
Its used in the CREATE_CAR command (read under the first function that uses that struct), it uses the exact same struct. For CAR_DATA command it is not used at all. You can set it to zero indeed. Varname purpose is to store the variable identifier, aka pointer, so we can refer to it later in the code.
Only variables you need to ignore completely are those named "unk1", "unk2" etc.. or "unknown" etc...
B-$hep wrote:Also the trailer model thingy, you said in sources that 0xFFFE is mini_car.
miss2 puts a 0x0000 instead of it.
Yes. miss2 is crazy. dont trust it... there are lots of bugs in it with those commands! for some commands MINI_CAR doesnt even work! but if you add 0xFFFE manually in the SCR file, then it works in gta2!
B-$hep wrote:In my compiler i write 0xFFFE if trailer is mini_car. GTA2 shows mini version of car although i don't know the purpose of it, i can't enter the car and control it. Probably for remote only.
Not sure what happened there, but there are lots of bugs indeed. I cant remember what was the logic anymore.........
Did you read this?
Code: Select all
if(data.trailer_id == 0xFFFE){ // note: compiler doesnt make MINI_CAR in car declarations!
optional = " MINI_CAR";
}else if(data.trailer_id != 0xFFFF){ // note: compiler doesnt make trailer in 2d car declarations!
optional = string(" ")+enum_cstr(CARS,data.trailer_id);
}
Just make the compiler so it makes code that works in GTA2. dont check your stuff with miss2, its buggy as hell.
B-$hep wrote:There are some things that miss2 does differently, to be exact, it saves some "odd" looking stuff / values that i don't understand. And because of these values some bytes are different in compiled .scr. I mean odd stuff for CAR_DATA specifically.
If you see some missing "h" letters in my posts, im sorry, my keyboard is dying here.
Those odd things are uninitialized bytes, just random trash, ignore them.
Perhaps its best if you create own struct for each of the commands.... currently im sharing same struct for multiple commands. Dunno really what is the easiest way. You need to think that yourself, i cant remember much from this, been year or two since i made it?