mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-30 19:40:31 -07:00
Move Rupee Dash Mode hook to its own file (#5178)
* Move Rupee Dash Mode hook to its own file * Rename initFunc
This commit is contained in:
parent
8b4cad1710
commit
4e8e6d2313
2 changed files with 42 additions and 26 deletions
42
soh/soh/Enhancements/ExtraModes/RupeeDash.cpp
Normal file
42
soh/soh/Enhancements/ExtraModes/RupeeDash.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#include <libultraship/bridge.h>
|
||||||
|
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||||
|
#include "soh/ShipInit.hpp"
|
||||||
|
#include "functions.h"
|
||||||
|
#include "macros.h"
|
||||||
|
#include "variables.h"
|
||||||
|
|
||||||
|
extern "C" PlayState* gPlayState;
|
||||||
|
|
||||||
|
static constexpr int32_t CVAR_RUPEE_DASH_DEFAULT = 0;
|
||||||
|
#define CVAR_RUPEE_DASH_NAME CVAR_ENHANCEMENT("RupeeDash")
|
||||||
|
#define CVAR_RUPEE_DASH_VALUE CVarGetInteger(CVAR_RUPEE_DASH_NAME, CVAR_RUPEE_DASH_DEFAULT)
|
||||||
|
|
||||||
|
static constexpr int32_t CVAR_RUPEE_DASH_INTERVAL_DEFAULT = 5;
|
||||||
|
#define CVAR_RUPEE_DASH_INTERVAL_NAME CVAR_ENHANCEMENT("RupeeDashInterval")
|
||||||
|
#define CVAR_RUPEE_DASH_INTERVAL_TIME \
|
||||||
|
CVarGetInteger(CVAR_RUPEE_DASH_INTERVAL_NAME, CVAR_RUPEE_DASH_INTERVAL_DEFAULT) * 20
|
||||||
|
|
||||||
|
void UpdateRupeeDash() {
|
||||||
|
// Initialize Timer
|
||||||
|
static uint16_t rupeeDashTimer = 0;
|
||||||
|
|
||||||
|
// Did time change by DashInterval?
|
||||||
|
if (rupeeDashTimer < CVAR_RUPEE_DASH_INTERVAL_TIME) {
|
||||||
|
rupeeDashTimer++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rupeeDashTimer = 0;
|
||||||
|
if (gSaveContext.rupees > 0) {
|
||||||
|
uint16_t walletSize = (CUR_UPG_VALUE(UPG_WALLET) + 1) * -1;
|
||||||
|
Rupees_ChangeBy(walletSize);
|
||||||
|
} else {
|
||||||
|
Health_ChangeBy(gPlayState, -16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterRupeeDash() {
|
||||||
|
COND_HOOK(OnPlayerUpdate, CVAR_RUPEE_DASH_VALUE, UpdateRupeeDash);
|
||||||
|
}
|
||||||
|
|
||||||
|
static RegisterShipInitFunc initFunc_RupeeDash(RegisterRupeeDash, { CVAR_RUPEE_DASH_NAME });
|
|
@ -134,31 +134,6 @@ void RegisterOcarinaTimeTravel() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterRupeeDash() {
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnPlayerUpdate>([]() {
|
|
||||||
if (!CVarGetInteger(CVAR_ENHANCEMENT("RupeeDash"), 0)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize Timer
|
|
||||||
static uint16_t rupeeDashTimer = 0;
|
|
||||||
uint16_t rdmTime = CVarGetInteger(CVAR_ENHANCEMENT("RupeeDashInterval"), 5) * 20;
|
|
||||||
|
|
||||||
// Did time change by DashInterval?
|
|
||||||
if (rupeeDashTimer >= rdmTime) {
|
|
||||||
rupeeDashTimer = 0;
|
|
||||||
if (gSaveContext.rupees > 0) {
|
|
||||||
uint16_t walletSize = (CUR_UPG_VALUE(UPG_WALLET) + 1) * -1;
|
|
||||||
Rupees_ChangeBy(walletSize);
|
|
||||||
} else {
|
|
||||||
Health_ChangeBy(gPlayState, -16);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rupeeDashTimer++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool hasAffectedHealth = false;
|
static bool hasAffectedHealth = false;
|
||||||
void UpdatePermanentHeartLossState() {
|
void UpdatePermanentHeartLossState() {
|
||||||
if (!GameInteractor::IsSaveLoaded())
|
if (!GameInteractor::IsSaveLoaded())
|
||||||
|
@ -982,7 +957,6 @@ void InitMods() {
|
||||||
TimeSavers_Register();
|
TimeSavers_Register();
|
||||||
RegisterTTS();
|
RegisterTTS();
|
||||||
RegisterOcarinaTimeTravel();
|
RegisterOcarinaTimeTravel();
|
||||||
RegisterRupeeDash();
|
|
||||||
RegisterPermanentHeartLoss();
|
RegisterPermanentHeartLoss();
|
||||||
RegisterDeleteFileOnDeath();
|
RegisterDeleteFileOnDeath();
|
||||||
RegisterHyperBosses();
|
RegisterHyperBosses();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue