PDA

View Full Version : Removal of AI from submissions


SNAFU
07-27-2011, 07:49 AM
I am trying to remove the AI which was loaded via submission with the script of the submission. The submission is lasting max. 3hrs then a new missions will be laoded. I use the following for removal of the AI planes



public override void OnTickGame()
{
double initTime;

if (Time.tickCounter() % 324000 == 323999) // 180mins
{

foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber))
{
AiActor[] members = group.GetItems();
for (int i = members.Length - 1; i > -1; i--)
{
(members[i] as AiAircraft).Destroy();
}
}
}
foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber))
{
AiActor[] members = group.GetItems();
for (int i = members.Length - 1; i > -1; i--)
{
(members[i] as AiGroundActor).Destroy();
}
}
}
}
}
}

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{

base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiGroundActor)
{
Timeout(324000, () => { // nach 180minuten werden AI entfernt
if (actor != null)
{
(actor as AiGroundActor).Destroy();
}
});
}
}


The "AIGroundGroup" is not really necessary I think, due the fact that actuall no ground groups are on the map, on AI ships, which should be take out of the map by the last part "AIGroundActor", at least that worked while testing. But now I already declared a "public override void OnTickGame()" in the main script to have time counter for the submission loading. Might that cause some problems and are there some issues I ve overseen? Testing on a small map it worked well with the removal of planes and groundunits, but it might be related to planes dissappearing or not even spawing visible, but possible to switch onto in the external view.
The mission with this script will be loaded into the main map after 1minute, so the 324000 ticks should acutally be far away?

Ataros
07-27-2011, 08:12 AM
I am not an expert in C# but maybe it is worth trying to do actor removal in the main script like

onActorCreated
timeout 180mins
destroy

It is done this way on Repka1. Check out the script in the mission http://forum.1cpublishing.eu/showpost.php?p=297605&postcount=44

I may guess that the code you posted destroys aircrafts not only once in 3 hours but every 3 hours... and if you load this code with every submission and if you have many submissions... there will be many pieces of code active that destroy aircraft every 3 hour. Many airgroups will be destroyed resulting in disappearing dots. Make sure all your airgroups have a landing waypoint in the end to prevent them from disappearing in the air.

Do you experience ghost planes on the server in the 1st 3 hours into the mission?

SNAFU
07-27-2011, 08:28 AM
Basically I am looking for an historically approach for squadron training and so the main missions will last 2-3 hours and are concentrated on one area, but every mainmission, might concentrate on another area. Therefore the submissions will be loaded every 3 hours. The intercept planes, triggered by planes entering a certain area, are reloaded every 2 hours, same for patrols over the channel.
This way I do load missions every 2 hours this shall keep the spawn freezes at bay and does not lead to a too crowded channel. ;) (I put all AI on radio silence, too, hope that does not cause problems with the radar.)

If I include the removal script into the main script, the AI will be removed no matter which submission loaded them. I think, but am not quite sure due to tie inaccuracy, the removal in the submissionscripts, do only remove the mission-loaded-AI and not the AI of other mis.files.

Some AI planes spawn, start rolling and disappear but keep on rolling as you see in the external view, this already after 30 seconds in game. Vessels too. The same happens without any script at all. When I host on my PC or play the mission SP, I do not have any problems, only when I play as client on our dedicated server.

FG28_Kodiak
07-27-2011, 08:56 AM
Can i have the complete code, please.
What i see will not work correctly, without some improvements ;)

SNAFU
07-27-2011, 09:14 AM
Can i have the complete code, please.
What i see will not work correctly, without some improvements ;)

As you wish! :grin:
This is main mission script:


using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{
////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// Abschnitt: Lade zufaellige Reihenfolge eine Submission


int LastMissionLoaded = 0;

double initTime;


public override void OnTickGame()
{
if (Time.tickCounter() % 216000 == 1800) // 1800 = 1min Beginn, wiederholt sich alle 120min
{ // randomly selects 1 of several submissions excluding the recent one

Random RandomIncident = new Random();
int CurrentMissionSelected;

do

CurrentMissionSelected = RandomIncident.Next(1, 4); // Hier ist die zweite Zahl in der Klammer die Anzahl Optionen + 1, du hast 3 Submissionen, also (1, 4)

while (LastMissionLoaded == CurrentMissionSelected);

LastMissionLoaded = CurrentMissionSelected;

switch (CurrentMissionSelected)

{
case 1:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940/Mid-July1940Submissionen/Mission1.mis"); // hier der Submission A den Pfad korrekt eingeben
GamePlay.gpHUDLogCenter("12th July - Mission No1 tasks set"); // hier Nachricht welche nach laden der Mission kommen soll

initTime = 0.0;
Timeout(initTime += 1800, () => // Hier Zeit (30) in Sekunden eingeben nach welcher die 1te Nachricht kommen soll, nach laden der Mission A
{
GamePlay.gpHUDLogCenter("30minutes into mission"); // Hier Text der 1ten Nachricht
});
Timeout(initTime += 3600, () => // Hier Zeit (60) in Sekunden eingeben nach welcher die 2te Nachricht kommen soll
{
GamePlay.gpHUDLogCenter("60 minutes into mission"); // Hier Text der 2ten Nachricht
});
break;
case 2:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940/Mid-July1940Submissionen/Mission1.mis"); // hier der Submission B den Pfad korrekt eingeben
GamePlay.gpHUDLogCenter("12th July - Mission No1 tasks set"); // hier Nachricht welche nach laden der Mission kommen soll

initTime = 0.0;
Timeout(initTime += 1800, () => // Hier Zeit (30) in Sekunden eingeben nach welcher die 1te Nachricht kommen soll, nach laden der Mission A
{
GamePlay.gpHUDLogCenter("30minutes into mission"); // Hier Text der 1ten Nachricht
});
Timeout(initTime += 3600, () => // Hier Zeit (60) in Sekunden eingeben nach welcher die 2te Nachricht kommen soll
{
GamePlay.gpHUDLogCenter("60 minutes into mission"); // Hier Text der 2ten Nachricht
});
break;
case 3:
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940/Mid-July1940Submissionen/Mission1.mis"); // hier der Submission C den Pfad korrekt eingeben
GamePlay.gpHUDLogCenter("12th July - Mission No1 tasks set"); // hier Nachricht welche nach laden der Mission kommen soll

initTime = 0.0;
Timeout(initTime += 1800, () => // Hier Zeit (30) in Sekunden eingeben nach welcher die 1te Nachricht kommen soll, nach laden der Mission A
{
GamePlay.gpHUDLogCenter("30minutes into mission"); // Hier Text der 1ten Nachricht
});
Timeout(initTime += 3600, () => // Hier Zeit (60) in Sekunden eingeben nach welcher die 2te Nachricht kommen soll
{
GamePlay.gpHUDLogCenter("60 minutes into mission"); // Hier Text der 2ten Nachricht
});
break;
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////Abschnitt: Lade regelmaeßig eine Submission ohne Nachricht
//

if (Time.tickCounter() % 162000 == 36000) // Start nach 20min, Wiederholung nach 1,5h
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940Mid-July1940Submissionen/Intercept1.mis"); // hier der Submission Wiederholung den Pfad korrekt eingeben
}

if (Time.tickCounter() % 216000 == 18000) // Start nach 10min=18000, Wied3erholung nach 2 Stundem 216000=120min
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940/Mid-July1940Submissionen/Intercept2.mis"); // hier der Submission Wiederholung den Pfad korrekt eingeben
}

if (Time.tickCounter() % 129600 == 1800) // Start nach 1min, Wiederholung nach 12h
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/July1940/Mid-July1940Submissionen/Vesseltraffic1.mis"); // hier der Submission Wiederholung den Pfad korrekt eingeben
}

}

//////////////////////////////////////////////////////////////////////////////////////////////////
////////////Abschnitt: Events aus Submission werden beruecksichtigt aktiviert

public override void Init(maddox.game.ABattle battle, int missionNumber)
{
base.Init(battle, missionNumber);
MissionNumberListener = -1;
}

