From 0f41ecb145a688f66ac311db31483a41908ad4d0 Mon Sep 17 00:00:00 2001 From: Jordan Longstaff Date: Mon, 24 Nov 2025 12:30:34 -0500 Subject: [PATCH] Modularize Hurt Container mode hook (#5874) * Modularize Hurt Container mode hook * Hook condition was wrong - fixed it * Change type of hurtEnabled for clarity * Change type back to bool * Add VB hook * Don't duplicate health capacity modifier calculation * Add constants, replace magic numbers * Clang format * Publicize more health unit macros * Make mod file self-contained --- soh/include/z64save.h | 4 ++ .../Enhancements/ExtraModes/HurtContainer.cpp | 42 +++++++++++++++++++ .../game-interactor/GameInteractionEffect.cpp | 6 ++- .../GameInteractor_RawAction.cpp | 8 ++-- .../vanilla-behavior/GIVanillaBehavior.h | 8 ++++ soh/soh/Enhancements/mods.cpp | 23 ---------- soh/soh/Enhancements/mods.h | 1 - .../Enhancements/randomizer/hook_handlers.cpp | 6 +-- .../Enhancements/randomizer/randomizer.cpp | 2 +- .../Enhancements/timesaver_hook_handlers.cpp | 2 +- soh/soh/SaveManager.cpp | 12 +++--- soh/soh/SohGui/SohMenuEnhancements.cpp | 3 -- soh/src/code/z_en_item00.c | 2 +- soh/src/code/z_lifemeter.c | 8 ++-- soh/src/code/z_message_PAL.c | 11 ++--- soh/src/code/z_parameter.c | 15 +++---- soh/src/code/z_sram.c | 4 +- .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 6 +-- .../actors/ovl_Boss_Ganon/z_boss_ganon.c | 4 +- .../ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c | 2 +- .../actors/ovl_player_actor/z_player.c | 12 +++--- .../ovl_file_choose/z_file_choose.c | 2 +- .../misc/ovl_kaleido_scope/z_kaleido_debug.c | 22 +++++----- .../ovl_kaleido_scope/z_kaleido_scope_PAL.c | 5 ++- 24 files changed, 117 insertions(+), 93 deletions(-) create mode 100644 soh/soh/Enhancements/ExtraModes/HurtContainer.cpp diff --git a/soh/include/z64save.h b/soh/include/z64save.h index bf1342360..c20bf2034 100644 --- a/soh/include/z64save.h +++ b/soh/include/z64save.h @@ -9,6 +9,10 @@ #include "soh/Enhancements/randomizer/randomizer_entrance.h" #include "soh/Enhancements/boss-rush/BossRush.h" +#define FULL_HEART_HEALTH 0x10 +#define STARTING_HEALTH (3 * FULL_HEART_HEALTH) +#define MAX_HEALTH (20 * FULL_HEART_HEALTH) + typedef enum { /* 0x0 */ MAGIC_STATE_IDLE, // Regular gameplay /* 0x1 */ MAGIC_STATE_CONSUME_SETUP, // Sets the speed at which magic border flashes diff --git a/soh/soh/Enhancements/ExtraModes/HurtContainer.cpp b/soh/soh/Enhancements/ExtraModes/HurtContainer.cpp new file mode 100644 index 000000000..ecf39ef31 --- /dev/null +++ b/soh/soh/Enhancements/ExtraModes/HurtContainer.cpp @@ -0,0 +1,42 @@ +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" +#include "soh/ShipInit.hpp" + +extern "C" { +#include "variables.h" +extern SaveContext gSaveContext; +} + +static constexpr int32_t CVAR_HURT_CONTAINER_DEFAULT = 0; +#define CVAR_HURT_CONTAINER_NAME CVAR_ENHANCEMENT("HurtContainer") +#define CVAR_HURT_CONTAINER_VALUE CVarGetInteger(CVAR_HURT_CONTAINER_NAME, CVAR_HURT_CONTAINER_DEFAULT) + +static bool hurtEnabled = false; + +static void UpdateHurtContainerModeState() { + hurtEnabled = CVAR_HURT_CONTAINER_VALUE; + uint16_t heartPieceContainers = gSaveContext.ship.stats.heartPieces / 4; + uint16_t heartContainers = gSaveContext.ship.stats.heartContainers; + uint16_t healthCapacityMod = (heartPieceContainers + heartContainers) * FULL_HEART_HEALTH; + + if (hurtEnabled != CVAR_HURT_CONTAINER_DEFAULT) { + gSaveContext.healthCapacity = MAX_HEALTH - healthCapacityMod; + } else { + gSaveContext.healthCapacity = STARTING_HEALTH + healthCapacityMod; + } +} + +static void RegisterHurtContainer() { + if (GameInteractor::IsSaveLoaded(false)) { + UpdateHurtContainerModeState(); + } + + COND_HOOK(OnLoadGame, hurtEnabled != CVAR_HURT_CONTAINER_VALUE, [](int32_t) { UpdateHurtContainerModeState(); }); + + COND_VB_SHOULD(VB_HEARTS_INCREASE_WITH_CONTAINERS, CVAR_HURT_CONTAINER_VALUE, { + *should = false; + gSaveContext.healthCapacity -= FULL_HEART_HEALTH; + gSaveContext.health -= FULL_HEART_HEALTH; + }); +} + +static RegisterShipInitFunc initFunc(RegisterHurtContainer, { CVAR_HURT_CONTAINER_NAME }); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp b/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp index 682a1271e..7c762ca66 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractionEffect.cpp @@ -101,8 +101,10 @@ void UnsetFlag::_Apply() { GameInteractionEffectQueryResult ModifyHeartContainers::CanBeApplied() { if (!GameInteractor::IsSaveLoaded(true)) { return GameInteractionEffectQueryResult::TemporarilyNotPossible; - } else if ((parameters[0] > 0 && (gSaveContext.healthCapacity + (parameters[0] * 0x10) > 0x140)) || - (parameters[0] < 0 && (gSaveContext.healthCapacity + (parameters[0] * 0x10) < 0x10))) { + } else if ((parameters[0] > 0 && + (gSaveContext.healthCapacity + (parameters[0] * FULL_HEART_HEALTH) > MAX_HEALTH)) || + (parameters[0] < 0 && + (gSaveContext.healthCapacity + (parameters[0] * FULL_HEART_HEALTH) < FULL_HEART_HEALTH))) { return GameInteractionEffectQueryResult::NotPossible; } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp index 793466c19..0e82ac7c3 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp @@ -17,7 +17,7 @@ extern PlayState* gPlayState; #include "overlays/actors/ovl_En_Bom/z_en_bom.h" void GameInteractor::RawAction::AddOrRemoveHealthContainers(int16_t amount) { - gSaveContext.healthCapacity += amount * 0x10; + gSaveContext.healthCapacity += amount * FULL_HEART_HEALTH; } void GameInteractor::RawAction::AddOrRemoveMagic(int8_t amount) { @@ -46,17 +46,17 @@ void GameInteractor::RawAction::AddOrRemoveMagic(int8_t amount) { void GameInteractor::RawAction::HealOrDamagePlayer(int16_t hearts) { if (hearts > 0) { - Health_ChangeBy(gPlayState, hearts * 0x10); + Health_ChangeBy(gPlayState, hearts * FULL_HEART_HEALTH); } else if (hearts < 0) { Player* player = GET_PLAYER(gPlayState); - Health_ChangeBy(gPlayState, hearts * 0x10); + Health_ChangeBy(gPlayState, hearts * FULL_HEART_HEALTH); func_80837C0C(gPlayState, player, 0, 0, 0, 0, 0); player->invincibilityTimer = 28; } } void GameInteractor::RawAction::SetPlayerHealth(int16_t hearts) { - gSaveContext.health = hearts * 0x10; + gSaveContext.health = hearts * FULL_HEART_HEALTH; } void GameInteractor::RawAction::SetLinkInvisibility(bool active) { diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h index fe437907a..8806b0a63 100644 --- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h +++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h @@ -1175,6 +1175,14 @@ typedef enum { // - None VB_HEALTH_METER_BE_CRITICAL, + // #### `result` + // ```c + // true + // ``` + // #### `args` + // - None + VB_HEARTS_INCREASE_WITH_CONTAINERS, + // #### `result` // ```c // (respawnFlag == 1) || (respawnFlag == -1) diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 93b4ce79e..f4ad7ee47 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -486,28 +486,6 @@ void RegisterEnemyDefeatCounts() { }); } -void UpdateHurtContainerModeState(bool newState) { - static bool hurtEnabled = false; - if (hurtEnabled == newState) { - return; - } - - hurtEnabled = newState; - uint16_t getHeartPieces = gSaveContext.ship.stats.heartPieces / 4; - uint16_t getHeartContainers = gSaveContext.ship.stats.heartContainers; - - if (hurtEnabled) { - gSaveContext.healthCapacity = 320 - ((getHeartPieces + getHeartContainers) * 16); - } else { - gSaveContext.healthCapacity = 48 + ((getHeartPieces + getHeartContainers) * 16); - } -} - -void RegisterHurtContainerModeHandler() { - GameInteractor::Instance->RegisterGameHook( - [](int32_t fileNum) { UpdateHurtContainerModeState(CVarGetInteger(CVAR_ENHANCEMENT("HurtContainer"), 0)); }); -} - void RegisterRandomizedEnemySizes() { GameInteractor::Instance->RegisterGameHook([](void* refActor) { // Randomized Enemy Sizes @@ -572,6 +550,5 @@ void InitMods() { RegisterEnemyDefeatCounts(); RegisterRandomizedEnemySizes(); RegisterPatchHandHandler(); - RegisterHurtContainerModeHandler(); RandoKaleido_RegisterHooks(); } diff --git a/soh/soh/Enhancements/mods.h b/soh/soh/Enhancements/mods.h index 24710d5b2..7ba012737 100644 --- a/soh/soh/Enhancements/mods.h +++ b/soh/soh/Enhancements/mods.h @@ -9,7 +9,6 @@ extern "C" { void DirtPathFix_UpdateZFightingMode(int32_t sceneNum); void UpdateMirrorModeState(int32_t sceneNum); -void UpdateHurtContainerModeState(bool newState); void UpdateToTMedallions(); void UpdatePermanentHeartLossState(); void UpdateHyperEnemiesState(); diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 82a9336fa..276270bad 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -391,11 +391,11 @@ void RandomizerOnItemReceiveHandler(GetItemEntry receivedItemEntry) { if (receivedItemEntry.modIndex == MOD_NONE && (receivedItemEntry.itemId == ITEM_HEART_PIECE || receivedItemEntry.itemId == ITEM_HEART_PIECE_2 || receivedItemEntry.itemId == ITEM_HEART_CONTAINER)) { - gSaveContext.healthAccumulator = 0x140; // Refill 20 hearts + gSaveContext.healthAccumulator = MAX_HEALTH; // Refill 20 hearts if ((s32)(gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000) { gSaveContext.inventory.questItems ^= 0x40000000; - gSaveContext.healthCapacity += 0x10; - gSaveContext.health += 0x10; + gSaveContext.healthCapacity += FULL_HEART_HEALTH; + gSaveContext.health += FULL_HEART_HEALTH; } } diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index cac735121..4ad550164 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -6221,7 +6221,7 @@ extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { case RG_DOUBLE_DEFENSE: gSaveContext.isDoubleDefenseAcquired = true; gSaveContext.inventory.defenseHearts = 20; - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; break; case RG_TYCOON_WALLET: Inventory_ChangeUpgrade(UPG_WALLET, 3); diff --git a/soh/soh/Enhancements/timesaver_hook_handlers.cpp b/soh/soh/Enhancements/timesaver_hook_handlers.cpp index 89bef13c5..ff1e18354 100644 --- a/soh/soh/Enhancements/timesaver_hook_handlers.cpp +++ b/soh/soh/Enhancements/timesaver_hook_handlers.cpp @@ -773,7 +773,7 @@ void TimeSaverOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_li (IS_RANDO || CVarGetInteger(CVAR_ENHANCEMENT("TimeSavers.SkipMiscInteractions"), IS_RANDO))) { if (IS_RANDO || *should) { Flags_SetRandomizerInf(flag); - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; Magic_Fill(gPlayState); } *should = false; diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index ab6350758..b05770c54 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -655,10 +655,10 @@ void SaveManager::InitFileNormal() { gSaveContext.ship.filenameLanguage = (gSaveContext.language == LANGUAGE_JPN) ? NAME_LANGUAGE_NTSC_JPN : NAME_LANGUAGE_NTSC_ENG; } - gSaveContext.healthCapacity = 0x30; - gSaveContext.health = 0x30; + gSaveContext.healthCapacity = STARTING_HEALTH; + gSaveContext.health = STARTING_HEALTH; gSaveContext.magicLevel = 0; - gSaveContext.magic = 0x30; + gSaveContext.magic = MAGIC_NORMAL_METER; gSaveContext.rupees = 0; gSaveContext.swordHealth = 0; gSaveContext.naviTimer = 0; @@ -950,10 +950,10 @@ void SaveManager::InitFileMaxed() { gSaveContext.ship.filenameLanguage = (gSaveContext.language == LANGUAGE_JPN) ? NAME_LANGUAGE_NTSC_JPN : NAME_LANGUAGE_NTSC_ENG; } - gSaveContext.healthCapacity = 0x140; - gSaveContext.health = 0x140; + gSaveContext.healthCapacity = MAX_HEALTH; + gSaveContext.health = MAX_HEALTH; gSaveContext.magicLevel = 2; - gSaveContext.magic = 0x60; + gSaveContext.magic = MAGIC_DOUBLE_METER; gSaveContext.rupees = 500; gSaveContext.swordHealth = 8; gSaveContext.naviTimer = 0; diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index 149eb6577..b528c6f45 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -1568,9 +1568,6 @@ void SohMenu::AddMenuEnhancements() { .Options(CheckboxOptions().Tooltip("A Wallmaster follows Link everywhere, don't get caught!")); AddWidget(path, "Hurt Container Mode", WIDGET_CVAR_CHECKBOX) .CVar(CVAR_ENHANCEMENT("HurtContainer")) - .Callback([](WidgetInfo& info) { - UpdateHurtContainerModeState(CVarGetInteger(CVAR_ENHANCEMENT("HurtContainer"), 0)); - }) .Options(CheckboxOptions().Tooltip("Changes Heart Piece and Heart Container functionality.\n\n" " - Each Heart Container or full Heart Piece reduces Link's Hearts by 1.\n" " - Can be enabled retroactively after a File has already started.")); diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index b6bf5ecdf..28459ba5e 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -1707,7 +1707,7 @@ void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnP } if (dropId == ITEM00_FLEXIBLE) { - if (gSaveContext.health <= 0x10) { // 1 heart or less + if (gSaveContext.health <= FULL_HEART_HEALTH) { // 1 heart or less Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, FAIRY_HEAL_TIMED, true); EffectSsDeadSound_SpawnStationary(play, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, diff --git a/soh/src/code/z_lifemeter.c b/soh/src/code/z_lifemeter.c index 451bdf9ab..cd6de967e 100644 --- a/soh/src/code/z_lifemeter.c +++ b/soh/src/code/z_lifemeter.c @@ -393,9 +393,9 @@ void HealthMeter_Draw(PlayState* play) { InterfaceContext* interfaceCtx = &play->interfaceCtx; GraphicsContext* gfxCtx = play->state.gfxCtx; Vtx* sp154 = interfaceCtx->beatingHeartVtx; - s32 curHeartFraction = gSaveContext.health % 0x10; - s16 totalHeartCount = gSaveContext.healthCapacity / 0x10; - s16 fullHeartCount = gSaveContext.health / 0x10; + s32 curHeartFraction = gSaveContext.health % FULL_HEART_HEALTH; + s16 totalHeartCount = gSaveContext.healthCapacity / FULL_HEART_HEALTH; + s16 fullHeartCount = gSaveContext.health / FULL_HEART_HEALTH; s32 pad2; f32 sp144 = interfaceCtx->unk_22A * 0.1f; s32 curCombineModeSet = 0; @@ -410,7 +410,7 @@ void HealthMeter_Draw(PlayState* play) { OPEN_DISPS(gfxCtx); - if (!(gSaveContext.health % 0x10)) { + if (!(gSaveContext.health % FULL_HEART_HEALTH)) { fullHeartCount--; } diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 6c357c612..25efbaadd 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -4653,7 +4653,7 @@ void Message_Update(PlayState* play) { } if ((msgCtx->textId >= 0xC2 && msgCtx->textId < 0xC7) || (msgCtx->textId >= 0xFA && msgCtx->textId < 0xFE)) { - gSaveContext.healthAccumulator = 0x140; // Refill 20 hearts + gSaveContext.healthAccumulator = MAX_HEALTH; // Refill 20 hearts } if (msgCtx->textId == 0x301F || msgCtx->textId == 0xA || msgCtx->textId == 0xC || msgCtx->textId == 0xCF || msgCtx->textId == 0x21C || msgCtx->textId == 9 || msgCtx->textId == 0x4078 || @@ -4691,12 +4691,9 @@ void Message_Update(PlayState* play) { } if ((s32)(gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000) { gSaveContext.inventory.questItems ^= 0x40000000; - if (!CVarGetInteger(CVAR_ENHANCEMENT("HurtContainer"), 0)) { - gSaveContext.healthCapacity += 0x10; - gSaveContext.health += 0x10; - } else { - gSaveContext.healthCapacity -= 0x10; - gSaveContext.health -= 0x10; + if (GameInteractor_Should(VB_HEARTS_INCREASE_WITH_CONTAINERS, true)) { + gSaveContext.healthCapacity += FULL_HEART_HEALTH; + gSaveContext.health += FULL_HEART_HEALTH; } } if (msgCtx->ocarinaAction != OCARINA_ACTION_CHECK_NOWARP_DONE) { diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index f2713c8d6..84cea3264 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -2318,19 +2318,16 @@ u8 Item_Give(PlayState* play, u8 item) { gSaveContext.ship.stats.heartPieces++; return Return_Item(item, MOD_NONE, ITEM_NONE); } else if (item == ITEM_HEART_CONTAINER) { - if (!CVarGetInteger(CVAR_ENHANCEMENT("HurtContainer"), 0)) { - gSaveContext.healthCapacity += 0x10; - gSaveContext.health += 0x10; - } else { - gSaveContext.healthCapacity -= 0x10; - gSaveContext.health -= 0x10; + if (GameInteractor_Should(VB_HEARTS_INCREASE_WITH_CONTAINERS, true)) { + gSaveContext.healthCapacity += FULL_HEART_HEALTH; + gSaveContext.health += FULL_HEART_HEALTH; } gSaveContext.ship.stats.heartContainers++; return Return_Item(item, MOD_NONE, ITEM_NONE); } else if (item == ITEM_HEART) { osSyncPrintf("回復ハート回復ハート回復ハート\n"); // "Recovery Heart" if (play != NULL) { - Health_ChangeBy(play, 0x10); + Health_ChangeBy(play, FULL_HEART_HEALTH); } return Return_Item(item, MOD_NONE, item); } else if (item == ITEM_MAGIC_SMALL) { @@ -2905,7 +2902,7 @@ s32 Health_ChangeBy(PlayState* play, s16 healthChange) { gSaveContext.health = gSaveContext.healthCapacity; } - heartCount = gSaveContext.health % 0x10; + heartCount = gSaveContext.health % FULL_HEART_HEALTH; healthLevel = heartCount; if (heartCount != 0) { @@ -3516,7 +3513,7 @@ void Interface_DrawMagicBar(PlayState* play) { R_MAGIC_FILL_X - 1; } } else { - if ((gSaveContext.healthCapacity - 1) / 0x10 >= lineLength && lineLength != 0) { + if ((gSaveContext.healthCapacity - 1) / FULL_HEART_HEALTH >= lineLength && lineLength != 0) { magicBarY = magicBarY_original_l + magicDrop * (lineLength == 0 ? 0 : ((gSaveContext.healthCapacity - 1) / (0x10 * lineLength) - 1)); diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 8fc6d1dde..7abc221a4 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -150,9 +150,9 @@ void Sram_OpenSave() { osSyncPrintf("scene_no = %d\n", gSaveContext.entranceIndex); osSyncPrintf(VT_RST); - if (gSaveContext.health < 0x30) { + if (gSaveContext.health < STARTING_HEALTH) { gSaveContext.health = - CVarGetInteger(CVAR_ENHANCEMENT("FullHealthSpawn"), 0) ? gSaveContext.healthCapacity : 0x30; + CVarGetInteger(CVAR_ENHANCEMENT("FullHealthSpawn"), 0) ? gSaveContext.healthCapacity : STARTING_HEALTH; } if (gSaveContext.scarecrowLongSongSet) { diff --git a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 2e3ad7888..a1fe242c6 100644 --- a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -475,7 +475,7 @@ void BgDyYoseizo_HealPlayer_NoReward(BgDyYoseizo* this, PlayState* play) { } if (this->healingTimer == 110) { - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; Magic_Fill(play); this->refillTimer = 200; } @@ -743,7 +743,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, PlayState* play) { } if (!this->healing) { - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; this->healing = true; if (actionIndex == 2) { Magic_Fill(play); @@ -771,7 +771,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, PlayState* play) { } this->itemSpawned = true; - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; Interface_ChangeAlpha(9); gSaveContext.itemGetInf[1] |= sItemGetFlags[actionIndex]; Item_Give(play, sItemIds[actionIndex]); diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index f845f323a..534988630 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -584,7 +584,7 @@ void BossGanon_IntroCutscene(BossGanon* this, PlayState* play) { this->unk_198 = 2; this->timers[2] = 110; if (GameInteractor_Should(VB_GANON_HEAL_BEFORE_FIGHT, true)) { - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; } Audio_QueueSeqCmd(NA_BGM_STOP); } else { @@ -800,7 +800,7 @@ void BossGanon_IntroCutscene(BossGanon* this, PlayState* play) { } if (this->csTimer == 25) { - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; } if (this->csTimer == 100) { diff --git a/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c b/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c index 712a9008d..129d94879 100644 --- a/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c +++ b/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c @@ -206,7 +206,7 @@ void EnBomBowlPit_Reset(EnBomBowlPit* this, PlayState* play) { // "Normal termination"/"completion" osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST); if (this->getItemId == GI_HEART_PIECE) { - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; // "Ah recovery!" (?) osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ あぁ回復! ☆☆☆☆☆ \n" VT_RST); } diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 7da8447c0..2de7113d2 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -9499,7 +9499,7 @@ void func_80843AE8(PlayState* play, Player* this) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_derth_rebirth, 1.0f, 99.0f, Animation_GetLastFrame(&gPlayerAnim_link_derth_rebirth), ANIMMODE_ONCE, 0.0f); } - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; this->av2.actionVar2 = -1; } } else if (gSaveContext.healthAccumulator == 0) { @@ -14581,20 +14581,20 @@ void Player_Action_8084EAC0(Player* this, PlayState* play) { rand = 3; } - if ((rand < 0) && (gSaveContext.health <= 0x10)) { + if ((rand < 0) && (gSaveContext.health <= FULL_HEART_HEALTH)) { rand = 3; } if (rand < 0) { - Health_ChangeBy(play, -0x10); + Health_ChangeBy(play, -FULL_HEART_HEALTH); } else { - gSaveContext.healthAccumulator = rand * 0x10; + gSaveContext.healthAccumulator = rand * FULL_HEART_HEALTH; } } else { s32 sp28 = D_808549FC[this->itemAction - PLAYER_IA_BOTTLE_POTION_RED]; if (sp28 & 1) { - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; } if (sp28 & 2) { @@ -14738,7 +14738,7 @@ void Player_Action_8084EED8(Player* this, PlayState* play) { Player_PlaySfx(this, NA_SE_EV_BOTTLE_CAP_OPEN); Player_PlaySfx(this, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } else if (LinkAnimation_OnFrame(&this->skelAnime, 47.0f)) { - gSaveContext.healthAccumulator = 0x140; + gSaveContext.healthAccumulator = MAX_HEALTH; } } diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 9e58f5e31..1870e760d 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -2209,7 +2209,7 @@ void FileChoose_DrawFileInfo(GameState* thisx, s16 fileIndex, s16 isActive) { gDPSetEnvColor(POLY_OPA_DISP++, heartBorder.r, heartBorder.g, heartBorder.b, 255); } - i = Save_GetSaveMetaInfo(fileIndex)->healthCapacity / 0x10; + i = Save_GetSaveMetaInfo(fileIndex)->healthCapacity / FULL_HEART_HEALTH; if (CVarGetInteger(CVAR_ENHANCEMENT("FileSelectMoreInfo"), 0) == 0 || this->menuMode != FS_MENU_MODE_SELECT) { // draw hearts diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c index 2eb5e15bb..b79da892f 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c @@ -140,7 +140,7 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); // Current Health Quarter (X / 4) - KaleidoScope_DrawDigit(play, (gSaveContext.health % 0x10) / 4, 194, 15); + KaleidoScope_DrawDigit(play, (gSaveContext.health % FULL_HEART_HEALTH) / 4, 194, 15); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); @@ -169,7 +169,7 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) { // Health capacity spD8[2] = 0; - spD8[3] = gSaveContext.healthCapacity / 0x10; + spD8[3] = gSaveContext.healthCapacity / FULL_HEART_HEALTH; while (spD8[3] >= 10) { spD8[2]++; spD8[3] -= 10; @@ -180,7 +180,7 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) { // Health spD8[2] = 0; - spD8[3] = gSaveContext.health / 0x10; + spD8[3] = gSaveContext.health / FULL_HEART_HEALTH; while (spD8[3] >= 10) { spD8[2]++; spD8[3] -= 10; @@ -368,15 +368,15 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) { case 1: if (CHECK_BTN_ALL(input->press.button, BTN_CUP) || CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { - gSaveContext.healthCapacity -= 0x10; - if (gSaveContext.healthCapacity < 0x30) { - gSaveContext.healthCapacity = 0x30; + gSaveContext.healthCapacity -= FULL_HEART_HEALTH; + if (gSaveContext.healthCapacity < STARTING_HEALTH) { + gSaveContext.healthCapacity = STARTING_HEALTH; } } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN) || CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { - gSaveContext.healthCapacity += 0x10; - if (gSaveContext.healthCapacity >= 0x140) { - gSaveContext.healthCapacity = 0x140; + gSaveContext.healthCapacity += FULL_HEART_HEALTH; + if (gSaveContext.healthCapacity >= MAX_HEALTH) { + gSaveContext.healthCapacity = MAX_HEALTH; } } break; @@ -387,9 +387,9 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) { } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { Health_ChangeBy(play, 4); } else if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) { - Health_ChangeBy(play, -0x10); + Health_ChangeBy(play, -FULL_HEART_HEALTH); } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { - Health_ChangeBy(play, 0x10); + Health_ChangeBy(play, FULL_HEART_HEALTH); } break; diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 14f749d43..627300036 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -4773,8 +4773,9 @@ void KaleidoScope_Update(PlayState* play) { // Reset frame counter to prevent autosave on respawn play->gameplayFrames = 0; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; - gSaveContext.health = - CVarGetInteger(CVAR_ENHANCEMENT("FullHealthSpawn"), 0) ? gSaveContext.healthCapacity : 0x30; + gSaveContext.health = CVarGetInteger(CVAR_ENHANCEMENT("FullHealthSpawn"), 0) + ? gSaveContext.healthCapacity + : STARTING_HEALTH; Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA); gSaveContext.healthAccumulator = 0; gSaveContext.magicState = MAGIC_STATE_IDLE;