Skip to content

Commit ca31dfb

Browse files
committed
port improvements from leggettc's version
1 parent 47317ef commit ca31dfb

File tree

5 files changed

+91
-41
lines changed

5 files changed

+91
-41
lines changed

soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,22 @@ typedef enum {
20192019
// - None
20202020
VB_SHOW_TITLE_CARD,
20212021

2022+
// #### `result`
2023+
// ```c
2024+
// this->actor.xyzDistToPlayerSq < 900.0f
2025+
// ```
2026+
// #### `args`
2027+
// - *EnGSwitch
2028+
VB_SILVER_COLLECT,
2029+
2030+
// #### `result`
2031+
// ```c
2032+
// true
2033+
// ```
2034+
// #### `args`
2035+
// - *EnGSwitch
2036+
VB_SILVER_COUNT_CHECK,
2037+
20222038
// #### `result`
20232039
// ```c
20242040
// Flags_GetSwitch(play, this->switchFlag)

soh/soh/Enhancements/randomizer/ShuffleSilver.cpp

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,31 +87,60 @@ static bool IsSilverCleared(s16 switchFlag) {
8787
return false;
8888
}
8989

90+
extern "C" void EnGSwitch_RandomizerDraw(Actor* thisx, PlayState* play) {
91+
EnGSwitch* silver = reinterpret_cast<EnGSwitch*>(thisx);
92+
Matrix_Push();
93+
Matrix_Scale(17.5f, 17.5f, 17.5f, MTXMODE_APPLY);
94+
if (silver->type == ENGSWITCH_SILVER_RUPEE) {
95+
if (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("MysteriousShuffle"), 0)) {
96+
GetItemEntry_Draw(play, GET_ITEM_MYSTERY);
97+
} else {
98+
auto silverIdentity =
99+
OTRGlobals::Instance->gRandomizer->IdentifySilver(gPlayState->sceneNum, silver->actor.world.pos);
100+
auto itemEntry =
101+
Rando::Context::GetInstance()->GetFinalGIEntry(silverIdentity.randomizerCheck, true, GI_NONE);
102+
GetItemEntry_Draw(play, itemEntry);
103+
}
104+
Matrix_Pop();
105+
}
106+
}
107+
90108
void RegisterShuffleSilver() {
91109
bool shouldRegister = IS_RANDO && RAND_GET_OPTION(RSK_SHUFFLE_SILVER);
92110

111+
COND_VB_SHOULD(VB_SILVER_COLLECT, shouldRegister, {
112+
if (*should) {
113+
EnGSwitch* silver = va_arg(args, EnGSwitch*);
114+
auto silverIdentity =
115+
OTRGlobals::Instance->gRandomizer->IdentifySilver(gPlayState->sceneNum, silver->actor.world.pos);
116+
Flags_SetRandomizerInf(silverIdentity.randomizerInf);
117+
Actor_Kill(&silver->actor);
118+
*should = false;
119+
}
120+
});
121+
122+
COND_VB_SHOULD(VB_SILVER_COUNT_CHECK, shouldRegister, {
123+
EnGSwitch* silver = va_arg(args, EnGSwitch*);
124+
*should = false;
125+
if (IsSilverCleared(silver->switchFlag)) {
126+
Flags_SetSwitch(gPlayState, silver->switchFlag);
127+
Actor_Kill(&silver->actor);
128+
}
129+
});
130+
93131
COND_VB_SHOULD(VB_SILVER_DESPAWN, shouldRegister, {
94132
EnGSwitch* silver = va_arg(args, EnGSwitch*);
95133
if (silver->type == ENGSWITCH_SILVER_RUPEE) {
96-
auto silverIdentity = OTRGlobals::Instance->gRandomizer->IdentifySilver(
97-
gPlayState->sceneNum, (s16)silver->actor.world.pos.x, (s16)silver->actor.world.pos.z);
98-
*should = true;
134+
auto silverIdentity =
135+
OTRGlobals::Instance->gRandomizer->IdentifySilver(gPlayState->sceneNum, silver->actor.world.pos);
99136
if (silverIdentity.randomizerCheck == RC_UNKNOWN_CHECK ||
100137
Flags_GetRandomizerInf(silverIdentity.randomizerInf)) {
138+
*should = true;
101139
return;
102140
}
103-
104-
EnItem00* item00 =
105-
(EnItem00*)Item_DropCollectible2(gPlayState, &silver->actor.world.pos, ITEM00_SOH_DUMMY | 0x4000);
106-
item00->randoCheck = silverIdentity.randomizerCheck;
107-
item00->randoInf = silverIdentity.randomizerInf;
108-
item00->itemEntry =
109-
Rando::Context::GetInstance()->GetFinalGIEntry(silverIdentity.randomizerCheck, false, GI_RUPEE_BLUE);
110-
item00->actor.draw = (ActorFunc)EnItem00_DrawRandomizedItem;
111-
} else if (silver->type == ENGSWITCH_SILVER_TRACKER) {
112-
if (IsSilverCleared(silver->switchFlag)) {
113-
Flags_SetSwitch(gPlayState, silver->switchFlag);
114-
}
141+
silver->actor.draw = EnGSwitch_RandomizerDraw;
142+
} else if (silver->type == ENGSWITCH_SILVER_TRACKER && IsSilverCleared(silver->switchFlag)) {
143+
Flags_SetSwitch(gPlayState, silver->switchFlag);
115144
*should = true;
116145
}
117146
});
@@ -214,8 +243,8 @@ void Rando::StaticData::RegisterSilverLocations() {
214243
locationTable[RC_SHADOW_MQ_SILVER_BLADES_4] = Location::Collectable(RC_SHADOW_MQ_SILVER_BLADES_4, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(3399, -838 ), "RC_SHADOW_MQ_SILVER_BLADES_4", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_BLADES_4));
215244
locationTable[RC_SHADOW_MQ_SILVER_BLADES_5] = Location::Collectable(RC_SHADOW_MQ_SILVER_BLADES_5, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(3558, -1490), "RC_SHADOW_MQ_SILVER_BLADES_5", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_BLADES_5));
216245
locationTable[RC_SHADOW_MQ_SILVER_PIT_1] = Location::Collectable(RC_SHADOW_MQ_SILVER_PIT_1, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(1970, 3372), "RC_SHADOW_MQ_SILVER_PIT_1", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_PIT_1));
217-
locationTable[RC_SHADOW_MQ_SILVER_PIT_2] = Location::Collectable(RC_SHADOW_MQ_SILVER_PIT_2, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(2110, 3372), "RC_SHADOW_MQ_SILVER_PIT_2", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_PIT_2));
218-
locationTable[RC_SHADOW_MQ_SILVER_PIT_3] = Location::Collectable(RC_SHADOW_MQ_SILVER_PIT_3, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(2110, 3372), "RC_SHADOW_MQ_SILVER_PIT_3", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_PIT_3));
246+
locationTable[RC_SHADOW_MQ_SILVER_PIT_2] = Location::Collectable(RC_SHADOW_MQ_SILVER_PIT_2, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(2110, -970), "RC_SHADOW_MQ_SILVER_PIT_2", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_PIT_2));
247+
locationTable[RC_SHADOW_MQ_SILVER_PIT_3] = Location::Collectable(RC_SHADOW_MQ_SILVER_PIT_3, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(2110, -1092), "RC_SHADOW_MQ_SILVER_PIT_3", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_PIT_3));
219248
locationTable[RC_SHADOW_MQ_SILVER_PIT_4] = Location::Collectable(RC_SHADOW_MQ_SILVER_PIT_4, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(2131, 3030), "RC_SHADOW_MQ_SILVER_PIT_4", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_PIT_4));
220249
locationTable[RC_SHADOW_MQ_SILVER_PIT_5] = Location::Collectable(RC_SHADOW_MQ_SILVER_PIT_5, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(2250, 3372), "RC_SHADOW_MQ_SILVER_PIT_5", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_PIT_5));
221250
locationTable[RC_SHADOW_MQ_SILVER_INVISIBLE_BLADES_1] = Location::Collectable(RC_SHADOW_MQ_SILVER_INVISIBLE_BLADES_1, RCQUEST_MQ, RCTYPE_SILVER, ACTOR_EN_G_SWITCH, SCENE_SHADOW_TEMPLE, TWO_ACTOR_PARAMS(5089, 2049), "RC_SHADOW_MQ_SILVER_INVISIBLE_BLADES_1", RHT_SHADOW_TEMPLE_SILVER, RG_BLUE_RUPEE, SpoilerCollectionCheck::RandomizerInf(RAND_INF_SHADOW_MQ_SILVER_INVISIBLE_BLADES_1));

