Jump to content
Sign in to follow this  
StrongHarm

CAS Helo Orbit Script Ideas

Recommended Posts

Hello,

After finishing my CAS Day2 Mission I'm now making plans for expanded capabilities. As it stands you can control the AI pilot in my mission while in the gunners seat through a special action menu and/or map clicks. This seems to work fine if you want to hover or do popups, but if you've ever seen an attack helo like the Apache or Cobra in the field, they typically orbit the target with about a 1+ mile slant range (I think the m230 has a 2.5 mile effective range that increases with altitude.. though I wouldn't expect that in ARMA.. so 1km will do). I would like to put a script together that will make the helo AI pilot orbit the current task by 800m at 50knots and 300ft alt. I'm just starting to consider what will be necessary to make this happen, and hoped I could brainstorm with some of the more experienced scripters here to get a jumpstart. Anyone have ideas?

Thanks in advance for your time,

StrongHarm

Share this post


Link to post
Share on other sites

I assume that you that you want to do this entirely in a script and not with editor waypoints. There might be a way to do it easily in the editor, but I don't know about. Hopefully some else saves you from a lot of coding. Anyway, this is how I would approach it.

You would need to generate positions around the center and use them as waypoints for the helicopter. The number of points, angle from the center, and order of points is determined by where the helicopter starts. If the target moves, you need to account for that and recalculate the orbit. You also need to keep the helicopter moving smoothly from one waypoint to the next without stopping. There has to be enough waypoints to make the path appear circular, but too many and you waste cpu time and will have more trouble making the helicopter move smoothly. You must also decide how many points you want to calculate in advance, based upon if the target is stationary or not. You could even go a step further and calculate an ellipse (or half of one rather) based upon the target having a constant velocity, thus keep the helicopter the same distance as it orbits a moving target. You must also consider if the helicopter will be facing the target, otherwise it cannot fire. You could even consider the terrain and make sure the gunner has a clear line-of-sight to the target. Finally, you need to be able to switch to orbiting a new target once one is destroyed. This last point makes me think that this is not possible in the editor.

I think I made that sound more difficult than it is. It comes down to what features you want and if there any unforeseen problems in implementation. I do not know how much scripting experience you have, so if you do not have the inclination or ability to code all this (and you can't find another way), I can post some code to get you started.

Share this post


Link to post
Share on other sites

Thank you Zenophon. I do have some scripting and programming knowledge.. check out the mission linked above. In my orbit script, I think I'll anchor the helo to my JTAC (there's one at every task) through a param. I'll want to set the nose inside no less than 30degrees, but I'll need to test the limits of yaw nullification against speed to get the magic speed/yaw value. I like your idea of generating waypoints.. it might be something like:

waypoint1 = pos crJTAC select 1,((select 2)+800),((select 3) +300)

waypoint2 = same +10degrees

waypoint3 = same +20degrees

etc.

. I just have to figure out the 'same +N degrees' method

I do like your idea of fixed waypoints around each of the AOs, but it would also be good to have a reusable script. Having a CAS asset orbit could be used in many different scenarios.. or even an unarmed AFAC..

Thanks for helping me brainstorm this... you've brought forth some great considerations.

Share this post


Link to post
Share on other sites

Anyone know an easy way to create the waypoint +10degrees circumference for an orbit script? I'm thinking that I'm going to have to create some waypoints in a circle.. do the math of the coordinate deltas, then use those baseline deltas to add/subtract from each position array. Any other thoughts?

Share this post


Link to post
Share on other sites

Polar coordinates are your friend:

Zen_ExtendPosition = {
   /*
   Returns a position that is a variable distance and direction 
   from a given position, angle is trigonometric
   Params:  1. Position, the center
            2. Scalar, the distance in meters
            3. Scalar, the angle in degrees
   Return:  Position
   */
   private ["_center","_distance","_phi", "_dx", "_dy"];

   _center = _this select 0;
   _distance = _this select 1;
   _phi = _this select 2;

   _dx = _distance * (cos _phi);
   _dy = _distance * (sin _phi);

   [(_center select 0) + _dx, (_center select 1) + _dy, 0]
};

You might also be interested in the notes on this page regarding finding 2d angles:

http://community.bistudio.com/wiki/atan2

Also, when I said waypoints, I did not mean real waypoints, I meant this:

http://community.bistudio.com/wiki/move

Share this post


Link to post
Share on other sites

Yes Zen.. that's the ticket! Thank you, this gives me something to work with. I appreciate your help as I'm pretty new to scripting... and I don't have strong trig.

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  

×