forked from HarbourMasters/Shipwright
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
158 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#include "ShufflePots.h" | ||
#include "soh_assets.h" | ||
#include "soh/Enhancements/game-interactor/GameInteractor.h" | ||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" | ||
#include "soh/OTRGlobals.h" | ||
|
||
extern "C" { | ||
#include "overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.h" | ||
#include "variables.h" | ||
|
||
u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey); | ||
GetItemEntry Randomizer_GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogId); | ||
PotIdentity Randomizer_IdentifyPot(s32 sceneNum, s32 posX, s32 posZ); | ||
extern PlayState* gPlayState; | ||
} | ||
|
||
|
||
extern "C" void ObjTsubo_RandomizerDraw(Actor* thisx, PlayState* play) { | ||
float potSize = 1.0f; | ||
|
||
OPEN_DISPS(play->state.gfxCtx); | ||
Gfx_SetupDL_25Opa(play->state.gfxCtx); | ||
Matrix_Scale(potSize, potSize, potSize, MTXMODE_APPLY); | ||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), | ||
G_MTX_MODELVIEW | G_MTX_LOAD); | ||
|
||
gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gRandoPotDL); | ||
CLOSE_DISPS(play->state.gfxCtx); | ||
} | ||
|
||
uint8_t ObjTsubo_RandomizerHoldsItem(ObjTsubo* potActor, PlayState* play) { | ||
uint8_t isDungeon = | ||
play->sceneNum < SCENE_GANONS_TOWER_COLLAPSE_INTERIOR || | ||
(play->sceneNum > SCENE_TREASURE_BOX_SHOP && play->sceneNum < SCENE_GANONS_TOWER_COLLAPSE_EXTERIOR); | ||
uint8_t potSetting = Randomizer_GetSettingValue(RSK_SHUFFLE_POTS); | ||
|
||
// Don't pull randomized item if pot isn't randomized or is already checked | ||
if (!IS_RANDO || (potSetting == RO_SHUFFLE_POTS_OVERWORLD && isDungeon) || | ||
(potSetting == RO_SHUFFLE_POTS_DUNGEONS && !isDungeon) || | ||
Flags_GetRandomizerInf(potActor->potIdentity.randomizerInf) || | ||
potActor->potIdentity.randomizerCheck == RC_UNKNOWN_CHECK) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
uint8_t ObjTsubo_RandomizerSkipItemCutscene(ObjTsubo* potActor) { | ||
/*return | ||
potActor->actor.params == ITEM00_SMALL_KEY && giEntry.modIndex == MOD_NONE && | ||
((giEntry.itemId >= ITEM_RUPEE_GREEN && giEntry.itemId <= ITEM_RUPEE_RED) || giEntry.itemId == ITEM_HEART || | ||
(giEntry.itemId >= ITEM_NUTS_5 && giEntry.itemId <= ITEM_SEEDS_30) || giEntry.itemId == ITEM_MAGIC_SMALL || | ||
giEntry.itemId == ITEM_MAGIC_LARGE);*/ | ||
} | ||
|
||
void ObjTsubo_RandomizerSpawnCollectible(ObjTsubo* potActor) { | ||
EnItem00* item00 = | ||
(EnItem00*)Item_DropCollectible2(gPlayState, &potActor->actor.world.pos, ITEM00_SOH_GIVE_ITEM_ENTRY); | ||
item00->randoInf = potActor->potIdentity.randomizerInf; | ||
item00->itemEntry = | ||
OTRGlobals::Instance->gRandomizer->GetItemFromKnownCheck(potActor->potIdentity.randomizerCheck, GI_NONE); | ||
item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem; | ||
item00->actor.velocity.y = 8.0f; | ||
item00->actor.speedXZ = 2.0f; | ||
item00->actor.gravity = -0.9f; | ||
item00->actor.world.rot.y = Rand_CenteredFloat(65536.0f); | ||
} | ||
|
||
void ObjTsubo_RandomizerInit(void* actorRef) { | ||
Actor* actor = static_cast<Actor*>(actorRef); | ||
|
||
if (actor->id != ACTOR_OBJ_TSUBO) return; | ||
|
||
ObjTsubo* potActor = static_cast<ObjTsubo*>(actorRef); | ||
|
||
potActor->potIdentity = | ||
Randomizer_IdentifyPot(gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z); | ||
|
||
if (ObjTsubo_RandomizerHoldsItem(potActor, gPlayState)) { | ||
potActor->potIdentity.isShuffled = true; | ||
} else { | ||
potActor->potIdentity.isShuffled = false; | ||
} | ||
} | ||
|
||
void PotOnVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, void* optionalArg) { | ||
ObjTsubo* potActor = static_cast<ObjTsubo*>(optionalArg); | ||
|
||
switch (id) { | ||
case VB_POT_DRAW: { | ||
if (potActor->potIdentity.isShuffled) { | ||
*should = false; | ||
potActor->actor.draw = (ActorFunc)ObjTsubo_RandomizerDraw; | ||
} | ||
break; | ||
} | ||
case VB_POT_DROP_ITEM: { | ||
if (potActor->potIdentity.isShuffled) { | ||
*should = false; | ||
ObjTsubo_RandomizerSpawnCollectible(potActor); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
|
||
void RegisterShufflePots() { | ||
static uint32_t onActorInitHook = 0; | ||
static uint32_t onVanillaBehaviorHook = 0; | ||
|
||
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnLoadGame>([](int32_t fileNum) { | ||
|
||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnActorInit>(onActorInitHook); | ||
GameInteractor::Instance->UnregisterGameHook<GameInteractor::OnVanillaBehavior>(onVanillaBehaviorHook); | ||
|
||
onActorInitHook = 0; | ||
onVanillaBehaviorHook = 0; | ||
|
||
if (!IS_RANDO) return; | ||
if (!Randomizer_GetSettingValue(RSK_SHUFFLE_POTS)) return; | ||
|
||
onActorInitHook = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorInit>(ObjTsubo_RandomizerInit); | ||
onVanillaBehaviorHook = GameInteractor::Instance->RegisterGameHook<GameInteractor::OnVanillaBehavior>(PotOnVanillaBehaviorHandler); | ||
|
||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef SHUFFLEPOTS_H | ||
#define SHUFFLEPOTS_H | ||
|
||
#include "z64.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
void ObjTsubo_RandomizerDraw(Actor* potActor, PlayState* play); | ||
void RegisterShufflePots(); | ||
#ifdef __cplusplus | ||
}; | ||
#endif | ||
|
||
#endif //SHUFFLEPOTS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters