mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 21:33:40 -07:00
ShuffleFreestanding: ShipInit (#5583)
This commit is contained in:
parent
1e60c48e3a
commit
7f3aac36b2
3 changed files with 13 additions and 33 deletions
|
@ -1,17 +1,17 @@
|
||||||
#include "ShuffleFreestanding.h"
|
#include <soh/OTRGlobals.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#include "variables.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
extern PlayState* gPlayState;
|
extern PlayState* gPlayState;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play);
|
extern void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play);
|
||||||
|
|
||||||
void ShuffleFreestanding_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_list originalArgs) {
|
void RegisterShuffleFreestanding() {
|
||||||
va_list args;
|
bool shouldRegister = IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_FREESTANDING);
|
||||||
va_copy(args, originalArgs);
|
|
||||||
|
|
||||||
if (id == VB_ITEM00_DESPAWN) {
|
COND_VB_SHOULD(VB_ITEM00_DESPAWN, shouldRegister, {
|
||||||
EnItem00* item00 = va_arg(args, EnItem00*);
|
EnItem00* item00 = va_arg(args, EnItem00*);
|
||||||
|
|
||||||
// Heart pieces and small keys are handled by default non-freestanding shuffles.
|
// Heart pieces and small keys are handled by default non-freestanding shuffles.
|
||||||
|
@ -22,14 +22,16 @@ void ShuffleFreestanding_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* sh
|
||||||
uint32_t params = TWO_ACTOR_PARAMS((int32_t)item00->actor.world.pos.x, (int32_t)item00->actor.world.pos.z);
|
uint32_t params = TWO_ACTOR_PARAMS((int32_t)item00->actor.world.pos.x, (int32_t)item00->actor.world.pos.z);
|
||||||
Rando::Location* loc =
|
Rando::Location* loc =
|
||||||
OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(item00->actor.id, gPlayState->sceneNum, params);
|
OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(item00->actor.id, gPlayState->sceneNum, params);
|
||||||
|
RandomizerCheck randomizerCheck = loc->GetRandomizerCheck();
|
||||||
|
if (Rando::Context::GetInstance()->GetItemLocation(randomizerCheck)->HasObtained()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
uint8_t isDungeon = loc->IsDungeon();
|
uint8_t isDungeon = loc->IsDungeon();
|
||||||
uint8_t freestandingSetting = RAND_GET_OPTION(RSK_SHUFFLE_FREESTANDING);
|
uint8_t freestandingSetting = RAND_GET_OPTION(RSK_SHUFFLE_FREESTANDING);
|
||||||
RandomizerCheck randomizerCheck = loc->GetRandomizerCheck();
|
|
||||||
bool checkObtained = Rando::Context::GetInstance()->GetItemLocation(randomizerCheck)->HasObtained();
|
|
||||||
|
|
||||||
// Don't change to randomized item if current freestanding item isn't shuffled or already obtained.
|
// Don't change to randomized item if current freestanding item isn't shuffled or already obtained.
|
||||||
if ((freestandingSetting == RO_SHUFFLE_FREESTANDING_OVERWORLD && isDungeon) ||
|
if ((freestandingSetting == RO_SHUFFLE_FREESTANDING_OVERWORLD && isDungeon) ||
|
||||||
(freestandingSetting == RO_SHUFFLE_FREESTANDING_DUNGEONS && !isDungeon) || checkObtained ||
|
(freestandingSetting == RO_SHUFFLE_FREESTANDING_DUNGEONS && !isDungeon) ||
|
||||||
randomizerCheck == RC_UNKNOWN_CHECK) {
|
randomizerCheck == RC_UNKNOWN_CHECK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +43,7 @@ void ShuffleFreestanding_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* sh
|
||||||
item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem;
|
item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem;
|
||||||
|
|
||||||
*should = false;
|
*should = false;
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rando::StaticData::RegisterFreestandingLocations() {
|
void Rando::StaticData::RegisterFreestandingLocations() {
|
||||||
|
@ -284,4 +286,5 @@ void Rando::StaticData::RegisterFreestandingLocations() {
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterShipInitFunc initFunc(Rando::StaticData::RegisterFreestandingLocations);
|
static RegisterShipInitFunc registerShuffleFreestanding(RegisterShuffleFreestanding, { "IS_RANDO" });
|
||||||
|
static RegisterShipInitFunc registerShuffleFreestandingLocations(Rando::StaticData::RegisterFreestandingLocations);
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#ifndef SHUFFLE_FREESTANDING_H
|
|
||||||
#define SHUFFLE_FREESTANDING_H
|
|
||||||
|
|
||||||
#include <z64.h>
|
|
||||||
#include <soh/OTRGlobals.h>
|
|
||||||
|
|
||||||
void ShuffleFreestanding_OnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_list originalArgs);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "soh/Enhancements/randomizer/dungeon.h"
|
#include "soh/Enhancements/randomizer/dungeon.h"
|
||||||
#include "soh/Enhancements/randomizer/fishsanity.h"
|
#include "soh/Enhancements/randomizer/fishsanity.h"
|
||||||
#include "soh/Enhancements/randomizer/static_data.h"
|
#include "soh/Enhancements/randomizer/static_data.h"
|
||||||
#include "soh/Enhancements/randomizer/ShuffleFreestanding.h"
|
|
||||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||||
#include "soh/SohGui/ImGuiUtils.h"
|
#include "soh/SohGui/ImGuiUtils.h"
|
||||||
|
@ -2330,8 +2329,6 @@ void RandomizerRegisterHooks() {
|
||||||
static uint32_t fishsanityOnVanillaBehaviorHook = 0;
|
static uint32_t fishsanityOnVanillaBehaviorHook = 0;
|
||||||
static uint32_t fishsanityOnItemReceiveHook = 0;
|
static uint32_t fishsanityOnItemReceiveHook = 0;
|
||||||
|
|
||||||
static uint32_t shuffleFreestandingOnVanillaBehaviorHook = 0;
|
|
||||||
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadGame>([](int32_t fileNum) {
|
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadGame>([](int32_t fileNum) {
|
||||||
ShipInit::Init("IS_RANDO");
|
ShipInit::Init("IS_RANDO");
|
||||||
|
|
||||||
|
@ -2365,9 +2362,6 @@ void RandomizerRegisterHooks() {
|
||||||
fishsanityOnVanillaBehaviorHook);
|
fishsanityOnVanillaBehaviorHook);
|
||||||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnItemReceive>(fishsanityOnItemReceiveHook);
|
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnItemReceive>(fishsanityOnItemReceiveHook);
|
||||||
|
|
||||||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnVanillaBehavior>(
|
|
||||||
shuffleFreestandingOnVanillaBehaviorHook);
|
|
||||||
|
|
||||||
onFlagSetHook = 0;
|
onFlagSetHook = 0;
|
||||||
onSceneFlagSetHook = 0;
|
onSceneFlagSetHook = 0;
|
||||||
onPlayerUpdateForRCQueueHook = 0;
|
onPlayerUpdateForRCQueueHook = 0;
|
||||||
|
@ -2393,8 +2387,6 @@ void RandomizerRegisterHooks() {
|
||||||
fishsanityOnVanillaBehaviorHook = 0;
|
fishsanityOnVanillaBehaviorHook = 0;
|
||||||
fishsanityOnItemReceiveHook = 0;
|
fishsanityOnItemReceiveHook = 0;
|
||||||
|
|
||||||
shuffleFreestandingOnVanillaBehaviorHook = 0;
|
|
||||||
|
|
||||||
if (!IS_RANDO)
|
if (!IS_RANDO)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2459,11 +2451,5 @@ void RandomizerRegisterHooks() {
|
||||||
fishsanityOnItemReceiveHook = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnItemReceive>(
|
fishsanityOnItemReceiveHook = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnItemReceive>(
|
||||||
Rando::Fishsanity::OnItemReceiveHandler);
|
Rando::Fishsanity::OnItemReceiveHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RAND_GET_OPTION(RSK_SHUFFLE_FREESTANDING) != RO_SHUFFLE_FREESTANDING_OFF) {
|
|
||||||
shuffleFreestandingOnVanillaBehaviorHook =
|
|
||||||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnVanillaBehavior>(
|
|
||||||
ShuffleFreestanding_OnVanillaBehaviorHandler);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue