Shield handling for pots and enemy drops and a few more NPCs

This commit is contained in:
2026-02-07 16:51:21 -06:00
parent 381868c3ce
commit 779c9a27ce
12 changed files with 112 additions and 40 deletions

View File

@@ -53,6 +53,12 @@ RTL
GiveBonkItem: GiveBonkItem:
LDA.w SprItemMWPlayer, X : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.w SprItemMWPlayer, X : STA.l !MULTIWORLD_ITEM_PLAYER_ID
LDA.w SprSourceItemId, X LDA.w SprSourceItemId, X
PHY : TAY
JSL ShieldCheck
TYA : PLY
BCC .done
JSR AbsorbKeyCheck : BCC .notKey JSR AbsorbKeyCheck : BCC .notKey
PHY : LDY.b #$24 : JSL AddInventory : PLY ; do inventory processing for a small key PHY : LDY.b #$24 : JSL AddInventory : PLY ; do inventory processing for a small key
LDA.l CurrentSmallKeys : INC A : STA.l CurrentSmallKeys LDA.l CurrentSmallKeys : INC A : STA.l CurrentSmallKeys
@@ -61,6 +67,7 @@ GiveBonkItem:
RTL RTL
.notKey .notKey
PHY : TAY : JSL Link_ReceiveItem : PLY PHY : TAY : JSL Link_ReceiveItem : PLY
.done
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
LoadBonkItem: LoadBonkItem:

View File

@@ -72,18 +72,27 @@ JML Dungeon_OpenKeyedObject_nextChest
TXA : LSR TXA : LSR
JSL RetrieveValueFromEncryptedTable JSL RetrieveValueFromEncryptedTable
JSL ShieldCheck
STA.b Scrap0C STA.b Scrap0C
PLA : STA.b Scrap02 : PLA : STA.b Scrap00 PLA : STA.b Scrap02 : PLA : STA.b Scrap00
LDA.l ChestData, X : ASL A : BCC .smallChest 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) JML Dungeon_OpenKeyedObject_bigChest ;(bank01.asm line #13783)
.smallChest .smallChest
JSL ShieldCheck : BCC .couldntFindChest PHY
LDY.b Scrap0C
JSL ShieldCheck
STY.b Scrap0C
PLY
BCC .couldntFindChest
JML Dungeon_OpenKeyedObject_smallChest JML Dungeon_OpenKeyedObject_smallChest
.couldntFindChest .couldntFindChest

View File

@@ -2,13 +2,20 @@
; Randomize Half Magic Bat ; Randomize Half Magic Bat
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
GetMagicBatItem: GetMagicBatItem:
JSL ItemSet_MagicBat
%GetPossiblyEncryptedItem(MagicBatItem, SpriteItemValues) %GetPossiblyEncryptedItem(MagicBatItem, SpriteItemValues)
CMP.b #$FF : BEQ .normalLogic CMP.b #$FF : BEQ .normalLogic
TAY 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 STZ.b ItemReceiptMethod ; 0 = Receiving item from an NPC or message
JML Link_ReceiveItem JML Link_ReceiveItem
.have_shield
PLA
RTL
.normalLogic .normalLogic
LDA.l HalfMagic LDA.l HalfMagic
STA.l MagicConsumption STA.l MagicConsumption

View File

@@ -11,10 +11,8 @@ HeartPieceGet:
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
HeartGet: HeartGet:
STY.b $0C
JSL ShieldCheck JSL ShieldCheck
BCC .done BCC .skip
LDY.b $0C
LDA.w SprItemMWPlayer, X : STA.l !MULTIWORLD_ITEM_PLAYER_ID 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 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 Link_ReceiveItem
JSL MaybeUnlockTabletAnimation JSL MaybeUnlockTabletAnimation
SEC SEC
.done RTL
.skip
JSL MaybeFreeLinkFromTablet
CLC
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
HeartContainerGet: HeartContainerGet:

View File

@@ -2010,7 +2010,7 @@ org $85EE53 ; <- 2EE53 - mushroom.asm : 22
JSL ItemCheck_Mushroom : NOP #2 JSL ItemCheck_Mushroom : NOP #2
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
org $85EE8C ; <- 2EE8C - mushroom.asm : 69 org $85EE8C ; <- 2EE8C - mushroom.asm : 69
JSL ItemSet_Mushroom : NOP JSL ItemSet_Mushroom : NOP #5
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
org $85F53E ; <- 2F53E - sprite_potion_shop.asm : 40 org $85F53E ; <- 2F53E - sprite_potion_shop.asm : 40
JSL ItemCheck_Powder : CMP.b #$20 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 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 JSL HeartPieceGet
PHP
JSL DynamicDrawCleanup JSL DynamicDrawCleanup
PLP : BCC +
JSL IsMedallion JSL IsMedallion
BCS + : BRA Sprite_EB_HeartPiece_handle_flags : + ; Don't change OW flags if we're BCS + : BRA Sprite_EB_HeartPiece_handle_flags : + ; Don't change OW flags if we're
STZ.w SpriteAITable, X : RTS ; getting a tablet item STZ.w SpriteAITable, X : RTS ; getting a tablet item

View File

@@ -650,14 +650,21 @@ CollectPowder:
BNE + BNE +
; if for any reason the item value is 0 reload it, just in case ; if for any reason the item value is 0 reload it, just in case
%GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) : TAY %GetPossiblyEncryptedItem(WitchItem, SpriteItemValues) : TAY
+ PHA +
PHA
JSL ShieldCheck
BCC .skip
LDA.l WitchItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l WitchItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
LDA.b #$01 : STA.l ShopEnableCount LDA.b #$01 : STA.l ShopEnableCount
PLA PLA
STZ.w ItemReceiptMethod ; item from NPC STZ.w ItemReceiptMethod ; item from NPC
JSL Link_ReceiveItem 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 JSL ItemSet_Powder
.skip
PLA
RTL RTL
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------

