I finally got the AI to get in vehicles to work. It's actually quite simple. It can be more than one AI getting in the vehicle. However, it is limited to the number of seats. So if the vehicle has 4 seats, 4 AI can get in. AI getting in vehicle is merely just an animation. No mapname_anim is needed, which is good.
Now this tutorial is more for advance scripters or someone who wants a challenge. Well, intermediate scripters can understand this too. This definitely is a great addition to any maps.
Radiant:
Create as many AI as you want. Create a vehicle as well. In my case, it is a jeep/uaz.
It helps to understand the basic vehicle tutorials.
http://modsonline.com/Tutorials-read-540.html
Be sure to give the AI a script_startingposition. First AI, script_startingposition/1, next AI, script_startingposition/2, etc. The AI and vehicle need to have the same script_vehicleride. Be sure to give the AI a targetname. You need it for scripting. The same for the vehicle. There is no need to make the AI a spawner. You can but that would require more work. More work as in, you need to define your actor after it spawns. Shouldn't be hard.
For the vehicle, create a trigger to spawn the vehicle. Give it a targetname as well.
It is best to spawn the vehicle but stop it after it spawns. So create several vehicle nodes. Make the first 3 close to each other. On the third vehicle node, select it and create a trigger. Give the vehicle node and the trigger a key/value. script_gatetrigger/ 1. So when the trigger is touched, the vehicle will move again. I guess you know for the first vehicle node, it needs a checkmark in the start_node.
Now on to scripting. The main script is maps\_vehicle_aianim. All the required animation is in there. The main line is thread guy_runtovehicle( actor, car). I will explain what they are in script.
Code:
#include maps\_utility;
#include maps\_vehicle;
#include maps\_helicopter_globals;
#include common_scripts\utility;
#include maps\_anim;
#include maps\_utility_code;
#include maps\_vehicle_aianim; //everything is here.
main()
{
precachevehicle("uaz");
maps\_uaz::main("vehicle_uaz_open");
maps\_load::main();
thread jeepin();
}
jeepin()
{
actorin = getent("actorin","targetname"); //trigger to spawn the vehicle
actorin waittill("trigger");
wait 1; //wait till the vehicle spawns.
level.actor = getent("actor","targetname"); //get the AI
level.car = getent("car","targetname"); //get the vehicle.
level.actor2 = getent("actor2","targetname"); //get the 2nd AI if you intend to have more than one.
wait 1; //no need but separate above from below to make things run smoothly
//level.car thread guy_handle(level.actor, 0); this handles the //vehicles animation events( stand, attack, duck, turn, unload ) - ai 1
//level.car thread guy_handle(level.actor2, 1); //ai 2
//the 0 in guy_handle(level.actor, 0) is the vehicle position or the startingposition. The level.actor is what you define the actor as in script. Make sure it is the vehicle that thread the function. Like you see above, level.car (which is the car that I defined.)
NOTE: This isn't necessary. Unless you want some animations.
wait 1.5;
level.car thread guy_runtovehicle( level.actor, level.car); //AI 1 run to vehicle and get in as driver. Make sure the vehicle threads the function as well.
level.car thread guy_runtovehicle( level.actor2, level.car); //AI 2 run to vehicle and get in as rider.
//guy_runtovehicle(level.actor, level.car) - level.actor is what you defined AI 1 in script. level.car is what you defined the car in script.
}
That's it! It is very simple. I wanted to speed up this tutorial b/c you should know the basics already and I don't have to tell everything.
I will upload a source file (attached to this topic) and a video.
video link
Here
The source file will consist of a helicopter attacking a tank and there are extra scripts. I didn't want to upload a standalone tutorial. I don't have the time. I will just upload one that I worked on. Play around with the map and script but don't steal.
Hope this tutorial helps you!