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 »

My conversion of the official GTA2 scripting information (300kB) is now in my website in HTML. Just a draft for now but I've made all the big decisions and lot of the actual work is done.

One amazing thing I've learnt is there are nearly 300 unique scripting commands! I'm going to re-arrange and categorise all the commands, eventually.

Hopefully this HTML version will make finding out how thing are supposed to work a lot easier. There's a topic to discuss it further, to keep this one focussed.

(EDIT) It seems IS_CAR_IN_BLOCK ignores the Z coordinate. So if you have two areas which overlap, the "winning" area will simply depend on how your code is arranged.

Remember the coordinate must be the exact centre of the area, with the total width and the total height of the area. The area must be rectangular but you could use multiple commands in OR expressions to check any shape. Might get slow or desync if you have hundreds in a WHILE_EXEC, though.

(EDIT) Pyro's use of GOSUB in WHILE_EXEC to a DELAY_HERE doesn't work, in my tests. The the DELAY_HERE didn't cause a delay; the RETURN sent my code straight back to the next command in the WHILE_EXEC block. I guess there was some coincidence in his code or the scenario which made Pyro think it work...
Last edited by BenMillard on 20 Jan 2011, 19:40, edited 2 times in total.
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 »

i added the posts about scripting oddities and made a code example
yur sa'nok ngeyä
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: Collection of gta scripting and map weirdness

Post by Gustavob »

BUSY_CAR_SHOP object doesn't work properly. It was supposed to simply fix the car ("the plates have been changed") instead repainting it to another colour but it glitches the car just like when you repaint it to remap 255, 256 or -2
You just lost the game.
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 »

added and also some of my own discoveries added
yur sa'nok ngeyä
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 »

SET_CAR_NO_COLLIDE only has to be set once, same as SET_CAR_ROCKETPROOF and so on. No loop required.

These collisions do much more damage to your car, shortening its useful life. Pacifier can become useless within a minute of ramming and shoving small cars.

It also stops the car bouncing off walls. Very hard to drive in narrow areas and use alleyways.
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 »

Yeah thats true, i noticed that too recently. I had a situation where it didn't work without that trick. I haven't probed when this has to be done yet.

I also didn't add yet the problem with the ELSE statement. sometimes it is linked with the wrong IF.
yur sa'nok ngeyä
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 »

  1. HAS_CHARACTER_DIED remains true until the camera updates.
    Workaround: Wait for at least 90 cycles.
  2. HAS_CHAR_BEEN_ARRESTED works the same. However, you remain in the Cop Car for about 140 cycles.
    Workaround: Wait for at least 150 cycles.
  3. DELAY_HERE doesn't work inside WHILE_EXEC
    Workaround below. (Actual running code.)
To fake a delay of 90 cycles, I do this:

Code: Select all

COUNTER loopage = 1
COUNTER p1wait = -1 // DELAY_HERE doesn't work in WHILE_EXEC

LEVELSTART

// Main Loop
DISPLAY_BRIEF (8001) // debug
WHILE_EXEC (loopage = 1)
  // Player 1 just died?
  IF ( (p1wait = -1) AND (CHECK_CHARACTER_HEALTH(p1, 0)) ) // not waiting AND player exists
    IF (HAS_CHARACTER_DIED(p2))
      --p1score_target // 
      SET p1wait = 1 // start the death timer
    ENDIF
  ENDIF
  
  // Wait for Player 1 to finish dying and camera to reset:
  // Note: At the start of a mission, p1wait = -1
  IF (p1wait > 0) // death timer is running
    ++p1wait // count from 1 to 90
  ENDIF
  IF (p1wait > 90)
    SET p1wait = -1 // reset the eath timer
  ENDIF
ENDWHILE

LEVELEND
Be sure to integrate this into your own code carefully. (Just like any sample.)
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 »

yeah HAS_CHARACTER_DIED is true for a while. thats why i use a delay in tiny tiny town army too, because if i would change the wanted level up to 4 too early it would be switched back to 0 again.

DELAY () in IF statements works can be used too sometimes in while_exec loops
yur sa'nok ngeyä
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: Collection of gta scripting and map weirdness

Post by Gustavob »

It seems diagonal walls (aka 45° walls) create invisible walls for no apparent reason
You just lost the game.
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 »

you mean when type is air?
yur sa'nok ngeyä
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 »

Gustavob wrote:It seems diagonal walls (aka 45° walls) create invisible walls for no apparent reason
You can also stand on top of them if set to field/pavement/road and looks like you're floating, but that's been known for ages ;)

On a similar note, GTA2 won't properly show 45° walls that have the "flat" option ticked (for transparency) - it will show but you will lose the transparency and it'll show black where the transparency was.
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 »

I added this too because it was missing. It's been known for ages yeah. Actually most of these things have been discovered by someone else before many times, i even discovered many things that after i found out to remember to have discovered it some years before already. So just in case anyone thinks ">I< know that for ages" don't take this "who discovered what" too seriously ;)
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 »

found out something what drove me crazy until i found it:

SET SET_CAR_NUMBER_GRAPHIC ( p1_ffield2 , 8 ) doesn't produce an compiler error or game crash but does weird things in other parts of the script.

obviously it should be SET_CAR_NUMBER_GRAPHIC ( p1_ffield2 , 8 )
yur sa'nok ngeyä
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 »

Any characters following you (scripted or instant gang) will never get on a train with you, even if you try using clever functions like storing the "car" the player is in then forcing NPC's to enter it. Always been a bug. :roll:
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 »

if you have at least ~16 static cars on a map and use store car command the car you where in disappears instantly after you get in another one <- not confirmed. found on tiny face off army lite.

it doesnt happen if you play singleplayer and if you are in field of sight of player1. it happend first at the place where firetruck is. could anybody please try to confirm that.
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 »

added:
IS_CHAR_IN_AIR (charname) does not work

KILL_CHAR can make the char hang mid air if he is falling when it is executed in WHILE_EXEC
Last edited by elypter on 27 Sep 2011, 15:01, edited 1 time in total.
yur sa'nok ngeyä
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 »

IS_CHAR_IN_AIR should be IS_CHAR_FALLING. Wrong/old name for the command in the documentation.

You don't see the standard falling animation if you do the grenade/molotov glitch to fall without taking damage but it still returns true.
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:IS_CHAR_IN_AIR should be IS_CHAR_FALLING. Wrong/old name for the command in the documentation.

You don't see the standard falling animation if you do the grenade/molotov glitch to fall without taking damage but it still returns true.
i scripted it differently now already but good to know that it is possible.
yur sa'nok ngeyä
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 »

A few things (mostly about trailers):
  • Trailers are ignored if you use the PARKED_CAR_DATA and only shows the towing vehicle. Work around: Use CAR_DATA instead. (I know this is listed but I thought I'd expand on it a little)
  • You can make any type of vehicle have any type of trailer (such as Dementias with Tanks as a trailer) but there are some (lots!) issues:
    • Only trucks (TRUKCAB1 and TRUKCAB2) can tow most vehicles at full speed (3rd gear). Any other car is limited to 1st gear with poor acceleration and turning.
    • Depending on the vehicle towing and what vehicle you have as a trailer, sometimes the towing vehicle cannot start moving unless you turn slightly. Rarely you cannot move or turn at all (usually applies to small vehicles trying to tow big vehicles).
    • Using a big, powerful vehicle to tow a small car will make the towing vehicle extremely agile compared to normal and accelerate to top speed extremely quickly.
    • Entering any vehicle attached as a trailer will crash the game. Detach it and then enter it to work correctly.
    • If you have a towing vehicle that has a gun on it (vehicle guns, Armed Land Roamer Gun, tank gun etc) it will not detach until you switch to a non-vehicle weapon.
    • Setting the trailer type to TRAIN (train passenger carriage) will make the trailer not appear until you get in the towing vehicle. However, this trailer is extremely buggy and will crash the game randomly. Will instantly explode if it touches another car and crash the game. (Thanks to TM for the basic information while I went and tested this and other train ones as well)
    • Setting the trailer type to TRAINFB (train flat-bed) will also appear hidden until you get in the towing vehicle. Even more buggy than TRAIN as trailer.
    • Setting the trailer type to BOXCAR (train box carriage) will appear hidden until you get in the towing vehicle. Still buggy as TRAIN.
    • Setting the trailer type to TRAINCAB (the train itself) will appear hidden until you get in the towing vehicle. Will instantly crash the game when you enter though and doesn't appear anyway.
    • Towing a tank and then detaching it will make the tank roll over the towing vehicle destroying it leaving a tank above the wreck you now can't enter.
  • GIVE_WEAPON command on a vehicle ignores the amount you list and always gives +50. Work around: Either use GIVE_WEAPON command twice to get 99 ammo (sets car bomb to 1 ammo) on a vehicle or use OBJ_DATA to create specific weapon under the vehicle if you want to specify an exact amount such as 1 vehicle bomb but at the cost of hearing the voice over on picking up a weapon. (Thanks Sektor for pointing out the work around)
Quite a list about trailers :P As you can guess trailers were only meant for the Truck Cabs and specific trailer types hence all these weird issues.
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 »

"Towing a tank and then detaching it will make the tank roll over the towing vehicle destroying it leaving a tank above the wreck you now can't enter."
lol
yur sa'nok ngeyä
Post Reply