Collection of gta scripting and map weirdness

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: Collection of gta scripting and map weirdness

Post by BenMillard »

If you prevent players exiting a car using SET_ENTER_CONTROL_STATUS, beware! Any subsequent command which affects the car, such as STORE_CAR_CHARACTER_IS_IN or even CHANGE_CAR_REMAP will restore the player's control.

For example, the player can still get out when using this loop:
[syntax=mis]// Gameplay
/*
Players are protected while on foot.
Bike colour matches the player who is driving it.
*/
WHILE_EXEC (stage = 1)

IF (CHECK_CHARACTER_HEALTH(p1, 0))
SET_CHAR_INVINCIBLE (p1, ON) // protected until reaching a bike
IF (IS_CHARACTER_IN_ANY_CAR (p1))
SET_ENTER_CONTROL_STATUS (p1, OFF) // cannot abandon current bike
STORE_CAR_CHARACTER_IS_IN (p1, p1car_temp)
IF (NOT (CHECK_CAR_REMAP(p1car_temp, 35)) )
CHANGE_CAR_REMAP (p1car_temp, 35) // Yellow to match player
ENDIF
ELSE
SET_ENTER_CONTROL_STATUS (p1, ON) // can get new bike after death
ENDIF
ENDIF

ENDWHILE[/syntax]

To make it work, move your ENTER_CONTROL_STATUS below the other commands. Like this:
[syntax=mis]// Gameplay
/*
Players are protected while on foot.
Bike colour matches the player who is driving it.
*/
WHILE_EXEC (stage = 1)

IF (CHECK_CHARACTER_HEALTH(p1, 0))
SET_CHAR_INVINCIBLE (p1, ON) // protected until reaching a bike
IF (IS_CHARACTER_IN_ANY_CAR (p1))
STORE_CAR_CHARACTER_IS_IN (p1, p1car_temp)
IF (NOT (CHECK_CAR_REMAP(p1car_temp, 35)) )
CHANGE_CAR_REMAP (p1car_temp, 35) // Yellow to match player
ENDIF
SET_ENTER_CONTROL_STATUS (p1, OFF) // cannot abandon current bike [moved beneath the other code in this branch]
ELSE
SET_ENTER_CONTROL_STATUS (p1, ON) // can get new bike after death
ENDIF
ENDIF

ENDWHILE[/syntax]
(Weird issues with text size after a .mis syntax highlighting code sample.)
User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: Collection of gta scripting and map weirdness

Post by Pyro »

More stuff, mostly about characters, groups and characters in cars...
  • (Oversight) Adding a character to a car will always make it drive away effectively making the MAKE_CAR_DRIVE_AWAY command semi-useless. Workaround: Use STOP_CHAR_DRIVING command right after to make the char stop and then use MAKE_CAR_DRIVE_AWAY when needed.
  • (Unexpected Behaviour) Using GIVE_DRIVER_AND_BRAKE will make the dummy driver switch on the engine and move the car forward a tiny bit before stopping.
  • (Limitation) You can't make a car have a driver without turning the engine on.
  • (Bug) If you attach a trailer to a truck and then use MAKE_CAR_A_DUMMY the truck will have its engine on but will never move even giving it a push.
  • (Bug) If you attach a trailer to a truck and then use CREATE_CHAR_INSIDE_CAR the engine will NOT start and will never move like above as well. Using SET_CHAR_DRIVE_AGGRESSION will not work either.
  • (Bug) If you make a car have a named driver using CREATE_CHAR_INSIDE_CAR and then use ADD_GROUP_TO_CHARACTER to him the group will appear outside the car in the middle and then enter as passengers.
  • (Oversight) If you have a group which is too large to fit inside a car the rest will walk off until you exit the car and will then follow you again even all the way across the map.
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Collection of gta scripting and map weirdness

Post by elypter »

Pyro wrote:More stuff, mostly about characters, groups and characters in cars...
  • (Oversight) Adding a character to a car will always make it drive away effectively making the MAKE_CAR_DRIVE_AWAY command semi-useless. Workaround: Use STOP_CHAR_DRIVING command right after to make the char stop and then use MAKE_CAR_DRIVE_AWAY when needed.i noticed that too, will add to the list
  • (Unexpected Behaviour) Using GIVE_DRIVER_AND_BRAKE will make the dummy driver switch on the engine and move the car forward a tiny bit before stopping.same
  • (Limitation) You can't make a car have a driver without turning the engine on.will add, btw you can create a car at the desired location with a driver by spawning it mid air.
  • (Bug) If you attach a trailer to a truck and then use MAKE_CAR_A_DUMMY the truck will have its engine on but will never move even giving it a push.thats only true for default gci values. you can make the truck work by reducing masses. but it will only drive in one direction and never brake. you can check that out on tiny tiny town army test. there is a explosive truck driving on the southern or northern road
  • (Bug) If you attach a trailer to a truck and then use CREATE_CHAR_INSIDE_CAR the engine will NOT start and will never move like above as well. Using SET_CHAR_DRIVE_AGGRESSION will not work either.workaround: put the trailer right to where it would be when it were attatched. in most situations it will be attatched after the driver starts driving. in some weir moments though the trailer tends to spawn at somewhere else.
  • (Bug) If you make a car have a named driver using CREATE_CHAR_INSIDE_CAR and then use ADD_GROUP_TO_CHARACTER to him the group will appear outside the car in the middle and then enter as passengers.workaround: create the gang when exiting the car like on tiny tiny town army
  • (Oversight) If you have a group which is too large to fit inside a car the rest will walk off until you exit the car and will then follow you again even all the way across the map.thats a well known fact from normal instant gangs
