New GTA2 Script Compiler

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler

Post by T.M. »

Sektor wrote:Don’t make it too smart, a counter can contain a player address and is used that way in some of my scripts.
Yeah, actually it might be more interesting if there were no limitations at all. Might open new doors for new hacks. Although, there probably should be an option to enable "safe mode" which prevents accidental bugs.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

T.M
do you have ID numbers of all occupations listed here?

https://projectcerbera.com/gta/2/tutorials/character-ai

I only have these

Code: Select all

		OccupTypes[L"no_occupation"] = 51;
		OccupTypes[L"dummy"] = 3;
		OccupTypes[L"psycho"] = 14;
		OccupTypes[L"mugger"] = 15;
		OccupTypes[L"bank_robber"] = 17;
		OccupTypes[L"criminal_type1"] = 33;
		OccupTypes[L"criminal_type2"] = 34;
		OccupTypes[L"tank_driver"] = 36;
		OccupTypes[L"drone"] = 41;
		OccupTypes[L"refugees"] = 45;
		OccupTypes[L"any_law_enforcement"] = 46;
		OccupTypes[L"any_emergency_service_man"] = 47;
		OccupTypes[L"any_gang_member"] = 48;
		OccupTypes[L"any_elvis"] = 49;
		OccupTypes[L"fireman"] = 38;
Thanks.

In the meantime i try to figure them out..
Always wear safety glasses while programming.
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler

Post by Sektor »

User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Yes, good but im wondering why this:
"These aren't in the compiler and can't be set with SET_CHAR_OCCUPATION command."

Is this fact or... ?

If they are not in compiler how it compiles these then?

SET_CHAR_OCCUPATION needs his special list ?


Weird
Always wear safety glasses while programming.
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler

Post by Sektor »

Maybe you can set them with your own compiler, just not with official compiler. Gta2 might use that command to set occupations like medic or another command, either way it doesn’t have the same restrictions as the compiler.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Ok, i will test the SET_CHAR_OCCUPATION today.

I now implemented the CREATE_CHAR.

Thanks for the occup. list Sektor.

This now compiles also. Nothing new to implement, just copy paste code pieces.

100% match with miss2 scr file.

[mis]PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 0 0
char_data bot1
char_data bot2
char_data bot3
char_data bot4
char_data bot5
char_data bot6
char_data bot7
char_data bot8
char_data bot9
bot2 = CREATE_CHAR ( 134.5 , 102.0 ) 24 270 player END
bot2 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 dummy END
bot3 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 psycho END
bot4 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 mugger END
bot5 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 carthief END
bot6 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 bank_robber END
bot7 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 criminal END
bot8 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 elvis END
bot9 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 police END//
bot1 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 swat END
bot2 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 fbi END
bot3 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 army END
bot4 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 guard END
bot5 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 GUARD_AGAINST_PLAYER END
bot6 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 criminal_type1 END
bot7 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 criminal_type2 END
bot8 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 SPECIAL_GROUP_MEMBER END
bot9 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 TANK_DRIVER END
bot1 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 fireman END
bot2 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 ROAD_BLOCK_TANK_MAN END
bot3 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 DRONE END
bot4 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 STAND_STILL_BLOKE END
bot5 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 ELVIS_LEADER END
bot6 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 REFUGEES END
bot7 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 ANY_LAW_ENFORCEMENT END
bot8 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 ANY_EMERGENCY_SERVICE_MAN END
bot9 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 ANY_GANG_MEMBER END
bot8 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 ANY_ELVIS END
bot9 = CREATE_CHAR ( 134.5 , 102.0 , 2.0 ) 24 270 NO_OCCUPATION END



LEVELSTART

LEVELEND[/mis]

But i dont update the attached compiler each time.
I will do some "small" major things and then i will update the attached compiler.


EDIT: scripting doc says about SET_CHAR_OBJECTIVE: "Not applicable to the player’s char!"

This is something!
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler

Post by T.M. »

B-$hep wrote:T.M
do you have ID numbers of all occupations listed here?
My decompiler has all strings that are decompileable, check the sources, i cant remember how much there are actually. Should be all though.

