Results 1 to 12 of 12

Thread: Why onActorDamaged not working?

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

    Why onActorDamaged not working?

    So I can use:

    onActorDead

    Code:
    public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
        {
            GamePlay.gpHUDLogCenter("Something is dead");
        }
    and

    onAircraftDamaged

    Code:
    public override void OnAircraftDamaged(int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft, maddox.game.world.AiDamageInitiator initiator, part.NamedDamageTypes damageType)
        {
            GamePlay.gpHUDLogCenter("Ouch!");
        }

    But why in the name of sanity does onActorDamaged not work?!

    Code:
        public override void OnActorDamaged(int missionNumber, string shortName, maddox.game.world.AiActor actor, maddox.game.world.AiDamageInitiator aiDamageInitiator, part.NamedDamageTypes namedDamageTypes)
        {
            GamePlay.gpHUDLogCenter("Something is damaged");
        }
    This is killing me.
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Why onActorDamaged not working?

    In 2017 "onActorDamaged" are a "to do" thing, see this Salmo post.

    https://theairtacticalassaultgroup.c...onActorDamaged

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

    Re: Why onActorDamaged not working?

    Quote Originally Posted by 1lokos View Post
    In 2017 "onActorDamaged" are a "to do" thing, see this Salmo post.

    https://theairtacticalassaultgroup.c...onActorDamaged
    But does that mean that it doesn't work at all, or that they wanted to add it to the script window of the FMB?
    I am Yo-Yo not YoYo (that's someone else)

  4. #4
    varrattu
    Guest

    Re: Why onActorDamaged not working?

    Hello Yo-Yo,

    public virtual void OnActorDamaged (int missionNumber, string shortName, AiActor actor, AiDamageInitiator initiator, NamedDamageTypes damageType)

    is member of "maddox.game.ABattle"

    and

    public virtual void OnActorDamaged (int missionNumber, string shortName, AiActor actor, AiDamageInitiator initiator, NamedDamageTypes damageType)

    is member of "maddox.game.AMission"

    Please explain what you want to do. The more we share, the more learn ...

    ~V~

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

    Re: Why onActorDamaged not working?

    Hi, this is all I'm trying to do, show a HUD message when an actor is damaged. I have myself in a hurricane attackign a target He111.

    Code:
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel.Design;
    using System.Diagnostics;
    using maddox.game;
    using maddox.game.world;
    
    
    
    public class Mission : AMission
    {
        public override void OnBattleStarted()
        {
            MissionNumberListener = -1;
            GamePlay.gpHUDLogCenter("Mission started");
        }
    
        public override void OnActorDamaged(int missionNumber, string shortName, AiActor actor, AiDamageInitiator initiator, part.NamedDamageTypes damageType)
        {
            GamePlay.gpHUDLogCenter("Something is damaged");
        }
    
    
    }
    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: Why onActorDamaged not working?

    Try OnAircraftDamaged().

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

    Re: Why onActorDamaged not working?

    Thanks but I've got onAircraftDamaged working fine, and onActorDestroyed I just wanted to test onActorDamaged but couldn't get it to work whereas the other two were strightforward, and that was the puzzle to me.
    I am Yo-Yo not YoYo (that's someone else)

  8. #8
    varrattu
    Guest

    Re: Why onActorDamaged not working?

    Give this little script a try....

    ~V~

    Code:
    /// @author Varrattu
    /// @version 1.10
    /// @date 2019-11-22
    
    using maddox.game;
    using maddox.game.world;
    using maddox.GP;
    using part;
    
    public class Mission : AMission
    {
        int Hits = 0;
    
        public override void OnAircraftDamaged(int missionNumber, string shortName, AiAircraft aircraft, AiDamageInitiator DamageFrom, part.NamedDamageTypes WhatDamaged)
        {
            base.OnAircraftDamaged(
                missionNumber,
                shortName, aircraft,
                DamageFrom,
                WhatDamaged
            );
    
            if (aircraft != (AiAircraft)GamePlay.gpPlayer().Place()
                && (aircraft != DamageFrom.Actor))
            {
                ShowDamgeEvent((DamageFrom.Actor as AiAircraft), (DamageFrom.Person as AiPerson), aircraft);
            }
        }
    
        public override void OnAircraftLimbDamaged(int missionNumber, string shortName, AiAircraft aircraft, AiLimbDamage limbDamage)
        {
            base.OnAircraftLimbDamaged(
                missionNumber,
                shortName,
                aircraft, limbDamage
            );
    
            if (aircraft != (AiAircraft)GamePlay.gpPlayer().Place()
                && (aircraft != limbDamage.Initiator.Actor))
            {
                ShowDamgeEvent((limbDamage.Initiator.Actor as AiAircraft), (limbDamage.Initiator.Person as AiPerson), aircraft);
            }
        }
    
        public override void OnAircraftCutLimb(int missionNumber, string shortName, AiAircraft aircraft, AiDamageInitiator initiator, LimbNames limbName)
        {
    
            base.OnAircraftCutLimb(
                missionNumber,
                shortName,
                aircraft,
                initiator,
                limbName);
    
            if (aircraft != (AiAircraft)GamePlay.gpPlayer().Place()
                && (aircraft != initiator.Actor))
            {
                ShowDamgeEvent((initiator.Actor as AiAircraft), (initiator.Person as AiPerson), aircraft);
            }
        }
    
        public override void OnPersonHealth(AiPerson person, AiDamageInitiator initiator, float deltaHealth)
        {
    
            base.OnPersonHealth(
                person,
                initiator,
                deltaHealth
            );
    
            if (initiator.Actor == (AiAircraft)GamePlay.gpPlayer().Place()
                && person.Cart() != initiator.Actor)
            {
                Hits++;
                GamePlay.gpLogServer(
                   null,
                   "({0}) in " +
                   "({1}) getroffen von " +
                   "({2}) in " +
                   "({3}), " +
                   "insgesamt [{4}] Treffer" +
                   "\n",
                   new object[] {
                    person,
                    person.Cart(),
                    initiator.Person,
                    initiator.Actor,
                    Hits
                   }
                   );
            }
        }
    
        public void ShowDamgeEvent(AiAircraft playerAircraft, AiPerson person, AiAircraft targetAircraft)
        {
    
            Point3d playerAircraftPoint3d = playerAircraft.Pos();
            Point3d targetAircraftPoint3d = targetAircraft.Pos();
    
            Hits++;
    
            GamePlay.gpLogServer(
                    null,
                    "({0}) getroffen " +
                    "von ({1}) " +
                    "in ({2}), " +
                    "Entfernung: ({3}m), " +
                    "insgesamt [{4}] Treffer" +
                    "\n",
                    new object[] {
                    targetAircraft,
                    person,
                    playerAircraft,
                    string.Format("{0:0}", DistanceP2P3d(playerAircraftPoint3d, targetAircraftPoint3d)),
                    Hits
                    }
                    );
        }
    
        ///  Find the Distance Between Two Points
        public double DistanceP2P3d(Point3d pointA, Point3d pointB)
        {
    
            double d = pointA.distance(ref pointB); return d;
        }
    }
    Quote Originally Posted by Yo-Yo View Post
    Hi, this is all I'm trying to do, show a HUD message when an actor is damaged. I have myself in a hurricane attackign a target He111.
    Last edited by varrattu; Sep-07-2020 at 15:27.

  9. Likes DD_FT liked this post
  10. #9
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: Why onActorDamaged not working?

    I tried this recently and also noticed it is not working.
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

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

    Re: Why onActorDamaged not working?

    Quote Originally Posted by varrattu View Post
    Give this little script a try....

    ~V~

    Code:
    /// @author Varrattu
    /// @version 1.10
    /// @date 2019-11-22
    
    using maddox.game;
    using maddox.game.world;
    using maddox.GP;
    using part;
    
    public class Mission : AMission
    {
        int Hits = 0;
    
        public override void OnAircraftDamaged(int missionNumber, string shortName, AiAircraft aircraft, AiDamageInitiator DamageFrom, part.NamedDamageTypes WhatDamaged)
        {
            base.OnAircraftDamaged(
                missionNumber,
                shortName, aircraft,
                DamageFrom,
                WhatDamaged
            );
    
            if (aircraft != (AiAircraft)GamePlay.gpPlayer().Place()
                && (aircraft != DamageFrom.Actor))
            {
                ShowDamgeEvent((DamageFrom.Actor as AiAircraft), (DamageFrom.Person as AiPerson), aircraft);
            }
        }
    
        public override void OnAircraftLimbDamaged(int missionNumber, string shortName, AiAircraft aircraft, AiLimbDamage limbDamage)
        {
            base.OnAircraftLimbDamaged(
                missionNumber,
                shortName,
                aircraft, limbDamage
            );
    
            if (aircraft != (AiAircraft)GamePlay.gpPlayer().Place()
                && (aircraft != limbDamage.Initiator.Actor))
            {
                ShowDamgeEvent((limbDamage.Initiator.Actor as AiAircraft), (limbDamage.Initiator.Person as AiPerson), aircraft);
            }
        }
    
        public override void OnAircraftCutLimb(int missionNumber, string shortName, AiAircraft aircraft, AiDamageInitiator initiator, LimbNames limbName)
        {
    
            base.OnAircraftCutLimb(
                missionNumber,
                shortName,
                aircraft,
                initiator,
                limbName);
    
            if (aircraft != (AiAircraft)GamePlay.gpPlayer().Place()
                && (aircraft != initiator.Actor))
            {
                ShowDamgeEvent((initiator.Actor as AiAircraft), (initiator.Person as AiPerson), aircraft);
            }
        }
    
        public override void OnPersonHealth(AiPerson person, AiDamageInitiator initiator, float deltaHealth)
        {
    
            base.OnPersonHealth(
                person,
                initiator,
                deltaHealth
            );
    
            if (initiator.Actor == (AiAircraft)GamePlay.gpPlayer().Place()
                && person.Cart() != initiator.Actor)
            {
                Hits++;
                GamePlay.gpLogServer(
                   null,
                   "({0}) in " +
                   "({1}) getroffen von " +
                   "({2}) in " +
                   "({3}), " +
                   "insgesamt [{4}] Treffer" +
                   "\n",
                   new object[] {
                    person,
                    person.Cart(),
                    initiator.Person,
                    initiator.Actor,
                    Hits
                   }
                   );
            }
        }
    
        public void ShowDamgeEvent(AiAircraft playerAircraft, AiPerson person, AiAircraft targetAircraft)
        {
    
            Point3d playerAircraftPoint3d = playerAircraft.Pos();
            Point3d targetAircraftPoint3d = targetAircraft.Pos();
    
            Hits++;
    
            GamePlay.gpLogServer(
                    null,
                    "({0}) getroffen " +
                    "von ({1}) " +
                    "in ({2}), " +
                    "Entfernung: ({3}m), " +
                    "insgesamt [{4}] Treffer" +
                    "\n",
                    new object[] {
                    targetAircraft,
                    person,
                    playerAircraft,
                    string.Format("{0:0}", DistanceP2P3d(playerAircraftPoint3d, targetAircraftPoint3d)),
                    Hits
                    }
                    );
        }
    
        ///  Find the Distance Between Two Points
        public double DistanceP2P3d(Point3d pointA, Point3d pointB)
        {
    
            double d = pointA.distance(ref pointB); return d;
        }
    }
    Thanks I will do. There's some interesting bits in there that will all help my understanding of what can be done.

    I have been told that the "base.Method()" bit of the code isn't required? So am curious as to it's purpose here? (No need to reply if you don't wish to, I will try it with and without and see how it runs)
    I am Yo-Yo not YoYo (that's someone else)

  12. #11
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: Why onActorDamaged not working?

    Quote Originally Posted by Yo-Yo View Post
    I have been told that the "base.Method()" bit of the code isn't required? So am curious as to it's purpose here? (No need to reply if you don't wish to, I will try it with and without and see how it runs)
    I don't know if it was once required due to different code setup or it was just circulated as "here is how you should do it" or perhaps some of the earliest scripters just did it for one reason or another, not knowing any better, and so then everyone copied that and here we are.

    I know all our scripts have religiously used base.XXX for all such routines and ATAG_Oskar let me know recently it's not necessary at all. Except for one single routine, "Init".

    Code:
        public override void Init(maddox.game.ABattle battle, int missionNumber)
        {
            base.Init(battle, missionNumber);
    If you don't really know what "base" is to start with, here is the MS explanation: https://docs.microsoft.com/en-us/dot.../keywords/base

    It is keyword similar to "this" and allows you to access the routines of the parent class from the child class. Or as they call it, the "base" class from the "derived" class--thus the keyword "base".

    Anyway if the underlying code doesn't need or want the base. call then there is no need to continue doing it.
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  13. Likes ATAG_Oskar, Yo-Yo liked this post
  14. #12
    Team Fusion Artist's Avatar
    Join Date
    Mar 2010
    Posts
    2,866
    Post Thanks / Like
    Total Downloaded
    319.97 MB

    Re: Why onActorDamaged not working?

    Oskar and me discussed this base.method(...) a couple of times and it is ... more a personal style question. In a nutshell, Oskar is correct: If you know that the base.method does not do anything than it is indeed superflous and a waste of processor time to nitpickingly call it every time. My problem is how do you know it for sure? With Mission.Init() we've at least on exception already. I personally feel much better with calling it just in case - case A being that my knowledge might be incorrect, case B being that the coder of the base class later decides to add some stuff in his method. Kind of belts and braces thinking.

  15. Likes Yo-Yo, TWC_Flug 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
  •