Results 1 to 3 of 3

Thread: onAircraftDamaged - for scripted spawned aircraft

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

    onAircraftDamaged - for scripted spawned aircraft

    At the moment I have onAircraftDamaged working ok with aircraft that are in the game from mission start, but I can't get any response when an aircraft that has spawned in by a trigger/script is damaged.

    Does anyone happen to know if it is simply not possible, or is it just that I simply need to adapt the code somehow?

    I did try onActorDamaged too, but not as extensively as onAircraftDamaged so may have had something written wrong.

    HTML Code:
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Diagnostics;
    using maddox.game;
    using maddox.game.world;
    
    
    public class Mission : AMission
    {
    
        public override void OnTrigger(int missionNumber, string shortName, bool active)
        {
            base.OnTrigger(missionNumber, shortName, active);
    
    
                AiAction Action = GamePlay.gpGetAction("trigger");
    
                if (Action != null)
                    Action.Do();
    
                GamePlay.gpGetTrigger(shortName).Enable = false;
    
            }
    
    
    
        public override void OnAircraftDamaged(int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft, maddox.game.world.AiDamageInitiator initiator, part.NamedDamageTypes damageType)
        {
                GamePlay.gpHUDLogCenter("Ping!");
        }
    }
    Last edited by Yo-Yo; Aug-31-2020 at 18:51. Reason: took out the extra brackets
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: onAircraftDamaged - for scripted spawned aircraft

    Oh C# you saucy minx, I think I have it working by adding this (that I found elsewhere) into the script.

    Code:
    public override void Init(maddox.game.ABattle battle, int missionNumber)
        {
            base.Init(battle, missionNumber);
            MissionNumberListener = -1; //Listen to events of every mission
        }
    This is one for the guide if further tests are ok.

    Edit: Which they are.
    Last edited by Yo-Yo; Sep-05-2020 at 18:13.
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: onAircraftDamaged - for scripted spawned aircraft

    Quote Originally Posted by Yo-Yo View Post
    Oh C# you saucy minx, I think I have it working by adding this (that I found elsewhere) into the script.

    Code:
    public override void Init(maddox.game.ABattle battle, int missionNumber)
        {
            base.Init(battle, missionNumber);
            MissionNumberListener = -1; //Listen to events of every mission
        }
    This is one for the guide if further tests are ok.

    Edit: Which they are.

    The line: MissionNumberListener = -1; is usually set in the OnBattleStarted function. You can set it to listen to a specific mission script or all by setting it to -1.

  4. Likes Yo-Yo 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
  •