pokecrystal-board/engine/battle/consumehelditem.asm

58 lines
690 B
NASM
Raw Normal View History

ConsumeHeldItem: ; 27192
push hl
push de
push bc
ld a, [hBattleTurn]
and a
ld hl, OTPartyMon1Item
ld de, EnemyMonItem
ld a, [CurOTMon]
jr z, .theirturn
ld hl, PartyMon1Item
ld de, BattleMonItem
ld a, [CurBattleMon]
.theirturn
push hl
push af
ld a, [de]
ld b, a
2017-12-24 09:47:30 -08:00
farcall GetItemHeldEffect
2018-01-25 18:34:42 -08:00
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
2018-01-25 18:34:42 -08:00
ld [hl], NO_ITEM
.done
pop bc
pop de
pop hl
ret
2018-01-25 18:34:42 -08:00
INCLUDE "data/battle/held_consumables.asm"