Results 1 to 12 of 12

Thread: delaying AI-flights

  1. #1
    Novice Pilot
    Join Date
    Mar 2013
    Posts
    62
    Post Thanks / Like
    Total Downloaded
    265.91 MB

    delaying AI-flights

    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

  2. #2
    Team Fusion LARRY69's Avatar
    Join Date
    Feb 2013
    Location
    Switzerland
    Posts
    1,060
    Post Thanks / Like
    Total Downloaded
    873.48 MB

    Re: delaying AI-flights

    Hi, look at this, maybe it helps..

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

    cheers Larry
    http://i1364.photobucket.com/albums/r739/larry691/GZ-H%201_zpsdphexiii.jpg

  3. #3
    ATAG Member ATAG_Freya's Avatar
    Join Date
    Jan 2013
    Location
    Lethbridge, Alberta
    Posts
    3,592
    Post Thanks / Like
    Total Downloaded
    16.16 MB

    Re: delaying AI-flights

    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:
    Code:
            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

    Code:
    [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~

  4. #4
    Novice Pilot
    Join Date
    Mar 2013
    Posts
    62
    Post Thanks / Like
    Total Downloaded
    265.91 MB

    Re: delaying AI-flights

    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

  5. #5
    Novice Pilot
    Join Date
    Mar 2013
    Posts
    62
    Post Thanks / Like
    Total Downloaded
    265.91 MB

    Re: delaying AI-flights

    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

  6. #6
    Team Fusion LARRY69's Avatar
    Join Date
    Feb 2013
    Location
    Switzerland
    Posts
    1,060
    Post Thanks / Like
    Total Downloaded
    873.48 MB

    Re: delaying AI-flights

    hmm... I wonder it`s possible ? ..ATAG Fraya?
    http://i1364.photobucket.com/albums/r739/larry691/GZ-H%201_zpsdphexiii.jpg

  7. #7
    Veteran Combat pilot
    Join Date
    Apr 2015
    Posts
    422
    Post Thanks / Like
    Total Downloaded
    700.64 MB

    Re: delaying AI-flights

    Quote Originally Posted by ATAG_Freya View Post
    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:
    Code:
            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

    Code:
    [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

  8. #8
    Team Fusion ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    865
    Post Thanks / Like
    Total Downloaded
    850.25 MB

    Re: delaying AI-flights

    Quote Originally Posted by Barone View Post
    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.

  9. #9
    Veteran Combat pilot
    Join Date
    Apr 2015
    Posts
    422
    Post Thanks / Like
    Total Downloaded
    700.64 MB

    Re: delaying AI-flights

    Quote Originally Posted by ATAG_Oskar View Post
    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?

  10. #10
    Team Fusion ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    865
    Post Thanks / Like
    Total Downloaded
    850.25 MB

    Re: delaying AI-flights

    Quote Originally Posted by Barone View Post
    Is it also possible to despawn them in flight?
    There is no way to do this with the FMB.

  11. #11
    Novice Pilot
    Join Date
    Oct 2021
    Posts
    49
    Post Thanks / Like
    Total Downloaded
    9.18 MB

    Re: delaying AI-flights

    The public interface AiCart provides a method: < void Destroy(); >
    So it should be possible via script (C#) I guess.
    Depending on the mission type 'Single' or 'Multi' the code is different.

    Quote Originally Posted by Barone View Post

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

    tks

  12. #12
    Supporting Member
    Join Date
    Oct 2020
    Posts
    80
    Post Thanks / Like
    Total Downloaded
    174.53 MB

    Re: delaying AI-flights

    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 :
    Code:
    [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 :
    Code:
    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)
            {
                
            }        
            
        }    
        
        
    }
    "You can teach monkeys to fly better than that!"

  13. Likes Artist, GANIX liked this post

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •