summaryrefslogtreecommitdiff
path: root/engine/battle/consume_held_item.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/battle/consume_held_item.asm')
-rw-r--r--engine/battle/consume_held_item.asm57
1 files changed, 57 insertions, 0 deletions
diff --git a/engine/battle/consume_held_item.asm b/engine/battle/consume_held_item.asm
new file mode 100644
index 000000000..d727a44e0
--- /dev/null
+++ b/engine/battle/consume_held_item.asm
@@ -0,0 +1,57 @@
+ConsumeHeldItem: ; 27192
+ push hl
+ push de
+ push bc
+ ld 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
+ push hl
+ push af
+ ld a, [de]
+ ld b, a
+ farcall GetItemHeldEffect
+ ld hl, ConsumableEffects
+.loop
+ ld a, [hli]
+ cp b
+ jr z, .ok
+ inc a
+ jr nz, .loop
+ pop af
+ pop hl
+ pop bc
+ pop de
+ pop hl
+ ret
+
+.ok
+ xor a
+ ld [de], a
+ pop af
+ pop hl
+ call GetPartyLocation
+ ld a, [hBattleTurn]
+ and a
+ jr nz, .ourturn
+ ld a, [wBattleMode]
+ dec a
+ jr z, .done
+
+.ourturn
+ ld [hl], NO_ITEM
+
+.done
+ pop bc
+ pop de
+ pop hl
+ ret
+
+INCLUDE "data/battle/held_consumables.asm"