New GTA2 Script Compiler

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
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 »

Could you make a 1 line compiler? I want to be able to enter something like p1car = CREATE_CAR (118.0,133.5,1.0) 35 270 TAXI END and get the hex version, it doesn't need the header or footer since I'm going to be writing it into GTA2 RAM, not loading an SCR.

Splitting an existing SCR into each hex line would be useful too, easier for me to copy and paste, I have a hard time figuring out where each command starts and ends when just looking in a hex editor.

I noticed this small script doesn't give a weapon when I use your compiler:

PLAYER_PED p1 = (117.0,133.5,255.0) 10 270 // Red
LEVELSTART
GIVE_WEAPON (p1, electro_gun)
LEVELEND
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 »

Hello Sektor.

Sorry for late reply.
I have been busy with my personal life and i was i ski vacation in Slovakia tatras for 1 week with gf. My first time serious mountain skiing.

I will try to make that 1 line compiler.
Probably i must just add some command line switch, so when you the switch then it allows compiling 1 line.

But the variables must be declared, in your example:
[mis]p1car = CREATE_CAR (118.0,133.5,1.0) 35 270 TAXI END[/mis]

"p1car" should be declared.


But im thinking...
Maybe make another separate tool for the current moment. So when you type in this example above then it will show you the HEX representation of it, how it would look like in .scr file.
Would this work?

But is your p1car declared already in game? When you write this line into game memory?


Dunno if you use some .cmd or .bat file to execute the compiler or you just drop the mis file onto the exe?
Should this be another compiler or just add command line switch?


Also i will check the reported bug. Dunno what it could be. So simple script. But i have some ideas already what could cause this.
I havent worked on this thing for a while.

Its just that coding motivation goes away for some time and then i dont have any interest in this stuff. I have to do other things.
Some time passes and i get my interest back in computer coding.

But i will check these 2 things and what i can do.

Thanks Sektor.
Always wear safety glasses while programming.
Logofero
Serial Killer
Serial Killer
Posts: 264
Joined: 09 Dec 2015, 14:18
Location: Russia, Gelendzhik
Contact:

Re: New GTA2 Script Compiler

Post by Logofero »

Sektor wrote:I noticed this small script doesn't give a weapon when I use your compiler:

PLAYER_PED p1 = (117.0,133.5,255.0) 10 270 // Red
LEVELSTART
GIVE_WEAPON (p1, electro_gun)
LEVELEND
Probably does not issue, because the character spawns outside the frame on this weapon is not written to the structure.

Note: I came across a similar phenomenon for this it is better to check whether a minimum of 1 frame has passed to accurately change the player's data:

Code: Select all

PLAYER_PED player = (117.0, 133.5) 10 270
LEVELSTART
EXEC
GIVE_WEAPON (player, electro_gun)
ENDEXEC
LEVELEND
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 »

It works fine on official compiler, so it's just a bug/unsupported feature in B-$hep's compiler.
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 »

B-$hep wrote:I have been busy with my personal life and i was i ski vacation in Slovakia tatras for 1 week with gf. My first time serious mountain skiing.
This is way more fun and important than GTA2.
B-$hep wrote:But is your p1car declared already in game? When you write this line into game memory?
Yes the car would need to be declared first, just adding CREATE_CAR to a live script without declaring first would crash.

Seems Logofero already figured out how to create objects/cars by modifying RAM, so I don't really need a one line compiler anymore but it could have other uses.
B-$hep wrote: Dunno if you use some .cmd or .bat file to execute the compiler or you just drop the mis file onto the exe?
Should this be another compiler or just add command line switch?
I'm not a drag and drop person, I prefer command line/batch files.
Logofero
Serial Killer
Serial Killer
Posts: 264
Joined: 09 Dec 2015, 14:18
Location: Russia, Gelendzhik
Contact:

Re: New GTA2 Script Compiler

Post by Logofero »