http://gtamp.com/forum/viewtopic.php?f=4&t=447

Hope that helps.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Ok, i will try to work out the missionscript stuff.
I have read previously and looked inside mission script .scr files, they are a bit different on the top but rest should be same.
But i take a fresh look.

Trying to figure out where the pointers point to.

And maybe i can even test a little mission script compiled by gta2miss09 later today in GTA2.

Currently i just have base script:
[mis]PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 25 0
LEVELSTART
launch_mission(test2.mis)
LEVELEND[/mis]

and that missionscript test2:
[mis]missionstart

missionend[/mis]

But of course writing of the test2.scr isnt working, well it kinda works but the pointers at the top should be generated correctly.
And maybe something else.


DO_PHONE_TEMPLATE,etc also needs special handling.

If i implement the multiscript support fully and the NOT command then i basically can try to compile that example included: BIL.MIS, with all other scripts in bil folder and see how it goes.
But i think there is also some DOOR related commands that are not working fully. I must have a look

Another thing is that i can "comment" or remove all unneeded mission script stuff from bil.mis and just compile the important things.
Makes a bit easier to debug if GTA2 crashes for some reason.
Easier to compare scr files (or whats important, find out what command made the crash),if there is not so much code.


EDIT:
After quick look into these 2 scr files above i noticed interesting thing.
[mis]PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 25 0
LEVELSTART
launch_mission(test2.mis)
LEVELEND[/mis]
Is looking like its combined into 1, just files are separately, in game memory they become like 1 script i guess:

[mis]1 PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 25 0
2 LEVELSTART
3 launch_mission(test2.mis)
4 LEVELEND
5 missionstart
6 missionend
[/mis]

LEVELEND command index is 4
and MISSIONSTART command index is 5.

So script continues in test2.scr file kinda....
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

I worked a bit on #IFDEF PC #ELSE #ENDIF sequence.
Rewrote some of the things related to it. Better logic.

I noticed bad bug in this today and fixed it.

I completely ignore PSX platform atm, becaause its not important currently and who uses it anyway?!


But i have to go thru each command and add some additional code for each command. Just 2 lines of code.
I tried to figure out how to make it without going thru all the commands and adding the 2 lines related to #ifdef but i dont think its possible.

There is ~11800 lines of C++ code in one file related to commands.. But i think i will use regex to insert these 2 lines to each command. I hate scrolling thru all these..


[mis]PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 0 0 // 5 commands, 24 bytes test2
LEVELSTART
#ifdef pc
DO_NOWT
DO_NOWT
//LIGHT k_m_1_light_121
#ELSe
DO_NOWT
//LIGHT k_m_1_light_1
//LIGHT k_m_1_light_12
#ENDIF
//launch_mission(test2.mis)
//launch_mission(test3.mis)
LEVELEND[/mis]
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler

Post by T.M. »

B-$hep wrote:But i have to go thru each command and add some additional code for each command. Just 2 lines of code.
Sounds like you have to generalize a lot of your code, care to show some in private message, maybe i can give some ideas?
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Code is generalized but when i did this all i didnt think about this stuff.
Now i kinda made it.

Do you know, how to compile for PSX with miss2?

How it knows when to compile to this platform? Currently it ignores PSX.
Is there (hidden) commandline option?

Just curious.
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

One thing i also dont understand how the miss2 calculates script size and line count.
Seems there is some hidden command included in calculation.

For example:
[mis]PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 0 0 // 5 commands, 24 bytes test2
LEVELSTART
DO_NOWT
LEVELEND[/mis]

1 PLAYER_PED EXEC 2 (15237120,12582912,131072) 0 0
2 LEVEL_START 3
3 DO NOWT 4
4 LEVEL_END -1



Miss2 displays script size: 60 bytes
and commands count 5.
Makes no sense.

Max size i can get from this is: 52.
8+8+28+8 = 52

and where is line 5???
Weird...

I will try to look into .scr file and calculate on "fingers".

