SoW Reddog
Nov-09-2013, 09:03
Hi all, Salmo gave me this function
#region Returns whether aircraft is an Ai plane (no humans in any seats)
private bool isAiControlledPlane(AiAircraft aircraft)
{ // returns true if specified aircraft is AI controlled with no humans aboard, otherwise false
if (aircraft == null) return false;
//check if a player is in any of the "places"
for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null) return false;
}
return true;
}
#endregion
Problem is, that it doesn't seem to work correctly in the following
public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);
AiAircraft a = actor as AiAircraft;
if (a != null && isAiControlledPlane(a))
{
//do stuff because it's an AI controlled plane
}
} as it's definitely adding in the players spawning in. I don't understand why though.
#region Returns whether aircraft is an Ai plane (no humans in any seats)
private bool isAiControlledPlane(AiAircraft aircraft)
{ // returns true if specified aircraft is AI controlled with no humans aboard, otherwise false
if (aircraft == null) return false;
//check if a player is in any of the "places"
for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null) return false;
}
return true;
}
#endregion
Problem is, that it doesn't seem to work correctly in the following
public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);
AiAircraft a = actor as AiAircraft;
if (a != null && isAiControlledPlane(a))
{
//do stuff because it's an AI controlled plane
}
} as it's definitely adding in the players spawning in. I don't understand why though.