New GTA2 Script Compiler

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

Re: New GTA2 Script Compiler

Post by T.M. » 09 Feb 2016, 11:53

B-$hep wrote:Its basically finished, just maybe 5 or even less commands to add.
Make supporting of #IFDEF #ENDIF (actually its supported but ignores the PC/PSX "flags").
And finally multiscript support.

NOT command needs to be figured out fully.
I worked on it last year but left it for later. Because it was a bit tricky, i was too lazy to think hard about its logic etc and i wanted to work on other things in compiler.
What's weird on the NOT command?

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

Re: New GTA2 Script Compiler

Post by B-$hep » 09 Feb 2016, 21:28

Why you ask such question?
If you know whats weird about it then inform me and others.

If you dont know whats the point?
Does it work in your decompiler?

If yes, then you should know everything about it and instead of asking like that you should post the info.
Otherwise you trying to be smart or something.

If you are so smart and NOT commands is piece of cake then go ahead and make compiler and decompiler support all these commands.

NOT command is not the point here and its not trickier than the other commands it just takes time.


Releasing the source will not help because you dont know what the hell im doing there.
Just like i dont know much what the hell you are doing in your decompiler.

I could add the IF..ENDIF and other logic to your compiler or just make mini compiler just for example DO_NOWT and all the logic statements like IF..ENDIF etc. and so you could rewrite your compiler with that info.

But i dont understand your code, where to add this and that and so on. Its hard to understand others code.

If you write your code from start to finish then only you know how everything works etc. I talking about programmers POV.

I will release source, but when its finished. Not earlier.
If you are not patient enough, sorry. And sorry to the others. But i will release source when its time.
Its not code with few hundred lines, there are thousands of code lines.

It just takes you also so much time to figure out what im doing there and then you will find ways to make it your way and i know how that will end.

Try to be patient.


I spent many many sleepless nights (slept only 5-6 hours) just to work on the compiler (because of you guys, so you could get better compiler) which you can modify later (new commands, easier syntax etc).

I know you will say that you could write that in few days what i wrote many months or even 1 year.

Go ahead write it if you want. I dont care. Thats the way i work.


You gave me great help and source. I respect that T.M and i credited you!!

But do not make some kind of king out of yourself. Respect others also and their work.
Sorry if i offended you but that was not the purpose.



I dont like people who are trying to push some others to do something or force them.

Sektor can ban me for this post, put me on moderation or whatever but life goes on. Even with(out) this stuff..
Always wear safety glasses while programming.

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler

Post by T.M. » 11 Feb 2016, 19:56

Dont take offense from such simple question which i meant to just brainstorm together about the issue with NOT commands... i didnt really read your rant, i dont want to get angry from nothing

User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: New GTA2 Script Compiler

Post by elypter » 16 Jun 2017, 20:47

it makes me a bit sad reading through all this progress and then the last posts. i hope this wasnt to demotivational and you still have it on the radar. i dont want to put you under preassure or anything. it would just be a shame if it ended just before the finish line. great work!
yur sa'nok ngeyä

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

Re: New GTA2 Script Compiler

Post by B-$hep » 02 Jul 2017, 19:55

Hello.


I have been watching the GTAMP forum. But i was lazy to log in for over a year.

About compiler..


Its almost complete, there are things that dont work yet: NOT command and maybe some DOOR commands.
But everything else basically works. Multiscript support is almost OK. Its in alpha stage and turned off.
It needs a bit work and better error checking. I havent worked on it so much.

I just worked out the mechanism how it will be done.

I just dont have time or motivation atm to test it fully. Its summer time, im on vacation and hang out more with my BMW in my garage and girls.

Not so much interest in computers and coding atm.


But i can upload the latest version so you all can test it for different scripts and commands.
And report bugs and weird things (if any).


Its pretty stable with good error check.
Give me few days. I will upload it.

I REPEAT: its 99% done.


Im not home atm.
Always wear safety glasses while programming.

User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: New GTA2 Script Compiler

Post by elypter » 02 Jul 2017, 22:41

great to hear this. take your time, to finish it. i hope you got better weather than its over here.
yur sa'nok ngeyä

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

Re: New GTA2 Script Compiler

Post by B-$hep » 07 Oct 2017, 13:40

Hello all.
I have been busy with so much things.
But i wanted to work on this thing again a bit.
There is not alot to do.
Its almost ready. I probably forgot something etc but i have notes here and there.

There are few commands that dont work atm, the ones listed below and maybe others which i forgot.
But i think 98% (if not 99) is implemented.

