Skip to content

Commit

Permalink
Merge branch 'pr/4889' into crate-grass-test
Browse files Browse the repository at this point in the history
  • Loading branch information
aMannus committed Feb 5, 2025
2 parents dc61fa0 + 5730a73 commit da8ce6a
Show file tree
Hide file tree
Showing 38 changed files with 2,353 additions and 65 deletions.
3 changes: 3 additions & 0 deletions soh/soh/Enhancements/game-interactor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ typedef enum {
VB_DOOR_BE_LOCKED,
// Vanilla condition: ((doorActor->params >> 7) & 7) == 3
VB_DOOR_PLAY_SCENE_TRANSITION,
// Opt: *EnKusa
VB_GRASS_SETUP_DRAW,
VB_GRASS_DROP_ITEM,

/*** Play Cutscenes ***/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ void StaticData::HintTable_Init_Exclude_Dungeon() {
hintTextTable[RHT_CRATE_DEKU_TREE] = HintText(CustomMessage("They say that a #crate in the Deku Tree# contains #[[1]]#.",
/*german*/ "",
/*french*/ "Selon moi, une #caisse dans l'Arbre Mojo# contient #[[1]]#.", {QM_RED, QM_GREEN}));

hintTextTable[RHT_DEKU_TREE_GRASS] = HintText(CustomMessage("They say that some #grass in the Deku Tree# hides #[[1]]#.",
/*german*/ "",
/*french*/ "", {QM_RED, QM_GREEN}));

/*--------------------------
| DODONGOS CAVERN |
Expand Down Expand Up @@ -302,6 +306,10 @@ hintTextTable[RHT_DODONGOS_CAVERN_BOSS_ROOM_CHEST] = HintText(CustomMessage("The
hintTextTable[RHT_CRATE_DODONGOS_CAVERN] = HintText(CustomMessage("They say that a #crate in Dodongo's Cavern# contains #[[1]]#.",
/*german*/ "",
/*french*/ "Selon moi, une #caisse dans la Caverne Dodongo# contient #[[1]]#.", {QM_RED, QM_GREEN}));

hintTextTable[RHT_DODONGOS_CAVERN_GRASS] = HintText(CustomMessage("They say that some #grass in Dodongo's Cavern# hides #[[1]]#.",
/*german*/ "!!!",
/*french*/ "", {QM_RED, QM_GREEN}));


/*--------------------------
Expand Down Expand Up @@ -467,6 +475,10 @@ hintTextTable[RHT_DODONGOS_CAVERN_BOSS_ROOM_CHEST] = HintText(CustomMessage("The
hintTextTable[RHT_CRATE_JABU_JABU] = HintText(CustomMessage("They say that a #crate in Jabu Jabu's Belly# contains #[[1]]#.",
/*german*/ "",
/*french*/ "Selon moi, une #caisse dans le Ventre de Jabu-Jabu# contient #[[1]]#.", {QM_RED, QM_GREEN}));

hintTextTable[RHT_JABU_JABUS_BELLY_GRASS] = HintText(CustomMessage("They say that some #grass in Jabu Jabu's Belly# hides #[[1]]#.",
/*german*/ "",
/*french*/ "", {QM_RED, QM_GREEN}));

/*--------------------------
| FOREST TEMPLE |
Expand Down Expand Up @@ -1719,6 +1731,10 @@ hintTextTable[RHT_SHADOW_TEMPLE_MAP_CHEST] = HintText(CustomMessage("They say th
/*german*/ "!!!",
/*french*/ "Selon moi, #appeler le soleil dans une impasse# à l’intérieur du puits révèle #[[1]]#.", {QM_RED, QM_GREEN}));

hintTextTable[RHT_BOTTOM_OF_THE_WELL_GRASS] = HintText(CustomMessage("They say that some #grass in the Bottom of the Well# hides #[[1]]#.",
/*german*/ "",
/*french*/ "", {QM_RED, QM_GREEN}));


/*--------------------------
| ICE CAVERN |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1993,5 +1993,26 @@ void StaticData::HintTable_Init_Exclude_Overworld() {
hintTextTable[RHT_CRATE_LAKESIDE_LABORATORY] = HintText(CustomMessage("They say that a #crate in the Laboratory# contains #[[1]]#.",
/*german*/ "",
/*french*/ "Selon moi, une #caisse dans un laboratoire# contient #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_KF_GRASS] = HintText(CustomMessage("They say that #cutting some grass in a forest# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_LW_GRASS] = HintText(CustomMessage("They say that #cutting some grass in the woods# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_MARKET_GRASS] = HintText(CustomMessage("They say that #cutting some grass in the market# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_HC_GRASS] = HintText(CustomMessage("They say that #cutting some grass near the castle# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_KAK_GRASS] = HintText(CustomMessage("They say that #cutting some grass in a village# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_GY_GRASS] = HintText(CustomMessage("They say that #cutting some grass in a graveyard# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_LH_GRASS] = HintText(CustomMessage("They say that #cutting some grass near a lake# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_HF_GRASS] = HintText(CustomMessage("They say that #cutting some grass on a field# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_ZR_GRASS] = HintText(CustomMessage("They say that #cutting some grass near a river# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

hintTextTable[RHT_GROTTO_GRASS] = HintText(CustomMessage("They say that #cutting some grass in a grotto# reveals #[[1]]#.", { QM_RED, QM_GREEN }));

}
}
8 changes: 8 additions & 0 deletions soh/soh/Enhancements/randomizer/3drando/item_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,14 @@ void GenerateItemPool() {
if (overworldCratesActive || dungeonCratesActive) {
PlaceItemsForType(RCTYPE_CRATE, overworldCratesActive, dungeonCratesActive, false);
PlaceItemsForType(RCTYPE_SMALL_CRATE, overworldCratesActive, dungeonCratesActive, false);

// Shuffle Grass
bool overworldGrassActive = ctx->GetOption(RSK_SHUFFLE_GRASS).Is(RO_SHUFFLE_GRASS_OVERWORLD) ||
ctx->GetOption(RSK_SHUFFLE_GRASS).Is(RO_SHUFFLE_GRASS_ALL);
bool dungeonGrassActive = ctx->GetOption(RSK_SHUFFLE_GRASS).Is(RO_SHUFFLE_GRASS_DUNGEONS) ||
ctx->GetOption(RSK_SHUFFLE_GRASS).Is(RO_SHUFFLE_GRASS_ALL);
if (overworldGrassActive || dungeonGrassActive) {
PlaceItemsForType(RCTYPE_GRASS, overworldGrassActive, dungeonGrassActive, false);
}

auto fsMode = ctx->GetOption(RSK_FISHSANITY);
Expand Down
113 changes: 113 additions & 0 deletions soh/soh/Enhancements/randomizer/ShuffleGrass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#include "ShuffleGrass.h"
#include "soh_assets.h"
#include "static_data.h"

extern "C" {
#include "variables.h"
#include "overlays/actors/ovl_En_Kusa/z_en_kusa.h"
#include "objects/gameplay_field_keep/gameplay_field_keep.h"
#include "objects/object_kusa/object_kusa.h"
extern PlayState* gPlayState;
}

#define RAND_GET_OPTION(option) Rando::Context::GetInstance()->GetOption(option).Get()

extern void EnItem00_DrawRandomizedItem(EnItem00* enItem00, PlayState* play);

extern "C" void EnKusa_RandomizerDraw(Actor* thisx, PlayState* play) {
static Gfx* dLists[] = { (Gfx*)gFieldBushDL, (Gfx*)object_kusa_DL_000140, (Gfx*)object_kusa_DL_000140 };
auto grassActor = ((EnKusa*)thisx);

OPEN_DISPS(play->state.gfxCtx);
Gfx_SetupDL_25Opa(play->state.gfxCtx);
gDPSetGrayscaleColor(POLY_OPA_DISP++, 175, 255, 0, 255);

if (grassActor->grassIdentity.randomizerCheck != RC_MAX &&
Flags_GetRandomizerInf(grassActor->grassIdentity.randomizerInf) == 0) {
gSPGrayscale(POLY_OPA_DISP++, true);
}

if (grassActor->actor.flags & ACTOR_FLAG_GRASS_DESTROYED) {
Gfx_DrawDListOpa(play, (Gfx*)object_kusa_DL_0002E0);
} else {
Gfx_DrawDListOpa(play, dLists[grassActor->actor.params & 3]);
}

gSPGrayscale(POLY_OPA_DISP++, false);

CLOSE_DISPS(play->state.gfxCtx);
}

uint8_t EnKusa_RandomizerHoldsItem(EnKusa* grassActor, PlayState* play) {
if (grassActor->grassIdentity.randomizerCheck == RC_MAX)
return false;

RandomizerCheck rc = grassActor->grassIdentity.randomizerCheck;

uint8_t isDungeon = Rando::StaticData::GetLocation(rc)->IsDungeon();
uint8_t grassSetting = Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_GRASS).Get();

// Don't pull randomized item if grass isn't randomized or is already checked
if (!IS_RANDO || (grassSetting == RO_SHUFFLE_GRASS_OVERWORLD && isDungeon) ||
(grassSetting == RO_SHUFFLE_GRASS_DUNGEONS && !isDungeon) ||
Flags_GetRandomizerInf(grassActor->grassIdentity.randomizerInf) ||
grassActor->grassIdentity.randomizerCheck == RC_UNKNOWN_CHECK) {
return false;
} else {
return true;
}
}

void EnKusa_RandomizerSpawnCollectible(EnKusa* grassActor, PlayState* play) {
EnItem00* item00 = (EnItem00*)Item_DropCollectible2(play, &grassActor->actor.world.pos, ITEM00_SOH_DUMMY);
item00->randoInf = grassActor->grassIdentity.randomizerInf;
item00->itemEntry =
Rando::Context::GetInstance()->GetFinalGIEntry(grassActor->grassIdentity.randomizerCheck, true, GI_NONE);
item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem;
item00->actor.velocity.y = 8.0f;
item00->actor.speedXZ = 2.0f;
item00->actor.world.rot.y = Rand_CenteredFloat(65536.0f);
}

void EnKusa_RandomizerInit(void* actorRef) {
Actor* actor = static_cast<Actor*>(actorRef);

if (actor->id != ACTOR_EN_KUSA)
return;

EnKusa* grassActor = static_cast<EnKusa*>(actorRef);
s16 respawnData = gSaveContext.respawn[RESPAWN_MODE_RETURN].data & ((1 << 8) - 1);

grassActor->grassIdentity = OTRGlobals::Instance->gRandomizer->IdentifyGrass(
gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z, respawnData, gPlayState->linkAgeOnLoad);
}

void RegisterShuffleGrass() {
bool shouldRegister = IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_GRASS);

COND_ID_HOOK(OnActorInit, ACTOR_EN_KUSA, shouldRegister, EnKusa_RandomizerInit);

COND_VB_SHOULD(VB_GRASS_SETUP_DRAW, shouldRegister, {
EnKusa* grassActor = va_arg(args, EnKusa*);
if (EnKusa_RandomizerHoldsItem(grassActor, gPlayState)) {
grassActor->actor.draw = (ActorFunc)EnKusa_RandomizerDraw;
*should = false;
} else {
*should = true;
}
});

COND_VB_SHOULD(VB_GRASS_DROP_ITEM, shouldRegister, {
EnKusa* grassActor = va_arg(args, EnKusa*);
if (EnKusa_RandomizerHoldsItem(grassActor, gPlayState)) {
EnKusa_RandomizerSpawnCollectible(grassActor, gPlayState);
grassActor->grassIdentity.randomizerCheck = RC_MAX;
grassActor->grassIdentity.randomizerInf = RAND_INF_MAX;
*should = false;
} else {
*should = true;
}
});
}

