ok the mission now works, so that the submissions will be loaded and also the planes are destroyed after they have landed.
but ground vehicles and trains just remain on the map after they have reached their last waypoint.how can i make it, that they achieve their "task"?
HTML Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using maddox.game;
using maddox.game.world;
public class Mission : AMission
{
Stopwatch MissionTimer = new Stopwatch();
public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionTimer.Start();
MissionNumberListener = -1;
}
public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
if(IsActorDestroyable(aircraft))
aircraft.Destroy();
}
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
if (IsActorDestroyable(aircraft))
aircraft.Destroy();
}
private bool IsActorDestroyable(AiActor actor)
{
bool actorDestroyable = true;
//Check if actor is empty (no Player)
if (actor is AiAircraft)
{
if ((actor as AiAircraft).ExistCabin(0))
for (int i = 0; i < (actor as AiAircraft).Places(); i++)
{
if ((actor as AiAircraft).Player(i) != null)
{
actorDestroyable = false;
break;
}
}
}
else if (actor is AiGroundActor)
{
if ((actor as AiGroundActor).ExistCabin(0))
for (int i = 0; i < (actor as AiGroundActor).Places(); i++)
{
if ((actor as AiGroundActor).Player(i) != null)
{
actorDestroyable = false;
break;
}
}
}
return actorDestroyable;
}
// to remove GroundActors after their Task is completed
public override void OnActorTaskCompleted(int missionNumber, string shortName, AiActor actor)
{
base.OnActorTaskCompleted(missionNumber, shortName, actor);
if (actor is AiGroundActor)
if (IsActorDestroyable(actor))
(actor as AiGroundActor).Destroy();
}
public override void OnTickGame()
{
if(MissionTimer.Elapsed.TotalSeconds >= 30) //Loads a mission every 120s
{
Random ZufaelligeMission = new Random();
MissionTimer.Restart(); // Sets timer to 0 and start again
switch (ZufaelligeMission.Next(1,4))
{
case 1:
GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission1.mis");
break;
case 2:
GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission2.mis");
break;
case 3:
GamePlay.gpPostMissionLoad("missions\\Blitzkrieg\\mission3.mis");
break;
}
}
}
}