Sektor wrote: Seems Logofero already figured out how to create objects/cars by modifying RAM, so I don't really need a one line compiler anymore but it could have other uses.
My method replaces the entire SCR and load at the start of the game.

Firstly: this is the need to avoid a crash (because there is a risk to change the SCR already created and you need to have a command to reboot the existing SCR in memory, but is none). Secondly, it clears the level of existing missions so that the scripter himself creates new ones in the LUA language.

Now I'm completing the search for all the offsets created by SCR. Then it will be necessary to prepare the documentation. All this requires painstaking work.
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 »

Hello all.

I found a bit of motivation to work on this stuff again.
There were some problems with NOT command stuff. I knew what was the problem when i left the project in december 2017.
Lots of time has passed since.
I kinda know what was the problem, i just have to refresh the memory and watch/read the code..

Project is huge and so is the sourcecode and it grows and grows. Its complex but this was the only biggest problem i had i think.
I know i tried to compile the whole BIL.MIS example that comes with miss2.

And then i noticed problems near the NOT command and then i started working on it and i stopped in december 2017 for some reason. Dunno..

Sektor wrote:I noticed this small script doesn't give a weapon when I use your compiler:

PLAYER_PED p1 = (117.0,133.5,255.0) 10 270 // Red
LEVELSTART
GIVE_WEAPON (p1, electro_gun)
LEVELEND

Interesting bug. I tested in my compiler and in GTA2. Weapon flashes for a sec and disappears. Dunno atm what causes it because it was fine before and working ok. There are indeed differences in miss2 scr file and new comp. scr file
Have to debug it.

Will post here if i get any new info on this stuff.

EDIT: seems that i fixed it. There was some code commented out for some reason and variable initialization mistype.
C++

Code: Select all

int ammo= -1;  // Was: int ammo= 0;
Expression expected the ammo to be initialized to -1 but it was actually 0.
So the expression was never executed.
C++

Code: Select all

                if(ammo!=-1){ 
                    header.type=SCRCMD_GIVE_WEAPON2;
                    ...
                }

                else{ // THIS EXPECTED ammo to be -1 initally
                    header.type=SCRCMD_GIVE_WEAPON1;
                    ...
                }
That was all to make it work again.
Will update the attached compiler later.

Interesting that i havent forgot C++.
Haven't coded for "ages" (since dec.2017). Same with Delphi.
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 some lines of C++ code that caused to crash the compiler when it had script with "NOT" command in them in particular cases.
Commented these lines out. Have to look later why they were added. Maybe they are useless anyway.

So far i have found stuff that works fine and some things that do not work with "NOT" command.

[mis]//OK
if(not(c1=2))
do_nowt
ENDIF

//-----------------------------------------------------------------------
//OK
if(not(is_brief_onscreen ()))


do_nowt
ENDIF

//-----------------------------------------------------------------------
// ALMOST OK. CMD_NEXT wrong or something.
if((is_brief_onscreen ()) and

(not(is_brief_onscreen ())))
do_nowt
ENDIF


// PRETTY MESSED UP:
if((is_brief_onscreen ()) and
(not(c1=2)))

do_nowt
ENDIF[/mis]

Maybe there is more, dunno. Im doing different tests and working on them.
This is where i left in dec. 2k17
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 »

Hi.

I think i found bug in miss2 or whats the problem, maybe somebody can tell me.
In doc:

• DO WHILE LOOPS
Another loop variant. However, this loop guarantees to execute the commands in the block once as the end check is at the end of the loop,
e.g.
DO
counter = counter + 1
WHILE_TRUE ( counter < 100 )

DO
commands
WHILE_TRUE ( expression )


Tried with simple script and miss2 doesnt compile this.

COUNTER c1
counter c2
counter c3
PLAYER_PED p1 = (117.0,133.5,255.0) 10 270 // Red
LEVELSTART
do
do_nowt
c1=c1+1
while_true(c1<3)

LEVELEND

Screams at the c1 invalid token
I cant even do:

[mis]SET c1 = c2 + 4[/mis]

Wth??
Is this "normal" bug in miss2 or im doing something wrong??

EDIT: its miss2. Its hungry for round brackets.


Anybody has a complete list of "expressions" miss2 supports?
I have:

[mis]set c1=(c1 + 1)
set c1=(c1 - 1)
set c1=(c1 * 1)
set c1=(c1 / 1)
set c1=(c1 mod 1)
set c1=(c1 + c2)
set c1=(c1 - c2)
set c1=(c1 * c2)
set c1=(c1 / c2)
set c1=(c1 mod c2)
++c1
--c2[/mis]

Also have some TM test scripts with weird syntax expressions that do not make sense.
Are they even used anywhere?
I mean in such "raw" form.

[mis]count1+ -1
count2+-2
count3+12
-1 +count1
-1+count2
12+count3
count5+count1
count4+count2
count3+count3
-1 -count1
-1-count2
12-count3
count5-count1
count4-count2
count3-count3[/mis]
Always wear safety glasses while programming.
User avatar
JernejL
Hitman
Hitman
Posts: 141
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: New GTA2 Script Compiler

Post by JernejL »

B-$hep: while not a answer to your question.. i did reply to your PM but got no answer, just a heads up.. to check your inbox.
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 »

Ah, ok, didnt notice. Have been too busy and tired after work..

Anyways, i was messing with NOT command and thats why i needed all kinds of possible expressions..
NOT command gave me alot of trouble but i figured it out.
Also it was messing up compile logic etc..
Now i figured out why..

Im currently fixing and working on it.
And because code is generalized then it should also fix the issues for do_while_true, while_endwhile.
Im currently using if..else..endif

For loops do not compile in miss2 but i think i can make for loop to work also in new compiler.
Later..
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.
BIL.mis compiles and runs in GTA2 fine.
I just compiled the bil.mis and the resulting bil.scr was copied over the original file in data folder.
Gta2 was happy with it. The rest of the files in bil folder are original.
Messed for 15 minutes in game and no crashes.
There shouldn't be. Because its compiled correctly.

Of course all the other missionscripts and stuff are not included in compilation atm.
I can read and parse them but there is some more work to do before i get into them fully.

But its nice to see huge bil.mis (132KB) compiled within few seconds and Gta2 accepting it.
It was not possible in earlier versions.. because of many missing complicated things..
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 »

wow, thats great progress
yur sa'nok ngeyä
gta2pl
Ped
Ped
Posts: 4
Joined: 04 Jul 2019, 11:56
GH nick: REDALERT

Re: New GTA2 Script Compiler

Post by gta2pl »

where I can download it
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 »

Hello.
Thanks for your interest.

I haven't made the latest version available. But i can make some quick zip with compiler only.
Give me some time.. Today or tomorrow i will upload it.
It works but has some unfinished stuff. Dont expect it to be 100% ready!
Its a work in progress..

I have been busy lately, no time for coding and computer stuff.
All because of changes in my personal life..
Heading towards the Finland for a more interesting job and much better monthly payments..
First week will be without any coding.
After that i might continue..
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 attached the "alpha" version to this post.
Its hard to call this beta.

It should support basically 99% of Gta2Miss commands.
The NOT command has problems and if i remember correctly if..else..endif are only ones included.
I think i commented out the while..endwhile etc structs..
Because they need rewriting for the NOT command.
I started with IF..ENDIF so they are included but again, code generated is not 100% correct.
Sorry.

As i said im busy atm with my life and it has more priorities. Im hungry for more money and that's what i do now.

But you can test out different commands, run in Gta2 and test them.
"Beta" testing this compiler is important also for me..

Lots of commands are supported, KF are half done if ever. Basically very few commands to add and its done.
And fix the if..endif etc looping structs..

When i get back i can continue..

You can drop .mis file to exe and it will compile it.
Or use the bat file..

Do not even try to compile bil.mis or other multiplayer scripts or scripts that have other scripts included.
It supports this but the feature is in half stage and switched off so users wont mess with it..
Attachments
Gta2Miss9aPub.zip
(546.46 KiB) Downloaded 604 times
Always wear safety glasses while programming.
gta2pl
Ped
Ped
Posts: 4
Joined: 04 Jul 2019, 11:56
GH nick: REDALERT

Re: New GTA2 Script Compiler

Post by gta2pl »

thanks
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 »

Hello.
Anyone tried out the compiler? I see 25 downloads but i guess most of is bots i guess?

I took the project out again and start working on it.
I know its been a while. But there is so little to do actually that it's not worth abandoning the project. I never wanted to abandon this but im just telling that lots of work is done and it's not worth stopping.
Lots of time passed since i touched it and forgot some things but i remember that NOT command had troubles with logic ops like IF..ELSE..ENDIF, DO..WHILE etc so i basically disabled these and started to rewrite them from scratch with adding full "NOT" support.
Not full compiler rewrite but just the IF..ENDIF, WHILE..TRUE etc whatever they were... I know what and why...

It almost supports the mission scripts also but because they are not 100% done i disabled the functionality but its there. Just not included in compilation.
NOT command was inside of this compiler and also other logic stuff but they kinda didnt want to work together so well and messed up the generated code.
I tried to compile the free DMA included bil.mis and in new generated .scr file i saw messed up stuff. And debugging pointed to conditional commands with NOT in them.
They messed all up.

Because these logic ops were made from the very beginning of this compiler project and the NOT command was almost the last addition to compiler command list and here the trouble started.

I didnt know they were so related / tied to each other, had to make NOT also with them and integrate it.
But anyways, i can do it.
There are tricky parts, code is complex and whole thing gets more and more complicated but its a nice challenge.

It was / is the trickiest part atm. 98-99% of the commands are included already and basically work. KF and some of the related stuff + phones needs work/code writing but this is much easier. They are just commands, they dont jump around, like IF..ELSE etc...

Im working..
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 »

The forum is pretty inactive it seems.
But anyways, GTA2 is still my favorite like 21 years now.
And im still doing stuff for it.

Im just living and working in Finland now, i have changed my life etc.
Since i have more free time also now to work on my electronics hobby and coding, i can now work more on this thingy also.

Nobody needs it anyway now i guess but i don't care.
Its interesting and complex app.

I have reviewed the code and many things are unnecessary complex.
I have managed to remake the DO..WHILE_TRUE command and WHILE..ENDWHILE.
The important thing is to understand the algorithm behind the complex commands.

I had cases where one script was compiled ok but with little changes, it was not compiled correctly.
But after rewriting/reviewing the algo behind it, it looked simpler than i was thinking.
I rewrote it and now matter how much complex the body is in it. It always works.

Same was with NOT command. I remember i solved some problems with it. But im unable to find the sourcecode for it.
I have so much stuff in computer here in Finland (FI) and at home (EE), so many snippets, sources etc.

But its not hard
I tried once to compile the included BIL.MIS but was stuck at the LOGIC commands (DO..WHILE_TRUE) etc.
They messed up things so i decided to finish them completely first.

Because other commands are easy and basically working.
They are just 1 line commands and there is much less to go wrong in them.

Even the SUB labels should work, if i remember correctly.

Just the subscripts (mission scripts) headers need some work.
Havent inspected yet how they are done.
But first things first.

Currently im messing with getting NOT command to work 100%
Always wear safety glasses while programming.
odg
Ped
Ped
Posts: 4
Joined: 26 Apr 2020, 23:59
GH nick: odg

Re: New GTA2 Script Compiler

Post by odg »

Hiya B-$hep! I've been following your work for a while and it looks great! Just wanted to let you know that not everyone's gone, at least some people still read this forum :)

I'd be happy to contribute in fact. If you open sourced your compiler - maybe put it on Github or Gitlab - I'd be happy to try to help and send in some pull requests.
Post Reply