You can/should set an 'action' for each waypoint. There are a bunch of different actions, everything from just flying from point to point to attacking nearby aircraft or ground targets, or taking off or landing.
So maybe your waypoints don't have the right action attached to them? I don't know what the default action would be, if you don't set one.
Example:
Code:
aaWP = new AiAirWayPoint(ref point, speed);
aaWP.Action = AiAirWayPointType.NORMFLY;
Other example actions:
Code:
AiAirWayPointType.GATTACK_TARG
AiAirWayPointType.GATTACK_POINT
aawp == AiAirWayPointType.COVER
aawp == AiAirWayPointType.ESCORT
aawp == AiAirWayPointType.FOLLOW
You can find all this info in the 'object browser' in Visual Studio if you go & load all the CloD .dlls into it. There are instructions for doing this online somewhere.
Also, your code seems to assume that "Timeout" waits for 10 seconds or whatever? It delays only the things that are within the Timeout call. Then it moves on to the next line of code instantly.
For example this code will settask agt then agt2 immediately, then 1 second later a message will pop up:
Code:
aiAirGroup.setTask(agt, aiAirGroup);
Timeout(initTime += 1, () =>
{
GamePlay.gpHUDLogCenter("Wait 1 s" );
});
aiAirGroup.setTask(agt2, aiAirGroup);
The other tip is, I'm pretty sure you need to set the first waypoint to the aircraft's current position. I can't remember what happens if the first waypoint is just way off somewhere, but I don't think it is good.
Here is a routine I've used to get a waypoint with the current speed/position, etc:
Code:
public AiWayPoint CurrentPosWaypoint(AiAirGroup airGroup, AiAirWayPointType aawpt = AiAirWayPointType.NORMFLY)
{
try
{
AiAirWayPoint aaWP = null;
//double speed = (airGroup.GetItems()[0] as AiAircraft).getParameter(part.ParameterTypes.Z_VelocityTAS, -1);
Vector3d Vwld = airGroup.Vwld();
double vel_mps = CalculatePointDistance(Vwld);
if (vel_mps < 70) vel_mps = 70;
if (vel_mps > 160) vel_mps = 160;
Point3d CurrentPos = airGroup.Pos();
aaWP = new AiAirWayPoint(ref CurrentPos, vel_mps);
aaWP.Action = aawpt;
return aaWP;
}
catch (Exception ex) { Console.WriteLine("CurrentPosWaypoint: " + ex.ToString()); return null; }
}
public double CalculatePointDistance(
Vector3d startPoint)
{
//Calculate the length of the adjacent and opposite
double diffX = Math.Abs(startPoint.x);
double diffY = Math.Abs(startPoint.y);
return distance(diffX, diffY);
}
But to answer your basic question: yes, it is very possible to reprogram an aircraft (or ship, vehicle, etc) path on the fly and so modify their flightplan and behavior.
Here is a module we use that makes extensive use of this idea - might give you some examples to look at:
https://github.com/bhugh/TWC_Mission...tsubmission.cs
Bookmarks