From 74093a1afcf85ac6c66329d47b30f0d9cdadb50b Mon Sep 17 00:00:00 2001 From: Erlite Date: Fri, 21 Oct 2022 20:42:36 +0200 Subject: Fix server crash from demigod setting health over max health. (#509) * Fix server crash from demigod set health > max health * Add the incredible optimization. :^) Co-authored-by: uniboi <64006268+uniboi@users.noreply.github.com> * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA. Co-authored-by: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> Co-authored-by: uniboi <64006268+uniboi@users.noreply.github.com> Co-authored-by: Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> --- Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Northstar.CustomServers/mod') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut b/Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut index c0e69ba5..3546e3b7 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/_utility.gnut @@ -2127,8 +2127,13 @@ void function EntityDemigod_TryAdjustDamageInfo( entity ent, var damageInfo ) return int bottomLimit = 5 + // Set it up so that you at least take 1 damage, for hit indicators etc to trigger if ( ent.GetHealth() <= bottomLimit ) - ent.SetHealth( bottomLimit + 1 ) //Set it up so that you at least take 1 damage, for hit indicators etc to trigger + { + // Prevent going over max health to avoid a server crash. + int newHealth = bottomLimit + 1 + ent.SetHealth( ent.GetMaxHealth() < newHealth ? ent.GetMaxHealth() : newHealth ) + } int health = ent.GetHealth() -- cgit v1.2.3