View File

@@ -696,6 +696,14 @@ KeyGet:
LDA.l StandingItemsOn : BNE + LDA.l StandingItemsOn : BNE +
PLA : RTL PLA : RTL
+ LDY.w SprSourceItemId, X + 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 SprItemIndex, X : STA.w SpawnedItemIndex
LDA.w SprItemFlags, X : STA.w SpawnedItemFlag LDA.w SprItemFlags, X : STA.w SpawnedItemFlag
STY.b Scrap00 STY.b Scrap00

View File

@@ -202,13 +202,22 @@ RTL
Multiworld_BottleVendor_GiveBottle: Multiworld_BottleVendor_GiveBottle:
{ {
PHA
JSL ShieldCheck
PLA
BCC .no_take_shield
PHA : PHP PHA : PHP
SEP #$20 SEP #$20
LDA.l BottleMerchant_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l BottleMerchant_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
PLP : PLA PLP : PLA
JSL Link_ReceiveItem ; thing we wrote over JSL Link_ReceiveItem ; thing we wrote over
RTL RTL
.no_take_shield
PLA : PLA : PLA : PLX
JML $85EB3A
} }
Multiworld_MiddleAgedMan_ReactToSecretKeepingResponse: Multiworld_MiddleAgedMan_ReactToSecretKeepingResponse:

View File

