From ec669873654a3fd689d9ba6db151be44b301061b Mon Sep 17 00:00:00 2001 From: Baoulettes Date: Fri, 20 May 2022 15:16:01 +0200 Subject: [PATCH] Add mod logic --- soh/src/code/z_lifemeter.c | 78 ++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/soh/src/code/z_lifemeter.c b/soh/src/code/z_lifemeter.c index 5f1863440..8677ce76f 100644 --- a/soh/src/code/z_lifemeter.c +++ b/soh/src/code/z_lifemeter.c @@ -317,6 +317,32 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { OPEN_DISPS(gfxCtx, "../z_lifemeter.c", 353); + if (CVar_GetS32("gForceMaxHeartCount", 0)) { + MaxHeartsCount = CVar_GetS32("gMaxHeartCount", gSaveContext.healthCapacity)*16; //16 is what a full heart is + if (MaxHeartsCount < 4) { //1/4 of an heart. + MaxHeartsCount = 16; //prevent some glitch like infinite breath. + HealthNow = 4; + } + if (MaxHeartsCount > gSaveContext.healthCapacity) { + MaxHeartsCount = gSaveContext.healthCapacity; + } + if (HealthNow > MaxHeartsCount) { + HealthNow = MaxHeartsCount; + gSaveContext.health = HealthNow; + } + curHeartFraction = HealthNow % 0x10; + totalHeartCount = MaxHeartsCount / 0x10; + fullHeartCount = HealthNow / 0x10; + } else { + MaxHeartsCount = gSaveContext.healthCapacity; + if (HealthNow > MaxHeartsCount) { + HealthNow = MaxHeartsCount; + } + curHeartFraction = HealthNow % 0x10; + totalHeartCount = MaxHeartsCount / 0x10; + fullHeartCount = HealthNow / 0x10; + } + if (!(gSaveContext.health % 0x10)) { fullHeartCount--; } @@ -514,15 +540,53 @@ void HealthMeter_HandleCriticalAlarm(GlobalContext* globalCtx) { u32 HealthMeter_IsCritical(void) { s32 var; + s16 MaxHeartsCount = gSaveContext.healthCapacity; + s16 HealthNow = gSaveContext.health; - if (gSaveContext.healthCapacity <= 0x50) { - var = 0x10; - } else if (gSaveContext.healthCapacity <= 0xA0) { - var = 0x18; - } else if (gSaveContext.healthCapacity <= 0xF0) { - var = 0x20; + if (CVar_GetS32("gForceMaxHeartCount", 0)) { + MaxHeartsCount = CVar_GetS32("gMaxHeartCount", gSaveContext.healthCapacity)*16; //16 is what a full heart is + if (MaxHeartsCount < 4) { //1/4 of an heart. + MaxHeartsCount = 16; //prevent some glitch like infinite breath. + HealthNow = 4; + } + if (MaxHeartsCount > gSaveContext.healthCapacity) { + MaxHeartsCount = gSaveContext.healthCapacity; + } + if (HealthNow > MaxHeartsCount) { + HealthNow = MaxHeartsCount; + gSaveContext.health = HealthNow; + } } else { - var = 0x2C; + MaxHeartsCount = gSaveContext.healthCapacity; + if (HealthNow > MaxHeartsCount) { + HealthNow = MaxHeartsCount; + } + } + + if (MaxHeartsCount <= 0x50) { + if (CVar_GetS32("gForceMaxHeartCount", 0)) { + var = 0; + } else { + var = 0x10; + } + } else if (MaxHeartsCount <= 0xA0) { + if (CVar_GetS32("gForceMaxHeartCount", 0)) { + var = 0; + } else { + var = 0x18; + } + } else if (MaxHeartsCount <= 0xF0) { + if (CVar_GetS32("gForceMaxHeartCount", 0)) { + var = 0; + } else { + var = 0x20; + } + } else { + if (CVar_GetS32("gForceMaxHeartCount", 0)) { + var = 0; + } else { + var = 0x2C; + } } if ((var >= gSaveContext.health) && (gSaveContext.health > 0)) {