List of stuff that doesnt work atm:

* Multiscript (mission script) support is implemented a bit but i turned it off.
I just did mechanism to actually allow it to compile other script.
Compiler was not able to compile the multiscripts because it was not able to find any variables declared in them.
This should now work but multiscript support its not completely implemented.
I wanted to make it accept and compile the multiscripts, thats all.

* CREATE_CHAR (NOT IMPLEMENTED)
* NOT command (NOT IMPLEMENTED)
* IFDEF PC/PCX ENDIF (NOT IMPLEMENTED / IGNORED BY COMPILER)
* some other command i forgot? (LET ME KNOW)

Some commands may have problems or can be buggy. Miss2 syntax and acting is weird sometimes.
It takes time to get these "hacks" and weird things working.

I used simple script.
For some weird reason the SET command doesnt change the value in variable c1.
Is that normal or BUG??

[mis]// player's normal start position
PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 25 0
OBJ_DATA ph_kris_info_phone = ( 234.5 , 193.5 , 2.0 ) 270 phone

COUNTER c1 = 0
SET c1 = 22 // why it doesnt work in miss2 and in my compiler? GTA2 ignores the value? BUG???

FORWARD ans_kris_info_phone:
THREAD_TRIGGER thr_kris_info_phone = THREAD_WAIT_FOR_ANSWER_PHONE ( shaft , ph_kris_info_phone , ans_kris_info_phone: )

ans_kris_info_phone:

DISPLAY_BRIEF ( 3728 ) //"The Yakuza brothers are dressed in blue."

DISPLAY_BRIEF ( 3729 ) //"We are Yakuza. We are strong. We have no time for the Zaibatsu. We have no time for you unless you prove yourself."

RETURN


LEVELSTART
if(c1 = 0)
DISPLAY_BRIEF ( 2954 ) //TANKS-GIVING!
else
DISPLAY_BRIEF ( 2957 ) //SINK OR SWIM!
endif
LEVELEND[/mis]

I attached the compiler.
You can basically drop the script with .mis (for example test.mis) extension into exe and it compiles it to same directory.

Try it, test it, make some scripts, compile, report the results.


Exe is clean (exe is big because of G++ and i dont want to compress the exe, i compiled in Release mode), later i will use stripper. Its not important in alpha/beta stage. Code is very complex and it will not compile in MS Visual C++ compilers. G++ rocks!!


Report:

https://www.virustotal.com/#/file/77fce ... /detection
Attachments
Gta2Miss-BSHEP.zip
GTA2 Script Compiler 0.9a
(584.44 KiB) Downloaded 179 times
Last edited by B-$hep on 14 Oct 2017, 17:58, edited 2 times in total.
Always wear safety glasses while programming.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler

Post by Sektor » 07 Oct 2017, 13:56

Welcome back.

Yes known bug with SET command.

Work around is SET c1 = (22 + 0)

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

Re: New GTA2 Script Compiler

Post by B-$hep » 07 Oct 2017, 14:05

Hello Sektor.
Interesting thing.

Miss2 doesnt compile this workaround for me
Always wear safety glasses while programming.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler

Post by Sektor » 07 Oct 2017, 20:13

That’s what happens when I post from my phone.

COUNTER c1 = 22
SET c1 = ( c1 + 0 )

Still posting from my phone but I think that’s right. You wouldn’t even need to use the SET command if c1 was always 22.

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

Re: New GTA2 Script Compiler

Post by B-$hep » 08 Oct 2017, 08:41

Yes, this works fine in miss2 and in new compiler.

I wanted to try it because SET should "replace" the value in variable and assign new value to it. That's why this code.
But it seems it doesn't change this value.

But i wonder why?

I searched SET command in my folder where i keep all the scripts, there was example:

[mis]COUNTER target_score_reached = 0
...
IF ( ( CHECK_SCORE_GREATER ( grnplayer , 4999 ) ) AND (target_score_reached = 0 ))
SET target_score_reached = 1
...
[/mis]
I guess it works. Simply setting 0 to 1 and 1 to 2.
This all was in WHILE LOOP (this matters?)

EDIT: tried in simple while loop, doesn't even display anything.

EDIT2, in this example, value is changed..
Maybe it needs to be between LEVELSTART LEVELEND to work properly?

[mis]// player's normal start position
PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 25 0
OBJ_DATA ph_kris_info_phone = ( 234.5 , 193.5 , 2.0 ) 270 phone
COUNTER loop = 1
COUNTER c1 = 22
SET c1 = ( c1 + 0 )

