Skip to content

Commit

Permalink
Fix Giant's Knife unexpected behaviours (#834)
Browse files Browse the repository at this point in the history
* Giant's Knife Behaviour Fixes

Fixes a case where Giant's Knife (specifically, breaking and re-buying it) can behave unexpectedly if you don't have a Kokiri Sword in your inventory.  Also fixes the broken icon not showing up in inventory after you break it.

* less whitespace

* fix 0xE check

Accidentally committed with the wrong check

* Move the grayscale code up

Moved the grayscaling portion up higher in the function and renamed "bool not_acquired" to "bool age_restricted".  Thanks to @vaguerant for the suggestion!
  • Loading branch information
Sarge-117 authored Jul 21, 2022
1 parent c19beca commit 52f2227
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
6 changes: 4 additions & 2 deletions soh/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1676,13 +1676,15 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) {
if (item == ITEM_SWORD_BGS) {
gSaveContext.swordHealth = 8;

if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF) {
gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD];
if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF
||(gSaveContext.n64ddFlag && ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xE)) { // In rando, when buying Giant's Knife, also check
gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; // for 0xE in case we don't have Kokiri Sword
if (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KNIFE) {
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS;
Interface_LoadItemIcon1(globalCtx, 0);
}
}

} else if (item == ITEM_SWORD_MASTER) {
gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER;
gSaveContext.equips.equipment &= 0xFFF0;
Expand Down
19 changes: 9 additions & 10 deletions soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,24 +637,23 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) {
gItemIcons[sAdultUpgradeItemBases[i] + CUR_UPG_VALUE(sAdultUpgrades[i]) - 1], 32, 32, 0);
}
}

// Draw inventory screen icons
for (k = 0, bit = rowStart, point = 4; k < 3; k++, point += 4, temp++, bit++) {

int itemId = ITEM_SWORD_KOKIRI + temp;
bool age_restricted = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge);
if (age_restricted) {
gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255);
gsSPGrayscale(POLY_KAL_DISP++, true);
}
if (((u32)i == 0) && (k == 2) && (gSaveContext.bgsFlag != 0)) {
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gBiggoronSwordIconTex, 32, 32, point);
} else if ((i == 0) && (k == 2) && (gBitFlags[bit + 1] & gSaveContext.inventory.equipment)) {
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gBrokenGiantsKnifeIconTex, 32, 32, point);
}
if (gBitFlags[bit] & gSaveContext.inventory.equipment) {
int itemId = ITEM_SWORD_KOKIRI + temp;
bool not_acquired = (gItemAgeReqs[itemId] != 9) && (gItemAgeReqs[itemId] != gSaveContext.linkAge);
if (not_acquired) {
gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255);
gsSPGrayscale(POLY_KAL_DISP++, true);
}
} else if (gBitFlags[bit] & gSaveContext.inventory.equipment) {
KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point);
gsSPGrayscale(POLY_KAL_DISP++, false);
}
gsSPGrayscale(POLY_KAL_DISP++, false);
}
}

Expand Down

0 comments on commit 52f2227

Please sign in to comment.