PDA

View Full Version : delaying AI-flights



Barraclough
Feb-09-2016, 08:19
Greeting all on the ATAG Forum

I wonder if there's a possibility in CloD to delay the start off time of an AI- flight.
Till so far I can't find a way to make that happen.

Can somebody help me here?
Barraclough

LARRY69
Feb-09-2016, 08:56
Hi, look at this, maybe it helps..

http://jimeez.weebly.com/triggers.html

cheers Larry

ATAG_Freya
Feb-09-2016, 10:10
You can use triggers and actions, if you so desire. USe the Ttime trigger and put an action to it (the action being spawn a flight of a/c). This example is from an old multiplayer mission:

in the script:


base.OnTrigger(missionNumber, shortName, active);

if ("F1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("action1");
if (action != null)
{
action.Do();
}
Timeout(10, () => sendScreenMessageTo(2, "Do 17's requesting escort! Meet at Calais at 6km in 10 minutes", null));
Timeout(600, () => sendScreenMessageTo(1, "Do 17's have been spotted over Calais @ 6000m heading west!", null));
GamePlay.gpGetTrigger(shortName).Enable = false;
}

In the .mis file


[AirGroups]
BoB_LW_KuFlGr_706.03
[BoB_LW_KuFlGr_706.03]
Flight0 1 2 3
Flight1 11 12
Class Aircraft.Do-17Z-2
Formation ECHELONLEFT
CallSign 29
Fuel 100
Weapons 1 1 1 1 1 1 5 2
SpawnFromScript 1
Skill 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3
[BoB_LW_KuFlGr_706.03_Way]
NORMFLY 343645.93 209815.65 6000.00 250.00
NORMFLY 265839.98 218732.06 6000.00 250.00
NORMFLY 245338.44 222772.07 6000.00 250.00
GATTACK_POINT 225078.39 228480.06 6000.00 250.00
NORMFLY 220038.89 230488.22 6000.00 250.00
NORMFLY 224067.89 236254.89 6000.00 250.00
NORMFLY 230789.18 236714.16 6000.00 250.00
LANDING 311609.17 190444.20 6000.00 250.00

[Trigger]
F1 TTime 1200

[Action]
action1 ASpawnGroup 1 BoB_LW_KuFlGr_706.03

When I have time later I can send you the whole mission for reference if you like. But this is the only way I know how, there may be a better way - not sure!

~S~

Barraclough
Feb-09-2016, 11:47
Thanks very much LARRY69 for the link to Basic Triggers,good old Kodiak's tutorial and you too ATAG_Freya for your Time trigger script example.
Think this information is sufficient and will be a great help, if not I let you know.

cheers Barraclough

Barraclough
Feb-10-2016, 04:50
Hi Larry69 and ATAG_Freya

Successfully spawned an AI- flight, that's ok now. But I wonder if there's a way by script to delay just the start off time of an AI flight, while the planes are visible from game-start on at their hangars or spawning points.

Barraclough

