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
This commit is contained in:
Jordan Longstaff
2025-11-24 12:30:34 -05:00
committed by GitHub
parent 3e6b590db4
commit 0f41ecb145
24 changed files with 117 additions and 93 deletions
+4
View File
@@ -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
@@ -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 });
@@ -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;
}
@@ -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) {
@@ -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)
-23
View File
@@ -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<GameInteractor::OnLoadGame>(
[](int32_t fileNum) { UpdateHurtContainerModeState(CVarGetInteger(CVAR_ENHANCEMENT("HurtContainer"), 0)); });
}
void RegisterRandomizedEnemySizes() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorInit>([](void* refActor) {
// Randomized Enemy Sizes
@@ -572,6 +550,5 @@ void InitMods() {
RegisterEnemyDefeatCounts();
RegisterRandomizedEnemySizes();
RegisterPatchHandHandler();
RegisterHurtContainerModeHandler();
RandoKaleido_RegisterHooks();
}
-1
View File
@@ -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();
@@ -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;
}
}
@@ -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);
@@ -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;
+6 -6
View File
@@ -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;
-3
View File
@@ -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."));
+1 -1
View File
@@ -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,
+4 -4
View File
@@ -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--;
}
+4 -7
View File
@@ -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) {
+6 -9
View File
@@ -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));
+2 -2
View File
@@ -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) {
@@ -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]);
@@ -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) {
@@ -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);
}
@@ -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;
}
}
@@ -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
@@ -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;
@@ -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;