StrataSource / Portal-2-Community-Edition

Task tracker for Portal 2: Community Edition
https://www.portal2communityedition.com
149 stars 3 forks source link

Player damage is reduced by half #1227

Open vrad-exe opened 1 year ago

vrad-exe commented 1 year ago

Describe the bug

~The SetHealth and RemoveHealth inputs appear to not lower health correctly in Portal 2; they only do half the damage they are supposed to, resulting in the entity's health not actually being set to the value specified, but to something higher.~

All player damage appears to be halved compared to the values specified. This apples to the SetHealth and RemoveHealth inputs, as well as other sources (e.g. HL2 weapons do half damage compared to what is specified in the skill cvars, poison headcrabs take half of the player's current health instead of lowering to 1)

If the player's health is visualized (e.g. with player_debug_print_damage or VScript), you can see that it seems to always deal exactly half of the damage it should; for SetHealth it's (current health - target health) / 2, while for RemoveHealth this is target damage / 2.

This doesn't happen when increasing the player's health. I only checked this with players, unsure if it also affects other entities.

Issue Map

Any

To Reproduce

  1. Turn on player_debug_print_damage
  2. Run ent_fire !self SetHealth 0
  3. Player does not die. Console reports only 50 damage dealt, when it should have been 100.

Operating System

Tested on Windows 10

vrad-exe commented 1 year ago

This seems to actually apply to all damage, not just these inputs. Portal turrets will probably need their damage halved to account for this being fixed, otherwise most existing Portal stuff is instakill so it shouldn't change much.

vrad-exe commented 1 year ago

To add to this, I don't think we should keep this behavior for backwards compatibility, for these inputs or for anything else. Backwards compat is good up to a point, but it's really not worth it when doing so requires keeping around bugs that are incredibly unintuitive to work with (when you tell the player to take 50 damage, they should take 50 damage, not 25). Especially for something like this, since most stuff in Portal is instant death anyway, and most of the common things that aren't (e.g. turrets) use hardcoded damage values which could be halved in code to compensate for the fix.

vrad-exe commented 1 year ago

Turns out this is actually because of a cvar sk_dmg_take_scale1 being defaulted to 0.5, I guess it's a weird leftover from the hl2 difficulty system then? I don't know honestly