mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-06 04:51:30 -07:00
ShufflePots: ShipInit (#5584)
This commit is contained in:
parent
4f95ab3f46
commit
073205c862
3 changed files with 17 additions and 56 deletions
|
@ -1,4 +1,4 @@
|
|||
#include "ShufflePots.h"
|
||||
#include "soh/OTRGlobals.h"
|
||||
#include "soh_assets.h"
|
||||
#include "static_data.h"
|
||||
|
||||
|
@ -51,48 +51,44 @@ void ObjTsubo_RandomizerSpawnCollectible(ObjTsubo* potActor, PlayState* play) {
|
|||
item00->actor.world.rot.y = static_cast<int16_t>(Rand_CenteredFloat(65536.0f));
|
||||
}
|
||||
|
||||
void ObjTsubo_RandomizerInit(void* actorRef) {
|
||||
Actor* actor = static_cast<Actor*>(actorRef);
|
||||
void RegisterShufflePots() {
|
||||
bool shouldRegister = IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_POTS);
|
||||
|
||||
ObjTsubo* potActor = static_cast<ObjTsubo*>(actorRef);
|
||||
COND_ID_HOOK(OnActorInit, ACTOR_OBJ_TSUBO, shouldRegister, [](void* actorRef) {
|
||||
Actor* actor = static_cast<Actor*>(actorRef);
|
||||
ObjTsubo* potActor = static_cast<ObjTsubo*>(actorRef);
|
||||
|
||||
potActor->potIdentity = OTRGlobals::Instance->gRandomizer->IdentifyPot(
|
||||
gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z);
|
||||
}
|
||||
|
||||
void ShufflePots_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_list originalArgs) {
|
||||
va_list args;
|
||||
va_copy(args, originalArgs);
|
||||
potActor->potIdentity = OTRGlobals::Instance->gRandomizer->IdentifyPot(
|
||||
gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z);
|
||||
});
|
||||
|
||||
// Draw custom model for pot to indicate it holding a randomized item.
|
||||
if (id == VB_POT_SETUP_DRAW) {
|
||||
COND_VB_SHOULD(VB_POT_SETUP_DRAW, shouldRegister, {
|
||||
ObjTsubo* potActor = va_arg(args, ObjTsubo*);
|
||||
if (ObjTsubo_RandomizerHoldsItem(potActor, gPlayState)) {
|
||||
potActor->actor.draw = (ActorFunc)ObjTsubo_RandomizerDraw;
|
||||
*should = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Do not spawn vanilla item from pot, instead spawn the ranomized item.
|
||||
if (id == VB_POT_DROP_ITEM) {
|
||||
COND_VB_SHOULD(VB_POT_DROP_ITEM, shouldRegister, {
|
||||
ObjTsubo* potActor = va_arg(args, ObjTsubo*);
|
||||
if (ObjTsubo_RandomizerHoldsItem(potActor, gPlayState)) {
|
||||
ObjTsubo_RandomizerSpawnCollectible(potActor, gPlayState);
|
||||
*should = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Unlock early Ganon's Boss Key doors to allow access to the pots there when pots are shuffled in dungeon
|
||||
if (id == VB_LOCK_BOSS_DOOR) {
|
||||
COND_VB_SHOULD(VB_LOCK_BOSS_DOOR, shouldRegister, {
|
||||
DoorShutter* doorActor = va_arg(args, DoorShutter*);
|
||||
uint8_t shufflePotSetting = RAND_GET_OPTION(RSK_SHUFFLE_POTS);
|
||||
if (gPlayState->sceneNum == SCENE_GANONS_TOWER && doorActor->dyna.actor.world.pos.y == 800 &&
|
||||
(shufflePotSetting == RO_SHUFFLE_POTS_DUNGEONS || shufflePotSetting == RO_SHUFFLE_POTS_ALL)) {
|
||||
*should = false;
|
||||
}
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
});
|
||||
}
|
||||
|
||||
void Rando::StaticData::RegisterPotLocations() {
|
||||
|
@ -653,4 +649,5 @@ void Rando::StaticData::RegisterPotLocations() {
|
|||
// clang-format on
|
||||
}
|
||||
|
||||
static RegisterShipInitFunc initFunc(Rando::StaticData::RegisterPotLocations);
|
||||
static RegisterShipInitFunc registerShufflePots(RegisterShufflePots, { "IS_RANDO" });
|
||||
static RegisterShipInitFunc registerShufflePotLocations(Rando::StaticData::RegisterPotLocations);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef SHUFFLEPOTS_H
|
||||
#define SHUFFLEPOTS_H
|
||||
|
||||
#include <z64.h>
|
||||
#include <soh/OTRGlobals.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void ObjTsubo_RandomizerInit(void* actorRef);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
void ShufflePots_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_list originalArgs);
|
||||
|
||||
#endif // SHUFFLEPOTS_H
|
|
@ -8,7 +8,6 @@
|
|||
#include "soh/Enhancements/randomizer/dungeon.h"
|
||||
#include "soh/Enhancements/randomizer/fishsanity.h"
|
||||
#include "soh/Enhancements/randomizer/static_data.h"
|
||||
#include "soh/Enhancements/randomizer/ShufflePots.h"
|
||||
#include "soh/Enhancements/randomizer/ShuffleFreestanding.h"
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||
|
@ -2332,9 +2331,6 @@ void RandomizerRegisterHooks() {
|
|||
static uint32_t fishsanityOnVanillaBehaviorHook = 0;
|
||||
static uint32_t fishsanityOnItemReceiveHook = 0;
|
||||
|
||||
static uint32_t shufflePotsOnActorInitHook = 0;
|
||||
static uint32_t shufflePotsOnVanillaBehaviorHook = 0;
|
||||
|
||||
static uint32_t shuffleFreestandingOnVanillaBehaviorHook = 0;
|
||||
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadGame>([](int32_t fileNum) {
|
||||
|
@ -2370,10 +2366,6 @@ void RandomizerRegisterHooks() {
|
|||
fishsanityOnVanillaBehaviorHook);
|
||||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnItemReceive>(fishsanityOnItemReceiveHook);
|
||||
|
||||
GameInteractor::Instance->UnregisterGameHookForID<GameInteractor::OnActorInit>(shufflePotsOnActorInitHook);
|
||||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnVanillaBehavior>(
|
||||
shufflePotsOnVanillaBehaviorHook);
|
||||
|
||||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnVanillaBehavior>(
|
||||
shuffleFreestandingOnVanillaBehaviorHook);
|
||||
|
||||
|
@ -2402,9 +2394,6 @@ void RandomizerRegisterHooks() {
|
|||
fishsanityOnVanillaBehaviorHook = 0;
|
||||
fishsanityOnItemReceiveHook = 0;
|
||||
|
||||
shufflePotsOnActorInitHook = 0;
|
||||
shufflePotsOnVanillaBehaviorHook = 0;
|
||||
|
||||
shuffleFreestandingOnVanillaBehaviorHook = 0;
|
||||
|
||||
ShuffleFairies_UnregisterHooks();
|
||||
|
@ -2474,14 +2463,6 @@ void RandomizerRegisterHooks() {
|
|||
Rando::Fishsanity::OnItemReceiveHandler);
|
||||
}
|
||||
|
||||
if (RAND_GET_OPTION(RSK_SHUFFLE_POTS) != RO_SHUFFLE_POTS_OFF) {
|
||||
shufflePotsOnActorInitHook = GameInteractor::Instance->RegisterGameHookForID<GameInteractor::OnActorInit>(
|
||||
ACTOR_OBJ_TSUBO, ObjTsubo_RandomizerInit);
|
||||
shufflePotsOnVanillaBehaviorHook =
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnVanillaBehavior>(
|
||||
ShufflePots_OnVanillaBehaviorHandler);
|
||||
}
|
||||
|
||||
if (RAND_GET_OPTION(RSK_SHUFFLE_FREESTANDING) != RO_SHUFFLE_FREESTANDING_OFF) {
|
||||
shuffleFreestandingOnVanillaBehaviorHook =
|
||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnVanillaBehavior>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue