I found this somewhere a while ago and just changed the timer for the AIAircraft:
Code:
public override void OnTickGame()
{
double initTime;
if (MissionTimer1M1.Elapsed.Minutes >= 59)
{
MissionTimer1M1.Restart();
foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(MissionNumber)) // Zeile L schen wenn auch AAA entfernt werden soll
{
AiActor[] members = group.GetItems();
for (int i = members.Length - 1; i > -1; i--)
{
(members[i] as AiAircraft).Destroy();
}
}
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
//Ground objects (except AA Guns) will die after 55 min when counted from their birth
public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);
if (actor is AiGroundActor)
if ((actor as AiGroundActor).Type() != maddox.game.world.AiGroundActorType.AAGun)
Timeout(3599, () =>
{
if (actor != null)
{ (actor as AiGroundActor).Destroy(); }
}
);
}
Note that you need to set the MissionTimer1M1 Stopwatch accordingly, f.e. in the OnBattleStarted-Section of you script:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
using System.Diagnostics;
public class Mission : AMission
{
Stopwatch MissionTimer1M1 = new Stopwatch();
public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionNumberListener = -1;
}
...
..
.
I found some issues with removing of the AI Airplanes, but these will be removed after landing by the standard remove-Ai-after-player-leaving script, so I left it that way. For ground units it works well.