Jump to content

Sign in to follow this  
Eclipse4349

how to make AI use the nearest vehicle

Recommended Posts

I recently reverse engineered the existing CTF template for Utes and made it into a CTF war, with respawning vehicles like heavy armor, attack choppers, jets, etc, and crates with every weapon and ammo type, and made the bases and flag areas much further apart. Thank you to all who helped me get this far, such as the awesome vehicle respawn script and ammo crate fill script, and how to load templates in the editor!

One question I have left is, how can I make an AI squad use the nearest vehicle to accomplish their objective? For instance, I want to make a fireteam that is ordered to capture the enemy flag, and one that is ordered to defend. How can I make them use a nearby vehicle and then continue on to their waypoint? I noticed that if I am in the group/squad, and I board a vehicle, the squad leader will order the squad to enter the vehicle as well, then order us to move on to the next waypoint again. How can I get AI squads to behave like this without human interaction?

Thanks guys! Once I finish the map and am happy with how it plays, I will post it in the User Mission forum.

Share this post


Link to post
Share on other sites

list all the vehicles or detect the vehicles via a trigger thislist and then random pick one, use _grp addvehicle _vehiclename and the AI wil use that vehicle..

When they are finished there journey just use _grp leavevehicle _vehiclename..

Share this post


Link to post
Share on other sites

Thanks for the response, but I am a scripting noobie. Could you spell it out a bit more specifically?

Share this post


Link to post
Share on other sites

anyone? Not sure where to put the lines of code and such or how to use the "thislist" command. Any help would be greatly appreciated

Share this post


Link to post
Share on other sites

awesome, thanks for the link to the "this" tutorial! I need more things like this (no pun intended) to educate myself on scripting. Very helpful!

The community around this game is amazing! I have never seen more people in forums who are eager to help one another, with a general lack poor attitude. It's very refreshing!

Share this post


Link to post
Share on other sites

Been messing with this for days now, still can't seem to grasp it. I am trying to make a trigger that detects whether an empty vehicle and a Blufor unit or units are present, and once this condition is true, command the Blufor units that are in the trigger area to get in and use the vehicle in that trigger area to proceed to their next waypoint.

So far, I have a trigger set up that is set to Blufor Present, and condition "this". On activation, I have "Blu1 assignasdriver V1; Blu2 assignasgunner V1; [blu1, Blu2] ordergetin true;", and it works so far. The units that I named Blu1 and Blu2 get in as driver and gunner! All I need to do now is get it set to only go off when another trigger that detects whether the empty vehicle is present goes off first. Here goes...

Edited by Eclipse4349

Share this post


Link to post
Share on other sites

so far, even using (triggername select 0) assignas___ vehiclename, and then ordergetin true, isnt working either. They obey when the round starts, as before, but they STILL will not obey after respawn!

Share this post


Link to post
Share on other sites

Also having this problem that respawned AI soldiers do nothing - how to give them an init?? :confused:

Share this post


Link to post
Share on other sites

I solved this issue. It seems that the respawned units and vehicle lose their name. They do not, however, lose their groupname. So, rather than referring to them by name to give units a ordergetin or assignas_ command, I did this:

Give units a group name. Create a trigger detecting the unit's presence in the area around their base (respawn area). Sync'ed the trigger to the group it pertained to.

Created another trigger set to detect anything. Sync'ing the trigger to the vehicle so that it will only detect that vehicle works just like calling the vehicle by name. It will work at round start, but NOT once the vehicle has respawned. So, I didn't sync it, I left the trigger set to detect "anybody".

Created a third trigger that activates when both the previous triggers are "true". In the activation field, I put:

if((list "vehiclepresenttriggername" select 0) iskindof "landvehicle") then {"unitgroupname" addvehicle (list "vehiclepresencetriggername" select 0)};

if((list "vehiclepresenttriggername" select 1) iskindof "landvehicle") then {"unitgroupname" addvehicle (list "vehiclepresencetriggername" select 1)};

if((list "vehiclepresenttriggername" select 2) iskindof "landvehicle") then {"unitgroupname" addvehicle (list "vehiclepresencetriggername" select 2)};

I used multiple variations with different "select" variables in case there happened to be a soldier standing in the vehiclepresence trigger activation area when the vehicle respawned, in which case, the soldier would be "select 0" in that trigger, and the vehicle would then be "select 1", and, if commanded to addvehicle on another soldier, the game locks up and crashed when one soldier tries to "get in" the other. Kind of funny, actually!

This trigger setup has my intended effect that if the AI are close enough to base to be within their trigger area, and if the vehicle is still at it's base location where it spawns, then they will decide to get in and use the vehicle that was "added" to them. If either they are too far away, or the vehicle is not at base still, they will simply proceed to their waypoint on foot.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×