From c17b5fa5862dd0ae29749e690bf7edaba23b19ab Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Wed, 3 May 2023 01:31:50 -0500 Subject: [PATCH] prevent ressurecting with more than max stats (#1064) for health and imagination --- dGame/dGameMessages/GameMessages.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 4d5a378c..3475c471 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -937,8 +937,13 @@ void GameMessages::SendResurrect(Entity* entity) { if (destroyableComponent != nullptr && entity->GetLOT() == 1) { auto* levelComponent = entity->GetComponent(); if (levelComponent) { - destroyableComponent->SetHealth(levelComponent->GetLevel() >= 45 ? 8 : 4); - destroyableComponent->SetImagination(levelComponent->GetLevel() >= 45 ? 20 : 6); + int32_t healthToRestore = levelComponent->GetLevel() >= 45 ? 8 : 4; + if (healthToRestore > destroyableComponent->GetMaxHealth()) healthToRestore = destroyableComponent->GetMaxHealth(); + destroyableComponent->SetHealth(healthToRestore); + + int32_t imaginationToRestore = levelComponent->GetLevel() >= 45 ? 20 : 6; + if (imaginationToRestore > destroyableComponent->GetMaxImagination()) imaginationToRestore = destroyableComponent->GetMaxImagination(); + destroyableComponent->SetImagination(imaginationToRestore); } } });