mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-04-28 13:17:58 +03:00
Merge f4f47c9f9a
into fbbfc07ff1
This commit is contained in:
commit
63e1785d84
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 });
|
|
@ -135,31 +135,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() {
|
||||
static bool shouldSpawn = false;
|
||||
static uint16_t delayTimer = 60;
|
||||
|
@ -1075,7 +1050,6 @@ void InitMods() {
|
|||
RegisterTTS();
|
||||
RegisterOcarinaTimeTravel();
|
||||
RegisterDaytimeGoldSkultullas();
|
||||
RegisterRupeeDash();
|
||||
RegisterShadowTag();
|
||||
RegisterPermanentHeartLoss();
|
||||
RegisterDeleteFileOnDeath();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue