Page 1 of 1
Car and driver AI script
Posted: 30 Apr 2011, 18:35
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.
Re: Car and driver AI script
Posted: 30 Apr 2011, 18:36
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
Re: Car and driver AI script
Posted: 30 Apr 2011, 18:40
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?
Re: Car and driver AI script
Posted: 30 Apr 2011, 18:41
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
Re: Car and driver AI script
Posted: 30 Apr 2011, 18:43
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.
Re: Car and driver AI script
Posted: 30 Apr 2011, 18:46
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.
Re: Car and driver AI script
Posted: 30 Apr 2011, 18:54
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.
Re: Car and driver AI script
Posted: 30 Apr 2011, 19:00
by B-$hep
Hmm, thanks.
I will try. It will be fun...
Re: Car and driver AI script
Posted: 30 Apr 2011, 20:15
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?
Re: Car and driver AI script
Posted: 30 Apr 2011, 20:24
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.
Re: Car and driver AI script
Posted: 02 May 2011, 22:34
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!
