Fix and hookify full health on spawn (#7239)

This commit is contained in:
Pepper0ni
2026-09-24 23:39:33 +01:00
committed by GitHub
parent 2e300d3acc
commit eccbc72cbe
3 changed files with 31 additions and 3 deletions
@@ -0,0 +1,20 @@
#include <libultraship/bridge/consolevariablebridge.h>
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h"
#include "soh/ShipInit.hpp"
#include "variables.h"
#define CVAR_FULL_HEALTH_SPAWN_NAME CVAR_ENHANCEMENT("FullHealthSpawn")
#define CVAR_FULL_HEALTH_SPAWN_VALUE CVarGetInteger(CVAR_FULL_HEALTH_SPAWN_NAME, 0)
static void RegisterFullhealthSpawn() {
COND_VB_SHOULD(VB_FULL_HEALTH_SPAWN, CVAR_FULL_HEALTH_SPAWN_VALUE, {
if (gSaveContext.health < gSaveContext.healthCapacity) {
gSaveContext.health = gSaveContext.healthCapacity;
}
*should = false;
});
}
static RegisterShipInitFunc initFunc(RegisterFullhealthSpawn, { CVAR_FULL_HEALTH_SPAWN_NAME });
@@ -926,6 +926,14 @@ typedef enum {
// - `s32` (drop id)
VB_FLEX_DROP_AMMO,
// #### `result`
// ```c
// gSaveContext.health < STARTING_HEALTH
// ```
// #### `args`
// - None
VB_FULL_HEALTH_SPAWN,
// #### `result`
// ```c
// true
+3 -3
View File
@@ -1,4 +1,5 @@
#include "global.h"
#include "soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h"
#include "vt.h"
#include <string.h>
@@ -147,9 +148,8 @@ void Sram_OpenSave() {
osSyncPrintf("scene_no = %d\n", gSaveContext.entranceIndex);
osSyncPrintf(VT_RST);
if (gSaveContext.health < STARTING_HEALTH) {
gSaveContext.health =
CVarGetInteger(CVAR_ENHANCEMENT("FullHealthSpawn"), 0) ? gSaveContext.healthCapacity : STARTING_HEALTH;
if (GameInteractor_Should(VB_FULL_HEALTH_SPAWN, gSaveContext.health < STARTING_HEALTH)) {
gSaveContext.health = STARTING_HEALTH;
}
if (gSaveContext.scarecrowLongSongSet) {