I'm trying to get an individual aircraft in an airgroup to RTB if a certain amount of damage or a particularly vital ststem is damaged. As a start, I'm just seeing if I can get the group or an airvraft in the group to RTB with the code below. I recall reading somewhere that you can't assign AI's new waypoints on the fly & that they have to go to their next waypoint before any dynamically added waypoints become active. Am I on the right track here? can anyone suggest a methodology?
Code:
public override void OnAircraftDamaged(int missionNumber, string shortName, AiAircraft aircraft, AiDamageInitiator initiator, part.NamedDamageTypes damageType)
{
base.OnAircraftDamaged(missionNumber, shortName, aircraft, initiator, damageType);
if (aircraft is AiAircraft && aircraft != null)
{
aircraft.AirGroup().setTask(AiAirGroupTask.LANDING, null);
}
}