jwllorens 43 Posted June 24, 2016 Ok, so I have been playing around on Tanoa. Very cool map. But there are loads of problems any time I try to do anything with any of the new assets. For example, the armed blackfish has all its guns on the left side of the hull. The "loiter" waypoint causes the aircraft to travel in a clockwise circle. ehem. Come on Bohemia, why don't you ever even consider that people want to use AI, especially scripted to do something like shoot at a point in space, in their missions!?!?! Anyways, I am working on a scripted workaround. I need to give the blackfish a bunch of "move" waypoints in a perfect circle around a target position. The trick isn't making a bunch of waypoints in a circle, though, the trick is to get the blackfish to follow them in a counterclockwise rotation. Part of the issue is placing the first waypoint. I need to get the position of the blackfish, the target position, get the direction from the target position to the blackfish, add 90 degrees to it, convert the result to radians, use that new angle to calculate a point on a circle around the target position that will ALWAYS be on the blackfish's right as it flies towards the target point. Then I have issues with cycling through radians as I generate the position of each waypoint. What do I do when I generate a number greater than 2 pi? less than zero? how do I come back around? Would it be easier to generate all the positions at once, sequentially in an array, then find the one that is the "rightmost" position when looking at the target position in the blackfish, rearrage the array by circularly "shifting" the elements until the rightmost is first, and then adding the waypoints sequentially? Share this post Link to post Share on other sites
serena 151 Posted June 24, 2016 // Arguments: [InitialObjectOrPosition, CirclingOriginObjectOrPosition, CircleRadius, WaypointCount, InitialAngleRelative] Fn_GetPositionsAroundCounterClockwise = { params ["_unt", "_trg", "_rad", "_wpc", "_ang"]; private _res = []; for "_wpn" from 0 to (_wpc - 1) do { _res pushBack (_trg getPos [_rad, -360 / _wpc * _wpn + _ang + (_unt getDir _trg)])}; _res }; Mission: Circling.Altis UPD: Fixed code 1 Share this post Link to post Share on other sites
jwllorens 43 Posted June 24, 2016 That is wonderful but unfortunately it is missing the point a little. Let me clarify. I know how to generate points at intervals around the circumference of a circle, given the radius and center. I can also figure how to generate them sequentially in a counterclockwise pattern. This works for what I want, but lets imagine that I generate waypoints and add them to a group in the order they are created, for a group in a plane (the blackfish). EVENTUALLY the blackfish will follow them closely and smoothly in the counterclockwise circle that I want. However, the blackfish might approach this circle to begin on its path along these waypoints from any direction. What this means is that the first waypoint in the waypoint list might be generated on the LEFT of the centerpoint of the circle (relative to the blackfish). So then the blackfish would travel to this waypoint, complete it, and then need to loop back around almost 180 degrees to get to the next waypoint. The idea behind what I want to do is always make sure that if you draw a line between the two points for the positions of the blackfish and the center of the circle, the FIRST position on the perimeter of the circle generated for the waypoints all around the perimeter will ALWAYS be on the right side. In other words, it will always be at a right angle to an imaginary line between the centerpoint of the circle and the position point of the blackfish. Imagine the target point (center of the circle) is at the north of the map. The blackfish is DIRECTLY south. The first point on the perimeter of the circle around the target point would be directly EAST of the target point, exactly _radius away from it on the X axis. This would ensure that the blackfish approaches from a vector that would be appropriate for circling the target point immediately in a counterclockwise rotation. Then comes the hassle of trying to fudge with the AI to get the pilot to carry on about this course and ignore enemies while still allowing the gunners to freely engage anything they see. Share this post Link to post Share on other sites
kylania 568 Posted June 24, 2016 Maybe leave math out of it and just use a Loiter waypoint? :) Share this post Link to post Share on other sites
serena 151 Posted June 24, 2016 The idea behind what I want to do is always make sure that if you draw a line between the two points for the positions of the blackfish and the center of the circle, the FIRST position on the perimeter of the circle generated for the waypoints all around the perimeter will ALWAYS be on the right side. In other words, it will always be at a right angle to an imaginary line between the centerpoint of the circle and the position point of the blackfish. I can not guarantee anything for the blackfish, but in my example waypoints are calculated exactly as you want. When additional angle is 90 degree (90 + (blackfish_initial_position directionTo circling_origin_position)) Share this post Link to post Share on other sites
jwllorens 43 Posted June 24, 2016 Oh my gosh. I feel so stupid now. Anyways, I got the script to work fine. I can create any number of points around a circle given the center, and specify the radius or the order (clockwise or counterclockwise) that I want to create them. Given a point outside of the circle, I can also specify a relative direction modifier to begin calculating the points at, so the first point will always be at a certain angle or tangent to the line I described earlier (for some reason 90 degrees doesn't work but 120 does when using getDir?) I did all that, tried loads of values to get the blackfish to follow the waypoints smoothly so it is banked slightly to the left for the majority of the time and therefore has guns on target (like an AC-130 IRL). Then I found this: https://community.bistudio.com/wiki/setWaypointLoiterType So. It turns out you can set a loiter waypoint to go counterclockwise with a simple command. Well ain't that somethin'. Kylania is on point. Share this post Link to post Share on other sites