Hi Ataros - Thanks
I'll take a look at that and see if I can't get something to work. As far as the scripts are concerned, there's nothing special lol. The knowledge all came from you guys. I just know how to copy/paste to fine tune!
But I use a combination of .cmd files (using f to load and timeout command to recycle the mission) and C# to be able to make the scripts work 24/7.
Here's the scripts for the main and submission:
Code:
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;
public class Mission : AMission
{
public override void OnBattleStarted()
{
base.OnBattleStarted();
//listen to events from all missions.
MissionNumberListener = -1;
}
public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);
Timeout(1, () =>
{ damageAiControlledPlane(actor); }
);
}
public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}
private bool isAiControlledPlane(AiAircraft aircraft)
{
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;
}
private void destroyPlane(AiAircraft aircraft)
{
if (aircraft != null)
aircraft.Destroy();
}
private void damageAiControlledPlane(AiActor actorMain)
{
foreach (AiActor actor in actorMain.Group().GetItems())
{
if (actor == null || !(actor is AiAircraft))
return;
AiAircraft aircraft = (actor as AiAircraft);
if (!isAiControlledPlane(aircraft))
return;
if (aircraft == null)
return;
aircraft.hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFailure);
int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
for (int i = 0; i < iNumOfEngines; i++)
{
aircraft.hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
}
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}
}
}
submissions
Code:
using System;
using maddox.game;
using maddox.game.world;
public class Mission : maddox.game.AMission
{
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);
if ("SpawnAirgroup1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup1");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("BR.20M's enroute to Hawkinge");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup5".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup5");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Blenheims enroute to Coquelles");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup2".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup2");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Stukas enroute to Hawkinge");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup6".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup6");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Wellingtons enroute to Caffiers");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup3".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup3");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("He 111s enroute to Lympne");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup7".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup7");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Wellingtons enroute to Pihen Airfield");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup4".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup4");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Ju 88's enroute to Hawkinge");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup8".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup8");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Wellingtons enroute to St. Inglevert");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}
As you can see there's nothing special