mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-10-13 15:33:53 -04:00
Fix and hookify full health on spawn (#7239)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user