FORWARD ans_kris_info_phone:
THREAD_TRIGGER thr_kris_info_phone = THREAD_WAIT_FOR_ANSWER_PHONE ( shaft , ph_kris_info_phone , ans_kris_info_phone: )

ans_kris_info_phone:

DISPLAY_BRIEF ( 3728 ) //"The Yakuza brothers are dressed in blue."

DISPLAY_BRIEF ( 3729 ) //"We are Yakuza. We are strong. We have no time for the Zaibatsu. We have no time for you unless you prove yourself."

RETURN


LEVELSTART

set c1 = 0 // HERE it changes value to 0 without problems and the TANKS-GIVING! is shown

if(c1 = 0)
DISPLAY_BRIEF ( 2954 ) //TANKS-GIVING!
else
DISPLAY_BRIEF ( 2957 ) //SINK OR SWIM!
endif
LEVELEND[/mis]

Weird stuff.


EDIT3: Script compiled with miss2 and the new compiler are identical. I guess its either LEVELSTART LEVELEND that matters or its just a BUG in GTA2.

Maybe i could fix the problem by just using S = S + I formula, like miss2 does for the first equation.
Second is stored as SET COUNTER INT command.

This of course make the .scr files different (if you do any hex comparing) by one command but it wont break anything i guess and fixes the bug.
This stuff should work directly not with some weird hacks.


I can detect if SET command is between LEVELSTART LEVELEND or not and if its not, then i can replace the SET command with that: S = S + I (change variable value to new int value) or vice versa. Its very confusing atm.

Have to drink some coffee.

I will try it.
Always wear safety glasses while programming.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler

Post by Sektor » 08 Oct 2017, 09:45

lol, seriously? I thought I always tested that after LEVELSTART but you are right, SET c1 = 1 seems to work, at least in a simple script.

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

Re: New GTA2 Script Compiler

Post by B-$hep » 08 Oct 2017, 09:51

Doesnt display anything:

[mis]// player's normal start position
PLAYER_PED shaft = ( 232.5 , 192.0 , 2.0 ) 25 0
OBJ_DATA ph_kris_info_phone = ( 234.5 , 193.5 , 2.0 ) 270 phone
COUNTER loop = 1
COUNTER c1 = 1
SET c1 = ( c1 + 0 )

FORWARD ans_kris_info_phone:
THREAD_TRIGGER thr_kris_info_phone = THREAD_WAIT_FOR_ANSWER_PHONE ( shaft , ph_kris_info_phone , ans_kris_info_phone: )

ans_kris_info_phone:

DISPLAY_BRIEF ( 3728 ) //"The Yakuza brothers are dressed in blue."

DISPLAY_BRIEF ( 3729 ) //"We are Yakuza. We are strong. We have no time for the Zaibatsu. We have no time for you unless you prove yourself."

RETURN


LEVELSTART
WHILE (loop = 1)
set c1 = 0
ENDWHILE

if(c1 = 0)
DISPLAY_BRIEF ( 2954 ) //TANKS-GIVING!
else
DISPLAY_BRIEF ( 2957 ) //SINK OR SWIM!
endif
LEVELEND[/mis]

have to give this a deep look, why it skips the IF..ENDIF
I dont think that is normal. Or is it?


loop var is always 1, so while loop should execute always. And it always should set the c1 value in there to 0.
I looked into debug info of this script and couldnt find anything weird. It should display brief 2954.

have to look into actual .scr file.

Either its bug or im doing something wrong.

Sektor:
Can you show simplest example how to display value of variable in GTA2?
I know you did something like this.
What flags should i check in power manager?
i use R* "updated" GTA2.
Always wear safety glasses while programming.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler

Post by Sektor » 08 Oct 2017, 10:15

Now I remember the SET bug, it wasn't a problem with SET a = 1 , it was a problem with SET a = b. This doesn't work, so you have to do SET a = (b+0).

For testing, I use ADD_SCORE to display a variable value.

ADD_SCORE (p1,-999999999)
ADD_SCORE (p1,x)

That's only good for one variable at a time, you could enable show ped/car IDs and set IDs to the variables you want. I've never used that for debugging since it's a bit overkill :P

Example of changing ped/car IDs: http://gtamp.com/forum/viewtopic.php?f= ... t=20#p9231

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

Re: New GTA2 Script Compiler

Post by B-$hep » 08 Oct 2017, 15:38

In what GTA2 version you used the script from this post?

http://gtamp.com/forum/viewtopic.php?p=9231#p9231

In 9.6 game executes but crashes immediately.
XP Pro
Always wear safety glasses while programming.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler

Post by Sektor » 08 Oct 2017, 22:00

11.44, it uses some modified commands to write memory, so it won’t work on 9.6.

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler

Post by T.M. » 09 Oct 2017, 14:34

B-$hep wrote: List of stuff that doesnt work atm:

* Multiscript (mission script) support is implemented a bit but i turned it off.
I just did mechanism to actually allow it to compile other script.
Compiler was not able to compile the multiscripts because it was not able to find any variables declared in them.
If i remember correctly, each mission script is an extension to the base script, and their pointers correspond to that logic, thus none of the mission script pointers can start from the first possible pointer number. Hope that helps.
B-$hep wrote: * CREATE_GANG_CAR (NOT IMPLEMENTED)
* CREATE_CHAR (NOT IMPLEMENTED)
In my decompiler the CREATE_GANG_CAR is same as CREATE_CAR, so the only difference is the command number, which are:
[mis]
#define SCRCMD_CREATE_GANG_CAR1 394 // 8A01
#define SCRCMD_CREATE_GANG_CAR2 395 // 8B01
#define SCRCMD_CREATE_GANG_CAR3 396 // 8C01
#define SCRCMD_CREATE_GANG_CAR4 397 // 8D01
[/mis]
Hope that helps.

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

Re: New GTA2 Script Compiler

Post by B-$hep » 09 Oct 2017, 17:44

Thank you T.M.

I forgot about these pointers in mission scripts.
I think thats were i left last time and decided to implement all other commands and stuff.

Good to know about CREATE_GANG_CAR.
Probably i can just use it in CREATE_CAR and modify just the command number like you wrote.


CREATE_CHAR is not implemented just because of lazyness.
But i will finish it.


Thanks to Sektor also.
When i tried that piece of code: ADD_SCORE (p1,x)
Modified to ADD_SCORE (shaft,c1).

I noticed that after compiling with new compiler, GTA2 crashed.
I wondered why... After looking differences between miss2 .scr file and new compiler .scr file i noticed that it didnt write variable indexes into .scr file.

In other words it had bug. Also there was no error checking for parameter 1 of ADD_SCORE (p1,x).
I mean for this example there was no error checking for p1, is it even declared, etc...

Fixed the bug and all working.


Of course i mention one thing also.

There is no "smart" variable checking currently. I mean for example again: ADD_SCORE (p1,x)
p1 is assumed to be PLAYER, but compiler will also compile this if the p1 is actually for example COUNTER p1, or CAR_DATA p1

This "smart" error checking will be made later after the all things are working, like in miss2.
I have many ideas how to make it better etc. But first it must be made working fully.

Like i said before, there is not much.
Few commands to add and basically test all commands (if possible).
I know its tedious.
Always wear safety glasses while programming.

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

Re: New GTA2 Script Compiler

Post by B-$hep » 09 Oct 2017, 19:45

I implemented CREATE_GANG_CAR now.
Copy/Paste basically. Later i can review it to avoid duplication. It doesnt matter atm.

Also CREATE_CAR seems to work. I had many problems with it.
But now it seems that .scr files match 100% with miss2 .scr files.

I debug a lot with hex comparing tool, to see differences. More than running GTA2 with these scripts.
I have looked into scr files so many times that i can basically tell with simple look, which command is which, whats its index etc, where is it etc.
The structure is so deep in head already. Practice?
Because of lots of messing around with these .scr files.

"BRAINHEX" tool ??? lol.


CREATE_CHAR will be next, but now i go to bed. Need to sleep and wake up early to the work.
Always wear safety glasses while programming.

User avatar
Sektor
Boss
Boss
Posts: 1369
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler

Post by Sektor » 09 Oct 2017, 20:00

B-$hep wrote:There is no "smart" variable checking currently. I mean for example again: ADD_SCORE (p1,x)
p1 is assumed to be PLAYER, but compiler will also compile this if the p1 is actually for example COUNTER p1, or CAR_DATA p1

This "smart" error checking will be made later after the all things are working, like in miss2.
I have many ideas how to make it better etc. But first it must be made working fully.

Like i said before, there is not much.
Few commands to add and basically test all commands (if possible).
I know its tedious.
Don’t make it too smart, a counter can contain a player address and is used that way in some of my scripts.

Post Reply