Results 1 to 7 of 7

Thread: Player health

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

    Player health

    Can anyone save me hours of scrolling through Jetbrains and visual studio by letting me know if I can get the Players health easily, and how to do that?

    I'm imagining some kind of player.GetHealth() or something.

    I could swear I managed this before, but at the time had no intention of using it.

    Thanks if anyone can help.
    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: Player health

    I figure it uses this somehow?

    Code:
        public virtual void OnPersonHealth(
          AiPerson person,
          AiDamageInitiator initiator,
          float deltaHealth)
        {
        }
    I am Yo-Yo not YoYo (that's someone else)

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

    Re: Player health

    Hi Yo-Yo,

    OnPersonHealth() is called when the health value of person is changed, i.e. when this person is wounded or killed.

    AiPerson person can be a player or an AI pilot or crewman.

    AiDamageInitiator initiator is a reference to the object which caused this person damage.

    float deltaHealth is a health value change.

    You can check the current health value for person by calling person.Health.

    The initial health value is 100.
    When person is hit, the person.Health value is decreased by deltaHealth.
    When person.Health <= 0, this person is dead.

    Here is a piece of the code from my old attempts to monitor what is happening during missions:

    Code:
        public override void OnPersonHealth(AiPerson person, AiDamageInitiator initiator, float deltaHealth)
        {
            base.OnPersonHealth(person, initiator, deltaHealth);
    
            if (person.Cart() == initiator.Actor) // person hit by own aircraft
            {
                GamePlay.gpLogServer(
                   null,
                   "+* {0} ({1}) in {2} ({3}) " +
                   "hit by {4} ({5}) in {6} ({7}), " +
                   "health -{8} ({9})\n",
                   new object[] {
                    person,
                    person.Place(),
                    person.Cart(),
                    (person.Cart() as AiAircraft).TypedName(),
                    initiator.Person,
                    initiator.Person.Place(),
                    initiator.Actor,
                    (initiator.Actor as AiAircraft).TypedName(),
                    deltaHealth,
                    person.Health
                   }
                );
            }
            else if (initiator.Actor == GamePlay.gpPlayer().Place()) // person hit by player's aircraft
            {
                Hits++;
                GamePlay.gpLogServer(
                   null,
                   "+> {0} ({1}) in {2} ({3}) " +
                   "hit by {4} ({5}) in {6} ({7}), " +
                   "health -{8} ({9}), " +
                   "=> {10} hits\n",
                   new object[] {
                    person,
                    person.Place(),
                    person.Cart(),
                    (person.Cart() as AiAircraft).TypedName(),
                    initiator.Person,
                    initiator.Person.Place(),
                    initiator.Actor,
                    (initiator.Actor as AiAircraft).TypedName(),
                    deltaHealth,
                    person.Health,
                    Hits
                   }
                );
            }
            else if (person.Cart() == GamePlay.gpPlayer().Place()) // person in player's aircraft hit by other aircraft (not flown by player)
            {
                Rec++;
                GamePlay.gpLogServer(
                   null,
                   "<+ {0} ({1}) in {2} ({3}) " +
                   "hit by {4} ({5}) in {6} ({7}), " +
                   "health -{8} ({9}), " +
                   "<= {10} hits\n",
                   new object[] {
                    person,
                    person.Place(),
                    person.Cart(),
                    (person.Cart() as AiAircraft).TypedName(),
                    initiator.Person,
                    initiator.Person.Place(),
                    initiator.Actor,
                    (initiator.Actor as AiAircraft).TypedName(),
                    deltaHealth,
                    person.Health,
                    Rec
                   }
                );
            }
            else // person in other aircraft (not flown by player) hit by another aircraft (not flown by player)
            {
                GamePlay.gpLogServer(
                   null,
                   "+= {0} ({1}) in {2} ({3}) " +
                   "hit by {4} ({5}) in {6} ({7}), " +
                   "health -{8} ({9})\n",
                   new object[] {
                    person,
                    person.Place(),
                    person.Cart(),
                    (person.Cart() as AiAircraft).TypedName(),
                    initiator.Person,
                    initiator.Person.Place(),
                    initiator.Actor,
                    (initiator.Actor as AiAircraft).TypedName(),
                    deltaHealth,
                    person.Health
                   }
                );
            }
        }
    Josef

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

    Re: Player health

    Thank you
    I am Yo-Yo not YoYo (that's someone else)

  6. #5
    Team Fusion
    Join Date
    Oct 2018
    Location
    Toronto, Ontario
    Posts
    555
    Post Thanks / Like
    Total Downloaded
    3.94 GB

    Re: Player health

    Yo-Yo
    What are you looking to accomplish with this? Very cool but not sure where this leads?
    Lenny
    Desktop - Alienware R10, AMD Ryzen 9 5950X, 64Gb DDR4-3400Mhz OC 3734Mhz, Dell RTX 3090 24Gb (512.15), Dell 3221QS (4K @ 60Hz), Win 11 (22000.567), C Drive Steam default, Reverb G2, WMR SteamVR beta - 100% (3160x3088), TM Warthog Throttle/Stick, TM T-Rudder, TM MFDx2, Razer Tartarus Pro
    Laptop - Dell G7 7590, Intel i7-8750H, 64Gb DDR-2666Mhz, GPU0 Intel UHD 630 1Gb GPU1 Dell RTX 2060 6Gb (512.15), BenQ EX3203R (3K @ 60Hz), Win 11 (22000.567), C drive Steam default, Samsung Odyssey+, WMR SteamVR beta - 100% (1440x1796), TM T16000M, TM TWCS

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

    Re: Player health

    I'm making an application that tracks a career and I want to allocate days (out) for recovery if the player was wounded in a mission.
    I am Yo-Yo not YoYo (that's someone else)

  8. Likes Sleepy_Fly, zzzxxxxzzz, Pinguim, Dauntless liked this post
  9. #7
    Novice Pilot Pinguim's Avatar
    Join Date
    Mar 2021
    Location
    Antarctica
    Posts
    84
    Post Thanks / Like
    Total Downloaded
    478.84 MB

    Re: Player health

    Nice to hear Yo-Yo! So far closest I got to a dynamic career was flying in theOden's DynMis and writing down number of missions and kills to compare with the configs of il-2 Great Battles, so I could know when my guy got a medal
    To have off-days in recovery would be a great dynamic flying long campaigns like BoB.

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
  •