EDIT: looked into .scr file and it seems it includes the first 8 weird bytes: 00 00 00 00 E8 FD 12 00 also into calculation.
Usually there is 84FD12 but sometimes it changes (84FD12 like i said). Probably just "start marker" some kind.
New compiler always writes same bytes into this location, probably could be set all to 0, but let it be like this for now.


EDIT2: #IF..#ELSE..#ENDIF now works fine. Crappy command thats just not needed anyway but just because of compatibility with miss2 it must be included.
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler

Post by T.M. »

B-$hep wrote:Do you know, how to compile for PSX with miss2?

How it knows when to compile to this platform? Currently it ignores PSX.
Is there (hidden) commandline option?
really? well i doubt anyone uses PSX anyways so better to just ignore it.
B-$hep wrote:EDIT: looked into .scr file and it seems it includes the first 8 weird bytes: 00 00 00 00 E8 FD 12 00 also into calculation.
Usually there is 84FD12 but sometimes it changes (84FD12 like i said). Probably just "start marker" some kind.
New compiler always writes same bytes into this location, probably could be set all to 0, but let it be like this for now.
i guess that is header information.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Noticed again one of the miss2 weird thing(s)/bug(s).

This compiles and works OK
[mis]#ifdef PC
MAP_ZONE B17 = ( 200 , 0 , 0 , 0 , 300 , 200 , 200 , 10 , 590 , 0 , 900 )
do_nowt
#endif[/mis]

But if you mess it up to save some space in mis file:
[mis]#ifdef PC MAP_ZONE B17 = ( 200 , 0 , 0 , 0 , 300 , 200 , 200 , 10 , 590 , 0 , 900 )
do_nowt #endif[/mis]


It completely confuses miss2. It writes wrong stuff into scr file.
I thought its bug in my compiler, wasted 2 days to figure out whats wrong. And again, its because of miss2 compiler bug.

In new compiler this code "packing" is not a problem.
You can write even this (miss2 doesnt allow this):
[mis]#ifdef PC MAP_ZONE B17 = ( 200 , 0 , 0 , 0 , 300 , 200 , 200 , 10 , 590 , 0 , 900 ) do_nowt #endif[/mis]

No probs.


What a garbage this Visual Parse ++ was, what they used for miss2.
And they asked so much money for it.


EDIT:
noticed bug in new compiler in "map_zone" command.
Script like this caused some wrong indexes. Now it works.
It was related to string headers
[mis]PLAYER_PED shaft = ( 44.5 , 102.0 , 2.0 ) 25 0
ARROW_DATA arrow
ARROW_DATA arrow_2
ARROW_DATA arrow_3
ARROW_DATA arrow_4
ARROW_DATA arrow_end
MAP_ZONE B01 = ( 0 , 0 , 0 , 0 , 200 , 0 , 0 , 0 , 1000 , 0 , 200 )
MAP_ZONE B02 = ( 0 , 0 , 0 , 0 , 300 , 0 , 0 , 0 , 1000 , 0 , 200 )
MAP_ZONE B03 = ( 0 , 0 , 0 , 0 , 200 , 0 , 0 , 0 , 1000 , 0 , 200 )
MAP_ZONE B04 = ( 0 , 0 , 0 , 0 , 300 , 0 , 0 , 0 , 1000 , 0 , 200 )
MAP_ZONE B05 = ( 0 , 0 , 0 , 0 , 400 , 0 , 0 , 0 , 1000 , 0 , 200 )
MAP_ZONE B06 = ( 0 , 0 , 0 , 0 , 200 , 0 , 0 , 0 , 1000 , 0 , 200 )
MAP_ZONE B07 = ( 0 , 0 , 0 , 0 , 300 , 0 , 0 , 0 , 1000 , 0 , 200 )
MAP_ZONE B08 = ( 0 , 0 , 0 , 0 , 400 , 0 , 0 , 0 , 1000 , 0 , 200 )
MAP_ZONE B09 = ( 400 , 100 , 100 , 500 , 600 , 0 , 0 , 0 , 0 , 1000 , 0 )
MAP_ZONE B10 = ( 400 , 100 , 100 , 500 , 600 , 0 , 0 , 0 , 0 , 1000 , 0 )
MAP_ZONE B11 = ( 300 , 100 , 500 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 )
MAP_ZONE B12 = ( 300 , 300 , 300 , 0 , 100 , 0 , 0 , 0 , 1000 , 0 , 100 )
MAP_ZONE B13 = ( 300 , 300 , 300 , 0 , 100 , 0 , 0 , 0 , 1000 , 0 , 100 )
MAP_ZONE B14 = ( 300 , 300 , 300 , 0 , 100 , 0 , 0 , 0 , 1000 , 0 , 100 )
MAP_ZONE B15 = ( 300 , 100 , 500 , 0 , 50 , 0 , 0 , 0 , 800 , 0 , 100 )
MAP_ZONE B16 = ( 300 , 100 , 500 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 )
#ifdef PC
MAP_ZONE B17 = ( 200 , 0 , 0 , 0 , 300 , 200 , 200 , 10 , 590 , 0 , 900 )
do_nowt
#endif
do_nowt
do_nowt
do_nowt
do_nowt
MAP_ZONE B18 = ( 300 , 100 , 500 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 )
MAP_ZONE B181 = ( 300 , 100 , 500 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 )
do_nowt
do_nowt
do_nowt
do_nowt
MAP_ZONE B184 = ( 300 , 100 , 500 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 )
do_nowt
levelstart
LEVELEND[/mis]

There is #ifdef PC and MAP_ZONE in it. String header ID was wrong for last MAP_ZONE. I assigned for some reason "variable_counter_number" to it but it should be "current_command_index_number".

There are few other commands that use string headers but they should work fine. They already have correct indexes assigned.

EDIT2:
This also shows miss2 bug.
Scr file is "messed up", some stuff is skipped and not even written to the file.
LEVELSTART, LEVELEND is missing completely.

Notice where the last */ is: // white top right*/
[mis]PLAYER_PED shaft = ( 44.5 , 102.0 , 2.0 ) 25 0
OBJ_DATA storagerocket8
/*
OBJ_DATA srpayshop01 = ( 122.0 , 115.0 , 2.0 ) 0 car_shop 2 // black bottom right
OBJ_DATA sprayshop02 = ( 103.0 , 115.0 , 2.0 ) 0 car_shop 5 // green bottom left
OBJ_DATA sprayshop03 = ( 103.0 , 97.0 , 2.0 ) 0 car_shop 10 // yellow top left
OBJ_DATA sprayshop04 = ( 122.0 , 97.0 , 2.0 ) 0 car_shop 33 // white top right*/
OBJ_DATA BOLLARD1 = ( 131.5 , 134.5 , 4.0 ) 90 mine

levelstart
levelend[/mis]

Move this */ down:
[mis]PLAYER_PED shaft = ( 44.5 , 102.0 , 2.0 ) 25 0
OBJ_DATA storagerocket8
/*
OBJ_DATA srpayshop01 = ( 122.0 , 115.0 , 2.0 ) 0 car_shop 2 // black bottom right
OBJ_DATA sprayshop02 = ( 103.0 , 115.0 , 2.0 ) 0 car_shop 5 // green bottom left
OBJ_DATA sprayshop03 = ( 103.0 , 97.0 , 2.0 ) 0 car_shop 10 // yellow top left
OBJ_DATA sprayshop04 = ( 122.0 , 97.0 , 2.0 ) 0 car_shop 33 // white top right
*/
OBJ_DATA BOLLARD1 = ( 131.5 , 134.5 , 4.0 ) 90 mine

levelstart
levelend[/mis]

And it generates correct scr file..
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Found 1-2 commands that were not implemented, now they are added.

I know there are some more that TM discovered and that are not documented at all. But i will work on them later.


Now i will work on writing mission scripts .scr files correctly.
Because 99% of the included script bil.mis from miss2 example folder, this compiles.
But it doesnt generate the mission scr files atm.

Also the NOT command must be implemented.