static RegisterShipInitFunc initFunc(RegisterShuffleGrass, { "IS_RANDO" });
15 changes: 15 additions & 0 deletions soh/soh/Enhancements/randomizer/ShuffleGrass.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef SHUFFLEGRASS_H
#define SHUFFLEGRASS_H

#include <z64.h>
#include <soh/OTRGlobals.h>

#ifdef __cplusplus
extern "C" {
#endif
void EnKusa_RandomizerInit(void* actorRef);
#ifdef __cplusplus
};
#endif

#endif //SHUFFLEGRASS_H
4 changes: 4 additions & 0 deletions soh/soh/Enhancements/randomizer/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ void Context::GenerateLocationPool() {
mOptions[RSK_SHUFFLE_CRATES].Is(RO_SHUFFLE_CRATES_ALL)) {
AddLocations(StaticData::GetOverworldCrateLocations());
AddLocations(StaticData::GetOverworldSmallCrateLocations());

if (mOptions[RSK_SHUFFLE_GRASS].Is(RO_SHUFFLE_GRASS_OVERWORLD) ||
mOptions[RSK_SHUFFLE_GRASS].Is(RO_SHUFFLE_GRASS_ALL)) {
AddLocations(StaticData::GetOverworldGrassLocations());
}

AddLocations(StaticData::GetAllDungeonLocations());
Expand Down
Loading

0 comments on commit da8ce6a

Please sign in to comment.