mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-14 00:53:07 -07:00
Rework Get Item Table to be more flexible for adding custom items (#1050)
* Adds ItemTableManager class. * Implements new getItem table in game. * Adds rando item table and way to differentiate tables in GetItemEntry. * Adds rough ability to differentiate between rando and vanilla items.merge stashed changes from before develop-zhora merge * Change ItemTableID to be uint16_t so we can use ModIndex for it. * Should fix switch build * Should fix switch build pt 2 * Adds new files to CMakeLists. * Implements fixes for competing getItem calls. * Correctly renders freestanding items Particle effects are probably broken, need to fix them still, I pretty much know how I would do that. * Fixed Particle effects in the new getItem system. * Fixes item fanfares * Partially fixes Ice Traps Obtaining a freestanding Ice Trap causes link to slide forward and receiving one from an NPC plays the sound effect and damage animation but doesn't freeze link. * Some more partial ice trap fixing that wasn't pushed earlier * Removes unused function override * Replaces ::find with ::at and adds exception handling * Removes some commented out code. * Refactors rando's GetItemEntry array into two arrays. One array is for the vanilla items that don't have GetItemEntries in vanilla, the other is for rando exclusive items. They are stored in separate arrays before getting added to the table so that we can apply different modIndexes. The items in the first table have are handled by the vanilla Item_Give, and the second table needed a custom `Randomizer_Item_Give` function. * Renames, relocates, and implements ModIndex enum. * Removes now unused ItemIDs and GetItemIDs Also makes all the necessary changes to other code that was still using them indirectly through the GI to GID map that was removed. There's quite a lot of changes here and I haven't had time to test them yet. * Re-implements GIMESSAGE_UNTRANSLATED as macro * Removes commented out function. * Throws exception if an invalid itemID is used Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r943694857 * Removes ARRAY_SIZE in favor of ARRAY_COUNT ARRAY_COUNT already exists in `macros.h`, I just didn't find it before. Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r943153833 * Inverts CheckContainsRandoItem to CheckContainsVanillaItem. Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r940895135 * Cleanup, bugfixes, removing the `- 1`s from `z_player.c` * Fixes some funky formatting that got committed earlier. * Adds else if to added fanfare sound cases. Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r940112924 and https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r940113492 * Extends GetItemEntry to include getItemId Also adapts some existing calls for both the entry and the id to only get the entry. * Extends GetItemEntry to include GID. This allows for using it later when drawing freestanding items. Addresses https://github.com/HarbourMasters/Shipwright/pull/1050#discussion_r943168136 * Rando-specific items use new textId again. This got lost when merging develop-zhora in because I didn't have custom messages merged when I started this. * Sets global modIndex to MOD_NONE on scene load Fixes a crash when buying items in shops due to them not triggering the rando code that normally sets these items. May have also been crashing vanilla playthroughs. * Realized I had the bgm conditions wrong. * Fixes "static drops" (i.e. sticks from withered babas) * Fixes LACS/Prelude situation... again. * Fixes too many arguments error. Not sure why this didn't fail to build on Windows before. * Fixes Link's Pocket items. * Simplifies sram init for rando-specific items * Fixes issues with approaching bottleable items. * Fixes Ruto's Letter. It was accidentally getting classified as a rando item. * Should re-fix freestanding ice traps * Makes freestanding items set player->getItemEntry. This prevents freestanding items from setting the global modIndex. This is part of a larger transition that needs to happen to switch to setting getItemEntries for all of the rando items. This prevents some things that set getItemId of GI_MAX from granting a Fire Medallion when the global modIndex is MOD_RANDOMIZER. * Makes sure we aren't using getItemEntry when not randoed. * Replace Randomizer_GetRandomizedItemId with Randomizer_GetRandomizedItem and Randomizer_GetItemIdFromKnownCheck with Randomizer_GetItemFromKnownCheck * Introduce some new methods and migrate most actors to them * Fixes ocarina game skull kids to set player->getItemEntry * Sets `z_en_box.c` to set `player->getItemEntry` * Fix logical errors and migrate most of the rest of the rando checks to GiveItemEntryFromActor * Use GiveItemEntryFromActorWithFixedRange in item00 * Fixes Anju to set player->getItemEntry. * Add a few missing cases * Additional fix for Skull Kid * Fixes vanilla ice traps and randomized ice smoke * Fixes rendering of treasure chest game items. * Removes unused `Randomizer_GetItemIdFromGetItemId`. * Cleans up an if statement for item00. * Cleans up another if statement in item00 * This should fix a bug with the Gerudo Archery minigame. I wasn't able to get the bug to happen after making this change. * Documents our new GiveItemEntry fuctions. * Uses more descriptive type name for ItemIDs for creating custom messages. * Fixes potential issue with if statement. * Fixes missed type change. Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
This commit is contained in:
parent
ed1708508a
commit
168e84498f
64 changed files with 1439 additions and 1087 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "vt.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <soh/Enhancements/randomizer/randomizerTypes.h>
|
||||
|
||||
#define NUM_DUNGEONS 8
|
||||
#define NUM_TRIALS 6
|
||||
|
@ -306,11 +307,11 @@ void GiveLinkDekuNutUpgrade(GetItemID giid) {
|
|||
}
|
||||
|
||||
void GiveLinkMagic(GetItemID giid) {
|
||||
if (giid == GI_SINGLE_MAGIC) {
|
||||
if (giid == RG_MAGIC_SINGLE) {
|
||||
gSaveContext.magicLevel = 1;
|
||||
gSaveContext.magicAcquired = true;
|
||||
gSaveContext.doubleMagic = false;
|
||||
} else if (giid == GI_DOUBLE_MAGIC) {
|
||||
} else if (giid == RG_MAGIC_DOUBLE) {
|
||||
gSaveContext.magicLevel = 2;
|
||||
gSaveContext.magicAcquired = true;
|
||||
gSaveContext.doubleMagic = true;
|
||||
|
@ -326,40 +327,40 @@ void GiveLinkSong(GetItemID getItemId) {
|
|||
uint32_t bitMask;
|
||||
|
||||
switch (getItemId) {
|
||||
case GI_ZELDAS_LULLABY:
|
||||
case RG_ZELDAS_LULLABY:
|
||||
bitMask = 1 << QUEST_SONG_LULLABY;
|
||||
break;
|
||||
case GI_SUNS_SONG:
|
||||
case RG_SUNS_SONG:
|
||||
bitMask = 1 << QUEST_SONG_SUN;
|
||||
break;
|
||||
case GI_EPONAS_SONG:
|
||||
case RG_EPONAS_SONG:
|
||||
bitMask = 1 << QUEST_SONG_EPONA;
|
||||
break;
|
||||
case GI_SONG_OF_STORMS:
|
||||
case RG_SONG_OF_STORMS:
|
||||
bitMask = 1 << QUEST_SONG_STORMS;
|
||||
break;
|
||||
case GI_SONG_OF_TIME:
|
||||
case RG_SONG_OF_TIME:
|
||||
bitMask = 1 << QUEST_SONG_TIME;
|
||||
break;
|
||||
case GI_SARIAS_SONG:
|
||||
case RG_SARIAS_SONG:
|
||||
bitMask = 1 << QUEST_SONG_SARIA;
|
||||
break;
|
||||
case GI_MINUET_OF_FOREST:
|
||||
case RG_MINUET_OF_FOREST:
|
||||
bitMask = 1 << QUEST_SONG_MINUET;
|
||||
break;
|
||||
case GI_BOLERO_OF_FIRE:
|
||||
case RG_BOLERO_OF_FIRE:
|
||||
bitMask = 1 << QUEST_SONG_BOLERO;
|
||||
break;
|
||||
case GI_SERENADE_OF_WATER:
|
||||
case RG_SERENADE_OF_WATER:
|
||||
bitMask = 1 << QUEST_SONG_SERENADE;
|
||||
break;
|
||||
case GI_NOCTURNE_OF_SHADOW:
|
||||
case RG_NOCTURNE_OF_SHADOW:
|
||||
bitMask = 1 << QUEST_SONG_NOCTURNE;
|
||||
break;
|
||||
case GI_REQUIEM_OF_SPIRIT:
|
||||
case RG_REQUIEM_OF_SPIRIT:
|
||||
bitMask = 1 << QUEST_SONG_REQUIEM;
|
||||
break;
|
||||
case GI_PRELUDE_OF_LIGHT:
|
||||
case RG_PRELUDE_OF_LIGHT:
|
||||
bitMask = 1 << QUEST_SONG_PRELUDE;
|
||||
break;
|
||||
}
|
||||
|
@ -367,43 +368,43 @@ void GiveLinkSong(GetItemID getItemId) {
|
|||
gSaveContext.inventory.questItems |= bitMask;
|
||||
}
|
||||
|
||||
void GiveLinkDungeonReward(GetItemID getItemId) {
|
||||
void GiveLinkDungeonReward(uint16_t getItemId) {
|
||||
s16 item;
|
||||
|
||||
u8 medallion = 0;
|
||||
|
||||
switch (getItemId) {
|
||||
case GI_MEDALLION_FOREST:
|
||||
case RG_FOREST_MEDALLION:
|
||||
item = ITEM_MEDALLION_FOREST;
|
||||
medallion = 1;
|
||||
break;
|
||||
case GI_MEDALLION_FIRE:
|
||||
case RG_FIRE_MEDALLION:
|
||||
item = ITEM_MEDALLION_FIRE;
|
||||
medallion = 1;
|
||||
break;
|
||||
case GI_MEDALLION_WATER:
|
||||
case RG_WATER_MEDALLION:
|
||||
item = ITEM_MEDALLION_WATER;
|
||||
medallion = 1;
|
||||
break;
|
||||
case GI_MEDALLION_SHADOW:
|
||||
case RG_SHADOW_MEDALLION:
|
||||
item = ITEM_MEDALLION_SHADOW;
|
||||
medallion = 1;
|
||||
break;
|
||||
case GI_MEDALLION_SPIRIT:
|
||||
case RG_SPIRIT_MEDALLION:
|
||||
item = ITEM_MEDALLION_SPIRIT;
|
||||
medallion = 1;
|
||||
break;
|
||||
case GI_MEDALLION_LIGHT:
|
||||
case RG_LIGHT_MEDALLION:
|
||||
item = ITEM_MEDALLION_LIGHT;
|
||||
medallion = 1;
|
||||
break;
|
||||
case GI_STONE_KOKIRI:
|
||||
case RG_KOKIRI_EMERALD:
|
||||
item = ITEM_KOKIRI_EMERALD;
|
||||
break;
|
||||
case GI_STONE_GORON:
|
||||
case RG_GORON_RUBY:
|
||||
item = ITEM_GORON_RUBY;
|
||||
break;
|
||||
case GI_STONE_ZORA:
|
||||
case RG_ZORA_SAPPHIRE:
|
||||
item = ITEM_ZORA_SAPPHIRE;
|
||||
break;
|
||||
}
|
||||
|
@ -416,9 +417,9 @@ void GiveLinkDungeonReward(GetItemID getItemId) {
|
|||
}
|
||||
|
||||
void GiveLinksPocketMedallion() {
|
||||
GetItemID getItemId = Randomizer_GetItemIdFromKnownCheck(RC_LINKS_POCKET, RG_NONE);
|
||||
GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_LINKS_POCKET, RG_NONE);
|
||||
|
||||
GiveLinkDungeonReward(getItemId);
|
||||
GiveLinkDungeonReward(getItemEntry.getItemId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -696,95 +697,71 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) {
|
|||
}
|
||||
|
||||
if(Randomizer_GetSettingValue(RSK_SKIP_CHILD_ZELDA)) {
|
||||
s32 giid = Randomizer_GetItemIdFromKnownCheck(RC_SONG_FROM_IMPA, GI_ZELDAS_LULLABY);
|
||||
|
||||
if(giid >= GI_ZELDAS_LULLABY && giid <= GI_PRELUDE_OF_LIGHT) {
|
||||
GiveLinkSong(giid);
|
||||
} else if (giid == GI_RUPEE_GREEN ||
|
||||
giid == GI_RUPEE_BLUE ||
|
||||
giid == GI_RUPEE_RED ||
|
||||
giid == GI_RUPEE_PURPLE ||
|
||||
giid == GI_RUPEE_GOLD) {
|
||||
GiveLinkRupeesByGetItemId(giid);
|
||||
} else if (giid == GI_BOMBCHUS_10 ||
|
||||
giid == GI_BOMBCHUS_5 ||
|
||||
giid == GI_BOMBCHUS_20) {
|
||||
GiveLinkBombchus(giid);
|
||||
} else if (giid == GI_STICKS_1 ||
|
||||
giid == GI_STICKS_5 ||
|
||||
giid == GI_STICKS_10) {
|
||||
GiveLinkDekuSticksByGetItemId(giid);
|
||||
} else if (giid == GI_NUTS_5 ||
|
||||
giid == GI_NUTS_10) {
|
||||
GiveLinkDekuNutsByGetItemId(giid);
|
||||
} else if (giid == GI_BEAN) {
|
||||
GiveLinkBeans();
|
||||
} else if (giid >= GI_MEDALLION_LIGHT && giid <= GI_STONE_ZORA) {
|
||||
GiveLinkDungeonReward(giid);
|
||||
} else if (giid == GI_SWORD_KOKIRI) {
|
||||
GiveLinkKokiriSword();
|
||||
} else if (giid == GI_SWORD_BGS) {
|
||||
GiveLinkBiggoronSword();
|
||||
} else if (giid == GI_SWORD_KNIFE) {
|
||||
GiveLinkGiantsKnife();
|
||||
} else if (giid == GI_SHIELD_DEKU) {
|
||||
GiveLinkDekuShield();
|
||||
} else if (giid == GI_SHIELD_HYLIAN) {
|
||||
GiveLinkHylianShield();
|
||||
} else if (giid == GI_SHIELD_MIRROR) {
|
||||
GiveLinkMirrorShield();
|
||||
} else if (giid == GI_TUNIC_GORON) {
|
||||
GiveLinkGoronTunic();
|
||||
} else if (giid == GI_TUNIC_ZORA) {
|
||||
GiveLinkZoraTunic();
|
||||
} else if (giid == GI_BOOTS_IRON) {
|
||||
GiveLinkIronBoots();
|
||||
} else if (giid == GI_BOOTS_HOVER) {
|
||||
GiveLinkHoverBoots();
|
||||
} else if (giid == GI_SLINGSHOT ||
|
||||
giid == GI_BULLET_BAG_40 ||
|
||||
giid == GI_BULLET_BAG_50) {
|
||||
GiveLinkBulletBagUpgrade(giid);
|
||||
} else if (giid == GI_BOW ||
|
||||
giid == GI_QUIVER_40 ||
|
||||
giid == GI_QUIVER_50) {
|
||||
GiveLinkQuiverUpgrade(giid);
|
||||
} else if (giid == GI_BOMB_BAG_20 ||
|
||||
giid == GI_BOMB_BAG_30 ||
|
||||
giid == GI_BOMB_BAG_40) {
|
||||
GiveLinkBombBagUpgrade(giid);
|
||||
} else if (giid == GI_BRACELET ||
|
||||
giid == GI_GAUNTLETS_SILVER ||
|
||||
giid == GI_GAUNTLETS_GOLD) {
|
||||
GiveLinkStrengthUpgrade(giid);
|
||||
} else if (giid == GI_SCALE_SILVER ||
|
||||
giid == GI_SCALE_GOLD) {
|
||||
GiveLinkScaleUpgrade(giid);
|
||||
} else if (giid == GI_WALLET_ADULT ||
|
||||
giid == GI_WALLET_GIANT) {
|
||||
GiveLinkWalletUpgrade(giid);
|
||||
} else if (giid == GI_STONE_OF_AGONY) {
|
||||
GiveLinkStoneOfAgony();
|
||||
} else if (giid == GI_GERUDO_CARD) {
|
||||
GiveLinkGerudoCard();
|
||||
} else if (giid == GI_HEART_PIECE) {
|
||||
GiveLinkPieceOfHeart();
|
||||
} else if (giid == GI_HEART_CONTAINER) {
|
||||
GiveLinkHeartContainer();
|
||||
} else if (giid == GI_STICK_UPGRADE_20 ||
|
||||
giid == GI_STICK_UPGRADE_30) {
|
||||
GiveLinkDekuStickUpgrade(giid);
|
||||
} else if (giid == GI_NUT_UPGRADE_30 ||
|
||||
giid == GI_NUT_UPGRADE_40) {
|
||||
GiveLinkDekuNutUpgrade(giid);
|
||||
} else if (giid == GI_SINGLE_MAGIC ||
|
||||
giid == GI_DOUBLE_MAGIC) {
|
||||
GiveLinkMagic(giid);
|
||||
} else if (giid == GI_DOUBLE_DEFENSE) {
|
||||
GiveLinkDoubleDefense();
|
||||
} else {
|
||||
s32 iid = Randomizer_GetItemIDFromGetItemID(giid);
|
||||
if (iid != -1) INV_CONTENT(iid) = iid;
|
||||
GetItemEntry getItem = Randomizer_GetItemFromKnownCheck(RC_SONG_FROM_IMPA, RG_ZELDAS_LULLABY);
|
||||
s32 giid = getItem.getItemId;
|
||||
|
||||
if (getItem.modIndex == MOD_NONE) {
|
||||
if (giid == GI_RUPEE_GREEN || giid == GI_RUPEE_BLUE || giid == GI_RUPEE_RED ||
|
||||
giid == GI_RUPEE_PURPLE || giid == GI_RUPEE_GOLD) {
|
||||
GiveLinkRupeesByGetItemId(giid);
|
||||
} else if (giid == GI_BOMBCHUS_10 || giid == GI_BOMBCHUS_5 || giid == GI_BOMBCHUS_20) {
|
||||
GiveLinkBombchus(giid);
|
||||
} else if (giid == GI_STICKS_1 || giid == GI_STICKS_5 || giid == GI_STICKS_10) {
|
||||
GiveLinkDekuSticksByGetItemId(giid);
|
||||
} else if (giid == GI_NUTS_5 || giid == GI_NUTS_10) {
|
||||
GiveLinkDekuNutsByGetItemId(giid);
|
||||
} else if (giid == GI_BEAN) {
|
||||
GiveLinkBeans();
|
||||
} else if (giid == GI_SWORD_KOKIRI) {
|
||||
GiveLinkKokiriSword();
|
||||
} else if (giid == GI_SWORD_BGS) {
|
||||
GiveLinkBiggoronSword();
|
||||
} else if (giid == GI_SWORD_KNIFE) {
|
||||
GiveLinkGiantsKnife();
|
||||
} else if (giid == GI_SHIELD_DEKU) {
|
||||
GiveLinkDekuShield();
|
||||
} else if (giid == GI_SHIELD_HYLIAN) {
|
||||
GiveLinkHylianShield();
|
||||
} else if (giid == GI_SHIELD_MIRROR) {
|
||||
GiveLinkMirrorShield();
|
||||
} else if (giid == GI_TUNIC_GORON) {
|
||||
GiveLinkGoronTunic();
|
||||
} else if (giid == GI_TUNIC_ZORA) {
|
||||
GiveLinkZoraTunic();
|
||||
} else if (giid == GI_BOOTS_IRON) {
|
||||
GiveLinkIronBoots();
|
||||
} else if (giid == GI_BOOTS_HOVER) {
|
||||
GiveLinkHoverBoots();
|
||||
} else if (giid == GI_SLINGSHOT || giid == GI_BULLET_BAG_40 || giid == GI_BULLET_BAG_50) {
|
||||
GiveLinkBulletBagUpgrade(giid);
|
||||
} else if (giid == GI_BOW || giid == GI_QUIVER_40 || giid == GI_QUIVER_50) {
|
||||
GiveLinkQuiverUpgrade(giid);
|
||||
} else if (giid == GI_BOMB_BAG_20 || giid == GI_BOMB_BAG_30 || giid == GI_BOMB_BAG_40) {
|
||||
GiveLinkBombBagUpgrade(giid);
|
||||
} else if (giid == GI_BRACELET || giid == GI_GAUNTLETS_SILVER || giid == GI_GAUNTLETS_GOLD) {
|
||||
GiveLinkStrengthUpgrade(giid);
|
||||
} else if (giid == GI_SCALE_SILVER || giid == GI_SCALE_GOLD) {
|
||||
GiveLinkScaleUpgrade(giid);
|
||||
} else if (giid == GI_WALLET_ADULT || giid == GI_WALLET_GIANT) {
|
||||
GiveLinkWalletUpgrade(giid);
|
||||
} else if (giid == GI_STONE_OF_AGONY) {
|
||||
GiveLinkStoneOfAgony();
|
||||
} else if (giid == GI_GERUDO_CARD) {
|
||||
GiveLinkGerudoCard();
|
||||
} else if (giid == GI_HEART_PIECE) {
|
||||
GiveLinkPieceOfHeart();
|
||||
} else if (giid == GI_HEART_CONTAINER) {
|
||||
GiveLinkHeartContainer();
|
||||
} else if (giid == GI_STICK_UPGRADE_20 || giid == GI_STICK_UPGRADE_30) {
|
||||
GiveLinkDekuStickUpgrade(giid);
|
||||
} else if (giid == GI_NUT_UPGRADE_30 || giid == GI_NUT_UPGRADE_40) {
|
||||
GiveLinkDekuNutUpgrade(giid);
|
||||
} else {
|
||||
s32 iid = getItem.itemId;
|
||||
if (iid != -1) INV_CONTENT(iid) = iid;
|
||||
}
|
||||
} else if (getItem.modIndex == MOD_RANDOMIZER) {
|
||||
Randomizer_Item_Give(NULL, getItem);
|
||||
}
|
||||
|
||||
// malon/talon back at ranch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue