IF logic .scr files

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: IF logic .scr files

Post by B-$hep »

Actually i dont remember if i was compiling this with levelend or not.
Didnt notice that. I usually code at nights. Too sleepy.
Maybe it crashed even with levelend.

Will try today
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: IF logic .scr files

Post by B-$hep »

Hi all.

Can somebody please make or show me some very complex expressions with IF..ENDIF?
I mean really complex.
Dont use anything else, just IF..ENDIF and DO_NOWT.

NOT & ELSE are not added yet. Actually added but commented out and need testing.


AND/OR are supported! So is IS_CAR_WRECKED ()
Its just for debugging compiler. Dont run script in GTA2.

I made something like this:
[mis]counter c1=1
counter c2=2
counter c3=2
counter c4=2
LEVELSTART
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT

ENDIF
if(c1=3)
do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT

ENDIF
endIf
DO_NOWT

ENDIF
endif
if((c1=3) and
(c1=3))

do_nowt

endif
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT

ENDIF
ENDIF
ENDIF
ENDIF
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT

ENDIF
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT

ENDIF
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT

ENDIF
endIf
DO_NOWT

ENDIF
do_nowt

endif
if(((c1=3) and
(c1=35)) and
//IF_JUMP
(c1=11))
//IF_JUMP
do_nowt

endif //IF_JUMP
IF( (IS_CAR_WRECKED(c1)) and
(c1=1) ) //and (nextcar1=1) )

do_nowt

ENDIF
IF ( IS_CAR_WRECKED ( c1 ) )
do_nowt
IF (( c1 =1 )
and (c1=3))
//if_jump
do_nowt
IF ( IS_CAR_WRECKED ( c1 ) )
do_nowt
IF (( c1 =1 )
and (c1=3))
//if_jump
do_nowt

endif
do_nowt

endif
endif
do_nowt
IF ( (c1=99)
or (c1=88))

do_nowt

endif
endif
IF ( (c1=99)
or (c1=88))

do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt
//0
endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=9)
do_noWt

endIf
DO_NOWT

ENDIF
endif
IF ( (c1=99)
and (c1=88))

do_nowt

endif
IF ( ((((( c1=3 )
AND ( c1=3 ) )

//ifjump
AND ( c1=3 ))
AND ( c1=3 ))
AND ( c1=3 ))
AND ( c1=3 ))
//ifjump
if(c1=3)
do_nowt

endif
DO_NOWT

ENDIF
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) ) AND
//ifjump
( c1=3 ))
//ifjump
if(c1=3)
do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) ) AND
//ifjump
( c1=3 ))
//ifjump
if(c1=3)
do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) ) AND
//ifjump
( c1=3 ))
//ifjump
if(c1=3)
do_nowt

endif
DO_NOWT

ENDIF
endif
DO_NOWT

ENDIF
endif
DO_NOWT

ENDIF
endif
if((c1=3) and
(c1=3))
//ifjump
do_nowt

endif
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) ) AND
//ifjump
( c1=3 ))
//ifjump
if(c1=3)
do_nowt

endif
DO_NOWT

ENDIF
endif
if(c1=3)
do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=3)
do_nowt
IF ( (( c1=3 )
AND ( c1=3 ) ) AND
//ifjump
( c1=3 ))
//ifjump
if(c1=3)
do_nowt

endif
DO_NOWT

ENDIF
endif
DO_NOWT

ENDIF

endif
IF ( (( c1=3 )
AND ( c1=3 ) ) AND
//ifjump
( c1=3 ))
//ifjump
if(c1=3)
do_nowt

endif
DO_NOWT

ENDIF
IF ( (( c1=3 )
AND ( c1=3 ) ) AND
//ifjump
( c1=3 ))
//ifjump
if(c1=3)
do_nowt

endif
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))
//ifjump
do_nowt

endif
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt

endif
endif
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt

endif
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt

endif
endif
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))
//ifjump
do_nowt

endif
endif
if((c1=3) and
(c1=3))

do_nowt

endif
if(c1=3)
do_nowt

endif
if(c1=3)
do_nowt

endif
if(c1=3)
do_nowt

endif
if(c1=3)
do_nowt

endif
if(c1=3)
do_nowt

endif
IF ( (( c1=3 )
AND ( c1=3 ) )
//ifjump
AND ( c1=3 ))
//ifjump
if(c1=3)
do_nowt

endif
DO_NOWT

ENDIF
if((c1=3) and
(c1=3))

do_nowt

endif
if(((c1=3) and
(c1=35)) and
//ifjump
(c1=35))

do_nowt

endif




IF( ((IS_CAR_WRECKED(c1)) and
(c1=1) ) and (c1=1) )

do_nowt

ENDIF
LEVELEND
[/mis]

It compiles fine in miss2 and in my compiler. 100% match.

But i want more complex.
I just took some parts, did copy paste between if..endif, after do_nowts etc.

Can it be more complex than this?
Show me.

TIA for any snippet.
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: IF logic .scr files

Post by T.M. »

I probably should note that (IIRC) nested ELSE commands are bugged in the compiler, so it should be avoided at all costs for doing those tests.
ENDIF
ENDIF
ENDIF
ENDIF
Might also be a good idea to have a specific code-styling format for the if commands, so you dont confuse yourself with lacking indents and so on.

I happened to design a format suitable for reading and writing the MIS code, long time ago when i made the decompiler:
[mis]
IF ((((counter1 = 1) // first braces (minus one) will tell how many AND/OR sub commands comes after the IF (4-1=3).
AND (counter2 = 1) ) // same here: but zero sub commands (1-1=0). will have extra ) at end with spacing (ends the started "(((" things).
AND ((counter3 = 1) OR (counter5 = 1)) ) // same, but 1 extra sub command (2-1=1).
AND (counter4 = 1) )
// code here.
ENDIF

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

Re: IF logic .scr files

Post by B-$hep »

Very good info. I will look into this.

I always have problems understanding how many braces i must put in script for it to compile in miss2.
I never understood the logic.

And still kinda dont get it.

But i will do some test with your info.


Do you have anything about "NOT" ?


I looked into it and its trickier than IF..ELSE..ENDIF.


Nested ELSE problem in miss2 seems to be that it jumps into some other "if" command "ELSE" block and messes everything up.
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: IF logic .scr files

Post by T.M. »

If i remember correctly, the NOT command adds some kind of flag into the IF statement/comparison functions. Not sure about this. Been too long since i last time looked at these :)
Post Reply