TisRyno / LethalProgression

All-client required version of Lethal Experience. Skillpoints and more.
1 stars 1 forks source link

[BUG] HP Regen not protecting players from death #33

Open TisRyno opened 5 months ago

TisRyno commented 5 months ago

Mod Version v1.7.X

Describe the bug When being hit with a shovel you can die instantly even though you have regenerated back to 100HP. Bug only occurs if hit by shovel multiple times, base game death always occurs on the 4th (maybe 5th) hit, that same hit will be fatal regardless of HP.

To Reproduce Steps to reproduce the behavior:

  1. Have 2 players online, with a shovel
  2. Player 1 put 5 points in HP regen
  3. Player 2 hits Player 1 only when HP has regenerated back to 100 HP
  4. On the 4th/6th hit Player 1 will die with 100HP

Expected behavior Hits should only do the damage they apply and not force instantaneous death

Screenshots If applicable, add screenshots to help explain your problem.

Mod list: Lethal Progression

Additional context The error occurs due to the IHittable.Hit function running server-side.

        DamageOnOtherClients(damageAmount, newHealthAmount);
        if (base.IsOwner && isPlayerControlled)
        {
            CentipedeAI[] array = UnityEngine.Object.FindObjectsByType<CentipedeAI>(FindObjectsSortMode.None);
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].clingingToPlayer == this)
                {
                    return;
                }
            }

            DamagePlayer(damageAmount, hasDamageSFX: true, callRPC: false, CauseOfDeath.Bludgeoning);
        }

In the code above, the Host runs DamageOnOtherClients and updates the Player's HP based off of it's own understanding of the HP and not the Player's regenerated HP.

To fix this issue, the Host (at minimum) will need to track a player's HP regeneration and update their HP accordingly, or alternatively a new RPC will need to be added for a client to inform the server of it's new HP value.