//andere Version für Redudanz
public override void OnBattleStarted()
{
base.OnBattleStarted();

//listen to events from all missions.
MissionNumberListener = -1;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////Abschnitt: Verlassene Flieger werden zerstoert/entfernt (Syndicate Server Version)

// destroys aircraft abandoned by a player.
private bool isAiControlledPlane (AiAircraft aircraft)
{
if (aircraft == null)
{
return false;
}

Player [] players = GamePlay.gpRemotePlayers ();
foreach (Player p in players)
{
if (p != null && (p.Place () is AiAircraft) && (p.Place () as AiAircraft) == aircraft)
{
return false;
}
}

return true;
}

private void destroyPlane (AiAircraft aircraft) {
if (aircraft != null) {
aircraft.Destroy ();
}
}

private void explodeFuelTank (AiAircraft aircraft)
{
if (aircraft != null)
{
aircraft.hitNamed (part.NamedDamageTypes.FuelTank0Exploded);
}
}

private void destroyAiControlledPlane (AiAircraft aircraft) {
if (isAiControlledPlane (aircraft)) {
destroyPlane (aircraft);
}
}

private void damageAiControlledPlane (AiActor actor)
{
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.Pars e(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
}

/***Timeout (240, () =>
{explodeFuelTank (aircraft);}
);
* ***/

Timeout (150, () =>
{destroyPlane (aircraft);}
);
}

//////////////////////////////////////////

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 (150, () =>
{ destroyPlane(aircraft); }
);
}
public override void OnAircraftLanded (int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
Timeout(150, () =>
{ destroyPlane(aircraft); }
);
}

}


This is main submission Script:


using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{
//-----------------------------------------------------------------------------------------------
//Section 1: Trigger Nachrichten

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
if ("Trigger1R".Equals(shortName) && active) //Trigger 1 Nachricht
{
GamePlay.gpHUDLogCenter("Blue succeeded and sunk 3 red tanker");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("Trigger2R".Equals(shortName) && active) //Trigger 1 Nachricht
{
GamePlay.gpHUDLogCenter("Red successfully reconnoitered LeHavre");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("Trigger1B".Equals(shortName) && active) //Trigger 2 Nachricht
{
GamePlay.gpHUDLogCenter("Red succeeded and shot down 20% blue bomber");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

// Trigger Aktionen
base.OnTrigger(missionNumber, shortName, active);

if ("SpawnIntercept1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("SpawnIntercept1");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("SpawnIntercept2".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("SpawnIntercept2");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("SpawnEscort1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("SpawnEscort1");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("SpawnEscort2".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("SpawnEscort2");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("SpawnStuka1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("SpawnStuka1");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("SpawnStuka2".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("SpawnStuka2");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}




//-----------------------------------------------------------------------------------------------
//Section 3: Briefing

public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);
AiAircraft aircraft = actor as AiAircraft;

if (aircraft != null)
switch (aircraft.Army())
{
case 1:
if (aircraft.Type() == AircraftType.Bomber) //Nachricht fuer rote Spieler beim spawnen
{ GamePlay.gpHUDLogCenter(new Player[] {player},"Fly a recon from Manston -AW25 to LeHavre -AN4"); }
else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Cover our shipping south of Isle of White - AD17"); }
break;
case 2:
if (aircraft.Type() == AircraftType.Bomber) //Nachricht fuer blaue Spieler beim spawnen
{ GamePlay.gpHUDLogCenter(new Player[] { player }, "Attack britisch shipping south of Isle of White - AD17"); }
else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Escort Ju87 from Theville - AC6 to AE15"); }
break;

}
}

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

if (GamePlay.gpPlayer().Place() != aircraft)
return;

switch (aircraft.Army())
{
case 1:
if (aircraft.Type() == AircraftType.Bomber) //Nachricht fuer rote Spieler nach Start
{ GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Fly a recon from Manston -AW25 to LeHavre -AN4"); }
else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Cover our shipping south of Isle of White - AD17"); }
break;
case 2:
if ((aircraft.Type() == AircraftType.Bomber) || (aircraft.Type() == AircraftType.DiveBomber)) //Nachricht fuer blaue Spieler nach Start
{ GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Attack britisch shipping south of Isle of White - AD17"); }
else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Escort Ju87 from Theville - AC6 to AE15"); }
break;

}
}

//Section 4 : AI entfernen
public override void OnTickGame()
{
double initTime;

if (Time.tickCounter() % 324000 == 323999) // Nach 180 Minuten werden die AI wieder entfernt
{

foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // 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();
}
}
}
foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // 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 AiGroundActor).Destroy();
}
}
}
}
}
}

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{

base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiGroundActor)
{
Timeout(324000, () => { // nach 180minuten werden AI entfernt
if (actor != null)
{
(actor as AiGroundActor).Destroy();
}
});
}
}
}



