View Single Post
  #3  
Old 09-16-2011, 08:25 AM
SNAFU SNAFU is offline
Approved Member
 
Join Date: Feb 2011
Posts: 324
Default

Quote:
Originally Posted by Das Attorney View Post
Thanks

I managed to modify the script to only work on player planes by adding a condition to ignore AI planes - using !isAiControlledPlane(aircraft)

It's working for player planes only now quite nicely.
Would you be so kind and check the code below, in which I tried to modify the script according to your hint (at the end of the original script) and tell me if this is the right direction?


Code:
...
..
.
    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);

	if (!isAiControlledPlane(aircraft))	// SNAFU
 	{   	//SNAFU

        Timeout(5, () =>
        {
            aircraft.Destroy();
        });
    	}

	return; 	// SNAFU
    }	// SNAFU

  public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftLanded(missionNumber, shortName, aircraft);
 
	if (!isAiControlledPlane(aircraft))	// SNAFU
 	{   	//SNAFU
    
        AiAirport NearestAirport = FindNearestAirport(aircraft);          
        if (NearestAirport != null)
        {
            PlanesQueue CurPlane = new PlanesQueue(aircraft, NearestAirport, 0);
            int ArmyPos = 0;
            CurPlane.health = (float)aircraft.getParameter(part.ParameterTypes.M_Health, -1);  
            if (GamePlay.gpFrontExist())
            {
                ArmyPos = GamePlay.gpFrontArmy(NearestAirport.Pos().x, NearestAirport.Pos().y);
            }
            else { ArmyPos = aircraft.Army(); };
            if (CurPlane.health < 1f)  
            {
                CurPlane.State |= ServiceType.EMERGENCY;
                CurPlane.State |= ServiceType.FIRE;
            }
            else if (aircraft.Army() == ArmyPos)
            {
                CurPlane.State |= ServiceType.FUEL;
                CurPlane.State |= ServiceType.AMMO;
                if (aircraft.Type() == AircraftType.Bomber) CurPlane.State |= ServiceType.BOMBS;
            };
            if (!(aircraft.Army() == ArmyPos)) CurPlane.State |= ServiceType.PRISONERCAPTURE;
            if (!CurPlanesQueue.Contains(CurPlane))
            {
                CurPlanesQueue.Add(CurPlane);
                CheckEmrgCarOnAirport(CurPlanesQueue.Count - 1);                
            }
            else
            {
                for (int i = 0; i < CurPlanesQueue.Count; i++)
                    if (CurPlanesQueue[i] == CurPlane)
                    { 
                        CheckEmrgCarOnAirport(i);                        
                        break;
                    }
            }
            CurPlane = null;
        };
    }
	return; 	// SNAFU
    	}	// SNAFU
}
__________________
http://cornedebrouwer.nl/cf48e
Reply With Quote