@@ -99,10 +99,8 @@ RTL
ItemSet_OldMan: ItemSet_OldMan:
PHA PHA
TYA : STA.b $0C
JSL ShieldCheck JSL ShieldCheck
BCC .skip BCC .skip
LDA.b $0C : TAY
LDA.l OldManItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l OldManItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
PLA PLA
@@ -119,10 +117,8 @@ RTL
ItemSet_SickKid: ItemSet_SickKid:
PHA PHA
TYA : STA.b $0C
JSL ShieldCheck JSL ShieldCheck
BCC .skip BCC .skip
LDA.b $0C : TAY
LDA.l SickKidItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l SickKidItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
PLA PLA
@@ -135,10 +131,8 @@ RTL
ItemSet_TreeKid: ItemSet_TreeKid:
PHA PHA
TYA : STA.b $0C
JSL ShieldCheck JSL ShieldCheck
BCC .skip BCC .skip
LDA.b $0C : TAY
LDA.l TreeKidItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l TreeKidItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
PLA PLA
@@ -151,10 +145,8 @@ RTL
ItemSet_Sahasrala: ItemSet_Sahasrala:
PHA PHA
TYA : STA.b $0C
JSL ShieldCheck JSL ShieldCheck
BCC .skip BCC .skip
LDA.b $0C : TAY
LDA.l SahasralaItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l SahasralaItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
PLA PLA
@@ -171,10 +163,8 @@ RTL
ItemSet_Library: ItemSet_Library:
PHA PHA
TYA : STA.b $0C
JSL ShieldCheck JSL ShieldCheck
BCC .skip BCC .skip
LDA.b $0C : TAY
LDA.l LibraryItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l LibraryItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
PLA PLA
@@ -187,15 +177,23 @@ RTL
ItemSet_Mushroom: ItemSet_Mushroom:
PHA PHA
LDA.l NpcFlags+1 : ORA.b #$10 : STA.l NpcFlags+1
LDY.w SprSourceItemId, X ; Retrieve stored item type LDY.w SprSourceItemId, X ; Retrieve stored item type
BNE + BNE +
; if for any reason the item value is 0 reload it, just in case ; if for any reason the item value is 0 reload it, just in case
%GetPossiblyEncryptedItem(MushroomItem, SpriteItemValues) : TAY %GetPossiblyEncryptedItem(MushroomItem, SpriteItemValues) : TAY
+ +
JSL ShieldCheck
BCC .skip
LDA.l MushroomItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID 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 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 RTL
ItemSet_Powder: ItemSet_Powder:
@@ -273,20 +271,16 @@ MarkThrownItem:
LDA.b OverworldIndex : CMP.b #$81 : BNE .catfish LDA.b OverworldIndex : CMP.b #$81 : BNE .catfish
.zora .zora
TYA : STA.b $0C
JSL ShieldCheck JSL ShieldCheck
BCC .skip BCC .skip
LDA.b $0C : TAY
JSL ItemSet_ZoraKing JSL ItemSet_ZoraKing
LDA.l ZoraItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l ZoraItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
BRA .done BRA .done
.catfish .catfish
TYA : STA.b $0C
JSL ShieldCheck JSL ShieldCheck
BCC .skip BCC .skip
LDA.b $0C : TAY
JSL ItemSet_Catfish JSL ItemSet_Catfish
LDA.l CatfishItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l CatfishItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID

View File

@@ -74,7 +74,11 @@ LinkAwaken:
RTL RTL
BigChest_ShieldCheck: BigChest_ShieldCheck:
PHY
LDY.b $0C
JSL ShieldCheck JSL ShieldCheck
STY.b $0C
PLY
BCC .no_open BCC .no_open
LDA.l BigKeyField LDA.l BigKeyField
AND.l BitMasks, X AND.l BitMasks, X
@@ -82,7 +86,11 @@ BigChest_ShieldCheck:
RTL RTL
SmallChest_ShieldCheck: SmallChest_ShieldCheck:
PHY
LDY.b $0C
JSL ShieldCheck JSL ShieldCheck
STY.b $0C
PLY
BCC .no_open BCC .no_open
LDA.w DungeonID LDA.w DungeonID
ORA.w RoomFlagMask, Y ORA.w RoomFlagMask, Y
@@ -93,7 +101,7 @@ ShieldCheck:
PHP PHP
REP #$30 REP #$30
PHX PHX
LDA.b $0C TYA
AND.w #$00FF AND.w #$00FF
TAX TAX
LDA.l PikitItemList, X LDA.l PikitItemList, X
@@ -110,8 +118,7 @@ ShieldCheck:
BNE .already_have_shield BNE .already_have_shield
TXA TXA
STA.l PikitItem STA.l PikitItem
LDA.w #$0004 LDY.w #$0004
STA.b $0C
PLX PLX
PLP PLP
SEC SEC

View File

@@ -132,6 +132,10 @@ GetSmithSword:
.buy .buy
LDA.l SmithItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID LDA.l SmithItem_Player : STA.l !MULTIWORLD_ITEM_PLAYER_ID
LDA.l SmithItem : TAY LDA.l SmithItem : TAY
JSL ShieldCheck
BCC .done
STZ.w ItemReceiptMethod ; Item from NPC STZ.w ItemReceiptMethod ; Item from NPC
PHX : JSL Link_ReceiveItem : PLX PHX : JSL Link_ReceiveItem : PLX

View File

@@ -62,6 +62,27 @@ MaybeUnlockTabletAnimation:
STZ.w ForceSwordUp ; release link from item-up pose STZ.w ForceSwordUp ; release link from item-up pose
LDA.b #$00 : STA.b LinkState ; set link to ground state 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 REP #$20 ; set 16-bit accumulator
LDA.b OverworldIndex : CMP.w #$0030 : BNE ++ ; Desert LDA.b OverworldIndex : CMP.w #$0030 : BNE ++ ; Desert
SEP #$20 ; set 8-bit accumulator SEP #$20 ; set 8-bit accumulator