This is intercept script:


using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("RedIntercept1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("RedIntercept1");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("RedIntercept2".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("RedIntercept2");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("RedIntercept3".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("RedIntercept3");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("RedIntercept4".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("RedIntercept4");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("RedIntercept5".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("RedIntercept5");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("BlueIntercept1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("BlueIntercept1");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("BlueIntercept2".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("BlueIntercept2");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("BlueIntercept3a".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("BlueIntercept3a");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("BlueIntercept3b".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("BlueIntercept3b");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("BlueIntercept4a".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("BlueIntercept4a");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("BlueIntercept4b".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("BlueIntercept4b");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("BlueIntercept5a".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("BlueIntercept5a");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("BlueIntercept5b".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("BlueIntercept5b");
if (action != null)
{
action.Do();
}
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}





public override void OnTickGame()
{
double initTime;

if (Time.tickCounter() % 160200 == 160199) // Nach 89 Minuten werden die AI wieder entfernt, wiederholt sich jede 2h
{

foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // 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();
}
}
}
foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // 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 AiGroundActor).Destroy();
}
}
}
}
}
}

}



This is patrol script:


using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{




public override void OnTickGame()
{
double initTime;

if (Time.tickCounter() % 214200 == 214199) // Nach 119 Minuten werden die AI wieder entfernt, wiederholt sich jede 2h
{

foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // 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();
}
}
}
foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // 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 AiGroundActor).Destroy();
}
}
}
}
}
}

}


And this is script for vesseltraffic:


using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : AMission
{ public override void OnTickGame()
{
double initTime;

if (Time.tickCounter() % 1294800 == 1294799) // Nach 11h59min Minuten werden die AI wieder entfernt, wiederholt sich jede 2h
{

foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // 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();
}
}
}
foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // 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 AiGroundActor).Destroy();
}
}
}
}
}
}

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{

base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiGroundActor)
{
Timeout(43140, () => { // nach 11h59minuten werden AI entfernt
if (actor != null)
{
(actor as AiGroundActor).Destroy();
}
});
}
}
}



That is not the latest version, in but basically more or less.

SNAFU
07-27-2011, 09:19 AM
As stated, the removal after time ticks worked so far on a small island map, but might not visible planes and ships (only smoke visible) related to the script?

I don´t think so, cause the planes also disappeared, without using any script at all, if i remember that right (spent around 20hrs testing on that script so far :rolleyes: ).

Furthermore I would need to know if the script in submission 1 removes AI from Submission 2 also? I couldn´t really find out while testing, because at some point i reduced mission times and removal times to only 10-20 seconds for better testing and it became a little confusing in the end. (Besides you are getting nuts after so many hours testing... ;) )

FG28_Kodiak
07-27-2011, 04:46 PM
Can you pm me the complete Mission (you know the german forum ;) )
I see serveral problems at the moment, so it's better i get a actual copy.

SNAFU
07-27-2011, 06:26 PM
Done.

Ataros
09-25-2011, 09:34 PM
TheEnlightenedFlorist offered his solution here
http://forum.1cpublishing.eu/showthread.php?t=23606

Not sure if it destroys ground units and ships.

You can try searching the forum for "actor destroy" to find more posts about this.