From 779c9a27ce18c6f11d3e8c19957641ae02189bb6 Mon Sep 17 00:00:00 2001 From: Kara Alexandra Date: Sat, 7 Feb 2026 16:51:21 -0600 Subject: [PATCH] Shield handling for pots and enemy drops and a few more NPCs --- bookofmudora.asm | 9 ++++++++- decryption.asm | 15 ++++++++++++--- halfmagicbat.asm | 11 +++++++++-- heartpieces.asm | 9 +++++---- hooks.asm | 4 +--- inventory.asm | 19 +++++++++++++------ keydrop/standing_items.asm | 8 ++++++++ multiworld.asm | 11 ++++++++++- npcitems.asm | 26 ++++++++++---------------- pikit.asm | 13 ++++++++++--- swordswap.asm | 4 ++++ tablets.asm | 23 ++++++++++++++++++++++- 12 files changed, 112 insertions(+), 40 deletions(-) diff --git a/bookofmudora.asm b/bookofmudora.asm index b1c8ddd..1077ab4 100644 --- a/bookofmudora.asm +++ b/bookofmudora.asm @@ -53,14 +53,21 @@ RTL GiveBonkItem: LDA.w SprItemMWPlayer, X : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.w SprSourceItemId, X + + PHY : TAY + JSL ShieldCheck + TYA : PLY + BCC .done + JSR AbsorbKeyCheck : BCC .notKey PHY : LDY.b #$24 : JSL AddInventory : PLY ; do inventory processing for a small key LDA.l CurrentSmallKeys : INC A : STA.l CurrentSmallKeys LDA.b #$2F : JSL Sound_SetSfx3PanLong LDA.b #$01 : STA.l UpdateHUDFlag RTL - .notKey + .notKey PHY : TAY : JSL Link_ReceiveItem : PLY + .done RTL ;-------------------------------------------------------------------------------- LoadBonkItem: diff --git a/decryption.asm b/decryption.asm index 4eb7538..f62b400 100644 --- a/decryption.asm +++ b/decryption.asm @@ -72,18 +72,27 @@ JML Dungeon_OpenKeyedObject_nextChest TXA : LSR JSL RetrieveValueFromEncryptedTable - JSL ShieldCheck STA.b Scrap0C PLA : STA.b Scrap02 : PLA : STA.b Scrap00 LDA.l ChestData, X : ASL A : BCC .smallChest - JSL ShieldCheck : BCC .couldntFindChest + PHY + LDY.b Scrap0C + JSL ShieldCheck + STY.b Scrap0C + PLY + BCC .couldntFindChest JML Dungeon_OpenKeyedObject_bigChest ;(bank01.asm line #13783) .smallChest - JSL ShieldCheck : BCC .couldntFindChest + PHY + LDY.b Scrap0C + JSL ShieldCheck + STY.b Scrap0C + PLY + BCC .couldntFindChest JML Dungeon_OpenKeyedObject_smallChest .couldntFindChest diff --git a/halfmagicbat.asm b/halfmagicbat.asm index dd41d03..477c00c 100644 --- a/halfmagicbat.asm +++ b/halfmagicbat.asm @@ -2,13 +2,20 @@ ; Randomize Half Magic Bat ;-------------------------------------------------------------------------------- GetMagicBatItem: - JSL ItemSet_MagicBat %GetPossiblyEncryptedItem(MagicBatItem, SpriteItemValues) CMP.b #$FF : BEQ .normalLogic TAY - PHA : LDA.l MagicBatItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID : PLA + PHA + JSL ShieldCheck + BCC .have_shield + LDA.l MagicBatItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID + JSL ItemSet_MagicBat + PLA STZ.b ItemReceiptMethod ; 0 = Receiving item from an NPC or message JML Link_ReceiveItem +.have_shield + PLA + RTL .normalLogic LDA.l HalfMagic STA.l MagicConsumption diff --git a/heartpieces.asm b/heartpieces.asm index b55158e..682e153 100644 --- a/heartpieces.asm +++ b/heartpieces.asm @@ -11,10 +11,8 @@ HeartPieceGet: RTL ;-------------------------------------------------------------------------------- HeartGet: - STY.b $0C JSL ShieldCheck - BCC .done - LDY.b $0C + BCC .skip LDA.w SprItemMWPlayer, X : STA.l !MULTIWORLD_ITEM_PLAYER_ID CPY.b #$26 : BNE .not_heart ; don't add a 1/4 heart if it's not a heart piece @@ -26,7 +24,10 @@ HeartGet: JSL Link_ReceiveItem JSL MaybeUnlockTabletAnimation SEC -.done + RTL +.skip + JSL MaybeFreeLinkFromTablet + CLC RTL ;-------------------------------------------------------------------------------- HeartContainerGet: diff --git a/hooks.asm b/hooks.asm index 31fff9b..357e816 100755 --- a/hooks.asm +++ b/hooks.asm @@ -2010,7 +2010,7 @@ org $85EE53 ; <- 2EE53 - mushroom.asm : 22 JSL ItemCheck_Mushroom : NOP #2 ;-------------------------------------------------------------------------------- org $85EE8C ; <- 2EE8C - mushroom.asm : 69 -JSL ItemSet_Mushroom : NOP +JSL ItemSet_Mushroom : NOP #5 ;-------------------------------------------------------------------------------- org $85F53E ; <- 2F53E - sprite_potion_shop.asm : 40 JSL ItemCheck_Powder : CMP.b #$20 @@ -2067,9 +2067,7 @@ JSL HeartPieceSpawnDelayFix ;-------------------------------------------------------------------------------- org $85F08A ; <- 2F08A - sprite_heart_upgrades.asm : 324 - (LDA $7EF36B : INC A : AND.b #$03 : STA $7EF36B : BNE .got_4_piecese) item determination JSL HeartPieceGet -PHP JSL DynamicDrawCleanup -PLP : BCC + JSL IsMedallion BCS + : BRA Sprite_EB_HeartPiece_handle_flags : + ; Don't change OW flags if we're STZ.w SpriteAITable, X : RTS ; getting a tablet item diff --git a/inventory.asm b/inventory.asm index fcbed68..c863bcb 100644 --- a/inventory.asm +++ b/inventory.asm @@ -648,16 +648,23 @@ RTL CollectPowder: LDY.w SprSourceItemId, X ; Retrieve stored item type BNE + - ; if for any reason the item value is 0 reload it, just in case - %GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) : TAY - + PHA - LDA.l WitchItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID - LDA.b #$01 : STA.l ShopEnableCount + ; if for any reason the item value is 0 reload it, just in case + %GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) : TAY + + + PHA + JSL ShieldCheck + BCC .skip + + + LDA.l WitchItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID + LDA.b #$01 : STA.l ShopEnableCount PLA STZ.w ItemReceiptMethod ; item from NPC JSL Link_ReceiveItem - PHA : LDA.b #$00 : STA.l ShopEnableCount : STA.l PowderFlag : PLA + PHA : LDA.b #$00 : STA.l ShopEnableCount : STA.l PowderFlag JSL ItemSet_Powder +.skip + PLA RTL ;-------------------------------------------------------------------------------- diff --git a/keydrop/standing_items.asm b/keydrop/standing_items.asm index f06ac28..7a2cbc8 100644 --- a/keydrop/standing_items.asm +++ b/keydrop/standing_items.asm @@ -696,6 +696,14 @@ KeyGet: LDA.l StandingItemsOn : BNE + PLA : RTL + LDY.w SprSourceItemId, X + + JSL ShieldCheck + BCS .not_replaced + PLA : PLA : PLA ; remove stored address to jump back to + PLA ; restore the A value going into KeyGet + JML $86D1A8 + .not_replaced + LDA.w SprItemIndex, X : STA.w SpawnedItemIndex LDA.w SprItemFlags, X : STA.w SpawnedItemFlag STY.b Scrap00 diff --git a/multiworld.asm b/multiworld.asm index 985a0df..1a1d729 100644 --- a/multiworld.asm +++ b/multiworld.asm @@ -202,13 +202,22 @@ RTL Multiworld_BottleVendor_GiveBottle: { + PHA + JSL ShieldCheck + PLA + BCC .no_take_shield + PHA : PHP SEP #$20 LDA.l BottleMerchant_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID PLP : PLA JSL Link_ReceiveItem ; thing we wrote over -RTL + RTL + +.no_take_shield + PLA : PLA : PLA : PLX + JML $85EB3A } Multiworld_MiddleAgedMan_ReactToSecretKeepingResponse: diff --git a/npcitems.asm b/npcitems.asm index 3263a0f..73e5b47 100644 --- a/npcitems.asm +++ b/npcitems.asm @@ -99,10 +99,8 @@ RTL ItemSet_OldMan: PHA - TYA : STA.b $0C JSL ShieldCheck BCC .skip - LDA.b $0C : TAY LDA.l OldManItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID PLA @@ -119,10 +117,8 @@ RTL ItemSet_SickKid: PHA - TYA : STA.b $0C JSL ShieldCheck BCC .skip - LDA.b $0C : TAY LDA.l SickKidItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID PLA @@ -135,10 +131,8 @@ RTL ItemSet_TreeKid: PHA - TYA : STA.b $0C JSL ShieldCheck BCC .skip - LDA.b $0C : TAY LDA.l TreeKidItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID PLA @@ -151,10 +145,8 @@ RTL ItemSet_Sahasrala: PHA - TYA : STA.b $0C JSL ShieldCheck BCC .skip - LDA.b $0C : TAY LDA.l SahasralaItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID PLA @@ -171,10 +163,8 @@ RTL ItemSet_Library: PHA - TYA : STA.b $0C JSL ShieldCheck BCC .skip - LDA.b $0C : TAY LDA.l LibraryItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID PLA @@ -187,15 +177,23 @@ RTL ItemSet_Mushroom: PHA - LDA.l NpcFlags+1 : ORA.b #$10 : STA.l NpcFlags+1 LDY.w SprSourceItemId, X ; Retrieve stored item type BNE + ; if for any reason the item value is 0 reload it, just in case %GetPossiblyEncryptedItem(MushroomItem, SpriteItemValues) : TAY + + + JSL ShieldCheck + BCC .skip LDA.l MushroomItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID - PLA STZ.w ItemReceiptMethod ; thing we wrote over - the mushroom is an npc for item purposes apparently + PLA + + JSL Link_ReceiveItem + PHA + LDA.l NpcFlags+1 : ORA.b #$10 : STA.l NpcFlags+1 +.skip + PLA RTL ItemSet_Powder: @@ -273,20 +271,16 @@ MarkThrownItem: LDA.b OverworldIndex : CMP.b #$81 : BNE .catfish .zora - TYA : STA.b $0C JSL ShieldCheck BCC .skip - LDA.b $0C : TAY JSL ItemSet_ZoraKing LDA.l ZoraItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID BRA .done .catfish - TYA : STA.b $0C JSL ShieldCheck BCC .skip - LDA.b $0C : TAY JSL ItemSet_Catfish LDA.l CatfishItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID diff --git a/pikit.asm b/pikit.asm index e6d9a81..ad7f3aa 100644 --- a/pikit.asm +++ b/pikit.asm @@ -74,7 +74,11 @@ LinkAwaken: RTL BigChest_ShieldCheck: + PHY + LDY.b $0C JSL ShieldCheck + STY.b $0C + PLY BCC .no_open LDA.l BigKeyField AND.l BitMasks, X @@ -82,7 +86,11 @@ BigChest_ShieldCheck: RTL SmallChest_ShieldCheck: + PHY + LDY.b $0C JSL ShieldCheck + STY.b $0C + PLY BCC .no_open LDA.w DungeonID ORA.w RoomFlagMask, Y @@ -93,7 +101,7 @@ ShieldCheck: PHP REP #$30 PHX - LDA.b $0C + TYA AND.w #$00FF TAX LDA.l PikitItemList, X @@ -110,8 +118,7 @@ ShieldCheck: BNE .already_have_shield TXA STA.l PikitItem - LDA.w #$0004 - STA.b $0C + LDY.w #$0004 PLX PLP SEC diff --git a/swordswap.asm b/swordswap.asm index 144c891..7d8863a 100644 --- a/swordswap.asm +++ b/swordswap.asm @@ -132,6 +132,10 @@ GetSmithSword: .buy LDA.l SmithItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l SmithItem : TAY + + JSL ShieldCheck + BCC .done + STZ.w ItemReceiptMethod ; Item from NPC PHX : JSL Link_ReceiveItem : PLX diff --git a/tablets.asm b/tablets.asm index 518ed6a..a96bc52 100644 --- a/tablets.asm +++ b/tablets.asm @@ -57,11 +57,32 @@ RTL MaybeUnlockTabletAnimation: PHA : PHP JSL IsMedallion : BCC + - JSR SetTabletItemFlag + JSR SetTabletItemFlag STZ.w MedallionFlag ; disable falling-medallion mode STZ.w ForceSwordUp ; release link from item-up pose LDA.b #$00 : STA.b LinkState ; set link to ground state + REP #$20 ; set 16-bit accumulator + LDA.b OverworldIndex : CMP.w #$0030 : BNE ++ ; Desert + SEP #$20 ; set 8-bit accumulator + LDA.b #$02 : STA.b LinkDirection ; face link forward + LDA.b #$3C : STA.b LinkIncapacitatedTimer ; lock link for 60f + STZ.w CutsceneFlag + ++ + SEP #$20 ; set 8-bit accumulator + + + PLP : PLA +RTL +;-------------------------------------------------------------------------------- +MaybeFreeLinkFromTablet: + PHA : PHP + JSL IsMedallion : BCC + + STZ.w MedallionFlag ; disable falling-medallion mode + STZ.w ForceSwordUp ; release link from item-up pose + LDA.b #$00 : STA.b LinkState ; set link to ground state + STZ.w CutsceneFlag + STZ.w NoDamage + REP #$20 ; set 16-bit accumulator LDA.b OverworldIndex : CMP.w #$0030 : BNE ++ ; Desert SEP #$20 ; set 8-bit accumulator