Results 1 to 17 of 17

Thread: Script creation

  1. #1
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Script creation

    Perhaps this is not complicated:

    AMission have:
    Code:
        public virtual void OnAutopilotOn(AiActor actor, int placeIndex)

    I what a script that when autopilot is turned on:

    Code:
       { 
        aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); // ... cut down elevators ... 
        aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); // ...  aileron ... 
        aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); // ...  rudder. 
        });
    But no idea on how join this together.
    Last edited by 1lokos; Sep-18-2020 at 17:25.

  2. #2
    ATAG Member ATAG_Flare's Avatar
    Join Date
    Oct 2013
    Location
    Interior BC --> Kingston ON
    Posts
    2,801
    Post Thanks / Like
    Total Downloaded
    383.91 MB

    Re: Script creation

    I have no idea how to do that, but damn Sokol that is one sneaky result you're looking for!

  3. #3
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    11,128
    Post Thanks / Like
    Total Downloaded
    255.73 MB

    Re: Script creation

    try this:
    Code:
    public virtual void OnAutopilotOn(AiActor actor, int placeIndex)
    {
    	AiAircraft aircraft = (AiAircraft) actor;
    	
    	aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); // ... cut down elevators ... 
    	aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); // ...  aileron ... 
    	aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); // ...  rudder. 
    }
    Explanation:
    actor, although defined as "AiActor", if the player is in a plane, is a variable of type "AiAircraft". All you have to do is tell the compiler that you want to access the variable as an AiAirplane instead of as the base class that is an AiActor.


    If you want to be on the safe side, you can check that it is indeed an AiAircraft like this:
    Code:
    public virtual void OnAutopilotOn(AiActor actor, int placeIndex)
    {
    	if(actor is AiAircraft)
    	{
    		AiAircraft aircraft = (AiAircraft) actor;
    		
    		aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); // ... cut down elevators ... 
    		aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); // ...  aileron ... 
    		aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); // ...  rudder. 
    	}
    }

    Edit: corrected variable. Thanks Josef.
    Last edited by ATAG_Colander; Sep-19-2020 at 07:02.

  4. #4
    Manual Creation Group
    Join Date
    May 2020
    Location
    Czech Republic
    Posts
    169
    Post Thanks / Like
    Total Downloaded
    230.81 MB

    Re: Script creation

    Quote Originally Posted by ATAG_Colander View Post
    try this:
    Code:
    public virtual void OnAutopilotOn(AiActor actor, int placeIndex)
    {
    	AiAircraft aircraft = (AiAircraft) AiActor;
    	
    	aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); // ... cut down elevators ... 
    	aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); // ...  aileron ... 
    	aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); // ...  rudder. 
    }
    Explanation:
    actor, although defined as "AiActor", if the player is in a plane, is a variable of type "AiAircraft". All you have to do is tell the compiler that you want to access the variable as an AiAirplane instead of as the base class that is an AiActor.


    If you want to be on the safe side, you can check that it is indeed an AiAircraft like this:
    Code:
    public virtual void OnAutopilotOn(AiActor actor, int placeIndex)
    {
    	if(actor is AiAircraft)
    	{
    		AiAircraft aircraft = (AiAircraft) AiActor;
    		
    		aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); // ... cut down elevators ... 
    		aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); // ...  aileron ... 
    		aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); // ...  rudder. 
    	}
    }
    Hi Colander,

    shouldn't there be rather

    Code:
    AiAircraft aircraft = (AiAircraft) actor;
    in your examples above?

    I think a variable should be overcasted and assigned to another variable, not a type.

    By the way, I have understood you have access to the sim code. What is needed for that? Some special agreement with TFS?

    Josef
    Last edited by ATAG_Colander; Sep-19-2020 at 07:02.

  5. #5
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    11,128
    Post Thanks / Like
    Total Downloaded
    255.73 MB

    Re: Script creation

    You are right Josef, my mistake. OP Corrected.

    To answer your question, I am one of the TFS founders which is why I have access to the source.
    Last edited by ATAG_Colander; Sep-19-2020 at 07:04.

  6. #6
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: Script creation

    Thanks guys.

    I am trying but for now, using AMission, have this error:

    "Warning CS0114: "Mission: OnAutopilotOn (maddox.game.world.AiActor, int) hides the inherited member 'maddox.game.AMission.OnAutopilotOn (maddox.game.world.AiActor, int).
    For the current member to replace this implementation, add the replacement key word. To not replace, add the new keyword."
    Last edited by 1lokos; Sep-19-2020 at 13:31.

  7. #7
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    11,128
    Post Thanks / Like
    Total Downloaded
    255.73 MB

    Re: Script creation

    Try this:

    Code:
    public override void OnAutopilotOn(AiActor actor, int placeIndex)

  8. Likes N/A liked this post
  9. #8
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: Script creation

    SUCCESS!

    Code:
    using System;
    using maddox.game;
    using maddox.game.world;
    using System.Collections.Generic;
    using maddox.GP;
    
    public class Mission : AMission
     {  
       public override void  OnAutopilotOn (maddox.game.world.AiActor actor, int placeIndex) 
      {
    	if(actor is AiAircraft)
           {
    	 AiAircraft aircraft = (AiAircraft) actor;
    	
    	 aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); // ... cut down elevators ... 
    	 aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); // ...  aileron ... 
    	 aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); // ...  rudder. 
           }
       }
    }




    Thank you.

  10. Likes N/A, Yo-Yo liked this post
  11. #9
    Manual Creation Group fenbeiduo's Avatar
    Join Date
    May 2013
    Posts
    70
    Post Thanks / Like
    Total Downloaded
    282.61 MB

    Question Re: Script creation

    BTW, what does OnAutopilotOn code mean('aftermath') here?

    - the aircfrat will damage if player press autopilot key?

    --further question: possible to make players plane in 'game-autopilot' mode at game start?

  12. #10
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: Script creation

    - the aircfrat will damage if player press autopilot key?
    Yes, in this example the idea is punish the player if he engage "AI autopilot" (Toggle AI Control), for a navigation challenge mission.

    --further question: possible to make players plane in 'game-autopilot' mode at game start?
    Yes - but don't ask how.

    In the "Training" module one of the missions start with Ai Autopilot on, after some time is disengaged for player control the plane briefly, after is engaged again - for AI autopilot crash the plane, because AI Autopilot are not able to landing Tiger Moth most time.


    This disengage/engage is not controlled by Player, but by script.

    Unfortunately the scripts used for this missions are buried inside game SFS files, not accessible for player. So you need create your own.
    Last edited by 1lokos; Sep-28-2020 at 19:46.

  13. #11
    Manual Creation Group fenbeiduo's Avatar
    Join Date
    May 2013
    Posts
    70
    Post Thanks / Like
    Total Downloaded
    282.61 MB

    Re: Script creation

    Quote Originally Posted by 1lokos View Post
    Yes, in this example the idea is punish the player if he engage "AI autopilot" (Toggle AI Control), for a navigation challenge mission.
    Nice idea

    Quote Originally Posted by 1lokos View Post
    but don't ask how....Unfortunately the scripts used for this missions are buried inside game SFS files, not accessible for player. So you need create your own.
    How do you know I'm going to ask for it. LOL
    ...But, seriously, I would like to creat it my self(actually have modified one .cs file for my mission), but... I've no idea where most of the cods come from(OnAutopilotOn, AiAction Action, OnAircraftTookOff... etc. - all kinds of these). The 'only' resources I can take are from some posts and some mission .cs files which are not 'complete' and also need to 'guess' how to work with it.

  14. #12
    Team Fusion ATAG_Noofy's Avatar
    Join Date
    Feb 2019
    Location
    https://w3w.co/chat.hisses.lofty
    Posts
    2,602
    Post Thanks / Like
    Total Downloaded
    1.25 GB

    Re: Script creation

    Quote Originally Posted by fenbeiduo View Post
    ...But, seriously, I would like to creat it my self(actually have modified one .cs file for my mission), but... I've no idea where most of the cods come from(OnAutopilotOn, AiAction Action, OnAircraftTookOff... etc. - all kinds of these). The 'only' resources I can take are from some posts and some mission .cs files which are not 'complete' and also need to 'guess' how to work with it.
    Try your luck here
    Gigabyte Z390 UD | i7 9700K @3.60GHz | 16.0 GB | Windows 10 Pro 64-Bit | NVIDIA GeForce GTX 1070 Ti
    TM Warthog HOTAS | Saitek pro rudder pedals | TrackIR 5 | TeamSpeak 3.3.2 | TS Notifier 1.6.0h

  15. #13
    Manual Creation Group fenbeiduo's Avatar
    Join Date
    May 2013
    Posts
    70
    Post Thanks / Like
    Total Downloaded
    282.61 MB

    Re: Script creation

    Quote Originally Posted by ATAG_Noofy View Post
    Try your luck here
    Thx Noofy

  16. #14
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: Script creation

    Quote Originally Posted by fenbeiduo View Post
    .. I've no idea where most of the cods come from(OnAutopilotOn, AiAction Action, OnAircraftTookOff... etc.
    See in this topic the majority of options available. Are others... "more advanced".

    https://theairtacticalassaultgroup.c...pt+master+list

    OnAutopilotOn and OnAutoPilotOff are in ABattle

    If you install Microsoft Visual Studio 2019 and follow YoYo guide for set the basics, can see what options is linked with game DLL's.

    I try, but are not able to do nothing in Visual Studio, so use Notepad++ for my scripts "trail and error".

    Perhaps using this you are able to make a script for AI Autopilot engage when the mission start:

    Code:
    public virtual void OnBattleStarted()
    
            {
                foreach (AMission mission in this.missions)
                {
                    mission.OnBattleStarted();
                }
            }
    Code:
    public virtual void OnAutopilotOn(AiActor actor, int placeIndex)
            {
                foreach (AMission mission in this.missions)
                {
                    mission.OnAutopilotOn(actor, placeIndex);
                }
            }
    In the old 1C forum for CloD (Noofy link) are good examples, some basics (triggers) some complex (e.g. Radar), but in many (IMO) people are just trying implement in CloD a kind of "Zombie gameplay": you shoot a plane, then the script spawn another in the place, and so on.
    Last edited by 1lokos; Sep-28-2020 at 21:42.

  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: Script creation

    Quote Originally Posted by 1lokos View Post
    This disengage/engage is not controlled by Player, but by script.

    Unfortunately the scripts used for this missions are buried inside game SFS files, not accessible for player. So you need create your own.
    This training functionality is built into the code and uses functions not available to mission script writers.

    Mission scripts can respond to events and read the current settings of controls and instruments. Mission scripts cannot change control settings.

  18. Likes fenbeiduo liked this post
  19. #16
    Manual Creation Group fenbeiduo's Avatar
    Join Date
    May 2013
    Posts
    70
    Post Thanks / Like
    Total Downloaded
    282.61 MB

    Wink Re: Script creation

    Quote Originally Posted by 1lokos View Post
    See in this topic the majority of options available...https://theairtacticalassaultgroup.c...pt+master+list
    Ahh... I missed out this thread somehow. That's what I am looking for.


    Quote Originally Posted by 1lokos View Post
    I try, but are not able to do nothing in Visual Studio, so use Notepad++ for my scripts "trail and error".
    Yes, I intalled V.S. it need further 10+G space for C# (to get access to .DLLs and I have no idea what to do with the 'method' 'solution' thing). Then cameacross the Notepad++ which you mentioned in one of your post(nice and space-saving)


    Quote Originally Posted by 1lokos View Post
    Perhaps using this you are able to make a script for AI Autopilot engage when the mission start:
    Would like to try it out! Thank you Sokol1

  20. #17
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: Script creation

    Quote Originally Posted by ATAG_Oskar View Post
    This training functionality is built into the code and uses functions not available to mission script writers.
    LOL, this means that "Training" is really a lost case.

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
  •