But i commented out few lines from bil.mis and it compiles fine and works in GTA2. No crashes.
There were few crashes but thanks to this i fixed some of the bugs from 1-3 commands.
Now it looks stable.

These i commented out:
[mis] IF ( ( counter_all_missions_passed = 21 )
AND ( flag_on_mission = 0 ) )
SET counter_all_missions_passed = 22
LAUNCH_MISSION ( bil_end.mis )
ENDIF


IF ( ( ( CHECK_SCORE_GREATER ( shaft , 4999999 ) )
AND ( flag_on_mission = 0 ) )
AND ( flag_reached_finish_score = 0 ) )
LEVEL_END_POINT_ARROW_AT ( arrow_end , 44.5 , 99.0 , 3.0 )
SET flag_reached_finish_score = 1
DISPLAY_BRIEF ( 3752 )
ENDIF

IF ( ( ( flag_reached_finish_score = 1 )
AND ( flag_on_mission = 1 ) )
AND ( CHECK_SCORE_GREATER ( shaft , 4999999 ) ) )
REMOVE_ARROW ( arrow_end )
SET flag_reached_finish_score = 0
ENDIF

IF ( ( ( flag_reached_finish_score = 1 )
AND ( flag_on_mission = 0 ) )
AND ( NOT ( CHECK_SCORE_GREATER ( shaft , 4999999 ) ) ) )
REMOVE_ARROW ( arrow_end )
SET flag_reached_finish_score = 0
DISPLAY_BRIEF ( 3753 )
ENDIF

IF ( ( ( flag_reached_finish_score = 1 )
AND ( flag_on_mission = 0 ) )
AND ( LOCATE_CHARACTER_ANY_MEANS ( shaft , 44.5 , 99.0 , 3.0 , 1.0 , 1.0 ) ) )
FINISH_LEVEL ( bonus_1 )
ENDIF[/mis]

Primarily because of LAUNCH_MISSION ( bil_end.mis ) and NOT commands inside.


Also i must implement same check for mission scripts, so that the "FORWARD" command must be not the FIRST command in any mission script.
If it is, then error will be shown. Like in miss2.

Maybe there are some other commands in mission script .mis files that are not implemented, but my compiler shows clear message if the command is unknown. I will then make it work and continue.

I want to compile the whole example bil.mis soon, including mission scripts and run it in GTA2.
Then i will try to finish all missions and stuff and see if there will be any crashes, bugs or something.

I work on it.
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Ok, yesterday i worked on the NOT command, figured out the logic behind it.
I hope i got it all. Seems to work fine. When i first looked at this command it was so confusing.
But after a months of break from this command and doing other things it doesnt look so complicated.




About some other things..

This piece works without problem:
[mis] IF (( ( flag_reached_finish_score = 1 )
AND ( flag_on_mission = 0 ) )
AND ( IS_CAR_WRECKED( shaft) ) )
do_nowt
ENDIF
[/mis]

But this messes things up:
[mis] IF (( ( flag_reached_finish_score = 1 )
AND ( flag_on_mission = 0 ) )
AND ( CHECK_SCORE_GREATER ( shaft , 4999999 ) ) )
do_nowt
ENDIF[/mis]

The reason is the "BOOL commands", commands that check the condition of something and which return either true or false.
Again, i was confused what messed this IF.ENDIF up. I didnt know it yesterday but i looked today with fresh look and know the problem.

Actually its not a problem but "not implemented" BOOL commands.
The only and first one i ever made in this compiler, was the IS_CAR_WRECKED. And in IF..ENDIF statements the "checking" for BOOL command is only made for this command. It was years ago when i left comment in code, that later all BOOL commands should be added.

So i first work on this CHECK_SCORE_GREATER, will implement this and see if this fixes this messed up .scr file.
But i know this what i have to do. Its not hard, just add command_id values inside C++ conditional statement (The statement that checks specific things when generating header.cmd_next values.) for all these commands that check different things and thats all.



After this i work on writing mission .scr files.


EDIT:
Figured out how to add rest of the "BOOL commands". Did a simple test:
[mis]// player's normal start position
PLAYER_PED shaft = ( 44.5 , 102.0 , 2.0 ) 25 0
COUNTER c1 = 30
COUNTER c2 = 40
COUNTER flag_reached_finish_score = 0
SAVED_COUNTER flag_on_mission = 0
ARROW_DATA arrow

ARROW_DATA arrow_2

ARROW_DATA arrow_3

ARROW_DATA arrow_4

ARROW_DATA arrow_end
DECLARE_MISSION_FLAG ( shaft , flag_on_mission )

LEVELSTART
IF (( (( flag_reached_finish_score = 1 )
AND ( flag_on_mission = 0 ) )
AND ( is_car_wrecked(shaft) ) )
AND ( CHECK_SCORE_GREATER ( shaft , 4999999 ) )

)
do_nowt
ENDIF
IF (((

( is_car_wrecked(shaft) )
AND ( flag_on_mission = 0 ) )
AND ( CHECK_SCORE_GREATER ( shaft , 4999999 ) ))
AND( flag_reached_finish_score = 1 )
)
do_nowt
ENDIF


LEVELEND[/mis]

Works fine. 100% Match with miss2 scr files.
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Im at the point of compiling bil.mis and and its mission scripts.
Very exciting to see what compiles and what not.

I just implemented writing of mission scr files but of course the testing needs more time and game crashing i guess.

When trying to compile bil.mis, compiler noticed few commands are missing/not fully implemented:

[mis]DO_PHONE_TEMPLATE
DO_EASY_PHONE_TEMPLATE
START_BASIC_KF_TEMPLATE
DO_BASIC_KF_TEMPLATE[/mis]

But i will add them as "plain" templates so compiler just accepts the script but doesnt write anything for these commands in .scr file.
This way i can quickly try to compile again and check what errors come again.

Hopefully there will not be many..
I will edit this post as soon as anything new is to say..


cant wait to test this bil.mis and all mission scripts in GTA2 and actually play it, do all the missions, KFz etc.

BIL.mis is HUGE!!
Always wear safety glasses while programming.
Jones
Psycho
Psycho
Posts: 51
Joined: 08 Aug 2012, 21:25

Re: New GTA2 Script Compiler

Post by Jones »

Really awesome work! [respect] Its also fun following your progress. Do you already have an idea how and when you implement new commands? Probably best to begin with peek and poke. Your compiler could convert those to the respective CHANGE_GANG_CHAR_RESPECT commands internally and it would be more simple to use those. Based on those we could build a "standard library" for all those goodies in the code snippets and memory addresses threads :-)
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Yep, about new commands i had same idea, make new command and do the internals in the background, i havent tried to do this but for example we can have command like: GETINTHECAR_AND_DRIVEAWAY(pedname, carname)

I can combine multiple commands into just this one and it will make the player or ped you created to get to the car, start it and drive away.

I guess there are some other commands that do specific things in multiple steps but with new command its possible to combine this into 1 simple command or even do multiple things with 1 step.

Compiler will generate all the necessary commands in memory and writes them to scr file.


But for this new stuff some commandline switch must be used because by default the compiler should not allow to compile new commands.
Because miss2 doesnt know anything about this. And it breaks compatibility.

If user wants to use new commands then commandline switch should be used when compiling.
User must understand that in this case, miss2 will not compile it.


But if the new compiler is stable enough one day then miss2 is not needed anyway.
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler

Post by B-$hep »

Ok, after some testing i discovered problems with NOT commands.
I just forgot some things for "OR" and "AND" commands. Including "NOT" command.

Found the problem when compiling bil.mis, noticed huge differences in scr file.
And after some hours, i noticed NOT command in some expressions, figured it out.


All i have to do now is update "command_next" values for expressions which have "NOT" before them.
Nothing difficult with this.

Because the way compiler core is implemented, this stuff makes it work for WHILE..ENDWHILE, DO..WHILE, IF..ENDIF and other stuff.
It fixes this for everything.
Always wear safety glasses while programming.
Post Reply