soh/soh/Enhancements/randomizer/randomizer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4151,13 +4151,16 @@ CheckIdentity Randomizer::IdentifyTree(s32 sceneNum, s32 posX, s32 posZ) {
41514151
return treeIdentity;
41524152
}
41534153

4154-
CheckIdentity Randomizer::IdentifySilver(s32 sceneNum, s32 posX, s32 posZ) {
4154+
CheckIdentity Randomizer::IdentifySilver(s32 sceneNum, Vec3f pos) {
41554155
struct CheckIdentity silverIdentity;
41564156

41574157
silverIdentity.randomizerInf = RAND_INF_MAX;
41584158
silverIdentity.randomizerCheck = RC_UNKNOWN_CHECK;
41594159

4160-
s32 actorParams = TWO_ACTOR_PARAMS(posX, posZ);
4160+
s32 actorParams = TWO_ACTOR_PARAMS((s16)pos.x, (s16)pos.z);
4161+
if (sceneNum == SCENE_SHADOW_TEMPLE && actorParams == TWO_ACTOR_PARAMS(2110, 3372)) {
4162+
actorParams = TWO_ACTOR_PARAMS((s16)pos.x, (s16)pos.y);
4163+
}
41614164

41624165
Rando::Location* location = GetCheckObjectFromActor(ACTOR_EN_G_SWITCH, sceneNum, actorParams);
41634166

soh/soh/Enhancements/randomizer/randomizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Randomizer {
5959
CheckIdentity IdentifyCrate(s32 sceneNum, s32 posX, s32 posZ);
6060
CheckIdentity IdentifySmallCrate(s32 sceneNum, s32 posX, s32 posZ);
6161
CheckIdentity IdentifyTree(s32 sceneNum, s32 posX, s32 posZ);
62-
CheckIdentity IdentifySilver(s32 sceneNum, s32 posX, s32 posZ);
62+
CheckIdentity IdentifySilver(s32 sceneNum, Vec3f pos);
6363
GetItemEntry GetItemFromKnownCheck(RandomizerCheck randomizerCheck, GetItemID ogItemId,
6464
bool checkObtainability = true);
6565
GetItemEntry GetItemFromActor(s16 actorId, s16 sceneNum, s16 actorParams, GetItemID ogItemId,

soh/src/overlays/actors/ovl_En_G_Switch/z_en_g_switch.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -212,36 +212,38 @@ void EnGSwitch_WaitForObject(EnGSwitch* this, PlayState* play) {
212212
void EnGSwitch_SilverRupeeTracker(EnGSwitch* this, PlayState* play) {
213213
static s8 majorScale[] = { 0, 2, 4, 5, 7, 9, 11, 13, 15, 17 };
214214

215-
if (this->noteIndex < sCollectedCount) {
216-
if (sCollectedCount < (CVarGetInteger(CVAR_ENHANCEMENT("SilverRupeeJingleExtend"), 0) ? 10 : 5)) {
217-
// "sound?"
218-
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 音? ☆☆☆☆☆ %d\n" VT_RST, this->noteIndex);
219-
Audio_PlaySoundTransposed(&gSfxDefaultPos, NA_SE_EV_FIVE_COUNT_LUPY, majorScale[this->noteIndex]);
220-
this->noteIndex = sCollectedCount;
215+
if (GameInteractor_Should(VB_SILVER_COUNT_CHECK, true, this)) {
216+
if (this->noteIndex < sCollectedCount) {
217+
if (sCollectedCount < (CVarGetInteger(CVAR_ENHANCEMENT("SilverRupeeJingleExtend"), 0) ? 10 : 5)) {
218+
// "sound?"
219+
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 音? ☆☆☆☆☆ %d\n" VT_RST, this->noteIndex);
220+
Audio_PlaySoundTransposed(&gSfxDefaultPos, NA_SE_EV_FIVE_COUNT_LUPY, majorScale[this->noteIndex]);
221+
this->noteIndex = sCollectedCount;
222+
}
221223
}
222-
}
223-
if (sCollectedCount >= this->silverCount) {
224-
// "It is now the end of the century."
225-
// This another reference to Hokuto no Ken.
226-
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 時はまさに世紀末〜 ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag);
227-
// "Last!"
228-
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ らすとぉ! ☆☆☆☆☆ \n" VT_RST);
229-
if ((play->sceneNum == SCENE_GERUDO_TRAINING_GROUND) && (this->actor.room == 2)) {
230-
Flags_SetTempClear(play, this->actor.room);
231-
} else {
232-
Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME);
233-
Flags_SetSwitch(play, this->switchFlag);
224+
if (sCollectedCount >= this->silverCount) {
225+
// "It is now the end of the century."
226+
// This another reference to Hokuto no Ken.
227+
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 時はまさに世紀末〜 ☆☆☆☆☆ %d\n" VT_RST, this->switchFlag);
228+
// "Last!"
229+
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ らすとぉ! ☆☆☆☆☆ \n" VT_RST);
230+
if ((play->sceneNum == SCENE_GERUDO_TRAINING_GROUND) && (this->actor.room == 2)) {
231+
Flags_SetTempClear(play, this->actor.room);
232+
} else {
233+
Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME);
234+
Flags_SetSwitch(play, this->switchFlag);
235+
}
236+
Sfx_PlaySfxCentered(NA_SE_SY_GET_RUPY);
237+
Actor_Kill(&this->actor);
234238
}
235-
Sfx_PlaySfxCentered(NA_SE_SY_GET_RUPY);
236-
Actor_Kill(&this->actor);
237239
}
238240
}
239241

240242
void EnGSwitch_SilverRupeeIdle(EnGSwitch* this, PlayState* play) {
241243
Player* player = GET_PLAYER(play);
242244

243245
this->actor.shape.rot.y += 0x800;
244-
if (this->actor.xyzDistToPlayerSq < 900.0f) {
246+
if (GameInteractor_Should(VB_SILVER_COLLECT, this->actor.xyzDistToPlayerSq < 900.0f, this)) {
245247
Rupees_ChangeBy(5);
246248
sCollectedCount++;
247249
Sfx_PlaySfxCentered(NA_SE_SY_GET_RUPY);

0 commit comments

Comments
 (0)