Results 1 to 15 of 15

Thread: What is 'taskArg' in this:

  1. #1
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    What is 'taskArg' in this:

    Any knowledge of what 'taskArg' refers to in the below please?:

    void setTask(maddox.game.world.AiAirGroupTask task, maddox.game.world.AiAirGroup taskArg)

    Member of maddox.game.world.AiAirGroup

    Ultimately though I'm still trying to figure out how to change the task of an airgroup and don't understand what 'taskArg' is in the above as I figure it is important. Any idea?


    I'm also in my desperate experiments trying to (naively/dumbly) use the following to set the task of an AirGroup to 'return' by putting in the AirGroup id of 2 in the wild hope that it needs the airgroup there:

    AiAirGroup.setTask(AiAirGroupTask.RETURN, 2);

    but I get a compile error

    error CS1503: Argument 2: cannot convert from 'int' to 'maddox.game.world.AiAirGroup'

    (I get a cannot convert form string error if I send it a string.)

    I can't quite figure out what needs to go in there, it is needing something other than a variable?

    (I am trying to learn C# but funnily enough there's no examples in any of the sources I've looked at that use Il2 Clod code as examples.)
    I am Yo-Yo not YoYo (that's someone else)

  2. #2
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: What is 'taskArg' in this:

    Code:
    public void setTask(AiAirGroupTask task, AiAirGroup taskArg)
    The task parameter is an AiAirGroupTask from this list:

    Code:
        public enum AiAirGroupTask
        {
            UNKNOWN = 0,
            FLY_WAYPOINT,
            ATTACH,
            DEFENDING,
            ATTACK_AIR,
            ATTACK_GROUND,
            PURSUIT,
            TAKEOFF,
            RETURN,
            LANDING,
            DO_NOTHING
        }
    The taskArg parameter is the AiAirGroup you want to change.

    Your call should look like this:

    Code:
    setTask(AiAirGroupTask.DO_NOTHING, someAirGroup);

  3. #3
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: What is 'taskArg' in this:

    Thanks, do you happen to know how to actually specify the someAirGroup?

    Is it this:

    [BoB_RAF_F_603Sqn_Late.02]
    or
    BoB_RAF_F_603Sqn_Late.02

    (Obviously that is the actual airgroup from the mission I am experimenting with)

    Or is there something more complex going on where I need to find some reference/numerical/array value etc.
    I am Yo-Yo not YoYo (that's someone else)

  4. #4
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: What is 'taskArg' in this:

    Two ways

    Code:
    public AiActor gpActorByName(string actorName)
    AiAirGroups are AiActors so you can cast the result.

    Or, with this array you can iterate through and find your group.

    Code:
    public AiAirGroup[] gpAirGroups(int Army)
    Actor names are in the form x:name where x is the mission number.

    So you get names like 0:BoB_LW_JG27_I.03

  5. #5
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: What is 'taskArg' in this:

    I am probably widely away form the mark here but I'm still stuck. I found a TWC mission on github that mentions AiAIrGroups, and setTask (in a commented section) and wiht what you said above have been trying to get somethign to work but am still lost. Is there a simple fix to what my garbage code below is trying?

    Code:
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using maddox.game;
    using maddox.game.world;
    using System.ComponentModel.Design;
    using System.Diagnostics;
    using maddox.GP;
    
    public class Mission : AMission
    {
    
        public override void OnBattleStarted()
    
        {
    
            GamePlay.gpHUDLogCenter("Battle started.");
            MissionNumberListener = -1;
    
    // I have 2 groups in the allied army, the first is the player, the second is Ai
    
    //I try to make an array and put the airgroups in it
    
        AiAirGroup[] Airgroups = GamePlay.gpAirGroups(1);
    
    //I try to show there is something in the second element of the array
    
            GamePlay.gpHUDLogCenter("Group is " + Airgroups[1]);
    
    // A message does display with a big, long string that looks like a UID  (i.e. random characters)
    
    //So I tried to use this array element, but I have seen two ways of setTask being used, so have tried both (one at a time, the next two lines of code I only used one at a time)
    
            AiAirGroup.setTask(AiAirGroupTask.DO_NOTHING, Airgroups[1]);
            setTask(AiAirGroupTask.DO_NOTHING, Airgroups[1]);
    
    // Without the AiAIrGroup at the start I get a compile error saying setTask does not exist in the current context
    // and with it I get an error saying An object reference is required for the non-static field, method, or property 'maddox.game.world.AiAirGroup.setTask(maddox.game.world.AiAirGroupTask, maddox.game.world.AiAirGroup)'
    
    I tried using a variable instead of the array element with the code below but got the same two errors (again last two lines I just used one or the other.)
    
    	 	AiAirGroup targetGroup;
       		targetGroup = Airgroups[1];
    
    		AiAirGroup.setTask(AiAirGroupTask.DO_NOTHING, targetGroup);
         	setTask(AiAirGroupTask.DO_NOTHING, targetGroup);
    
    
        }
    
    
    
    
    
    
    
    
    }
    I am Yo-Yo not YoYo (that's someone else)

  6. #6
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: What is 'taskArg' in this:

    Try this:

    Code:
      AiAirGroup aGroup = Airgroups[1];
      GamePlay.gpHUDLogCenter("Group is " + aGroup.Name());
    or this:

    Code:
      GamePlay.gpHUDLogCenter("Group is " + Airgroups[1].Name());
    BTW what tool are you using for development?



    Quote Originally Posted by Yo-Yo View Post
    I am probably widely away form the mark here but I'm still stuck. I found a TWC mission on github that mentions AiAIrGroups, and setTask (in a commented section) and wiht what you said above have been trying to get somethign to work but am still lost. Is there a simple fix to what my garbage code below is trying?

    Code:
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using maddox.game;
    using maddox.game.world;
    using System.ComponentModel.Design;
    using System.Diagnostics;
    using maddox.GP;
    
    public class Mission : AMission
    {
    
        public override void OnBattleStarted()
    
        {
    
            GamePlay.gpHUDLogCenter("Battle started.");
            MissionNumberListener = -1;
    
    // I have 2 groups in the allied army, the first is the player, the second is Ai
    
    //I try to make an array and put the airgroups in it
    
        AiAirGroup[] Airgroups = GamePlay.gpAirGroups(1);
    
    //I try to show there is something in the second element of the array
    
            GamePlay.gpHUDLogCenter("Group is " + Airgroups[1]);
    
    // A message does display with a big, long string that looks like a UID  (i.e. random characters)
    
    //So I tried to use this array element, but I have seen two ways of setTask being used, so have tried both (one at a time, the next two lines of code I only used one at a time)
    
            AiAirGroup.setTask(AiAirGroupTask.DO_NOTHING, Airgroups[1]);
            setTask(AiAirGroupTask.DO_NOTHING, Airgroups[1]);
    
    // Without the AiAIrGroup at the start I get a compile error saying setTask does not exist in the current context
    // and with it I get an error saying An object reference is required for the non-static field, method, or property 'maddox.game.world.AiAirGroup.setTask(maddox.game.world.AiAirGroupTask, maddox.game.world.AiAirGroup)'
    
    I tried using a variable instead of the array element with the code below but got the same two errors (again last two lines I just used one or the other.)
    
    	 	AiAirGroup targetGroup;
       		targetGroup = Airgroups[1];
    
    		AiAirGroup.setTask(AiAirGroupTask.DO_NOTHING, targetGroup);
         	setTask(AiAirGroupTask.DO_NOTHING, targetGroup);
    
    
        }
    
    
    
    
    
    
    
    
    }

  7. #7
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: What is 'taskArg' in this:

    I use Visual Studio, but admitedly sometimes am just ham-fistedly directly typing into the script page on the mission editor. The error messages I mentioned are in the in game script compiler.

    Displaying the name of the group in the HUD isn't really my primary problem I don't think, I mean it is not my main objective, it is using setTask that is my ultimate aim. I can use getTask on an aiairgroup to display what their current taks is, but I just can't seem to change their task.

    My end aim is to try to get a way of checking if an airgroup is on RETURN after they do AIR ATTACK, and if so then put them back on FLY WAYPOINT (or whatever it is they should be). This would perhaps need a repeating , timed process to run through fighter air groups, have a check or flag for running out of ammo/fuel, or count remaining aircraft to see if RETURN is actually the best... but that is waaaay ahead of what I want to do first, which is 'simply' change the task of an aiairgroup from one thing to another.

    The code I've seen on github from TWC I'm sure has the answer but unfortunately at my current level of C# knowledge, interpretting some of it is quite tricky, because there is so much clever stuff going on. I mean I've seen things like hashset (I think) that isn't even in my basic guides to C#.
    I am Yo-Yo not YoYo (that's someone else)

  8. #8
    Combat pilot
    Join Date
    Oct 2021
    Posts
    113
    Post Thanks / Like
    Total Downloaded
    12.95 MB

    Re: What is 'taskArg' in this:

    Deleted by GANIX.
    Last edited by GANIX; Apr-11-2023 at 13:35.

  9. Likes Yo-Yo liked this post
  10. #9
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: What is 'taskArg' in this:

    Quote Originally Posted by GANIX View Post
    Hello Yo-Yo,

    from what I remember, since 2016 <setTask> allows only ATTACK_AIR and FLY_WAYPOINT...

    Please have a look: CLICK HERE - Making an auto landing script

    I didn't find an info that this 'incomplete part of the game' is fixed...
    Omg, that is soooo helpful to know!

    It is one thing to try and learn C# via scripting CloD missions, but another to be trying to learn C# whilst trying to do things in missions that are broken in the game!
    I am Yo-Yo not YoYo (that's someone else)

  11. #10
    Combat pilot
    Join Date
    Oct 2021
    Posts
    113
    Post Thanks / Like
    Total Downloaded
    12.95 MB

    Re: What is 'taskArg' in this:

    Deleted by GANIX.
    Last edited by GANIX; Apr-11-2023 at 13:34.

  12. #11
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: What is 'taskArg' in this:

    No AI aircraft would land until a bug was fixed about three or four years ago. They would just circle the airfield until they ran out of fuel.

  13. #12
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: What is 'taskArg' in this:

    If you want to make AI aircraft land you need to give them a Landing waypoint. Using SetTask is not going to work.

  14. #13
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: What is 'taskArg' in this:

    Wow, I managed it. Thank you thank you.

    So my mission had just the player in a hurricane, and a spit (second airgroup) with 4 waypoints, just set to follow them (no enemy about to trigger attack_air!).

    The code that worked is here, I have added commetns with my understanding of what is going on. This is obviously for anyone trying to learn the scripting and may come across this, not you clever people who already know what you are doing.

    Code:
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using maddox.game;
    using maddox.game.world;
    using System.ComponentModel.Design;
    using System.Diagnostics;
    using maddox.GP;
    
    public class Mission : AMission
    {
    
        //    AiAirGroup airGroup;
    
        public override void OnBattleStarted()
    
        {
    
     
            MissionNumberListener = -1; 									//Not sure if needed, but is required for some other scripting
    
    
            AiAirGroup[] Airgroups;										//Creates an array called Airgroups
    
            Airgroups = GamePlay.gpAirGroups(1);							//Fills the array with each airgroup in the mission (ther are just two in this mission, player and 1 friendly AI)
            
    	Airgroups[1].setTask(AiAirGroupTask.ATTACK_AIR, Airgroups[1]);			//Sets the task for the second airgroup in the array (first airgroup is indexed 0, second is 1 etc.
    
    
    	GamePlay.gpHUDLogCenter("Task is " + Airgroups[1].getTask()) ;			// Shows the new task that the second aigroup in the array has.
    
    
    
        }
    }
    Obviously it is all run as the mission starts (onBattle Started) not in a meaningful use for it, but, the spitfire in the second airgroup, immediately changes to an attack_air task, as evidenced by the HUD message, and then rather amusingly by it starting to attack the water.

    spit_attacking.jpg
    I am Yo-Yo not YoYo (that's someone else)

  15. Likes GANIX liked this post
  16. #14
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: What is 'taskArg' in this:

    Quote Originally Posted by ATAG_Oskar View Post
    If you want to make AI aircraft land you need to give them a Landing waypoint. Using SetTask is not going to work.
    I watched the video above on having the AI landing properly by setting their formation and distance through radio commands, would I be right in thinking you could code that in a mission, so that the formation for the player flight changes automatically on reaching the last waypoint, so the player doesn't have to do anything, except clear runway on landing? (I'm not asking how to do it, just if the principle is sound).

    Incidentally I had a Eureka moment with your addition of .name() to the airgroup in teh HUD example higher up, I suddenly understood how things like .pos() can also work now for actors, so thanks.
    I am Yo-Yo not YoYo (that's someone else)

  17. #15
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: What is 'taskArg' in this:

    No AI aircraft would land until a bug was fixed about three or four years ago.

    To make AI aircraft land you can put a landing waypoint at the end of it's path in the FMB or using code. That is all you need to do.

    To see this make a mission where an airgroup lands and watch the AI behaviour.

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
  •