From 5311ada58261c97b6e74eb0e64dafab3fc4596ee Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Mon, 25 Jul 2022 01:00:04 +0600 Subject: [PATCH] Fix player regen --- src/player.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/player.cpp b/src/player.cpp index 1f90526..ce3eec9 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -148,26 +148,36 @@ void Player::Init() float maxArmour = BY_GAME(pInfo->m_nMaxArmour, pInfo->m_nMaxArmour, 100); static float prevVal = 0; - float curVal = (player->m_fHealth == player->m_fMaxHealth) ? player->m_fHealth : player->m_fArmour; + float curVal = player->m_fHealth; + + if (player->m_fHealth >= player->m_fMaxHealth) + { + curVal = player->m_fArmour; + } + if (curVal != prevVal) { lastDmg = timer; - curVal = prevVal; + prevVal = curVal; } if (timer - lastDmg > 5000 && timer - lastTimer > 1000) { - if (player->m_fHealth != maxHealth || player->m_fArmour != maxArmour) + if (player->m_fHealth < maxHealth || player->m_fArmour < maxArmour) { - if (player->m_fHealth != maxHealth) + if (player->m_fHealth < maxHealth) { player->m_fHealth += 0.2f; prevVal = player->m_fHealth; } else - { - player->m_fArmour += 0.2f; - prevVal = player->m_fArmour; + { + // Only give armour if player has some already + if (player->m_fArmour >= 1) + { + player->m_fArmour += 0.2f; + prevVal = player->m_fArmour; + } } lastTimer = timer;