Hookify Shooting Gallery options (#6972)

This commit is contained in:
Jordan Longstaff
2026-07-23 19:33:50 -04:00
committed by GitHub
parent af8cac9e6b
commit cca66cdc5d
4 changed files with 97 additions and 17 deletions
@@ -0,0 +1,68 @@
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/ShipInit.hpp"
extern "C" {
#include "functions.h"
#include "src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.h"
extern PlayState* gPlayState;
}
#define CVAR_GALLERY_NAME CVAR_ENHANCEMENT("CustomizeShootingGallery")
#define CVAR_GALLERY_VALUE CVarGetInteger(CVAR_GALLERY_NAME, 0)
#define CVAR_INSTANT_WIN_NAME CVAR_ENHANCEMENT("InstantShootingGalleryWin")
#define CVAR_INSTANT_WIN_VALUE CVarGetInteger(CVAR_INSTANT_WIN_NAME, 0)
#define CVAR_CONSTANT_ADULT_NAME CVAR_ENHANCEMENT("ConstantAdultGallery")
#define CVAR_CONSTANT_ADULT_VALUE CVarGetInteger(CVAR_CONSTANT_ADULT_NAME, 0)
static constexpr s32 SHOOTING_GALLERY_AMMO_DEFAULT = 15;
#define CVAR_GALLERY_AMMO_CHILD_NAME CVAR_ENHANCEMENT("ShootingGalleryAmmoChild")
#define CVAR_GALLERY_AMMO_CHILD_VALUE CVarGetInteger(CVAR_GALLERY_AMMO_CHILD_NAME, SHOOTING_GALLERY_AMMO_DEFAULT)
#define CVAR_GALLERY_AMMO_ADULT_NAME CVAR_ENHANCEMENT("ShootingGalleryAmmoAdult")
#define CVAR_GALLERY_AMMO_ADULT_VALUE CVarGetInteger(CVAR_GALLERY_AMMO_ADULT_NAME, SHOOTING_GALLERY_AMMO_DEFAULT)
static void RegisterShootingGalleryInstantWin() {
COND_VB_SHOULD(VB_PLAY_SHOOTING_GALLERY, CVAR_GALLERY_VALUE && CVAR_INSTANT_WIN_VALUE, {
EnSyatekiItm* gallery = va_arg(args, EnSyatekiItm*);
gallery->hitCount = 10;
gallery->signal = ENSYATEKI_END;
*should = false;
});
}
static void RegisterShootingGalleryConstantAdult() {
COND_VB_SHOULD(VB_SHOOTING_GALLERY_SHUFFLE_ADULT_RUPEES, CVAR_GALLERY_VALUE && CVAR_CONSTANT_ADULT_VALUE,
{ *should = false; });
}
static void RegisterShootingGalleryAmmoChild() {
COND_VB_SHOULD(VB_SET_SHOOTING_GALLERY_AMMO,
CVAR_GALLERY_VALUE && (CVAR_GALLERY_AMMO_CHILD_VALUE != SHOOTING_GALLERY_AMMO_DEFAULT), {
if (LINK_IS_CHILD) {
s32* ammo = va_arg(args, s32*);
*ammo = CVAR_GALLERY_AMMO_CHILD_VALUE;
}
});
}
static void RegisterShootingGalleryAmmoAdult() {
COND_VB_SHOULD(VB_SET_SHOOTING_GALLERY_AMMO,
CVAR_GALLERY_VALUE && (CVAR_GALLERY_AMMO_ADULT_VALUE != SHOOTING_GALLERY_AMMO_DEFAULT), {
if (LINK_IS_ADULT) {
s32* ammo = va_arg(args, s32*);
*ammo = CVAR_GALLERY_AMMO_ADULT_VALUE;
}
});
}
static RegisterShipInitFunc initFunc_InstantWin(RegisterShootingGalleryInstantWin,
{ CVAR_GALLERY_NAME, CVAR_INSTANT_WIN_NAME });
static RegisterShipInitFunc initFunc_Constant(RegisterShootingGalleryConstantAdult,
{ CVAR_GALLERY_NAME, CVAR_CONSTANT_ADULT_NAME });
static RegisterShipInitFunc initFunc_AmmoChild(RegisterShootingGalleryAmmoChild,
{ CVAR_GALLERY_NAME, CVAR_GALLERY_AMMO_CHILD_NAME });
static RegisterShipInitFunc initFunc_AmmoAdult(RegisterShootingGalleryAmmoAdult,
{ CVAR_GALLERY_NAME, CVAR_GALLERY_AMMO_ADULT_NAME });
@@ -2050,6 +2050,14 @@ typedef enum {
// - None
VB_PLAY_SHIEK_BLOCK_MASTER_SWORD_CS,
// #### `result`
// ```c
// true
// ```
// #### `args`
// - `*EnSyatekiItm`
VB_PLAY_SHOOTING_GALLERY,
// #### `result`
// ```c
// (giEntry.itemId != ITEM_NONE) && (giEntry.gi >= 0) && (Item_CheckObtainability(giEntry.itemId) == ITEM_NONE)
@@ -2405,6 +2413,14 @@ typedef enum {
// - `s16` (default time limit)
VB_SET_FROG_OCARINA_GAME_TIME_LIMIT,
// #### `result`
// ```c
// true
// ```
// #### `args`
// - `*s32` (ammo count)
VB_SET_SHOOTING_GALLERY_AMMO,
// #### `result`
// ```c
// SurfaceType_GetFloorEffect(&play->colCtx, poly, bgId) == 2
@@ -2431,6 +2447,14 @@ typedef enum {
// - None
VB_SHIEK_PREPARE_TO_GIVE_SERENADE_OF_WATER,
// #### `result`
// ```c
// LINK_IS_ADULT
// ```
// #### `args`
// - None
VB_SHOOTING_GALLERY_SHUFFLE_ADULT_RUPEES,
// #### `result`
// ```c
// false
@@ -3,6 +3,7 @@
#include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h"
#include "overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.h"
#include "overlays/actors/ovl_En_G_Switch/z_en_g_switch.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#define FLAGS ACTOR_FLAG_UPDATE_CULLING_DISABLED
@@ -110,11 +111,7 @@ void EnSyatekiItm_Idle(EnSyatekiItm* this, PlayState* play) {
player->actor.world.rot.x = player->actor.shape.rot.x = player->actor.world.rot.z = player->actor.shape.rot.z =
0;
s32 ammunition = 15;
if (CVarGetInteger(CVAR_ENHANCEMENT("CustomizeShootingGallery"), 0)) {
ammunition = CVarGetInteger(LINK_IS_ADULT ? CVAR_ENHANCEMENT("ShootingGalleryAmmoAdult")
: CVAR_ENHANCEMENT("ShootingGalleryAmmoChild"),
15);
}
GameInteractor_Should(VB_SET_SHOOTING_GALLERY_AMMO, true, &ammunition);
func_8008EF44(play, ammunition);
this->roundNum = this->hitCount = 0;
for (i = 0; i < 6; i++) {
@@ -133,8 +130,7 @@ void EnSyatekiItm_StartRound(EnSyatekiItm* this, PlayState* play) {
Player* player = GET_PLAYER(play);
if (this->unkTimer == 0) {
if (LINK_IS_ADULT && !(CVarGetInteger(CVAR_ENHANCEMENT("CustomizeShootingGallery"), 0) &&
CVarGetInteger(CVAR_ENHANCEMENT("ConstantAdultGallery"), 0))) {
if (GameInteractor_Should(VB_SHOOTING_GALLERY_SHUFFLE_ADULT_RUPEES, LINK_IS_ADULT)) {
for (i = 0, j = 0; i < SYATEKI_ROUND_MAX; i++) {
if (this->roundFlags[i]) {
j++;
@@ -287,11 +287,7 @@ void EnSyatekiMan_StartGame(EnSyatekiMan* this, PlayState* play) {
Message_CloseTextbox(play);
gallery = ((EnSyatekiItm*)this->actor.parent);
if (gallery->actor.update != NULL) {
if (CVarGetInteger(CVAR_ENHANCEMENT("CustomizeShootingGallery"), 0) &&
CVarGetInteger(CVAR_ENHANCEMENT("InstantShootingGalleryWin"), 0)) {
gallery->hitCount = 10;
gallery->signal = ENSYATEKI_END;
} else {
if (GameInteractor_Should(VB_PLAY_SHOOTING_GALLERY, true, gallery)) {
gallery->signal = ENSYATEKI_START;
}
this->actionFunc = EnSyatekiMan_WaitForGame;
@@ -389,11 +385,7 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, PlayState* play) {
case SYATEKI_RESULT_ALMOST:
this->timer = 20;
s32 ammunition = 15;
if (CVarGetInteger(CVAR_ENHANCEMENT("CustomizeShootingGallery"), 0)) {
ammunition = CVarGetInteger(LINK_IS_ADULT ? CVAR_ENHANCEMENT("ShootingGalleryAmmoAdult")
: CVAR_ENHANCEMENT("ShootingGalleryAmmoChild"),
15);
}
GameInteractor_Should(VB_SET_SHOOTING_GALLERY_AMMO, true, &ammunition);
func_8008EF44(play, ammunition);
this->actionFunc = EnSyatekiMan_RestartGame;
break;