mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
Move Rupee Dash Mode hook to its own file
This commit is contained in:
parent
985bf91945
commit
c095530c90
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(RegisterRupeeDash, { CVAR_RUPEE_DASH_NAME });
|
|
@ -132,31 +132,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++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegisterShadowTag() {
|
void RegisterShadowTag() {
|
||||||
static bool shouldSpawn = false;
|
static bool shouldSpawn = false;
|
||||||
static uint16_t delayTimer = 60;
|
static uint16_t delayTimer = 60;
|
||||||
|
@ -1031,7 +1006,6 @@ void InitMods() {
|
||||||
RegisterTTS();
|
RegisterTTS();
|
||||||
RegisterOcarinaTimeTravel();
|
RegisterOcarinaTimeTravel();
|
||||||
RegisterDaytimeGoldSkultullas();
|
RegisterDaytimeGoldSkultullas();
|
||||||
RegisterRupeeDash();
|
|
||||||
RegisterShadowTag();
|
RegisterShadowTag();
|
||||||
RegisterPermanentHeartLoss();
|
RegisterPermanentHeartLoss();
|
||||||
RegisterDeleteFileOnDeath();
|
RegisterDeleteFileOnDeath();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue