Jump to content
Sign in to follow this  
Zak3056

Ai boarding helos at non-fixed lzs?

Recommended Posts

Hello,

I'm trying to figure out how to handle the following situation:  

I have an AI squad that spawns at an arbitrary location.  The player-led squad's task is to link up with them, and guide them to an LZ (helos should also be flown by players) and board for an extraction.

The AI squad members cannot join the player squad (both will, hopefully, be full--here's hoping no combat damage!wink.gif so issuing orders that way is out.  I'm pretty sure that I could write a script to send them to the nearest LZ, but then the two squads will likely separate.  Is there anyway to get the AI squad to simply follow the player squad to the LZ?

Once that's done, how do I get them to board the helo?  I could use an invisible H pad, and a radio trigger to accomplish this, but I don't think a player pilot will have the precision to set it down on a pad he can't even see.  A visible H pad would cut down on realism.

Any ideas?

John

(Edited to clarify: Having a single LZ is impractical, as the positions the AI squad might be at are at least 10k meters apart--I need a minimum of three usable landing zones.)

Share this post


Link to post
Share on other sites

I think as long as the AI units are assigned as cargo for that chopper, they will get in it when they reach their GET IN WP, wherever the chopper is (on the ground).

Using the command

unitname AssignAsCargo choppername

Share this post


Link to post
Share on other sites

This is a tricky one. You know GUARD waypoint doesn't work for moving objects so you can't make an AI group to "GUARD" your own group. Same goes to "doFollow" command because AIunits are in different group than players.

Here is one suggestion (there might be a lot of simpler ones! ):

1. Make a "MOVE" waypoint for AI group, no matter where it points. Put on condition field nextWPAfterTransport, it is some boolean value so that you can make AI to move onto next waypoint later in the mission after the helicopter transportation. Remember to initialize this to FALSE in "init.sqs" file.

2. Make a run-once trigger with condition TRUE (or write into "init.sqs" -file) that on activation it will execute a following script:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">[AIGroupName,1] setWPPos getPos AILeaderName<span id='postcolor'>

This way the waypoint is moved to the location where AI group arbitrarily spawned.

3. Now you need a trigger that makes AI to follow your group. Make a run-once trigger with condition "player distance AILeaderName < distInMeters". Replace distInMeters with some value you want AI units start to follow you (maybe 100 meters?). On activation field set a boolean value followThePlayer to TRUE. And remember to initialize that to FALSE in "init.sqs"...

4. Because AIGroup won't move to next waypoint until nextWPAfterTransport is set to TRUE you can update the existing "MOVE" waypoint repeatedly. You can do this with a timer so that waypoint is updated in regular intervals or with a trigger that updates WP when AI is close enough the WP. Let's choose the latter one:

Trigger that runs repeatedly with condition:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">followThePlayer && (sqrt(((getPos AILeaderName select 0) - (getWPPos [AIGroupName,1] select 0))^2 + ((getPos AILeaderName select 1) - (getWPPos [AIGroupName,1] select 1))^2) < 30)<span id='postcolor'>

And on activation:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">[AIGroupName,1] setWPPos getPos player<span id='postcolor'>

This will check that AIgroup has started to follow player and calculates the distance between AILeader and its waypoint. When distance is less than 30 meters (you can adjust that) waypoint is updated to player's position.

5. When player embarks the helo a trigger can be set to make AIunits to board the helo and allow the AIgroup to continue to the next WP by setting nextWPAfterTransport to TRUE + followThePlayer to FALSE. You can simply set a "GET IN" WP (second waypoint for AIs) to helo or use assignAsCargo + orderGetIn -commands.

That was a lot of speculation because I cannot test it myself now...

Share this post


Link to post
Share on other sites

Hop, I noticed from other posts that you can make a distance calculation a lot simpler (see step 4.):

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">followThePlayer && (AILeaderName distance getWPPos [AIGroupName,1] < 30)<span id='postcolor'>

Although "getWPPos" returns an array it might be possible to use it directly in "distance" -command. Or maybe not...

Share this post


Link to post
Share on other sites

Chartier,

Thanks for the suggestions, they sound workable (and clever as hell) but an added level of complexity is with that many bodies running around, multiple helos will be required to transport them all. There are a total of five helos available in the missions (3 Hinds, and a pair of Kiowas--if the players want the Hinds, they have to fight for them) which should be enough transport even if a helo is shot down.

Breaking up the player squad is easy, breaking up the AI squad is something I can't, for the life of me, even theorize how to do--too many variables to keep in my head (just what combination of helos will be landing at the LZ? Total transport capacity of those helos?)

Okay, I can theorize. Radio trigger (Call the choppers) creates another trigger thats got a 50 meter radius (the LZ.) The first helo that enters the LZ has a Get In waypoint for the AI squad assigned to it. A script is run when the AI enters the helo, removes the AI from its group, assigns it a Get Out waypoint at the friendly base, and counts the total number of people in the chopper. Once the chopper is full, the script reassigns the "get in" waypoint to the 2nd chopper that enters the LZ. Wash, rinse, repeat.

Anybody see any hangups with this?

Share this post


Link to post
Share on other sites

^BTT

Hate to do that, but I'm stuck and could use a hand.

Share this post


Link to post
Share on other sites

The problem might be that when assigning a "GET IN" wp the whole group tries to board the chopper. Maybe better way to do it is to let player squad leader to radio some "Board choppers" message that would activate AIsquad to execute a boarding script. In the script calculate available cargo positions for choppers currently in LZ and separately assignAsCargo and orderGetIn for all the units in AIsquad.

I can see instantly a slight problem when player radios the "Board choppers" BEFORE each player squad member is boarded... How to make sure that all player squad members are already boarded before radio command can be issued?

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  

×