TWEAK: SoT Time Travel - Allow Swordless (#5716)

* Magic number + more modular

* tweak + switch

* forgot basic oot

* linebreak

* c-lang
This commit is contained in:
PurpleHato 2025-08-13 04:57:19 +02:00 committed by GitHub
commit c597e1c4ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 5 deletions

View file

@ -112,7 +112,9 @@ typedef enum {
typedef enum { typedef enum {
TIME_TRAVEL_DISABLED, TIME_TRAVEL_DISABLED,
TIME_TRAVEL_OOT, TIME_TRAVEL_OOT,
TIME_TRAVEL_OOT_MS,
TIME_TRAVEL_ANY, TIME_TRAVEL_ANY,
TIME_TRAVEL_ANY_MS
} TimeTravelType; } TimeTravelType;
typedef enum { typedef enum {

View file

@ -130,10 +130,27 @@ void RegisterOcarinaTimeTravel() {
bool notNearAnySource = !nearbyTimeBlockEmpty && !nearbyTimeBlock && !nearbyOcarinaSpot && !nearbyDoorOfTime && bool notNearAnySource = !nearbyTimeBlockEmpty && !nearbyTimeBlock && !nearbyOcarinaSpot && !nearbyDoorOfTime &&
!nearbyFrogs && !nearbyGossipStone; !nearbyFrogs && !nearbyGossipStone;
bool hasOcarinaOfTime = (INV_CONTENT(ITEM_OCARINA_TIME) == ITEM_OCARINA_TIME); bool hasOcarinaOfTime = (INV_CONTENT(ITEM_OCARINA_TIME) == ITEM_OCARINA_TIME);
bool doesntNeedOcarinaOfTime = CVarGetInteger(CVAR_ENHANCEMENT("TimeTravel"), 0) == 2;
bool hasMasterSword = CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER); bool hasMasterSword = CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER);
// TODO: Once Swordless Adult is fixed: Remove the Master Sword check int timeTravelSetting = CVarGetInteger(CVAR_ENHANCEMENT("TimeTravel"), 0);
if (justPlayedSoT && notNearAnySource && (hasOcarinaOfTime || doesntNeedOcarinaOfTime) && hasMasterSword) { bool meetsTimeTravelRequirements = false;
switch (timeTravelSetting) {
case TIME_TRAVEL_ANY:
meetsTimeTravelRequirements = true;
break;
case TIME_TRAVEL_ANY_MS:
meetsTimeTravelRequirements = hasMasterSword;
break;
case TIME_TRAVEL_OOT_MS:
meetsTimeTravelRequirements = hasMasterSword && hasOcarinaOfTime;
break;
case TIME_TRAVEL_OOT:
default:
meetsTimeTravelRequirements = hasOcarinaOfTime;
break;
}
if (justPlayedSoT && notNearAnySource && meetsTimeTravelRequirements) {
SwitchAge(); SwitchAge();
} }
}); });

View file

@ -56,7 +56,9 @@ static const std::unordered_map<int32_t, const char*> chestStyleMatchesContentsO
static const std::unordered_map<int32_t, const char*> timeTravelOptions = { static const std::unordered_map<int32_t, const char*> timeTravelOptions = {
{ TIME_TRAVEL_DISABLED, "Disabled" }, { TIME_TRAVEL_DISABLED, "Disabled" },
{ TIME_TRAVEL_OOT, "Ocarina of Time" }, { TIME_TRAVEL_OOT, "Ocarina of Time" },
{ TIME_TRAVEL_OOT_MS, "Ocarina of Time + Master Sword" },
{ TIME_TRAVEL_ANY, "Any Ocarina" }, { TIME_TRAVEL_ANY, "Any Ocarina" },
{ TIME_TRAVEL_ANY_MS, "Any Ocarina + Master Sword" },
}; };
static const std::unordered_map<int32_t, const char*> sleepingWaterfallOptions = { static const std::unordered_map<int32_t, const char*> sleepingWaterfallOptions = {
@ -783,9 +785,9 @@ void SohMenu::AddMenuEnhancements() {
.Tooltip("Allows Link to freely change age by playing the Song of Time.\n" .Tooltip("Allows Link to freely change age by playing the Song of Time.\n"
"Time Blocks can still be used properly.\n\n" "Time Blocks can still be used properly.\n\n"
"Requirements:\n" "Requirements:\n"
" - Obtained the Ocarina of Time (depends on selection)\n"
" - Obtained the Song of Time\n" " - Obtained the Song of Time\n"
" - Obtained the Master Sword\n" " - Obtained the Ocarina of Time (depends on selection)\n"
" - Obtained the Master Sword (depends on selection)\n"
" - Not within range of a Time Block\n" " - Not within range of a Time Block\n"
" - Not within range of Ocarina Playing spots")); " - Not within range of Ocarina Playing spots"));