mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-02-16 15:20:11 -05:00
Supersonic merge fixes (#2553)
* ss2 * Remove Comments and Rupees when dead. * Rupees removal for real * Updated Inline formatting as well as changed Mode Idenitifier from Super Sonic to Rupee Dash. * Add OnPlayerUpdate hook * Move rupee dash to hooks * Update comment for DashInterval * ss2 * Remove Comments and Rupees when dead. * Rupees removal for real * Updated Inline formatting as well as changed Mode Idenitifier from Super Sonic to Rupee Dash. * Add OnPlayerUpdate hook * Move rupee dash to hooks * Update comment for DashInterval * Update Health to not crash on less than 16 units. * lus * fix build, use `Health_ChangeBy` --------- Co-authored-by: Caladius <Caladius@users.noreply.github.com> Co-authored-by: David Chavez <david@dcvz.io>
This commit is contained in:
parent
f0be8c7b0c
commit
7f5221b149
@ -88,7 +88,7 @@ public:
|
||||
DEFINE_HOOK(OnExitGame, void(int32_t fileNum));
|
||||
DEFINE_HOOK(OnReceiveItem, void(u8 item));
|
||||
DEFINE_HOOK(OnSceneInit, void(s16 sceneNum));
|
||||
|
||||
DEFINE_HOOK(OnPlayerUpdate, void());
|
||||
|
||||
DEFINE_HOOK(OnSaveFile, void(int32_t fileNum));
|
||||
DEFINE_HOOK(OnLoadFile, void(int32_t fileNum));
|
||||
|
@ -22,6 +22,10 @@ void GameInteractor_ExecuteOnSceneInitHooks(s16 sceneNum) {
|
||||
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnSceneInit>(sceneNum);
|
||||
}
|
||||
|
||||
void GameInteractor_ExecuteOnPlayerUpdate() {
|
||||
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnPlayerUpdate>();
|
||||
}
|
||||
|
||||
// MARK: - Save Files
|
||||
|
||||
void GameInteractor_ExecuteOnSaveFile(int32_t fileNum) {
|
||||
|
@ -5,6 +5,7 @@ extern "C" void GameInteractor_ExecuteOnLoadGame(int32_t fileNum);
|
||||
extern "C" void GameInteractor_ExecuteOnExitGame(int32_t fileNum);
|
||||
extern "C" void GameInteractor_ExecuteOnReceiveItemHooks(u8 item);
|
||||
extern "C" void GameInteractor_ExecuteOnSceneInit(s16 sceneNum);
|
||||
extern "C" void GameInteractor_ExecuteOnPlayerUpdate();
|
||||
|
||||
// MARK: - Save Files
|
||||
extern "C" void GameInteractor_ExecuteOnSaveFile(int32_t fileNum);
|
||||
|
@ -7,6 +7,8 @@ extern "C" {
|
||||
extern SaveContext gSaveContext;
|
||||
extern PlayState* gPlayState;
|
||||
extern void Play_PerformSave(PlayState* play);
|
||||
extern s32 Health_ChangeBy(PlayState* play, s16 healthChange);
|
||||
extern void Rupees_ChangeBy(s16 rupeeChange);
|
||||
}
|
||||
|
||||
void RegisterAutoSaveOnReceiveItemHook() {
|
||||
@ -72,6 +74,31 @@ void RegisterAutoSaveOnReceiveItemHook() {
|
||||
});
|
||||
}
|
||||
|
||||
void RegisterRupeeDash() {
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPlayerUpdate>([]() {
|
||||
if (!CVarGetInteger("gRupeeDash", 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize Timer
|
||||
static uint16_t rupeeDashTimer = 0;
|
||||
uint16_t rdmTime = CVarGetInteger("gDashInterval", 5) * 20;
|
||||
|
||||
// Did time change by DashInterval?
|
||||
if (rupeeDashTimer >= rdmTime) {
|
||||
rupeeDashTimer = 0;
|
||||
if (gSaveContext.rupees > 0) {
|
||||
Rupees_ChangeBy(-1);
|
||||
} else {
|
||||
Health_ChangeBy(gPlayState, -16);
|
||||
}
|
||||
} else {
|
||||
rupeeDashTimer++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void InitMods() {
|
||||
RegisterRupeeDash();
|
||||
RegisterAutoSaveOnReceiveItemHook();
|
||||
}
|
||||
|
@ -617,6 +617,14 @@ namespace GameMenuBar {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
UIWidgets::Spacer(0);
|
||||
|
||||
UIWidgets::PaddedEnhancementCheckbox("Rupee Dash Mode", "gRupeeDash", true, false);
|
||||
UIWidgets::Tooltip("Rupees reduced over time, Link suffers damage when the count hits 0.");
|
||||
UIWidgets::PaddedEnhancementSliderInt("Rupee Dash Interval: %d", "##DashInterval", "gDashInterval", 3, 5, "", 5, false, true, false,
|
||||
!CVarGetInteger("gRupeeDash", 0), "This option is disabled because \"Rupee Dash Mode\" is turned off");
|
||||
UIWidgets::Tooltip("Interval between Rupee reduction in Rupee Dash Mode");
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
|
@ -11038,6 +11038,8 @@ void Player_Update(Actor* thisx, PlayState* play) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GameInteractor_ExecuteOnPlayerUpdate();
|
||||
}
|
||||
|
||||
static struct_80858AC8 D_80858AC8;
|
||||
|
Loading…
Reference in New Issue
Block a user