mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-08-12 12:18:32 -04:00
Hookify frogs' Ocarina game (#6969)
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||
#include "soh/ShipInit.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "functions.h"
|
||||
#include "src/overlays/actors/ovl_En_Fr/z_en_fr.h"
|
||||
extern PlayState* gPlayState;
|
||||
|
||||
extern void EnFr_SetupReward(EnFr* enFr, PlayState* play, u8 unkCondition);
|
||||
}
|
||||
|
||||
#define CVAR_FROGS_CUSTOMIZE_NAME CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame")
|
||||
#define CVAR_FROGS_CUSTOMIZE_VALUE CVarGetInteger(CVAR_FROGS_CUSTOMIZE_NAME, 0)
|
||||
|
||||
#define CVAR_FROGS_MODIFY_TIME_NAME CVAR_ENHANCEMENT("FrogsModifyFailTime")
|
||||
#define CVAR_FROGS_MODIFY_TIME_VALUE CVarGetInteger(CVAR_FROGS_MODIFY_TIME_NAME, 1)
|
||||
|
||||
#define CVAR_FROGS_INFINITE_TIME_NAME CVAR_ENHANCEMENT("FrogsUnlimitedFailTime")
|
||||
#define CVAR_FROGS_INFINITE_TIME_VALUE CVarGetInteger(CVAR_FROGS_INFINITE_TIME_NAME, 0)
|
||||
|
||||
#define CVAR_FROGS_INSTANT_WIN_NAME CVAR_ENHANCEMENT("InstantFrogsGameWin")
|
||||
#define CVAR_FROGS_INSTANT_WIN_VALUE CVarGetInteger(CVAR_FROGS_INSTANT_WIN_NAME, 0)
|
||||
|
||||
static void RegisterFrogsOcarinaGameModifyTime() {
|
||||
COND_VB_SHOULD(VB_SET_FROG_OCARINA_GAME_TIME_LIMIT,
|
||||
CVAR_FROGS_CUSTOMIZE_VALUE && (CVAR_FROGS_MODIFY_TIME_VALUE != 1), {
|
||||
EnFr* enFr = va_arg(args, EnFr*);
|
||||
s32 timeLimit = va_arg(args, s32);
|
||||
enFr->frogSongTimer = timeLimit * CVAR_FROGS_MODIFY_TIME_VALUE;
|
||||
*should = false;
|
||||
});
|
||||
}
|
||||
|
||||
static void RegisterFrogsOcarinaGameInfiniteTime() {
|
||||
COND_VB_SHOULD(VB_FROGS_OCARINA_GAME_TIMER_TICK, CVAR_FROGS_CUSTOMIZE_VALUE && CVAR_FROGS_INFINITE_TIME_VALUE,
|
||||
{ *should = false; });
|
||||
}
|
||||
|
||||
static void RegisterFrogsOcarinaGameInstantWin() {
|
||||
COND_VB_SHOULD(VB_PLAY_FROG_OCARINA_GAME, CVAR_FROGS_CUSTOMIZE_VALUE && CVAR_FROGS_INSTANT_WIN_VALUE, {
|
||||
EnFr* enFr = va_arg(args, EnFr*);
|
||||
enFr->actor.textId = 0x40AC;
|
||||
EnFr_SetupReward(enFr, gPlayState, false);
|
||||
*should = false;
|
||||
});
|
||||
}
|
||||
|
||||
static RegisterShipInitFunc initFunc_ModifyTime(RegisterFrogsOcarinaGameModifyTime,
|
||||
{ CVAR_FROGS_CUSTOMIZE_NAME, CVAR_FROGS_MODIFY_TIME_NAME });
|
||||
static RegisterShipInitFunc initFunc_InfiniteTime(RegisterFrogsOcarinaGameInfiniteTime,
|
||||
{ CVAR_FROGS_CUSTOMIZE_NAME, CVAR_FROGS_INFINITE_TIME_NAME });
|
||||
static RegisterShipInitFunc initFunc_InstantWin(RegisterFrogsOcarinaGameInstantWin,
|
||||
{ CVAR_FROGS_CUSTOMIZE_NAME, CVAR_FROGS_INSTANT_WIN_NAME });
|
||||
@@ -799,6 +799,14 @@ typedef enum {
|
||||
// - `*EnFr`
|
||||
VB_FROGS_GO_TO_IDLE,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
// ```
|
||||
// #### `args`
|
||||
// - None
|
||||
VB_FROGS_OCARINA_GAME_TIMER_TICK,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
@@ -1900,6 +1908,14 @@ typedef enum {
|
||||
// - None
|
||||
VB_PLAY_FIRE_ARROW_CS,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
// ```
|
||||
// #### `args`
|
||||
// - `*EnFr`
|
||||
VB_PLAY_FROG_OCARINA_GAME,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
@@ -2380,6 +2396,15 @@ typedef enum {
|
||||
// - None
|
||||
VB_SET_DIVING_GAME_TIME_LIMIT,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
// ```
|
||||
// #### `args`
|
||||
// - `*EnFr`
|
||||
// - `s16` (default time limit)
|
||||
VB_SET_FROG_OCARINA_GAME_TIME_LIMIT,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// SurfaceType_GetFloorEffect(&play->colCtx, poly, bgId) == 2
|
||||
|
||||
@@ -824,22 +824,10 @@ void EnFr_SetupFrogSong(EnFr* this, PlayState* play) {
|
||||
if (this->frogSongTimer != 0) {
|
||||
this->frogSongTimer--;
|
||||
} else {
|
||||
// #region SOH [Enhancement]
|
||||
if (CVarGetInteger(CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), 0)) {
|
||||
this->frogSongTimer = 40 * CVarGetInteger(CVAR_ENHANCEMENT("FrogsModifyFailTime"), 1);
|
||||
if (CVarGetInteger(CVAR_ENHANCEMENT("InstantFrogsGameWin"), 0)) {
|
||||
this->actor.textId = 0x40AC;
|
||||
EnFr_SetupReward(this, play, false);
|
||||
} else {
|
||||
this->ocarinaNoteIndex = 0;
|
||||
func_8010BD58(play, OCARINA_ACTION_FROGS);
|
||||
this->ocarinaNote = EnFr_GetNextNoteFrogSong(this->ocarinaNoteIndex);
|
||||
EnFr_CheckOcarinaInputFrogSong(this->ocarinaNote);
|
||||
this->actionFunc = EnFr_ContinueFrogSong;
|
||||
}
|
||||
// #endregion
|
||||
} else {
|
||||
if (GameInteractor_Should(VB_SET_FROG_OCARINA_GAME_TIME_LIMIT, true, this, 40)) {
|
||||
this->frogSongTimer = 40;
|
||||
}
|
||||
if (GameInteractor_Should(VB_PLAY_FROG_OCARINA_GAME, true, this)) {
|
||||
this->ocarinaNoteIndex = 0;
|
||||
func_8010BD58(play, OCARINA_ACTION_FROGS);
|
||||
this->ocarinaNote = EnFr_GetNextNoteFrogSong(this->ocarinaNoteIndex);
|
||||
@@ -867,11 +855,7 @@ s32 EnFr_IsFrogSongComplete(EnFr* this, PlayState* play) {
|
||||
ocarinaNote = EnFr_GetNextNoteFrogSong(ocarinaNoteIndex);
|
||||
this->ocarinaNote = ocarinaNote;
|
||||
EnFr_CheckOcarinaInputFrogSong(ocarinaNote);
|
||||
// #region SOH [Enhancement]
|
||||
if (CVarGetInteger(CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), 0)) {
|
||||
this->frogSongTimer = sTimerFrogSong[index] * CVarGetInteger(CVAR_ENHANCEMENT("FrogsModifyFailTime"), 1);
|
||||
// #endregion
|
||||
} else {
|
||||
if (GameInteractor_Should(VB_SET_FROG_OCARINA_GAME_TIME_LIMIT, true, this, sTimerFrogSong[index])) {
|
||||
this->frogSongTimer = sTimerFrogSong[index];
|
||||
}
|
||||
}
|
||||
@@ -896,10 +880,7 @@ void EnFr_ContinueFrogSong(EnFr* this, PlayState* play) {
|
||||
if (this->frogSongTimer == 0) {
|
||||
EnFr_OcarinaMistake(this, play);
|
||||
} else {
|
||||
// #region SOH [Enhancement] - Don't decrement timer
|
||||
if (!CVarGetInteger(CVAR_ENHANCEMENT("CustomizeFrogsOcarinaGame"), 0) ||
|
||||
!CVarGetInteger(CVAR_ENHANCEMENT("FrogsUnlimitedFailTime"), 0)) {
|
||||
// #endregion
|
||||
if (GameInteractor_Should(VB_FROGS_OCARINA_GAME_TIMER_TICK, true)) {
|
||||
this->frogSongTimer--;
|
||||
}
|
||||
if (play->msgCtx.msgMode == MSGMODE_FROGS_PLAYING) {
|
||||
|
||||
Reference in New Issue
Block a user