Shipwright/soh/src/code/z_sram.c
briaguya 2b78bea475
Randomizer v2 (#1065)
* Revert changes to GetItemFromGet

* Fixes Ganon's Boss Key shuffled while regular boss Keys aren't.

* Enum + combo box

* Add obtainability checks correctly

* combobox title rename + no number tracking

* Fix repeatable purchases and bottles rendering incorrectly

* Move shopsanity option in GUI

* Struct instead of ImVec + basic comportment for all case

* Attempt to fix odd build issue

* Cast randoGet for ganons boss key

* Remove redundancy in KD room

* Update logic Cvar names

* Fix Ganons Trials coming from old save files. Fixes #1365

* Fixes crash when entering Ganon's Castle lobby on linux.

* Makes `Item_Give` safe to use with a NULL globalCtx.

This should allow it's use for giving items to Link's Pocket
during rando save initialization.

* Converts Song from Impa to use `Item_Give`

* Adds more options for Link's starting item.

* Removes unneeded `GiveLinkItem` functions.

* and make it build

* bring back new rando dropdown

* gSaveContext access in GameMenuBar.cpp

* Implement Skip Scarecrow's Song

* Reimplement progressive Bombchus

* Rando-next: Deku Nut and Seed ammo gives a blue rupee
Fixes #1390

* Fixes Link starting with BGS

* Persist item tracker notes

* Adjust Hooks include

* Use SohImGui::RequestCvarSaveOnNextTick

* Fix issues from LUS refactor

* Fix for overriding deku scrub messages

* Fix mistake from merge

oops

* Restore checkboxes to enhancements menu

These got lost in the merge

* Update location access logic

Including MQ locations in Spirit and GC now

* Implement rando bombchu drops

* Missing break

* Simplify mudwall collision check

There was no need to have a second collider specifically for Ice Arrow hits

* Update settings.cpp

* Simplify mudwall collision check

* Restore checkboxes in menu

Accidentally lost these during merge

* Clean up bool

* Update logic Cvar name

* Fixed capacity on ammmo tracking

* Fix for beans obtainability

* Hook into file delete and clear notes

* Incorporate magic arrows in rando settings

* Update tooltip

To inform the player that they might have to reload the room if they're enabling this for the first time.

* Update tooltip

* Add line break in tooltip

* Tooltip wording + line break

* tweak on main logic

* All color logic for all types

* Fix: changes to please new LUS

* Ensure itemTrackerNotes vector is not fully empty

* Implement's Tycoon Wallet.

* Refactor DrawItemCount and Use EnhancementCombobox for tracker capacity options

* small tweaks and rename

* always display XX/YY when in ammo/capacity mode

* Move all merchant messages to be generated on file load

* added hovertext for the number display

* Swap german and french translations for shop messages

* Set key colors to be on by default

* Add another flag to skip mask shop

* Fix Sold Out bug

* Fix gerudo keys, add disabled checkbox

* tooltip line break

* Add trials required and merchant prices to save file instead of loading from active spoiler log

* Remove trialsRequired persisting in save manager

* Adds slotIndex to girla (shop item actor) and uses that for IdentifyShopItem.

* Fix issue when merchantPrices is empty

* Fix for a single zeroed merchantPrice entry

* Fix #1417

* Implements items selling out and fixes issues with purchasing some items.

* Fixes order of operations so Rupees will be spent.

* Fixes sold out items not getting overwritten by the randomized info.

* Clarify var names and comments

Also preserve chain platform cutscene in spirit based on Link's position

* Remove !=0 from cvar check

* Clarify var names and comments

* Rename randomizerMerchantPrices to merchantPrices

* Handle shop items in SaveManager

* Fix merge mistake

* Base whats in the bazaar shop on entranceIndex instead of age

* Tidy up chain platform cutscene check

* Fix merge error

Didn't mean to have Zhora changes in here yet

* Use 3drando item table for parsing spoiler names

* Use another nested method instead of one at the top level to fetch the table

* Add missing newline

* Remove log

* Respect custom draw functions

* Fix issues with rendering songs

* Fix localized item names for shopsanity

* Implements a larger array of Sprites for the Icon Hash.

* Uses the hash instead of seed for spoilerfile name and icons.

* Removes some unused functions and variables in `spoiler_log.cpp`

* Prevents leading 0s added to hash from being in file name

* Changes filename format to icon indexes separated by dashes

* Hopefully makes Jenkins happy

* Hopefully makes Jenkins happy

* [Rando] Child Gerudo Fortress 37th Heartpiece randomized
Fixes #1071

* Add descriptions to save editor flags editor, and added randomizer flags (#1386)

* Add descriptions to save editor flags editor, and added randomizer flags

* Hide randomizer flags when not on a randomizer save

* Move flag descriptions to header file

* Update soh/soh/Enhancements/debugger/debugSaveEditor.h

* Update soh/soh/Enhancements/debugger/debugSaveEditor.h

* Fix merge error

* crash on pause menu on linux (only in appimage)
Fixes #1437

* Applies fix to Song from Impa as well.

* Allow buying tunics as child when shopsanity is on

* Fix for custom draw methods overriding sold out sign

* Simplify logic around shopsanity and fix some issues

* Fix dungeon reward stone rotation and add particles

* Fix some issues with ice traps

* Fix adult wallet having its own max capacity

* Fix amount of keys given for BotW

* format

* Use EnGirlAShopItem enum instead of raw hex values

* [#1434] Renders non-warp songs more consistently with warp songs

* A few changes around merchant messages

* Various changes from PR feedback

* Rando: Junk Hint missing french translation

* Typo

* Fix free scrub being at 0 instead of TEXT_SCRUB_RANDOM

* Replace magic numbers in message handler

* Update soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>

* Update soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>

* Fix BGS softlock for shopsanity

* Support tycoon wallet on tracker

* Revert "Fix BGS softlock for shopsanity"

This reverts commit 5fdb961ea4.

* [#1053] Resolves an issue with shop items and bombchu bowling where BGS would display two message boxes

* Implements some necessary plumbing and resolves several Ice Trap Softlocks.

Adds a way for an item entry to tell what type of check it came from (NPC vs Chest vs Freestanding, etc.)
Sets this value from chests and item00 actors.

Relocates pendingIceTraps to save context so it can persist through cutscenes and get stored on save init for Link's Pocket and Song from Impa.

Restructures pendingIceTraps into a counter rather than a true or false, so that we can be frozen multiple times in a row if applicable (atm that should only be at the start of a run if Link's Pocket and Song from Impa were both Ice Traps).

Adds a textbox for Ice Traps and a special case of holding up nothing in the get item process. This fixes all the cases where Ice Traps would softlock due to the actor giving the item expecting a closing textbox. After holding the item above his head Link increments the pendingIceTraps counter by one and sets whatever flag he has pending.

None of the above plumbing applies to Ice Traps from chests, those work exactly the same as before, as do freestanding item00 ice traps (thanks to the additional check for ITEM_FROM_FREESTANDING.

OoT and Ruto's Letter count as NPC's, so they get the FOWL text box and set a pending ice trap rather than immediately freezing, since Link weill be in the water. Link will get frozen the next time he touches land, which in the case of OoT is after the fade to white and right before the Song of Time check.

Fixes all the other softlocks I'm aware of, including Fishing, Bombchu Bowling, Skull Kid, and losing the second Gerudo Archery check.

* fix bgs check in player

* move bgs logic for tokensanity into MOD_NONE check

* set bgs flag before `Item_Give`ing

* move bgs flag into `MOD_NONE` check in girla

* use existing check in `z_player`

* Adds comment explaining the decision to default ITEM_FROM_NPC.

* Rename pendingIceTraps to pendingIceTrapCount

* Adds some RANDOTODO comments about cleaning up a couple things.

* Merge branch 'develop-zhora' into ztornn

* manually restore changes to `z_player.c`

* Fix after some ice trap prepwork from earlier

* Actual fix

* Woops

* More rupee names

* Actually fix it

* Add back comment

* Fix Skip Scarecrow Song

* Fix ruto's letter and LH sun stick rendering

* Also fixes it for treasure chest game

* Tweak: Rando French Wallet

* ADD: French Tycoon

* Hide dungeon items/notes by default

* [#1301] Fix issue with UI not restoring after getting an item from biggoron

* Update soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c

* Update soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c

* Fix random crash that only affected one person for some reason

Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Sarge-117 <adam_branston@outlook.com>
Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: lil David <1337lilDavid@gmail.com>
Co-authored-by: Sarge-117 <108380086+Sarge-117@users.noreply.github.com>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
2022-09-21 00:50:22 -04:00

552 lines
21 KiB
C

#include "global.h"
#include "vt.h"
#include <string.h>
#include <soh/Enhancements/randomizer/randomizerTypes.h>
#include <soh/Enhancements/randomizer/randomizer_inf.h>
#include "soh/Enhancements/randomizer/adult_trade_shuffle.h"
#define NUM_DUNGEONS 8
#define NUM_COWS 10
/**
* Initialize new save.
* This save has an empty inventory with 3 hearts and single magic.
*/
void Sram_InitNewSave(void) {
Save_InitFile(false);
}
/**
* Initialize debug save. This is also used on the Title Screen
* This save has a mostly full inventory with 10 hearts and single magic.
*
* Some noteable flags that are set:
* Showed Mido sword/shield, met Deku Tree, Deku Tree mouth opened,
* used blue warp in Gohmas room, Zelda fled castle, light arrow cutscene watched,
* and set water level in Water Temple to lowest level.
*/
void Sram_InitDebugSave(void) {
Save_InitFile(true);
}
// RANDOTODO replace most of these GiveLink functions with calls to
// Item_Give in z_parameter, we'll need to update Item_Give to ensure
// nothing breaks when calling it without a valid globalCtx first
void GiveLinkRupees(int numOfRupees) {
int maxRupeeCount;
if (CUR_UPG_VALUE(UPG_WALLET) == 0) {
maxRupeeCount = 99;
} else if (CUR_UPG_VALUE(UPG_WALLET) == 1) {
maxRupeeCount = 200;
} else if (CUR_UPG_VALUE(UPG_WALLET) == 2) {
maxRupeeCount = 500;
}
int newRupeeCount = gSaveContext.rupees;
newRupeeCount += numOfRupees;
if (newRupeeCount > maxRupeeCount) {
gSaveContext.rupees = maxRupeeCount;
} else {
gSaveContext.rupees = newRupeeCount;
}
}
void GiveLinkDekuSticks(int howManySticks) {
int maxStickCount;
if (CUR_UPG_VALUE(UPG_STICKS) == 0) {
INV_CONTENT(ITEM_STICK) = ITEM_STICK;
Inventory_ChangeUpgrade(UPG_STICKS, 1);
maxStickCount = 10;
} else if (CUR_UPG_VALUE(UPG_STICKS) == 1) {
maxStickCount = 10;
} else if (CUR_UPG_VALUE(UPG_STICKS) == 2) {
maxStickCount = 20;
} else if (CUR_UPG_VALUE(UPG_STICKS) == 3) {
maxStickCount = 30;
}
if ((AMMO(ITEM_STICK) + howManySticks) > maxStickCount) {
AMMO(ITEM_STICK) = maxStickCount;
} else {
AMMO(ITEM_STICK) += howManySticks;
}
}
void GiveLinkDekuNuts(int howManyNuts) {
int maxNutCount;
if (CUR_UPG_VALUE(UPG_NUTS) == 0) {
INV_CONTENT(ITEM_NUT) = ITEM_NUT;
Inventory_ChangeUpgrade(UPG_NUTS, 1);
maxNutCount = 20;
} else if (CUR_UPG_VALUE(UPG_NUTS) == 1) {
maxNutCount = 20;
} else if (CUR_UPG_VALUE(UPG_NUTS) == 2) {
maxNutCount = 30;
} else if (CUR_UPG_VALUE(UPG_NUTS) == 3) {
maxNutCount = 40;
}
if ((AMMO(ITEM_NUT) + howManyNuts) > maxNutCount) {
AMMO(ITEM_NUT) = maxNutCount;
} else {
AMMO(ITEM_NUT) += howManyNuts;
}
}
void GiveLinksPocketItem() {
if (Randomizer_GetSettingValue(RSK_LINKS_POCKET) < 3) {
GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LINKS_POCKET, RG_NONE);
if (getItemEntry.modIndex == MOD_NONE) {
if (getItemEntry.getItemId == GI_SWORD_BGS) {
gSaveContext.bgsFlag = true;
}
Item_Give(NULL, getItemEntry.itemId);
} else if (getItemEntry.modIndex == MOD_RANDOMIZER) {
if (getItemEntry.getItemId == RG_ICE_TRAP) {
gSaveContext.pendingIceTrapCount++;
} else {
Randomizer_Item_Give(NULL, getItemEntry);
}
}
}
}
/**
* Copy save currently on the buffer to Save Context and complete various tasks to open the save.
* This includes:
* - Set proper entrance depending on where the game was saved
* - If health is less than 3 hearts, give 3 hearts
* - If either scarecrow song is set, copy them from save context to the proper location
* - Handle a case where the player saved and quit after zelda cutscene but didnt get the song
* - Give and equip master sword if player is adult and doesnt have kokiri sword (bug?)
* - Revert any trade items that spoil
*/
void Sram_OpenSave() {
static s16 dungeonEntrances[] = {
0x0000, 0x0004, 0x0028, 0x0169, 0x0165, 0x0010, 0x0082, 0x0037,
0x0098, 0x0088, 0x041B, 0x0008, 0x0486, 0x0467, 0x0179, 0x056C,
};
u16 i;
u16 j;
u8* ptr;
Save_LoadFile();
if (!CVar_GetS32("gRememberSaveLocation", 0) || gSaveContext.savedSceneNum == SCENE_YOUSEI_IZUMI_TATE ||
gSaveContext.savedSceneNum == SCENE_KAKUSIANA) {
switch (gSaveContext.savedSceneNum) {
case SCENE_YDAN:
case SCENE_DDAN:
case SCENE_BDAN:
case SCENE_BMORI1:
case SCENE_HIDAN:
case SCENE_MIZUSIN:
case SCENE_JYASINZOU:
case SCENE_HAKADAN:
case SCENE_HAKADANCH:
case SCENE_ICE_DOUKUTO:
case SCENE_GANON:
case SCENE_MEN:
case SCENE_GERUDOWAY:
case SCENE_GANONTIKA:
gSaveContext.entranceIndex = dungeonEntrances[gSaveContext.savedSceneNum];
break;
case SCENE_YDAN_BOSS:
gSaveContext.entranceIndex = 0;
break;
case SCENE_DDAN_BOSS:
gSaveContext.entranceIndex = 4;
break;
case SCENE_BDAN_BOSS:
gSaveContext.entranceIndex = 0x28;
break;
case SCENE_MORIBOSSROOM:
gSaveContext.entranceIndex = 0x169;
break;
case SCENE_FIRE_BS:
gSaveContext.entranceIndex = 0x165;
break;
case SCENE_MIZUSIN_BS:
gSaveContext.entranceIndex = 0x10;
break;
case SCENE_JYASINBOSS:
gSaveContext.entranceIndex = 0x82;
break;
case SCENE_HAKADAN_BS:
gSaveContext.entranceIndex = 0x37;
break;
case SCENE_GANON_SONOGO:
case SCENE_GANONTIKA_SONOGO:
case SCENE_GANON_BOSS:
case SCENE_GANON_FINAL:
case SCENE_GANON_DEMO:
gSaveContext.entranceIndex = 0x41B;
break;
default:
if (gSaveContext.savedSceneNum != SCENE_LINK_HOME) {
gSaveContext.entranceIndex = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? 0xBB : 0x5F4;
} else {
gSaveContext.entranceIndex = 0xBB;
}
break;
}
}
osSyncPrintf("scene_no = %d\n", gSaveContext.entranceIndex);
osSyncPrintf(VT_RST);
if (gSaveContext.health < 0x30) {
gSaveContext.health = 0x30;
}
if (gSaveContext.scarecrowCustomSongSet) {
osSyncPrintf(VT_FGCOL(BLUE));
osSyncPrintf("\n====================================================================\n");
memcpy(gScarecrowCustomSongPtr, gSaveContext.scarecrowCustomSong, sizeof(gSaveContext.scarecrowCustomSong));
ptr = (u8*)gScarecrowCustomSongPtr;
for (i = 0; i < ARRAY_COUNT(gSaveContext.scarecrowCustomSong); i++, ptr++) {
osSyncPrintf("%d, ", *ptr);
}
osSyncPrintf("\n====================================================================\n");
osSyncPrintf(VT_RST);
}
if (gSaveContext.scarecrowSpawnSongSet) {
osSyncPrintf(VT_FGCOL(GREEN));
osSyncPrintf("\n====================================================================\n");
memcpy(gScarecrowSpawnSongPtr, gSaveContext.scarecrowSpawnSong, sizeof(gSaveContext.scarecrowSpawnSong));
ptr = gScarecrowSpawnSongPtr;
for (i = 0; i < ARRAY_COUNT(gSaveContext.scarecrowSpawnSong); i++, ptr++) {
osSyncPrintf("%d, ", *ptr);
}
osSyncPrintf("\n====================================================================\n");
osSyncPrintf(VT_RST);
}
// if zelda cutscene has been watched but lullaby was not obtained, restore cutscene and take away letter
if ((gSaveContext.eventChkInf[4] & 1) && !CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) && !gSaveContext.n64ddFlag) {
i = gSaveContext.eventChkInf[4] & ~1;
gSaveContext.eventChkInf[4] = i;
INV_CONTENT(ITEM_LETTER_ZELDA) = ITEM_CHICKEN;
for (j = 1; j < ARRAY_COUNT(gSaveContext.equips.buttonItems); j++) {
if (gSaveContext.equips.buttonItems[j] == ITEM_LETTER_ZELDA) {
gSaveContext.equips.buttonItems[j] = ITEM_CHICKEN;
}
}
}
// check for owning kokiri sword.. to restore master sword? bug or debug feature?
if (LINK_AGE_IN_YEARS == YEARS_ADULT && !CHECK_OWNED_EQUIP(EQUIP_SWORD, 1)) {
gSaveContext.inventory.equipment |= gBitFlags[1] << gEquipShifts[EQUIP_SWORD];
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER;
gSaveContext.equips.equipment &= ~0xF;
gSaveContext.equips.equipment |= 2;
}
if (!(gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE))) {
for (i = 0; i < ARRAY_COUNT(gSpoilingItems); i++) {
if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[i]) {
INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i];
for (j = 1; j < ARRAY_COUNT(gSaveContext.equips.buttonItems); j++) {
if (gSaveContext.equips.buttonItems[j] == gSpoilingItems[i]) {
gSaveContext.equips.buttonItems[j] = gSpoilingItemReverts[i];
}
}
}
}
}
gSaveContext.magicLevel = 0;
}
void Sram_InitSave(FileChooseContext* fileChooseCtx) {
u16 offset;
u16 j;
u16* ptr;
u16 checksum;
if (fileChooseCtx->buttonIndex != 0 || !CVar_GetS32("gDebugEnabled", 0)) {
Sram_InitNewSave();
} else {
Sram_InitDebugSave();
}
gSaveContext.entranceIndex = 0xBB;
gSaveContext.linkAge = 1;
gSaveContext.dayTime = 0x6AAB;
gSaveContext.cutsceneIndex = 0xFFF1;
if ((fileChooseCtx->buttonIndex == 0 && CVar_GetS32("gDebugEnabled", 0)) || CVar_GetS32("gNaviSkipCutscene", 0)) {
gSaveContext.cutsceneIndex = 0;
}
for (offset = 0; offset < 8; offset++) {
gSaveContext.playerName[offset] = Save_GetSaveMetaInfo(fileChooseCtx->buttonIndex)->playerName[offset];
}
if (CVar_GetS32("gRandomizer", 0) != 0 &&
strcmp(CVar_GetString("gSpoilerLog", ""), "") != 0) {
// Set N64DD Flags for save file
fileChooseCtx->n64ddFlags[fileChooseCtx->buttonIndex] = 1;
fileChooseCtx->n64ddFlag = 1;
gSaveContext.n64ddFlag = 1;
// Sets all rando flags to false
for (s32 i = 0; i < ARRAY_COUNT(gSaveContext.randomizerInf); i++) {
gSaveContext.randomizerInf[i] = 0;
}
// Set all trials to cleared if trial count is random or anything other than 6
if (Randomizer_GetSettingValue(RSK_RANDOM_TRIALS) || (Randomizer_GetSettingValue(RSK_TRIAL_COUNT) != 6)) {
for (u16 i = RAND_INF_TRIALS_DONE_LIGHT_TRIAL; i <= RAND_INF_TRIALS_DONE_SHADOW_TRIAL; i++) {
if (!Randomizer_IsTrialRequired(i)) {
Flags_SetRandomizerInf(i);
}
}
}
// Set Cutscene flags to skip them
gSaveContext.eventChkInf[0xC] |= 0x10; // returned to tot with medallions
gSaveContext.eventChkInf[0xC] |= 0x20; //sheik at tot pedestal
gSaveContext.eventChkInf[4] |= 0x20; // master sword pulled
gSaveContext.eventChkInf[4] |= 0x8000; // entered master sword chamber
gSaveContext.infTable[0] |= 1;
if (!Randomizer_GetSettingValue(RSK_ENABLE_GLITCH_CUTSCENES)) {
gSaveContext.infTable[17] |= 0x400; // Darunia in Fire Temple
}
gSaveContext.cutsceneIndex = 0;
Flags_SetEventChkInf(5);
// Skip boss cutscenes
gSaveContext.eventChkInf[7] |= 1; // gohma
gSaveContext.eventChkInf[7] |= 2; // dodongo
gSaveContext.eventChkInf[7] |= 4; // phantom ganon
gSaveContext.eventChkInf[7] |= 8; // volvagia
gSaveContext.eventChkInf[7] |= 0x10; // morpha
gSaveContext.eventChkInf[7] |= 0x20; // twinrova
gSaveContext.eventChkInf[7] |= 0x40; // barinade
gSaveContext.eventChkInf[7] |= 0x80; // bongo bongo
// Skip cutscene before Nabooru fight
gSaveContext.eventChkInf[3] |= 0x800;
gSaveContext.eventChkInf[12] |= 1;
// shuffle adult trade quest
if (Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE)) {
gSaveContext.adultTradeItems = 0;
}
// Starts pending ice traps out at 0 before potentially incrementing them down the line.
gSaveContext.pendingIceTrapCount = 0;
// Give Link's pocket item
GiveLinksPocketItem();
int openForest = Randomizer_GetSettingValue(RSK_FOREST);
switch (openForest) {
case 0: // closed
break;
case 1: // open
Flags_SetEventChkInf(7);
gSaveContext.eventChkInf[0] |= 0x10;
break;
case 2: // closed deku
Flags_SetEventChkInf(7);
break;
}
int doorOfTime = Randomizer_GetSettingValue(RSK_DOOR_OF_TIME);
switch (doorOfTime) {
case 0: // open
gSaveContext.eventChkInf[4] |= 0x800;
break;
}
int kakGate = Randomizer_GetSettingValue(RSK_KAK_GATE);
switch (kakGate) {
case 1: // open
gSaveContext.infTable[7] |= 0x40;
break;
}
if(Randomizer_GetSettingValue(RSK_STARTING_KOKIRI_SWORD)) Item_Give(NULL, ITEM_SWORD_KOKIRI);
if(Randomizer_GetSettingValue(RSK_STARTING_DEKU_SHIELD)) Item_Give(NULL, ITEM_SHIELD_DEKU);
if(Randomizer_GetSettingValue(RSK_STARTING_OCARINA)) {
INV_CONTENT(ITEM_OCARINA_FAIRY) = ITEM_OCARINA_FAIRY;
}
// "Start with" == 0 for Maps and Compasses
if(Randomizer_GetSettingValue(RSK_STARTING_MAPS_COMPASSES) == 0) {
uint32_t mapBitMask = 1 << 1;
uint32_t compassBitMask = 1 << 2;
uint32_t startingDungeonItemsBitMask = mapBitMask | compassBitMask;
for(int scene = SCENE_YDAN; scene <= SCENE_ICE_DOUKUTO; scene++) {
gSaveContext.inventory.dungeonItems[scene] |= startingDungeonItemsBitMask;
}
}
if (Randomizer_GetSettingValue(RSK_STARTING_CONSUMABLES)) {
GiveLinkDekuSticks(10);
GiveLinkDekuNuts(20);
}
if(Randomizer_GetSettingValue(RSK_SKIP_CHILD_ZELDA)) {
GetItemEntry getItem = Randomizer_GetItemFromKnownCheck(RC_SONG_FROM_IMPA, RG_ZELDAS_LULLABY);
s32 giid = getItem.getItemId;
if (getItem.modIndex == MOD_NONE) {
if (getItem.getItemId == GI_SWORD_BGS) {
gSaveContext.bgsFlag = true;
}
Item_Give(NULL, getItem.itemId);
} else if (getItem.modIndex == MOD_RANDOMIZER) {
if (getItem.getItemId == RG_ICE_TRAP) {
gSaveContext.pendingIceTrapCount++;
} else {
Randomizer_Item_Give(NULL, getItem);
}
}
// malon/talon back at ranch
gSaveContext.eventChkInf[1] |= (1 << 0);
gSaveContext.eventChkInf[1] |= (1 << 2);
gSaveContext.eventChkInf[1] |= (1 << 3);
gSaveContext.eventChkInf[1] |= (1 << 4);
// Set "Got Zelda's Letter" flag. Also ensures Saria is back at SFM. TODO: Is this flag used for anything else?
gSaveContext.eventChkInf[4] |= 1;
// Got item from impa
gSaveContext.eventChkInf[5] |= 0x200;
// set this at the end to ensure we always start with the letter
// this is for the off chance we got the weird egg from impa (which should never happen)
INV_CONTENT(ITEM_LETTER_ZELDA) = ITEM_LETTER_ZELDA;
}
if (Randomizer_GetSettingValue(RSK_FULL_WALLETS)) {
GiveLinkRupees(9001);
}
// "Start with" == 0 for Keysanity
if(Randomizer_GetSettingValue(RSK_KEYSANITY) == 0) {
// TODO: If master quest there are different key counts
gSaveContext.inventory.dungeonKeys[SCENE_BMORI1] = 5; // Forest
gSaveContext.inventory.dungeonKeys[SCENE_HIDAN] = 8; // Fire
gSaveContext.inventory.dungeonKeys[SCENE_MIZUSIN] = 6; // Water
gSaveContext.inventory.dungeonKeys[SCENE_JYASINZOU] = 5; // Spirit
gSaveContext.inventory.dungeonKeys[SCENE_HAKADAN] = 5; // Shadow
gSaveContext.inventory.dungeonKeys[SCENE_HAKADANCH] = 3; // BotW
gSaveContext.inventory.dungeonKeys[SCENE_MEN] = 9; // GTG
gSaveContext.inventory.dungeonKeys[SCENE_GANONTIKA] = 2; // Ganon
}
// "Start with" == 0 for Boss Kesanity
if(Randomizer_GetSettingValue(RSK_BOSS_KEYSANITY) == 0) {
gSaveContext.inventory.dungeonItems[SCENE_BMORI1] |= 1; // Forest
gSaveContext.inventory.dungeonItems[SCENE_HIDAN] |= 1; // Fire
gSaveContext.inventory.dungeonItems[SCENE_MIZUSIN] |= 1; // Water
gSaveContext.inventory.dungeonItems[SCENE_JYASINZOU] |= 1; // Spirit
gSaveContext.inventory.dungeonItems[SCENE_HAKADAN] |= 1; // Shadow
}
// "Start with" == 2 for Ganon's Boss Key
if(Randomizer_GetSettingValue(RSK_GANONS_BOSS_KEY) == 2) {
gSaveContext.inventory.dungeonItems[SCENE_GANON] |= 1;
}
HIGH_SCORE(HS_POE_POINTS) = 1000 - (100 * Randomizer_GetSettingValue(RSK_BIG_POE_COUNT));
if(Randomizer_GetSettingValue(RSK_SKIP_EPONA_RACE)) {
gSaveContext.eventChkInf[1] |= (1 << 8);
}
// skip the z target talk instructions by the kokiri shop
gSaveContext.sceneFlags[85].swch |= (1 << 0x1F);
//Ruto already met in jabu and spawns down the hole immediately
gSaveContext.infTable[20] |= 2;
gSaveContext.infTable[20] |= 4;
// Go away ruto (water temple first cutscene)
gSaveContext.sceneFlags[05].swch |= (1 << 0x10);
// Opens locked Water Temple door to prevent softlocks
// West door on the middle level that leads to the water raising thing
// Happens in 3DS rando and N64 rando as well
gSaveContext.sceneFlags[05].swch |= (1 << 0x15);
// Skip intro cutscene when bombing mud wall in Dodongo's cavern
// this also makes the lower jaw render, and the eyes react to explosives
Flags_SetEventChkInf(0xB0);
// skip verbose lake owl, skip to "i'm on my way back to the castle"
gSaveContext.infTable[25] |= 0x20;
// fast gerudo fortress
if (Randomizer_GetSettingValue(RSK_GERUDO_FORTRESS) == 1 || Randomizer_GetSettingValue(RSK_GERUDO_FORTRESS) == 2) {
gSaveContext.eventChkInf[9] |= 2;
gSaveContext.eventChkInf[9] |= 4;
gSaveContext.eventChkInf[9] |= 8;
gSaveContext.sceneFlags[12].swch |= (1 << 0x02);
gSaveContext.sceneFlags[12].swch |= (1 << 0x03);
gSaveContext.sceneFlags[12].swch |= (1 << 0x04);
gSaveContext.sceneFlags[12].swch |= (1 << 0x06);
gSaveContext.sceneFlags[12].swch |= (1 << 0x07);
gSaveContext.sceneFlags[12].swch |= (1 << 0x08);
gSaveContext.sceneFlags[12].swch |= (1 << 0x10);
gSaveContext.sceneFlags[12].swch |= (1 << 0x12);
gSaveContext.sceneFlags[12].swch |= (1 << 0x13);
gSaveContext.sceneFlags[12].collect |= (1 << 0x0A);
gSaveContext.sceneFlags[12].collect |= (1 << 0x0E);
gSaveContext.sceneFlags[12].collect |= (1 << 0x0F);
}
// open gerudo fortress
if (Randomizer_GetSettingValue(RSK_GERUDO_FORTRESS) == 2) {
gSaveContext.eventChkInf[9] |= 1;
gSaveContext.sceneFlags[12].swch |= (1 << 0x01);
gSaveContext.sceneFlags[12].swch |= (1 << 0x05);
gSaveContext.sceneFlags[12].swch |= (1 << 0x11);
gSaveContext.sceneFlags[12].collect |= (1 << 0x0C);
if (!Randomizer_GetSettingValue(RSK_SHUFFLE_GERUDO_MEMBERSHIP_CARD)) {
Item_Give(NULL, ITEM_GERUDO_CARD);
}
}
// complete mask quest
if (Randomizer_GetSettingValue(RSK_COMPLETE_MASK_QUEST)) {
gSaveContext.infTable[7] |= 0x80; // Soldier Wears Keaton Mask
gSaveContext.itemGetInf[3] |= 0x100; // Sold Keaton Mask
gSaveContext.itemGetInf[3] |= 0x200; // Sold Skull Mask
gSaveContext.itemGetInf[3] |= 0x400; // Sold Spooky Mask
gSaveContext.itemGetInf[3] |= 0x800; // bunny hood related
gSaveContext.itemGetInf[3] |= 0x8000; // Obtained Mask of Truth
gSaveContext.eventChkInf[8] |= 0x8000; // sold all masks
}
}
Save_SaveFile();
}
void Sram_InitSram(GameState* gameState) {
Save_Init();
func_800F6700(gSaveContext.audioSetting);
}