mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-10-31 23:55:06 -04:00
Sets up hook to override silver rupee behavior.
This commit is contained in:
parent
e53040e504
commit
3fc40fa3ff
@ -27,6 +27,7 @@
|
||||
#include "src/overlays//actors/ovl_Fishing/z_fishing.h"
|
||||
#include "objects/object_link_boy/object_link_boy.h"
|
||||
#include "objects/object_link_child/object_link_child.h"
|
||||
#include "soh/Enhancements/randomizer/actors/z_en_g_switch_rando.h"
|
||||
|
||||
extern "C" {
|
||||
#include <z64.h>
|
||||
@ -1151,6 +1152,26 @@ void RegisterRandomizerSheikSpawn() {
|
||||
});
|
||||
}
|
||||
|
||||
//Changes silver rupee update and draw functions, if silver rupees shuffle is enabled
|
||||
void RegisterSilverRupeeShuffle() {
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorInit>([](void* refActor) {
|
||||
if (!gPlayState) {
|
||||
return;
|
||||
}
|
||||
if (!IS_RANDO || OTRGlobals::Instance->gRandoContext->GetOption(RSK_SHUFFLE_SILVER_RUPEES).Is(RO_SILVER_SHUFFLE_VANILLA)) {
|
||||
return;
|
||||
}
|
||||
auto* actor = static_cast<Actor*>(refActor);
|
||||
if (actor->id == ACTOR_EN_G_SWITCH) {
|
||||
auto* silverRupee = reinterpret_cast<EnGSwitch*>(actor);
|
||||
if (silverRupee->type == ENGSWITCH_SILVER_RUPEE) {
|
||||
silverRupee->actionFunc = EnGSwitch_Randomizer_SilverRupeeIdle;
|
||||
silverRupee->actor.draw = EnGSwitch_Randomizer_Draw;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//Boss souls require an additional item (represented by a RAND_INF) to spawn a boss in a particular lair
|
||||
void RegisterBossSouls() {
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorInit>([](void* actor) {
|
||||
@ -1627,6 +1648,7 @@ void InitMods() {
|
||||
RegisterAltTrapTypes();
|
||||
RegisterRandomizerSheikSpawn();
|
||||
RegisterBossSouls();
|
||||
RegisterSilverRupeeShuffle();
|
||||
RegisterRandomizedEnemySizes();
|
||||
RegisterToTMedallions();
|
||||
RegisterNoSwim();
|
||||
|
37
soh/soh/Enhancements/randomizer/actors/z_en_g_switch_rando.c
Normal file
37
soh/soh/Enhancements/randomizer/actors/z_en_g_switch_rando.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include "z_en_g_switch_rando.h"
|
||||
|
||||
void EnGSwitch_Kill(EnGSwitch* this, PlayState* play);
|
||||
|
||||
void EnGSwitch_Randomizer_SilverRupeeIdle(EnGSwitch* self, PlayState* play) {
|
||||
Player* player = GET_PLAYER(play);
|
||||
|
||||
self->actor.shape.rot.y += 0x800;
|
||||
if (self->actor.xyzDistToPlayerSq < 900.0f) {
|
||||
if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_SILVER_RUPEES) != RO_SILVER_SHUFFLE_VANILLA) {
|
||||
GetItemEntry getItem = ItemTable_RetrieveEntry(MOD_NONE, GI_NUTS_5);
|
||||
if (getItem.modIndex == MOD_NONE) {
|
||||
// RANDOTOD: Move this into Item_Give() or some other more central location
|
||||
if (getItem.getItemId == GI_SWORD_BGS) {
|
||||
gSaveContext.bgsFlag = true;
|
||||
}
|
||||
Item_Give(play, getItem.itemId);
|
||||
} else if (getItem.modIndex == MOD_RANDOMIZER) {
|
||||
Randomizer_Item_Give(play, getItem);
|
||||
}
|
||||
self->killTimer = 0;
|
||||
self->actionFunc = EnGSwitch_Kill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnGSwitch_Randomizer_Draw(Actor* thisx, PlayState* play) {
|
||||
EnGSwitch* this = (EnGSwitch*)thisx;
|
||||
if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_SILVER_RUPEES) != RO_SILVER_SHUFFLE_VANILLA &&
|
||||
this->type == ENGSWITCH_SILVER_RUPEE) {
|
||||
OPEN_DISPS(play->state.gfxCtx);
|
||||
Matrix_Scale(17.5f, 17.5f, 17.5f, MTXMODE_APPLY);
|
||||
GetItemEntry getItem = ItemTable_RetrieveEntry(MOD_NONE, GI_NUTS_5);
|
||||
GetItemEntry_Draw(play, getItem);
|
||||
CLOSE_DISPS(play->state.gfxCtx);
|
||||
}
|
||||
}
|
17
soh/soh/Enhancements/randomizer/actors/z_en_g_switch_rando.h
Normal file
17
soh/soh/Enhancements/randomizer/actors/z_en_g_switch_rando.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef SHIP_Z_EN_G_SWITCH_RANDO_H
|
||||
#define SHIP_Z_EN_G_SWITCH_RANDO_H
|
||||
|
||||
#include "overlays/actors/ovl_En_G_Switch/z_en_g_switch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void EnGSwitch_Randomizer_SilverRupeeIdle(EnGSwitch *self, PlayState *play);
|
||||
void EnGSwitch_Randomizer_Draw(Actor *thisx, PlayState *play);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif //SHIP_Z_EN_G_SWITCH_RANDO_H
|
Loading…
Reference in New Issue
Block a user