did you try to create a driver as passenger and then switch seats to avoid switching the engine on, maybe that works?
yur sa'nok ngeyä
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Collection of gta scripting and map weirdness

Post by T.M. »

dont try this on the compiler: [mis]WARP_FROM_CAR_TO_POINT (p1, 1.1,2.2,1015454545324337.436436253253426236466236236236236436346347952839752839752839752893522839528937523585389592837589250114364361111111111113644364361111111111111111142314142142142142, 155)[/mis]
It crashed my computer completely: couldnt start it up anymore and it said it couldnt find my harddrives anymore, had to plug out one of my harddrives and then i managed to start it after fucking around in the bios a while. I think i did this once before with same effect but forgot, damn nasty. DONT TRY IT. YOUR COMPUTER WILL BLOW UP.

i wont try to confirm it if it was actually about that line, but i was compiling and testing the maximum value for floats and at first the compiler crashed when i reached 16 bytes before the dot in "1015454545324337.0" value, after that i kept adding numbers after the dot and my computer crashed severely. and i have a vague memory this has happened to me before when i did similar or same test!
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Collection of gta scripting and map weirdness

Post by Sektor »

That didn't even crash mispad on my system but it added a horizontal scrollbar to this page. I have to fix the syntax highlighter so that it wraps long lines or give it a horizontal scrollbar of its very own.

It might be able to crash your OS but anything else is just a coincidence.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Collection of gta scripting and map weirdness

Post by T.M. »

I doubt its coincidence... i wasnt doing anything else on the computer at the moment, no downloads running etc. so the system was very stable at that moment it crashed. and it crashed exactly at the moment i pressed compile button.

Sektor, if it didnt crash: add one or more bytes before the dot so you reach 17 numbers or more. i think that code had 1 number less because i wanted to test how many decimals i can put there, until it crashed. but as i said: dont do it! you dont want your harddrive/OS blow up.

i dont think you should fix the syntax highlighter scrollbar since such lines are not supposed to even have in MIS code, the problem is same what i hear all the time from newbies who test their HTML tables and whine how it doesnt word-wrap because he used a test string with no spaces to break at all :D -> there is no such case in real life where you would have such text. the solution is simply to not do it. although, you COULD try to fix it.. but i doubt you can... since its already stretching it to page width, if you add horizontal scrollbar to that code box, that will fuck up everything then. just bear with it, its just 1 message out of million that can cause such annoyances.
User avatar
Cuban-Pete
Immortal
Posts: 909
Joined: 29 Jan 2010, 15:03
GH nick: Cuban-Pete

Re: Collection of gta scripting and map weirdness

Post by Cuban-Pete »

Here it fits perfectly on the screen. Solution: buy a bigger screen :P
"Mmmm, your eyes are so beautiful."
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Collection of gta scripting and map weirdness

Post by B-$hep »

Cuban-Pete wrote:buy a bigger screen :P
Send me money, then i will.

EDIT: imagine a forum script saying this because of long lines: "Buy a new monitor, then you will see whole line."
Last edited by B-$hep on 23 Nov 2011, 22:01, edited 1 time in total.
Always wear safety glasses while programming.
User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: Collection of gta scripting and map weirdness

Post by Pyro »

elypter wrote:thats only true for default gci values. you can make the truck work by reducing masses. but it will only drive in one direction and never brake. you can check that out on tiny tiny town army test. there is a explosive truck driving on the southern or northern road
Thought so too, but figured might as well add since not many people mess with the GCI stuff.
elypter wrote:workaround: put the trailer right to where it would be when it were attatched. in most situations it will be attatched after the driver starts driving. in some weir moments though the trailer tends to spawn at somewhere else.
Tried this, but every time I tried it always moved both the truck and trailer, sometimes the truck behind the trailer. Seems you can't have a truck and trailer within 1.0 distance or so without it messing up.
elypter wrote:workaround: create the gang when exiting the car like on tiny tiny town army
Depends what you want to do. You can do it that way yes or create gang before entering a vehicle, but the "bug" should be a logical way of cutting down the code.
elypter wrote:did you try to create a driver as passenger and then switch seats to avoid switching the engine on, maybe that works?
Not sure what you mean? Can't create characters inside a car as passengers, need to make them outside and then use ENTER_CAR_AS_PASSENGER.
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Collection of gta scripting and map weirdness

Post by elypter »

sorrz, i thought that was possible but i was probablz wrong. then i dont know another waz
yur sa'nok ngeyä
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Collection of gta scripting and map weirdness

Post by T.M. »

- ELSE command doesnt work, dont use it. solution: use: "if(*check*) *code* ENDIF if(NOT(*check*)) *code* ENDIF".

Sektor noticed this while i was sent to asylum for insanity (again) after trying to figure out why my map didnt work. now im BACK and everything is fine again! say NO for ELSE!
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Collection of gta scripting and map weirdness

Post by Sektor »

EXEC and ENDEXEC don't seem to be used for anything important. More commands for Vike to make useful. ENDEXEC is used by the official scripts but as far as I can tell, it doesn't do anything on PC.
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Collection of gta scripting and map weirdness

Post by elypter »

T.M. wrote:- ELSE command doesnt work, dont use it. solution: use: "if(*check*) *code* ENDIF if(NOT(*check*)) *code* ENDIF".

Sektor noticed this while i was sent to asylum for insanity (again) after trying to figure out why my map didnt work. now im BACK and everything is fine again! say NO for ELSE!
well, thats not a secret. didn't i post that somewhere a year ago?
else works but not relyably. especially in nested structures it fails sometimes. therefore it was quite a pain to discover it.

That was kind of a WTF moment when i realized that it was not my script that was broken but the language itself at its core.

I mean, DMA, really?
yur sa'nok ngeyä
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Collection of gta scripting and map weirdness

Post by elypter »

Sektor wrote:EXEC and ENDEXEC don't seem to be used for anything important. More commands for Vike to make useful. ENDEXEC is used by the official scripts but as far as I can tell, it doesn't do anything on PC.
maybe that allows external missions scripts to run at exec speed
yur sa'nok ngeyä
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Collection of gta scripting and map weirdness

Post by T.M. »

- you cant change car remap afterwards if you create the car with -1 or 0 (zero) remap.

- 0 and -1 remaps use the car default sprite colors without any remap applied to it, thus you cant use the blue remap color by setting it to 0. use CHANGE_CAR_REMAP() to set it to blue after you created the car with some other remap than -1 or 0 (see the point above).
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Collection of gta scripting and map weirdness

Post by T.M. »

Has anyone made a full list of the special tile numbers that have own features in GTA2, such as the tile that makes cars to stop on front of it sometimes. Would be useful in my editor later.

--

I found this error:
- (GTA2) you can walk on air blocks, but if you stop, you will fall down.
it should be:
- (GTA2) you can walk on air blocks with slopetype > 0, but if you stop, you will fall down.

I havent tested all the blocks, but you definitely cant walk on slopetype zero even if its air. and i bet you cant walk on other flat slopes, only diagonal slopes that go up/down i think.

Edit:
Noticed also this while reading the list:
- (LIMITATION) Maximum of code lines in a script is 3014 workaround
should be:
- (LIMITATION) Maximum script size = 45544 bytes with maximum of 5999 commands (note: some commands such as IF's takes space more than 1 command). workaround: use LAUNCH_MISSION() to extend the script, or the hacked compiler.
Last edited by T.M. on 28 Nov 2011, 15:14, edited 1 time in total.
User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: Collection of gta scripting and map weirdness

Post by Pyro »

Looking at the official STY files (bil, ste and wil) the junctions in Delfi's STY tool all have the property "road junction special (floor)" attribute. Actually observing said tiles in action makes them similar to traffic light zones for that one road tile though cars not on the same road as junction will sometimes slow down to let them out. Other than that, other tile properties are mostly the sound they make when you walk on it or shoot it as well as the 'electrified' property for rail. Nothing too exciting...

So, use Delfi's STY tool to have a look at the tiles and see what properties they have.

PS - After reading this I should modify the junction tiles in all the GTA1 STY files!
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Collection of gta scripting and map weirdness

Post by T.M. »

Those floor sound properties are defined separately in STY file which you can change yourself, nothing to do with hardcoded hidden tile features (which i am looking for).

I checked the stytool, and it seems to show only the road special tile, is that all special tiles there are?

Edit: stytool shows the road special within the other sound types :o thats very odd, i had no idea they are part of that system! looks like there arent other (or any) specialities then?
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Code Snippets

Post by elypter »

BenMillard wrote:GTA2 crashes if you use CHANGE_CHAR_REMAP on a player who is in a car :/
WHILE_EXEC (loop = 1)
CHANGE_CHAR_REMAP (p1, 00)
ENDWHILE

That will crash as soon as you enter any car. Happily SET_CHAR_GRAPHIC_TYPE doesn't crash and since that command also sets remap, as the final parameter, it's safe.
yur sa'nok ngeyä
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Collection of gta scripting and map weirdness

Post by T.M. »

would be cool to have a list of commands that require more commands to make them safe, for example those commands when you need to use CHECK_CHAR_HEALTH or something or else it crashes. if i make the compiler i can implement that directly in it so all commands are safe to use without special needs to take care of it yourself.
Post Reply