summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--soh/soh/Enhancements/Minigames/ShootingGallery.cpp68
-rw-r--r--soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h24
-rw-r--r--soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c10
-rw-r--r--soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c12
4 files changed, 97 insertions, 17 deletions
diff --git a/soh/soh/Enhancements/Minigames/ShootingGallery.cpp b/soh/soh/Enhancements/Minigames/ShootingGallery.cpp
new file mode 100644
index 000000000..8af35223f
--- /dev/null
+++ b/soh/soh/Enhancements/Minigames/ShootingGallery.cpp
@@ -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 });
diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h
index b53081db9..dad1e863b 100644
--- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h
+++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h
@@ -2052,6 +2052,14 @@ typedef enum {
// #### `result`
// ```c
+ // true
+ // ```
+ // #### `args`
+ // - `*EnSyatekiItm`
+ VB_PLAY_SHOOTING_GALLERY,
+
+ // #### `result`
+ // ```c
// (giEntry.itemId != ITEM_NONE) && (giEntry.gi >= 0) && (Item_CheckObtainability(giEntry.itemId) == ITEM_NONE)
// ```
// #### `args`
@@ -2407,6 +2415,14 @@ typedef enum {
// #### `result`
// ```c
+ // true
+ // ```
+ // #### `args`
+ // - `*s32` (ammo count)
+ VB_SET_SHOOTING_GALLERY_AMMO,
+
+ // #### `result`
+ // ```c
// SurfaceType_GetFloorEffect(&play->colCtx, poly, bgId) == 2
// ```
// #### `args`
@@ -2433,6 +2449,14 @@ typedef enum {
// #### `result`
// ```c
+ // LINK_IS_ADULT
+ // ```
+ // #### `args`
+ // - None
+ VB_SHOOTING_GALLERY_SHUFFLE_ADULT_RUPEES,
+
+ // #### `result`
+ // ```c
// false
// ```
// #### `args`
diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c b/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c
index 2e8d0f04d..f349277c8 100644
--- a/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c
+++ b/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c
@@ -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++;
diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c
index 02bb2f75f..44abdb172 100644
--- a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c
+++ b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c
@@ -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;