Results 1 to 11 of 11

Thread: OnActorDead - was it the player?

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

    OnActorDead - was it the player?

    I'm trying to determine if when an aricraft/actor is shot down if the player was involved.

    My thought is that the onActorDead provides the actor that died, but also a list of damage initiators and the score and time for each of these? I seem to be able to count these from the 'list' but am stuck trying to loop through the list with a 'foreach'. I have never used a C# list before so might be totally wrong on what I'm attempting.

    So count works, I think:

    Code:
     public override void OnActorDead(int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List<maddox.game.world.DamagerScore> damages)
        {
            
            Console.WriteLine("" + shortName + " is dead actor");
    
    
                Console.WriteLine("Count " + damages.Count);
    
    
        }
    But if I try this to hopefully go through each score value (I actually intend to check the initiators if one is the player but am trying to just start with the score values as practice on getting something from the list):

    Code:
      public override void OnActorDead(int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List<maddox.game.world.DamagerScore> damages)
        {
            
            Console.WriteLine("" + shortName + " is dead actor");
    
    
            //Console.WriteLine("Count " + damages.Count);
    
            foreach (double s in damages)
                Console.WriteLine(s);
    
    
        }
    I get an errror in the script compiler saying: Cannot convert type 'maddox.game.world.DamagerScore' to 'double'

    but if I see correctly in my object browser the DamagerScore method is like this: public DamagerScore(maddox.game.world.AiDamageInitiator i, double s, double t)


    Am I even close? Is there an easy way to check if a dead/killed/destroyed aircraft(actor) was damaged by the player?
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: OnActorDead - was it the player?

    Try this:
    Code:
    foreach(maddox.game.world.DamagerScore damage in damages)
    {
    Now do something with  "damage.whatever"
    ...
    }

  3. Likes Yo-Yo liked this post
  4. #3
    Supporting Member
    Join Date
    Oct 2020
    Posts
    196
    Post Thanks / Like
    Total Downloaded
    197.43 MB

    Re: OnActorDead - was it the player?

    Quote Originally Posted by Yo-Yo View Post

    But if I try this to hopefully go through each score value (I actually intend to check the initiators if one is the player but am trying to just start with the score values as practice on getting something from the list):

    Code:
      public override void OnActorDead(int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List<maddox.game.world.DamagerScore> damages)
        {
            
            Console.WriteLine("" + shortName + " is dead actor");
    
    
            //Console.WriteLine("Count " + damages.Count);
    
            foreach (double s in damages)
                Console.WriteLine(s);
    
    
        }
    maddox.game.world.DamagerScore objects expose those properties :

    initiator : as AiDamageInitiator
    score : as double
    time : as double

    So, your code could be like :

    Code:
      public override void OnActorDead(int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List<maddox.game.world.DamagerScore> damages)
        {
            
            Console.WriteLine("" + shortName + " is dead actor");
    
    
            //Console.WriteLine("Count " + damages.Count);
    
            foreach ((maddox.game.world.DamagerScore)objDamage in damages)
                Console.WriteLine(objDamage.score);
    
    
        }
    This is lunch time so I have no time to test yet.
    Last edited by Sleepy_Fly; Mar-17-2023 at 09:21. Reason: Replace <> by () for correct cast in foreach
    "You can teach monkeys to fly better than that!"

    Win 11 Pro - I5-12600KF - 32GB Ram - RTX 3080 TI 12GB (non OC) - SSD Sata 970 GBB (System) - NVMe 980 GB (games storage) - Lenovo 27'' 144Hz - HP Reverb G2 v2 -
    WMR environment : Empty room (SkySpaces) - SteamVR resolution : 2192x2144 (48%)
    nVidia driver : 536.23

  5. Likes Yo-Yo liked this post
  6. #4
    Supporting Member
    Join Date
    Oct 2020
    Posts
    196
    Post Thanks / Like
    Total Downloaded
    197.43 MB

    Re: OnActorDead - was it the player?

    BTW, I use this tool :

    https://www.jetbrains.com/decompiler/

    Very useful to discover interfaces of classes, inheritances, subtypes and more.
    "You can teach monkeys to fly better than that!"

    Win 11 Pro - I5-12600KF - 32GB Ram - RTX 3080 TI 12GB (non OC) - SSD Sata 970 GBB (System) - NVMe 980 GB (games storage) - Lenovo 27'' 144Hz - HP Reverb G2 v2 -
    WMR environment : Empty room (SkySpaces) - SteamVR resolution : 2192x2144 (48%)
    nVidia driver : 536.23

  7. Likes Yo-Yo, 1lokos liked this post
  8. #5
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: OnActorDead - was it the player?

    Thanks both, that should be enough for me to go on for now. Appreciated.
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: OnActorDead - was it the player?

    Quote Originally Posted by Sleepy_Fly View Post
    BTW, I use this tool :

    https://www.jetbrains.com/decompiler/

    Very useful to discover interfaces of classes, inheritances, subtypes and more.
    Oh that seems very usefiul indeed. Will take me a while to get my head around it but I think that allows me to see much of the stuff I was generally banging my head over repeatedly.
    I am Yo-Yo not YoYo (that's someone else)

  11. Likes Sleepy_Fly liked this post
  12. #7
    Supporting Member
    Join Date
    Oct 2020
    Posts
    196
    Post Thanks / Like
    Total Downloaded
    197.43 MB

    Re: OnActorDead - was it the player?

    Quote Originally Posted by Yo-Yo View Post
    Oh that seems very usefiul indeed. Will take me a while to get my head around it but I think that allows me to see much of the stuff I was generally banging my head over repeatedly.
    (un)fortunately, the core code is obfuscated
    "You can teach monkeys to fly better than that!"

    Win 11 Pro - I5-12600KF - 32GB Ram - RTX 3080 TI 12GB (non OC) - SSD Sata 970 GBB (System) - NVMe 980 GB (games storage) - Lenovo 27'' 144Hz - HP Reverb G2 v2 -
    WMR environment : Empty room (SkySpaces) - SteamVR resolution : 2192x2144 (48%)
    nVidia driver : 536.23

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

    Re: OnActorDead - was it the player?

    Code:
            foreach (DamagerScore ds in damages)
            {
                if (ds.initiator.Player != null) {
                    // check Player name
                }
            }

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

    Re: OnActorDead - was it the player?

    Quote Originally Posted by ATAG_Oskar View Post
    Code:
            foreach (DamagerScore ds in damages)
            {
                if (ds.initiator.Player != null) {
                    // check Player name
                }
            }
    Ooo nice! Thanks.
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: OnActorDead - was it the player?

    Deleted by GANIX.
    Last edited by GANIX; Apr-12-2023 at 05:35.

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

    Re: OnActorDead - was it the player?

    Deleted by GANIX.
    Last edited by GANIX; Apr-12-2023 at 05:35.

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
  •