From 3619bcb2f2bd0f394258dc14a204ae0cebcfac41 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 11 Nov 2022 17:27:58 +1000 Subject: [PATCH] Don't recalculate all solo handicaps on every tick --- src/game/lv.c | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/game/lv.c b/src/game/lv.c index a581aef13..418299fe6 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -132,6 +132,8 @@ u32 g_FadePrevColour = 0; u32 g_FadeColour = 0; s16 g_FadeDelay = 0; +void lvResetSoloHandicaps(void); + u32 getVar80084040(void) { return var80084040; @@ -363,6 +365,7 @@ void lvReset(s32 stagenum) animsReset(); objectivesReset(); vtxstoreReset(); + lvResetSoloHandicaps(); modelmgrReset(); propsndReset(); setupLoadFiles(stagenum); @@ -1704,7 +1707,7 @@ u32 var800840b4 = 0; u32 var800840b8 = 0; u32 var800840bc = 0; -void lvUpdateSoloHandicaps(void) +void lvResetSoloHandicaps(void) { if (g_Vars.antiplayernum >= 0) { if (g_Difficulty == DIFF_A) { @@ -1778,26 +1781,13 @@ void lvUpdateSoloHandicaps(void) } } else { if (g_Difficulty == DIFF_A) { - f32 totalhealth; - f32 frac = 1; - - if (g_Vars.coopplayernum < 0 && g_Vars.antiplayernum < 0) { - totalhealth = playerGetHealthFrac() + playerGetShieldFrac(); - - if (totalhealth <= 0.125f) { - frac = 0.5f; - } else if (totalhealth <= 0.6f) { - frac = (totalhealth - 0.125f) * 0.5f / 0.47500002384186f + 0.5f; - } - } - - g_AutogunAccuracyScale = 0.5f * frac; - g_AutogunDamageTxScale = 0.5f * frac; + g_AutogunAccuracyScale = 0.5f; + g_AutogunDamageTxScale = 0.5f; g_AutogunDamageRxScale = 2; g_EnemyAccuracyScale = 0.6f; - g_PlayerDamageRxScale = 0.5f * frac; + g_PlayerDamageRxScale = 0.5f; g_PlayerDamageTxScale = 2; - g_ExplosionDamageTxScale = 0.25f * frac; + g_ExplosionDamageTxScale = 0.25f; g_AutoAimScale = 1.5f; g_AmmoQuantityScale = 2; g_AttackWalkDurationScale = 0.2f; @@ -1838,6 +1828,27 @@ void lvUpdateSoloHandicaps(void) } } +void lvUpdateSoloHandicaps(void) +{ + if (g_Difficulty == DIFF_A && g_Vars.coopplayernum < 0 && g_Vars.antiplayernum < 0) { + f32 totalhealth; + f32 frac = 1; + + totalhealth = playerGetHealthFrac() + playerGetShieldFrac(); + + if (totalhealth <= 0.125f) { + frac = 0.5f; + } else if (totalhealth <= 0.6f) { + frac = (totalhealth - 0.125f) * 0.5f / 0.47500002384186f + 0.5f; + } + + g_AutogunAccuracyScale = 0.5f * frac; + g_AutogunDamageTxScale = 0.5f * frac; + g_PlayerDamageRxScale = 0.5f * frac; + g_ExplosionDamageTxScale = 0.25f * frac; + } +} + #if PIRACYCHECKS #if PAL