LARRY69
Feb-10-2016, 07:24
hmm... I wonder it`s possible ? ..ATAG Fraya?:S

Barone
Aug-24-2022, 10:57
You can use triggers and actions, if you so desire. USe the Ttime trigger and put an action to it (the action being spawn a flight of a/c). This example is from an old multiplayer mission:

in the script:


base.OnTrigger(missionNumber, shortName, active);

if ("F1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("action1");
if (action != null)
{
action.Do();
}
Timeout(10, () => sendScreenMessageTo(2, "Do 17's requesting escort! Meet at Calais at 6km in 10 minutes", null));
Timeout(600, () => sendScreenMessageTo(1, "Do 17's have been spotted over Calais @ 6000m heading west!", null));
GamePlay.gpGetTrigger(shortName).Enable = false;
}

In the .mis file


[AirGroups]
BoB_LW_KuFlGr_706.03
[BoB_LW_KuFlGr_706.03]
Flight0 1 2 3
Flight1 11 12
Class Aircraft.Do-17Z-2
Formation ECHELONLEFT
CallSign 29
Fuel 100
Weapons 1 1 1 1 1 1 5 2
SpawnFromScript 1
Skill 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3
[BoB_LW_KuFlGr_706.03_Way]
NORMFLY 343645.93 209815.65 6000.00 250.00
NORMFLY 265839.98 218732.06 6000.00 250.00
NORMFLY 245338.44 222772.07 6000.00 250.00
GATTACK_POINT 225078.39 228480.06 6000.00 250.00
NORMFLY 220038.89 230488.22 6000.00 250.00
NORMFLY 224067.89 236254.89 6000.00 250.00
NORMFLY 230789.18 236714.16 6000.00 250.00
LANDING 311609.17 190444.20 6000.00 250.00

[Trigger]
F1 TTime 1200

[Action]
action1 ASpawnGroup 1 BoB_LW_KuFlGr_706.03

When I have time later I can send you the whole mission for reference if you like. But this is the only way I know how, there may be a better way - not sure!

~S~

Hi,

is it possible also to despawn the AI after a certain time or a specific waypoint?

tks

ATAG_Oskar
Aug-24-2022, 16:33
Hi,

is it possible also to despawn the AI after a certain time or a specific waypoint?

tks

If your last waypoint is a Landing waypoint, which it should be, then they will land and despawn. The default is ten minutes after landing but you can change that.

Barone
Aug-24-2022, 19:40
If your last waypoint is a Landing waypoint, which it should be, then they will land and despawn. The default is ten minutes after landing but you can change that.

Hi Oskar,
Noted thanks.

Is it also possible to despawn them in flight?

ATAG_Oskar
Aug-28-2022, 19:34
Is it also possible to despawn them in flight?

There is no way to do this with the FMB.

GANIX
Aug-28-2022, 20:35
Deleted by GANIX.

Sleepy_Fly
Aug-29-2022, 14:14
Hello,

Yes, Ganix puts the finger on it.

I found a solution (for MP or lobby)
You need to know the name of the group to destroy. Please note, you need to prefix the name with '0:' (don't know why and to lazy to find the reason)
This solution parse all groups in all army (function DestroyTarget() called by menu). The group name is compared to the one to destroy.
Once the group found, check each actor if it is an AI (we don't want commit a suicide or kill one of our wingmen), if not a player we can destroy the actor.

You can test it with this mission and code.
Hope that help.

Mission :


[PARTS]
core.100
bob.100
tobruk.100
[MAIN]
MAP Land$English_Channel_1940
DespawnAfterLandingTimeout 600
BattleArea 0 0 393215 393215 5000
TIME 10.0000002421439
WeatherIndex 0
CloudsHeight 1000
BreezeActivity 10
ThermalActivity 10
[GlobalWind_0]
Power 3.000 0.000 0.000
BottomBound 0.00
TopBound 1500.00
GustPower 0
GustAngle 45
[splines]
[AirGroups]
BoB_RAF_F_FatCat_Early.01
[BoB_RAF_F_FatCat_Early.01]
Flight0 1 2 3 4
Class Aircraft.SpitfireMkIIa
Formation VIC3
CallSign 26
Fuel 100
Weapons 1
Skill 0.84 0.53 0.53 0.37 0.37 0.53 0.53 0.53
Aging 0
[BoB_RAF_F_FatCat_Early.01_Way]
NORMFLY 206207.10 160896.00 500.00 300.00
NORMFLY 206438.40 160896.00 500.00 300.00
NORMFLY 206668.80 188543.10 500.00 300.00
NORMFLY 240998.40 212275.20 500.00 300.00
NORMFLY 277401.60 247065.60 500.00 300.00
[CustomChiefs]
[Stationary]
[Buildings]
[BuildingsLinks]
[BirthPlace]
BirthPlace_0 1 203903 159513 500 5 0 1 . . . 0
[BirthPlace0]
Aircraft.SpitfireMkIIa



Script :



using System;
using maddox.game;
using maddox.game.world;
using maddox.GP;
using part;

public class Mission : AMission
{



private void setMainMenu(Player player)
{
GamePlay.gpSetOrderMissionMenu(player, false, 0, new string[] { "Destroy group" }, new bool[] { true });
}

public override void OnOrderMissionMenuSelected(Player player, int ID, int menuItemIndex)
{
if (ID == 0)
{
if (menuItemIndex == 1)
{
try
{
DestroyTarget();
}
catch(Exception ex)
{
GamePlay.gpLogServer("OnMenu : " + ex.Message);
}
}
}
}


public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);
try
{
setMainMenu(player);
}
catch(Exception ex)
{
GamePlay.gpLogServer(ex.Message);
}
}

private bool isAIPlane(AiAircraft aircraft)
{
if (aircraft == null) return false;
for (int i = 0; i < aircraft.Places(); i++)
{
if (aircraft.Player(i) != null) return false;
}
return true;
}

private void DestroyTarget()
{
try
{
foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if(group.Name() == "0:BoB_RAF_F_FatCat_Early.01")
{
foreach (AiAircraft item in group.GetItems())
{
if(isAIPlane(item) == true)
{
item.Destroy();
}
}
}
}
}
}
catch(Exception ex)
{

}

}


}