Actually start randomizing silver rupees

Remaining locations yet to be added, but the ones that were added are working.
This commit is contained in:
Christopher Leggett 2024-02-11 17:02:26 -05:00
parent cd27dc5c45
commit c1bd869c94
No known key found for this signature in database
GPG Key ID: 7093AE5FF7037D79
10 changed files with 59 additions and 8 deletions

View File

@ -1165,6 +1165,10 @@ void RegisterSilverRupeeShuffle() {
if (actor->id == ACTOR_EN_G_SWITCH) {
auto* silverRupee = reinterpret_cast<EnGSwitch*>(actor);
if (silverRupee->type == ENGSWITCH_SILVER_RUPEE) {
Rando::Position randoPos = {static_cast<SceneID>(gPlayState->sceneNum), actor->world.pos};
silverRupee->rc = Rando::StaticData::silverRupeeMap.at(randoPos);
silverRupee->rg = OTRGlobals::Instance->gRandoContext->GetItemLocation(silverRupee->rc)->GetPlacedRandomizerGet();
silverRupee->giEntry = OTRGlobals::Instance->gRandoContext->GetItemLocation(silverRupee->rc)->GetPlacedItem().GetGIEntry().get();
silverRupee->actionFunc = EnGSwitch_Randomizer_SilverRupeeIdle;
silverRupee->actor.draw = EnGSwitch_Randomizer_Draw;
}

View File

@ -19,6 +19,7 @@ enum class Category {
cVanillaCompass,
cAdultTrade,
cBeehive,
cSilverRupee,
};
enum class OptionCategory {

View File

@ -660,6 +660,9 @@ static void WriteAllLocations() {
auto ctx = Rando::Context::GetInstance();
for (const RandomizerCheck key : ctx->allLocations) {
Rando::ItemLocation* location = ctx->GetItemLocation(key);
if (Rando::StaticData::GetLocation(location->GetRandomizerCheck())->GetName().empty()) {
continue;
}
std::string placedItemName;
switch (ctx->GetOption(RSK_LANGUAGE).GetSelectedOptionIndex()) {

View File

@ -8,15 +8,14 @@ void EnGSwitch_Randomizer_SilverRupeeIdle(EnGSwitch* self, PlayState* play) {
self->actor.shape.rot.y += 0x800;
if (self->actor.xyzDistToPlayerSq < 900.0f) {
if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_SILVER_RUPEES) != RO_SILVER_SHUFFLE_VANILLA) {
GetItemEntry getItem = ItemTable_RetrieveEntry(MOD_NONE, GI_NUTS_5);
if (getItem.modIndex == MOD_NONE) {
if (self->giEntry->modIndex == MOD_NONE) {
// RANDOTOD: Move this into Item_Give() or some other more central location
if (getItem.getItemId == GI_SWORD_BGS) {
if (self->giEntry->getItemId == GI_SWORD_BGS) {
gSaveContext.bgsFlag = true;
}
Item_Give(play, getItem.itemId);
} else if (getItem.modIndex == MOD_RANDOMIZER) {
Randomizer_Item_Give(play, getItem);
Item_Give(play, self->giEntry->itemId);
} else if (self->giEntry->modIndex == MOD_RANDOMIZER) {
Randomizer_Item_Give(play, *self->giEntry);
}
self->killTimer = 0;
self->actionFunc = EnGSwitch_Kill;
@ -30,8 +29,7 @@ void EnGSwitch_Randomizer_Draw(Actor* thisx, PlayState* play) {
this->type == ENGSWITCH_SILVER_RUPEE) {
OPEN_DISPS(play->state.gfxCtx);
Matrix_Scale(17.5f, 17.5f, 17.5f, MTXMODE_APPLY);
GetItemEntry getItem = ItemTable_RetrieveEntry(MOD_NONE, GI_NUTS_5);
GetItemEntry_Draw(play, getItem);
GetItemEntry_Draw(play, *this->giEntry);
CLOSE_DISPS(play->state.gfxCtx);
}
}

View File

@ -108,6 +108,7 @@ enum class LocationType {
GrottoScrub,
Delayed,
TempleReward,
SilverRupee,
HintStone,
OtherHint,
};

View File

@ -1,6 +1,7 @@
#include "static_data.h"
#define TWO_ACTOR_PARAMS(a, b) (abs(a) << 16) | abs(b)
#define THREE_ACTOR_PARAMS(a, b, c) (abs(a) << 32 | abs(b) << 16 | abs(c))
std::array<Rando::Location, RC_MAX> Rando::StaticData::locationTable;
@ -1512,6 +1513,12 @@ void Rando::StaticData::InitLocationTable() {
locationTable[RC_ZD_FISH_4] = Location::Base(RC_ZD_FISH_4, RCQUEST_BOTH, RCTYPE_FISH, RCAREA_ZORAS_DOMAIN, ACTOR_EN_FISH, SCENE_ZORAS_DOMAIN, -1 ^ 3, 0x00, "Fish 4", "ZD Fish 4", RHT_ZD_FISH, RG_FISH, { Category::cFish }, SpoilerCollectionCheck::Fish(0xFF, SCENE_ZORAS_DOMAIN), SpoilerCollectionCheckGroup::GROUP_ZORAS_DOMAIN);
locationTable[RC_ZD_FISH_5] = Location::Base(RC_ZD_FISH_5, RCQUEST_BOTH, RCTYPE_FISH, RCAREA_ZORAS_DOMAIN, ACTOR_EN_FISH, SCENE_ZORAS_DOMAIN, -1 ^ 4, 0x00, "Fish 5", "ZD Fish 5", RHT_ZD_FISH, RG_FISH, { Category::cFish }, SpoilerCollectionCheck::Fish(0xFF, SCENE_ZORAS_DOMAIN), SpoilerCollectionCheckGroup::GROUP_ZORAS_DOMAIN);
// Silver Rupees
locationTable[RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_1] = Location::Base(RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_1, RCQUEST_VANILLA, RCTYPE_SILVER_RUPEE, RCAREA_ICE_CAVERN, ACTOR_EN_G_SWITCH, SCENE_ICE_CAVERN,0, 0x0, "Spinning Blades Silver Rupee 1", "Ice Cavern Spinning Blades Silver Rupee 1", RHT_NONE, RG_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE, {Category::cSilverRupee}, SpoilerCollectionCheck::RandomizerInf(SCENE_ICE_CAVERN, RAND_INF_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_1));
locationTable[RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_2] = Location::Base(RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_2, RCQUEST_VANILLA, RCTYPE_SILVER_RUPEE, RCAREA_ICE_CAVERN, ACTOR_EN_G_SWITCH, SCENE_ICE_CAVERN,0, 0x0, "Spinning Blades Silver Rupee 2", "Ice Cavern Spinning Blades Silver Rupee 2", RHT_NONE, RG_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE, {Category::cSilverRupee}, SpoilerCollectionCheck::RandomizerInf(SCENE_ICE_CAVERN, RAND_INF_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_2));
locationTable[RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_3] = Location::Base(RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_3, RCQUEST_VANILLA, RCTYPE_SILVER_RUPEE, RCAREA_ICE_CAVERN, ACTOR_EN_G_SWITCH, SCENE_ICE_CAVERN,0, 0x0, "Spinning Blades Silver Rupee 3", "Ice Cavern Spinning Blades Silver Rupee 3", RHT_NONE, RG_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE, {Category::cSilverRupee}, SpoilerCollectionCheck::RandomizerInf(SCENE_ICE_CAVERN, RAND_INF_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_3));
locationTable[RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_4] = Location::Base(RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_4, RCQUEST_VANILLA, RCTYPE_SILVER_RUPEE, RCAREA_ICE_CAVERN, ACTOR_EN_G_SWITCH, SCENE_ICE_CAVERN,0, 0x0, "Spinning Blades Silver Rupee 4", "Ice Cavern Spinning Blades Silver Rupee 4", RHT_NONE, RG_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE, {Category::cSilverRupee}, SpoilerCollectionCheck::RandomizerInf(SCENE_ICE_CAVERN, RAND_INF_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_4));
locationTable[RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_5] = Location::Base(RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_5, RCQUEST_VANILLA, RCTYPE_SILVER_RUPEE, RCAREA_ICE_CAVERN, ACTOR_EN_G_SWITCH, SCENE_ICE_CAVERN,0, 0x0, "Spinning Blades Silver Rupee 5", "Ice Cavern Spinning Blades Silver Rupee 5", RHT_NONE, RG_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE, {Category::cSilverRupee}, SpoilerCollectionCheck::RandomizerInf(SCENE_ICE_CAVERN, RAND_INF_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_5));
// Gossip Stones
// RandomizerCheck Randomizer Check Quest Area Scene Params Flag Short Name Spoiler name Categories

View File

@ -114,6 +114,7 @@ typedef enum {
RCTYPE_OCARINA, // Ocarina locations
RCTYPE_BEEHIVE, // Beehives
RCTYPE_FISH,
RCTYPE_SILVER_RUPEE
} RandomizerCheckType;
typedef enum { RCQUEST_VANILLA, RCQUEST_MQ, RCQUEST_BOTH } RandomizerCheckQuest;

View File

@ -1,6 +1,17 @@
#include <unordered_map>
#include "silver_rupee.h"
#include "static_data.h"
namespace Rando {
std::unordered_map<Position, RandomizerCheck> StaticData::silverRupeeMap = {
{ { SCENE_ICE_CAVERN, {414.0f, 178.0f, -579.0f} }, RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_1 },
{ { SCENE_ICE_CAVERN, {389.0f, 0.0f, -382.0f } }, RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_2 },
{ { SCENE_ICE_CAVERN, {278.0f, 0.0f, -637.0f } }, RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_3 },
{ { SCENE_ICE_CAVERN, { 198.0f, 0.0f, -388.0f } }, RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_4 },
{ { SCENE_ICE_CAVERN, { 1.0f, 0.0f, -143.0f } }, RC_ICE_CAVERN_SPINNING_BLADES_SILVER_RUPEE_5 },
};
SilverRupees::SilverRupees() {
mSilverRupees = {
// Vanilla

View File

@ -7,6 +7,10 @@
#include "location.h"
namespace Rando {
struct Position{
SceneID scene;
Vec3f pos;
};
/**
* @brief Singleton for storing and accessing static Randomizer-related data
*
@ -37,7 +41,24 @@ class StaticData {
static std::vector<RandomizerCheck> overworldFishLocations;
static std::array<std::pair<RandomizerCheck, RandomizerCheck>, 17> randomizerFishingPondFish;
static std::unordered_map<int8_t, RandomizerCheck> randomizerGrottoFishMap;
static std::unordered_map<Position, RandomizerCheck> silverRupeeMap;
StaticData();
~StaticData();
};
}
namespace std {
template<>
struct hash<Rando::Position> {
inline size_t operator()(const Rando::Position& pos) const {
return hash<int>{}(pos.scene) ^ hash<float>{}(pos.pos.x) ^ hash<float>{}(pos.pos.y) ^ hash<float>{}(pos.pos.z);
}
};
template<>
struct equal_to<Rando::Position> {
inline bool operator()(const Rando::Position& a, const Rando::Position& b) const {
return a.scene == b.scene && a.pos.x == b.pos.x && a.pos.y == b.pos.y && a.pos.z == b.pos.z;
}
};
}

View File

@ -56,6 +56,10 @@ typedef struct EnGSwitch {
/* 0x0178 */ s8 objIndex;
/* 0x017C */ ColliderCylinder collider;
/* 0x01C8 */ EnGSwitchEffect effects[100];
// #region SOH [Randomizer]
/* */ RandomizerCheck rc;
/* */ RandomizerGet rg;
/* */ GetItemEntry* giEntry;
} EnGSwitch; // size = 0x12F8
#endif