Skip to content

Commit

Permalink
Merge pull request #28 from FredrIQ/item_backups
Browse files Browse the repository at this point in the history
ConsumeHeldItem is now a wrapper for ConsumeUserItem
  • Loading branch information
SoupPotato authored Dec 10, 2024
2 parents 33de03d + 4c69c6a commit cdcdca0
Showing 1 changed file with 9 additions and 35 deletions.
44 changes: 9 additions & 35 deletions engine/battle/consume_held_item.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@ ConsumeHeldItem:
push hl
push de
push bc
ldh a, [hBattleTurn]
and a
ld hl, wOTPartyMon1Item
ld de, wEnemyMonItem
ld a, [wCurOTMon]
jr z, .theirturn
ld hl, wPartyMon1Item
ld de, wBattleMonItem
ld a, [wCurBattleMon]

.theirturn
farcall SwitchTurnCore
farcall GetUserItem
push hl
push af
ld a, [de]
ld b, a
farcall SwitchTurnCore
pop hl
ld b, [hl]
farcall GetItemHeldEffect
ld hl, ConsumableEffects
.loop
Expand All @@ -25,29 +16,12 @@ ConsumeHeldItem:
jr z, .ok
inc a
jr nz, .loop
pop af
pop hl
pop bc
pop de
pop hl
ret
jr .done

.ok
xor a
ld [de], a
pop af
pop hl
call GetPartyLocation
ldh a, [hBattleTurn]
and a
jr nz, .ourturn
ld a, [wBattleMode]
dec a
jr z, .done

.ourturn
ld [hl], NO_ITEM

farcall SwitchTurnCore
farcall ConsumeUserItem
farcall SwitchTurnCore
.done
pop bc
pop de
Expand Down

0 comments on commit cdcdca0

Please sign in to comment.