prevent ressurecting with more than max stats (#1064)

for health and imagination
This commit is contained in:
Aaron Kimbrell 2023-05-03 01:31:50 -05:00 committed by GitHub
parent 6aa90ad5b2
commit c17b5fa586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -937,8 +937,13 @@ void GameMessages::SendResurrect(Entity* entity) {
if (destroyableComponent != nullptr && entity->GetLOT() == 1) { if (destroyableComponent != nullptr && entity->GetLOT() == 1) {
auto* levelComponent = entity->GetComponent<LevelProgressionComponent>(); auto* levelComponent = entity->GetComponent<LevelProgressionComponent>();
if (levelComponent) { if (levelComponent) {
destroyableComponent->SetHealth(levelComponent->GetLevel() >= 45 ? 8 : 4); int32_t healthToRestore = levelComponent->GetLevel() >= 45 ? 8 : 4;
destroyableComponent->SetImagination(levelComponent->GetLevel() >= 45 ? 20 : 6); 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);
} }
} }
}); });