Car and driver AI script

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

Car and driver AI script

Post by B-$hep »

I have one idea in my head. But i need to know some things first.
Is it possible to script such thing.
I haven't scripted much but you guys should know the answer.

Just very basic script, no missions or anything.

Let's say startpos is (X,Y,Z): 55,55,2
Endpos is: 15,15,2

I create car at the startpos and give him driver.
I know that we can create cars and put driver in it.

Now, is it possible to make this car / driver to drive to the endpos from the startpos, as soon as he enters the car?
Let's say he will just run to the car, enters it and drives the car to the endpos and quits the car.
And then starts walking or whatever.


I guess roads are must have also or not?

I don't ask you guys to code it.
Don't! I just ask if its possible with commands the miss2 offers?


TIA.
Last edited by B-$hep on 30 Apr 2011, 18:38, edited 1 time in total.
Always wear safety glasses while programming.
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: Car and driver AI script

Post by Gustavob »

from what I know, it is possible but it needs road blocks+paths on the gmp file or just road blocks so the driver knows which directions to take and where to drive

ps: needs confirmation
Last edited by Gustavob on 30 Apr 2011, 18:40, edited 1 time in total.
You just lost the game.
User avatar
B-$hep
Immortal
Posts: 571
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Car and driver AI script

Post by B-$hep »

So without any arrows and things it will not drive anywhere?
What happens if you give him a command to drive but there are no roads or directions?

Crash?
Always wear safety glasses while programming.
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: Car and driver AI script

Post by Gustavob »

i once tried something similar accidentally and the driver was just driving forward untill he hit a wall, then backwards untill he hit another wall, etc, trying to find arrow paths, no crash no nothing
You just lost the game.
User avatar
Sektor
Boss
Boss
Posts: 1426
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Car and driver AI script

Post by Sektor »

It sucks that you have to edit the GMP file just to make the AI drive from A to B in a straight line. If you don't, they will keep on driving past the point you told them to and they go a little crazy. DMA Design never planned for GMP files that don't have roads.
User avatar
B-$hep
Immortal
Posts: 571
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Car and driver AI script

Post by B-$hep »

Gustavob:

Lol, that's funny.

Ok, i guess, without roads it's impossible and i have to use MAKE_CAR_A_DUMMY and then point the arrows to the endpos. Hopefully he will drive to there where i want

And check somehow if its there and blow his head off. Lol.
Gonna read the scripting doc.

I will show you what i had in mind when i get this working.



Yep, Sektor. I agree.


EDIT:

is it possible to make some AI to main character or camera?
So camera would follow the dummy car when it arrives or starts moving?
Or i have to run or drive after the dummy car to see it and see how it drives the car reaches the destination?

I know that remote car has such behavior that camera follows the remote car instead player.
Always wear safety glasses while programming.
User avatar
Sektor
Boss
Boss
Posts: 1426
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Car and driver AI script

Post by Sektor »

You could give the player remote control of the car, disable their controls and make the AI drive the car or have the player as a passenger and teleport them out before the destination.
User avatar
B-$hep
Immortal
Posts: 571
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Car and driver AI script

Post by B-$hep »

Hmm, thanks.

I will try. It will be fun...
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: Car and driver AI script

Post by Pyro »

Have you tried using the red arrows in map editor?

Also, perhaps you could do checks to see if the car has reached XYZ then give it new orders?
User avatar
B-$hep
Immortal
Posts: 571
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: Car and driver AI script

Post by B-$hep »

Yep Pyro, i already figured that arrow thing out.
I saw that many cars were created on my tiny road, but i wanted only 1, so i used red arrows and it works. Dummy just drives on that road alone with his copcar, back and forward.

I will try now make it stop and quit the car, then the camera thing.
Always wear safety glasses while programming.
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: Car and driver AI script

Post by BenMillard »

Online version of the DMA scripting guide for GTA2 might be helpful. It's not 100% complete or error-free, so please report bugs!

We can link to the commands we're suggesting and ones you have tried out. Just add a # and then the command name in full, with uppercase and underscores. Commands I've seen mentioned and various commands for drivers: A more powerful but long-winded approach is to use a CHAR_DATA for the driver, create the driver inside the car, then you can use a couple more commands for fine-tuning the behaviour.
  • CHAR_DATA reserves the name for the character.
  • CREATE_CHAR_INSIDE_CAR is a bit like MAKE_CAR_A_DUMMY but lets you use the full character AI system. Yeah, a lot more things become possible this way!
  • SET_CHAR_MAX_DRIVESPEED slow cars might be driven at 'warp speed' without this.
  • SET_CHAR_DRIVE_AGGRESSION turning this ON makes the driver bash through traffic, if necessary.
  • FOLLOW_CAR_IN_CAR using the character objectives system, you can make the driver follow another vehicle. To follow a character, even when they change vehicle, you'll need a complex loop with various other commands.
Hopefully enough to get you started. Learn by doing, as I always say! :P
Post Reply