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,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:

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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
;--------------------------------------------------------------------------------

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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