Player Cant Survive Lethal Damage When Healing In DamagedEvent Callback

Summary

Previously, we would use FortChar.DamagedEvent().Subscribe() to attach player damage events to callbacks. In those callbacks, we would check how much health the player has after being damaged, and if the target health was less than 0, we could heal the target, and they would stay alive.

Now, we are seeing that this player does not stay alive when healing the target in the damaged event callback.

We recreated minimum reproduction in a private code to demonstrate. there is a weapon and two spawn pads to test PVP damage, and a debug button that applies self damage for solo testing.

verse code used:

damage_heal_repro_device := class(creative_device):
@editable SelfDamageButton : button_device = button_device{}

OnBegin<override>()<suspends> : void =
    SelfDamageButton.InteractedWithEvent.Subscribe(OnButtonPressed)
    GetPlayspace().PlayerAddedEvent().Subscribe(PlayerJoinedEvent)

    Sleep(1.0)
    for (Player : GetPlayspace().GetPlayers()):
        OnPlayerAdded(Player)

PlayerJoinedEvent(Player:player):void=
    if(FortChar := Player.GetFortCharacter[]):
        FortChar.DamagedEvent().Subscribe(OnCharacterDamaged)

OnCharacterDamaged(Result : damage_result) : void =
    if (TargetFort := fort_character[Result.Target]):
        Health := TargetFort.GetHealth()
        Print("[REPRO] Damaged for {Result.Amount}, health is now {Health}")
        if (Health <= 0.0):
            TargetFort.Heal(Result.Amount)
            Print("[REPRO] Healed for {Result.Amount}, health is now {TargetFort.GetHealth()}")

OnPlayerAdded(Player : player) : void =
    spawn{ SubscribeToCharacter(Player) }

SubscribeToCharacter(Player : player)<suspends> : void =
    if(FortChar := Player.GetFortCharacter[]):
        FortChar.DamagedEvent().Subscribe(OnCharacterDamaged)

OnButtonPressed(Agent : agent) : void =
    if (FortChar := Agent.GetFortCharacter[]):
        FortChar.Damage(FortChar.GetHealth() + 50.0)

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Character

Steps to Reproduce

  1. Be in a map with verse code healing characters in the DamagedEvent callback on receiving lethal damage
  2. Take lethal damage
  3. Observe character still is eliminated

Expected Result

Players survive lethal damage when healed in the DamagedEvent callback

Observed Result

Players do not survive lethal damage when healed in the DamagedEvent callback

Platform(s)

ALL

Island Code

6413-2482-8273

The status of FORT-1133680 changed to ‘Needs Triage’. We are routing this to the appropriate team for investigation.