summaryrefslogtreecommitdiff
path: root/soh/src/code
diff options
context:
space:
mode:
authorJordan Longstaff <JordanLongstaff@users.noreply.github.com>2025-11-24 12:30:34 -0500
committerGitHub <noreply@github.com>2025-11-24 17:30:34 +0000
commit0f41ecb145a688f66ac311db31483a41908ad4d0 (patch)
treed9b5c6b273089c4405e66970e7fd286dbb0d311a /soh/src/code
parent3e6b590db47910e079ef2141485f704c02c0de87 (diff)
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
Diffstat (limited to 'soh/src/code')
-rw-r--r--soh/src/code/z_en_item00.c2
-rw-r--r--soh/src/code/z_lifemeter.c8
-rw-r--r--soh/src/code/z_message_PAL.c11
-rw-r--r--soh/src/code/z_parameter.c15
-rw-r--r--soh/src/code/z_sram.c4
5 files changed, 17 insertions, 23 deletions
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) {