pokecrystal-board/engine/item_effects.asm

3278 lines
47 KiB
NASM
Raw Normal View History

_DoItemEffect:: ; e722
ld a, [CurItem]
ld [wd265], a
call GetItemName
call CopyName1
ld a, 1
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
ld a, [CurItem]
dec a
ld hl, ItemEffects
rst JumpTable
ret
; e73c
ItemEffects: ; e73c
2017-12-16 09:49:43 -08:00
; entries correspond to item ids (see constants/item_constants.asm)
dw MasterBall
dw UltraBall
dw Brightpowder
dw GreatBall
dw PokeBall
dw TownMap
dw Bicycle
dw MoonStone
dw Antidote
dw BurnHeal
dw IceHeal
dw Awakening
dw ParlyzHeal
dw FullRestore
dw MaxPotion
dw HyperPotion
dw SuperPotion
dw Potion
dw EscapeRope
dw Repel
dw MaxElixer
dw FireStone
dw Thunderstone
dw WaterStone
dw Item19
2015-12-15 07:55:56 -08:00
dw HPUp
dw Protein
dw Iron
dw Carbos
dw LuckyPunch
dw Calcium
dw RareCandy
dw XAccuracy
dw LeafStone
dw MetalPowder
dw Nugget
dw PokeDoll
dw FullHeal
dw Revive
dw MaxRevive
dw GuardSpec
dw SuperRepel
dw MaxRepel
dw DireHit
dw Item2D
dw FreshWater
dw SodaPop
dw Lemonade
dw XAttack
dw Item32
dw XDefend
dw XSpeed
dw XSpecial
dw CoinCase
dw Itemfinder
dw PokeFlute
dw ExpShare
dw OldRod
dw GoodRod
dw SilverLeaf
dw SuperRod
2015-12-15 07:55:56 -08:00
dw PPUp
dw Ether
dw MaxEther
dw Elixer
dw RedScale
dw Secretpotion
dw SSTicket
dw MysteryEgg
dw ClearBell
dw SilverWing
dw MoomooMilk
dw QuickClaw
dw Psncureberry
dw GoldLeaf
dw SoftSand
dw SharpBeak
dw Przcureberry
dw BurntBerry
dw IceBerry
dw PoisonBarb
dw KingsRock
dw BitterBerry
dw MintBerry
dw RedApricorn
dw Tinymushroom
dw BigMushroom
dw Silverpowder
dw BluApricorn
dw Item5A
dw AmuletCoin
dw YlwApricorn
dw GrnApricorn
dw CleanseTag
dw MysticWater
dw Twistedspoon
dw WhtApricorn
dw Blackbelt
dw BlkApricorn
dw Item64
dw PnkApricorn
dw Blackglasses
dw Slowpoketail
dw PinkBow
dw Stick
dw SmokeBall
dw Nevermeltice
dw Magnet
dw Miracleberry
dw Pearl
dw BigPearl
dw Everstone
dw SpellTag
dw Ragecandybar
dw GsBall
dw BlueCard
dw MiracleSeed
dw ThickClub
dw FocusBand
dw Item78
dw Energypowder
dw EnergyRoot
dw HealPowder
dw RevivalHerb
dw HardStone
dw LuckyEgg
dw CardKey
dw MachinePart
dw EggTicket
dw LostItem
dw Stardust
dw StarPiece
dw BasementKey
dw Pass
dw Item87
dw Item88
dw Item89
dw Charcoal
dw BerryJuice
dw ScopeLens
dw Item8D
dw Item8E
dw MetalCoat
dw DragonFang
dw Item91
dw Leftovers
dw Item93
dw Item94
dw Item95
dw Mysteryberry
dw DragonScale
dw BerserkGene
dw Item99
dw Item9A
dw Item9B
dw SacredAsh
dw HeavyBall
dw FlowerMail
dw LevelBall
dw LureBall
dw FastBall
dw ItemA2
dw LightBall
dw FriendBall
dw MoonBall
dw LoveBall
dw NormalBox
dw GorgeousBox
dw SunStone
dw PolkadotBow
dw ItemAB
dw UpGrade
dw Berry
dw GoldBerry
dw Squirtbottle
dw ItemB0
dw ParkBall
dw RainbowWing
dw ItemB3
; e8a2
2013-05-07 23:02:15 -07:00
MasterBall:
UltraBall:
GreatBall:
PokeBall:
HeavyBall:
LevelBall:
LureBall:
FastBall:
FriendBall:
MoonBall:
LoveBall:
ParkBall: ; e8a2
ld a, [wBattleMode]
2013-05-07 23:02:15 -07:00
dec a
jp nz, UseBallInTrainerBattle
2013-05-07 23:02:15 -07:00
ld a, [PartyCount]
cp PARTY_LENGTH
jr nz, .room_in_party
ld a, BANK(sBoxCount)
2013-05-07 23:02:15 -07:00
call GetSRAMBank
ld a, [sBoxCount]
cp MONS_PER_BOX
2013-05-07 23:02:15 -07:00
call CloseSRAM
jp z, Ball_BoxIsFullMessage
2013-05-07 23:02:15 -07:00
.room_in_party
2013-05-07 23:02:15 -07:00
xor a
2015-11-09 13:41:09 -08:00
ld [wWildMon], a
2013-05-07 23:02:15 -07:00
ld a, [CurItem]
cp PARK_BALL
call nz, ReturnToBattle_UseBall
2013-05-07 23:02:15 -07:00
ld hl, Options
res NO_TEXT_SCROLL, [hl]
ld hl, UsedItemText
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
ld a, [EnemyMonCatchRate]
ld b, a
ld a, [BattleType]
cp BATTLETYPE_TUTORIAL
jp z, .catch_without_fail
2013-05-07 23:02:15 -07:00
ld a, [CurItem]
cp MASTER_BALL
jp z, .catch_without_fail
2013-05-07 23:02:15 -07:00
ld a, [CurItem]
ld c, a
ld hl, BallMultiplierFunctionTable
2013-05-07 23:02:15 -07:00
.get_multiplier_loop
2013-05-07 23:02:15 -07:00
ld a, [hli]
cp $ff
jr z, .skip_or_return_from_ball_fn
2013-05-07 23:02:15 -07:00
cp c
jr z, .call_ball_function
2013-05-07 23:02:15 -07:00
inc hl
inc hl
jr .get_multiplier_loop
2013-05-07 23:02:15 -07:00
.call_ball_function
2013-05-07 23:02:15 -07:00
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .skip_or_return_from_ball_fn
2013-05-07 23:02:15 -07:00
push de
jp hl
2013-05-07 23:02:15 -07:00
.skip_or_return_from_ball_fn
2013-05-07 23:02:15 -07:00
ld a, [CurItem]
2013-12-24 14:11:52 -08:00
cp LEVEL_BALL
2013-05-07 23:02:15 -07:00
ld a, b
jp z, .skip_hp_calc
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
ld a, b
ld [hMultiplicand + 2], a
2013-12-24 14:11:52 -08:00
ld hl, EnemyMonHP
2013-05-07 23:02:15 -07:00
ld b, [hl]
inc hl
ld c, [hl]
inc hl
ld d, [hl]
inc hl
ld e, [hl]
sla c
rl b
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
ld h, d
ld l, e
add hl, de
add hl, de
2013-05-07 23:02:15 -07:00
ld d, h
ld e, l
ld a, d
and a
jr z, .okay_1
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
srl d
rr e
srl d
rr e
srl b
rr c
srl b
rr c
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
ld a, c
and a
jr nz, .okay_1
2013-05-07 23:02:15 -07:00
ld c, $1
.okay_1
2013-05-07 23:02:15 -07:00
ld b, e
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
push bc
ld a, b
sub c
ld [hMultiplier], a
xor a
ld [hDividend + 0], a
ld [hMultiplicand + 0], a
ld [hMultiplicand + 1], a
2013-05-07 23:02:15 -07:00
call Multiply
pop bc
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
ld a, b
ld [hDivisor], a
2013-05-07 23:02:15 -07:00
ld b, $4
call Divide
ld a, [hQuotient + 2]
2013-05-07 23:02:15 -07:00
and a
jr nz, .statuscheck
ld a, 1
.statuscheck
; This routine is buggy. It was intended that SLP and FRZ provide a higher
; catch rate than BRN/PSN/PAR, which in turn provide a higher catch rate than
; no status effect at all. But instead, it makes BRN/PSN/PAR provide no
; benefit.
2016-03-27 09:47:28 -07:00
; Uncomment the line below to fix this.
2013-05-07 23:02:15 -07:00
ld b, a
ld a, [EnemyMonStatus]
2013-12-24 14:11:52 -08:00
and 1 << FRZ | SLP
ld c, 10
jr nz, .addstatus
2016-03-27 09:47:28 -07:00
; ld a, [EnemyMonStatus]
2013-05-07 23:02:15 -07:00
and a
2013-12-24 14:11:52 -08:00
ld c, 5
jr nz, .addstatus
2013-12-24 14:11:52 -08:00
ld c, 0
.addstatus
2013-05-07 23:02:15 -07:00
ld a, b
add c
jr nc, .max_1
2013-05-07 23:02:15 -07:00
ld a, $ff
.max_1
2013-05-07 23:02:15 -07:00
ld d, a
push de
2017-12-24 09:47:30 -08:00
; BUG: farcall overwrites a,
; and GetItemHeldEffect takes b anyway.
; This is probably the reason
; the HELD_CATCH_CHANCE effect
; is never used.
; Uncomment the line below to fix.
2013-05-07 23:02:15 -07:00
ld a, [BattleMonItem]
; ld b, a
2017-12-24 09:47:30 -08:00
farcall GetItemHeldEffect
2013-05-07 23:02:15 -07:00
ld a, b
cp HELD_CATCH_CHANCE
2013-05-07 23:02:15 -07:00
pop de
ld a, d
jr nz, .skip_hp_calc
2013-05-07 23:02:15 -07:00
add c
jr nc, .skip_hp_calc
2013-05-07 23:02:15 -07:00
ld a, $ff
.skip_hp_calc
2013-05-07 23:02:15 -07:00
ld b, a
ld [Buffer1], a
call Random
2013-05-07 23:02:15 -07:00
cp b
2013-12-24 14:11:52 -08:00
ld a, 0
jr z, .catch_without_fail
jr nc, .fail_to_catch
2013-05-07 23:02:15 -07:00
.catch_without_fail
2013-05-07 23:02:15 -07:00
ld a, [EnemyMonSpecies]
.fail_to_catch
2015-11-09 13:41:09 -08:00
ld [wWildMon], a
2013-12-24 14:11:52 -08:00
ld c, 20
2013-05-07 23:02:15 -07:00
call DelayFrames
ld a, [CurItem]
cp POKE_BALL + 1 ; Assumes Master/Ultra/Great come before
jr c, .not_kurt_ball
2013-12-24 14:11:52 -08:00
ld a, POKE_BALL
.not_kurt_ball
2016-01-27 09:25:12 -08:00
ld [wBattleAnimParam], a
2013-12-24 14:11:52 -08:00
ld de, ANIM_THROW_POKE_BALL
2013-05-07 23:02:15 -07:00
ld a, e
2017-12-09 16:41:03 -08:00
ld [FXAnimID], a
2013-05-07 23:02:15 -07:00
ld a, d
2017-12-09 16:41:03 -08:00
ld [FXAnimID + 1], a
2013-05-07 23:02:15 -07:00
xor a
ld [hBattleTurn], a
ld [Buffer2], a
2015-12-23 11:00:29 -08:00
ld [wNumHits], a
predef PlayBattleAnim
2013-05-07 23:02:15 -07:00
2015-11-09 13:41:09 -08:00
ld a, [wWildMon]
2013-05-07 23:02:15 -07:00
and a
jr nz, .caught
2013-05-07 23:02:15 -07:00
ld a, [Buffer2]
cp $1
ld hl, Text_NoShake
jp z, .shake_and_break_free
2013-05-07 23:02:15 -07:00
cp $2
ld hl, Text_OneShake
jp z, .shake_and_break_free
2013-05-07 23:02:15 -07:00
cp $3
ld hl, Text_TwoShakes
jp z, .shake_and_break_free
2013-05-07 23:02:15 -07:00
cp $4
ld hl, Text_ThreeShakes
jp z, .shake_and_break_free
.caught
2013-05-07 23:02:15 -07:00
ld hl, EnemyMonStatus
ld a, [hli]
push af
inc hl
ld a, [hli]
push af
ld a, [hl]
push af
push hl
ld hl, EnemyMonItem
ld a, [hl]
push af
push hl
ld hl, EnemySubStatus5
ld a, [hl]
push af
set SUBSTATUS_TRANSFORMED, [hl]
2017-12-19 16:04:56 -08:00
; This code is buggy. Any wild Pokémon that has Transformed will be
; caught as a Ditto, even if it was something else like Mew.
; To fix, do not set [TempEnemyMonSpecies] to DITTO.
bit SUBSTATUS_TRANSFORMED, a
2016-01-10 14:44:09 -08:00
jr nz, .ditto
jr .not_ditto
2013-05-07 23:02:15 -07:00
2016-01-10 14:44:09 -08:00
.ditto
2013-12-24 14:11:52 -08:00
ld a, DITTO
2013-05-07 23:02:15 -07:00
ld [TempEnemyMonSpecies], a
2016-01-10 14:44:09 -08:00
jr .load_data
2013-05-07 23:02:15 -07:00
2016-01-10 14:44:09 -08:00
.not_ditto
set SUBSTATUS_TRANSFORMED, [hl]
ld hl, wEnemyBackupDVs
ld a, [EnemyMonDVs]
2013-05-07 23:02:15 -07:00
ld [hli], a
ld a, [EnemyMonDVs + 1]
2013-05-07 23:02:15 -07:00
ld [hl], a
2016-01-10 14:44:09 -08:00
.load_data
2013-05-07 23:02:15 -07:00
ld a, [TempEnemyMonSpecies]
ld [CurPartySpecies], a
ld a, [EnemyMonLevel]
ld [CurPartyLevel], a
2017-12-24 09:47:30 -08:00
farcall LoadEnemyMon
2013-05-07 23:02:15 -07:00
pop af
ld [EnemySubStatus5], a
2013-05-07 23:02:15 -07:00
pop hl
pop af
ld [hl], a
pop hl
pop af
ld [hld], a
pop af
ld [hld], a
dec hl
pop af
ld [hl], a
2013-05-07 23:02:15 -07:00
ld hl, EnemySubStatus5
bit SUBSTATUS_TRANSFORMED, [hl]
jr nz, .Transformed
2015-11-09 13:41:09 -08:00
ld hl, wWildMonMoves
ld de, EnemyMonMoves
ld bc, NUM_MOVES
2013-05-07 23:02:15 -07:00
call CopyBytes
2015-11-09 13:41:09 -08:00
ld hl, wWildMonPP
ld de, EnemyMonPP
ld bc, NUM_MOVES
2013-05-07 23:02:15 -07:00
call CopyBytes
.Transformed:
2013-05-07 23:02:15 -07:00
ld a, [EnemyMonSpecies]
2015-11-09 13:41:09 -08:00
ld [wWildMon], a
2013-05-07 23:02:15 -07:00
ld [CurPartySpecies], a
ld [wd265], a
2013-05-07 23:02:15 -07:00
ld a, [BattleType]
cp BATTLETYPE_TUTORIAL
jp z, .FinishTutorial
2017-12-24 09:47:30 -08:00
farcall TrainerRankings_WildMonsCaught
2013-05-07 23:02:15 -07:00
ld hl, Text_GotchaMonWasCaught
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
call ClearSprites
ld a, [wd265]
2013-05-07 23:02:15 -07:00
dec a
2013-12-24 14:11:52 -08:00
call CheckCaughtMon
2013-05-07 23:02:15 -07:00
ld a, c
push af
ld a, [wd265]
2013-05-07 23:02:15 -07:00
dec a
2013-12-24 14:11:52 -08:00
call SetSeenAndCaughtMon
2013-05-07 23:02:15 -07:00
pop af
and a
jr nz, .skip_pokedex
2013-05-07 23:02:15 -07:00
call CheckReceivedDex
jr z, .skip_pokedex
ld hl, Text_AddedToPokedex
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
call ClearSprites
ld a, [EnemyMonSpecies]
ld [wd265], a
predef NewPokedexEntry
2013-05-07 23:02:15 -07:00
.skip_pokedex
2013-05-07 23:02:15 -07:00
ld a, [BattleType]
cp BATTLETYPE_CONTEST
jp z, .catch_bug_contest_mon
cp BATTLETYPE_CELEBI
jr nz, .not_celebi
2015-10-24 07:34:19 -07:00
ld hl, wBattleResult
2013-05-07 23:02:15 -07:00
set 6, [hl]
.not_celebi
2013-05-07 23:02:15 -07:00
ld a, [PartyCount]
cp PARTY_LENGTH
jr z, .SendToPC
2013-12-24 14:11:52 -08:00
xor a ; PARTYMON
2013-05-07 23:02:15 -07:00
ld [MonType], a
call ClearSprites
predef TryAddMonToParty
2013-05-07 23:02:15 -07:00
2017-12-24 09:47:30 -08:00
farcall SetCaughtData
2013-05-07 23:02:15 -07:00
ld a, [CurItem]
2013-12-24 14:11:52 -08:00
cp FRIEND_BALL
jr nz, .SkipPartyMonFriendBall
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
ld a, [PartyCount]
dec a
ld hl, PartyMon1Happiness
ld bc, PARTYMON_STRUCT_LENGTH
2013-05-07 23:02:15 -07:00
call AddNTimes
ld a, FRIEND_BALL_HAPPINESS
2013-05-07 23:02:15 -07:00
ld [hl], a
.SkipPartyMonFriendBall:
ld hl, Text_AskNicknameNewlyCaughtMon
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
ld a, [CurPartySpecies]
ld [wd265], a
2013-12-24 14:11:52 -08:00
call GetPokemonName
2013-05-07 23:02:15 -07:00
2013-12-03 23:49:12 -08:00
call YesNoBox
jp c, .return_from_capture
2013-05-07 23:02:15 -07:00
ld a, [PartyCount]
dec a
ld [CurPartyMon], a
ld hl, PartyMonNicknames
2013-12-24 14:11:52 -08:00
ld bc, PKMN_NAME_LENGTH
2013-05-07 23:02:15 -07:00
call AddNTimes
ld d, h
ld e, l
push de
xor a ; PARTYMON
2013-05-07 23:02:15 -07:00
ld [MonType], a
2013-12-24 14:11:52 -08:00
ld b, 0
2017-12-24 09:47:30 -08:00
farcall NamingScreen
2013-05-07 23:02:15 -07:00
2015-11-20 08:47:52 -08:00
call RotateThreePalettesRight
2013-05-07 23:02:15 -07:00
2015-11-04 13:14:27 -08:00
call LoadStandardFont
2013-05-07 23:02:15 -07:00
pop hl
ld de, StringBuffer1
2013-07-29 20:58:02 -07:00
call InitName
2013-05-07 23:02:15 -07:00
jp .return_from_capture
2013-05-07 23:02:15 -07:00
.SendToPC:
2013-05-07 23:02:15 -07:00
call ClearSprites
2015-08-30 04:17:14 -07:00
predef SentPkmnIntoBox
2013-05-07 23:02:15 -07:00
2017-12-24 09:47:30 -08:00
farcall SetBoxMonCaughtData
2013-05-07 23:02:15 -07:00
ld a, BANK(sBoxCount)
2013-05-07 23:02:15 -07:00
call GetSRAMBank
ld a, [sBoxCount]
cp MONS_PER_BOX
jr nz, .BoxNotFullYet
2015-10-24 07:34:19 -07:00
ld hl, wBattleResult
2013-05-07 23:02:15 -07:00
set 7, [hl]
.BoxNotFullYet:
2013-05-07 23:02:15 -07:00
ld a, [CurItem]
2013-12-24 14:11:52 -08:00
cp FRIEND_BALL
jr nz, .SkipBoxMonFriendBall
; The captured mon is now first in the box
ld a, FRIEND_BALL_HAPPINESS
ld [sBoxMon1Happiness], a
.SkipBoxMonFriendBall:
2013-05-07 23:02:15 -07:00
call CloseSRAM
ld hl, Text_AskNicknameNewlyCaughtMon
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
ld a, [CurPartySpecies]
ld [wd265], a
2013-12-24 14:11:52 -08:00
call GetPokemonName
2013-05-07 23:02:15 -07:00
2013-12-03 23:49:12 -08:00
call YesNoBox
jr c, .SkipBoxMonNickname
2013-05-07 23:02:15 -07:00
xor a
ld [CurPartyMon], a
ld a, BOXMON
2013-05-07 23:02:15 -07:00
ld [MonType], a
2015-12-18 17:07:09 -08:00
ld de, wMonOrItemNameBuffer
2013-05-07 23:02:15 -07:00
ld b, $0
2017-12-24 09:47:30 -08:00
farcall NamingScreen
2013-05-07 23:02:15 -07:00
2015-10-04 11:14:51 -07:00
ld a, BANK(sBoxMonNicknames)
2013-05-07 23:02:15 -07:00
call GetSRAMBank
2015-12-18 17:07:09 -08:00
ld hl, wMonOrItemNameBuffer
2015-10-04 11:14:51 -07:00
ld de, sBoxMonNicknames
ld bc, PKMN_NAME_LENGTH
2013-05-07 23:02:15 -07:00
call CopyBytes
2015-10-04 11:14:51 -07:00
ld hl, sBoxMonNicknames
2013-05-07 23:02:15 -07:00
ld de, StringBuffer1
2013-07-29 20:58:02 -07:00
call InitName
2013-05-07 23:02:15 -07:00
call CloseSRAM
.SkipBoxMonNickname:
2015-10-04 11:14:51 -07:00
ld a, BANK(sBoxMonNicknames)
2013-05-07 23:02:15 -07:00
call GetSRAMBank
2015-10-04 11:14:51 -07:00
ld hl, sBoxMonNicknames
2015-12-18 17:07:09 -08:00
ld de, wMonOrItemNameBuffer
2015-10-04 11:14:51 -07:00
ld bc, PKMN_NAME_LENGTH
2013-05-07 23:02:15 -07:00
call CopyBytes
call CloseSRAM
ld hl, Text_SentToBillsPC
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
2015-11-20 08:47:52 -08:00
call RotateThreePalettesRight
2015-11-04 13:14:27 -08:00
call LoadStandardFont
jr .return_from_capture
2013-05-07 23:02:15 -07:00
.catch_bug_contest_mon
2017-12-24 09:47:30 -08:00
farcall BugContest_SetCaughtContestMon
jr .return_from_capture
2013-05-07 23:02:15 -07:00
.FinishTutorial:
ld hl, Text_GotchaMonWasCaught
2013-05-07 23:02:15 -07:00
.shake_and_break_free
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
call ClearSprites
.return_from_capture
2013-05-07 23:02:15 -07:00
ld a, [BattleType]
2013-12-24 14:11:52 -08:00
cp BATTLETYPE_TUTORIAL
2013-05-07 23:02:15 -07:00
ret z
2015-09-09 16:27:07 -07:00
cp BATTLETYPE_DEBUG
2013-05-07 23:02:15 -07:00
ret z
cp BATTLETYPE_CONTEST
jr z, .used_park_ball
2013-12-24 14:11:52 -08:00
2015-11-09 13:41:09 -08:00
ld a, [wWildMon]
2013-05-07 23:02:15 -07:00
and a
jr z, .toss
2013-05-07 23:02:15 -07:00
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
2013-05-07 23:02:15 -07:00
call ClearTileMap
.toss
2013-05-07 23:02:15 -07:00
ld hl, NumItems
inc a
2015-11-01 15:13:31 -08:00
ld [wItemQuantityChangeBuffer], a
2013-12-24 14:11:52 -08:00
jp TossItem
2013-05-07 23:02:15 -07:00
.used_park_ball
2015-11-08 10:27:26 -08:00
ld hl, wParkBallsRemaining
2013-05-07 23:02:15 -07:00
dec [hl]
ret
; ec0a
BallMultiplierFunctionTable:
; table of routines that increase or decrease the catch rate based on
; which ball is used in a certain situation.
dbw ULTRA_BALL, UltraBallMultiplier
dbw GREAT_BALL, GreatBallMultiplier
dbw SAFARI_BALL, SafariBallMultiplier ; Safari Ball, leftover from RBY
dbw HEAVY_BALL, HeavyBallMultiplier
dbw LEVEL_BALL, LevelBallMultiplier
dbw LURE_BALL, LureBallMultiplier
dbw FAST_BALL, FastBallMultiplier
dbw MOON_BALL, MoonBallMultiplier
dbw LOVE_BALL, LoveBallMultiplier
dbw PARK_BALL, ParkBallMultiplier
2018-01-10 19:53:42 -08:00
db -1 ; end
2013-05-08 00:27:46 -07:00
UltraBallMultiplier:
; multiply catch rate by 2
2013-05-08 00:27:46 -07:00
sla b
ret nc
ld b, $ff
ret
2014-10-23 23:43:50 -07:00
SafariBallMultiplier:
GreatBallMultiplier:
2014-10-23 23:43:50 -07:00
ParkBallMultiplier:
; multiply catch rate by 1.5
2013-05-08 00:27:46 -07:00
ld a, b
srl a
add b
ld b, a
ret nc
ld b, $ff
ret
GetPokedexEntryBank:
2013-05-27 20:28:21 -07:00
push hl
push de
ld a, [EnemyMonSpecies]
rlca
rlca
and 3
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
add hl, de
ld a, [hl]
pop de
pop hl
ret
2013-05-08 00:27:46 -07:00
.PokedexEntryBanks:
GLOBAL PokedexEntries1
GLOBAL PokedexEntries2
GLOBAL PokedexEntries3
GLOBAL PokedexEntries4
2013-05-27 20:28:21 -07:00
db BANK(PokedexEntries1)
db BANK(PokedexEntries2)
db BANK(PokedexEntries3)
db BANK(PokedexEntries4)
2013-05-08 00:27:46 -07:00
HeavyBallMultiplier:
; subtract 20 from catch rate if weight < 102.4 kg
; else add 0 to catch rate if weight < 204.8 kg
; else add 20 to catch rate if weight < 307.2 kg
; else add 30 to catch rate if weight < 409.6 kg
; else add 40 to catch rate (never happens)
2013-05-08 00:27:46 -07:00
ld a, [EnemyMonSpecies]
2013-05-27 20:28:21 -07:00
ld hl, PokedexDataPointerTable
2013-05-08 00:27:46 -07:00
dec a
ld e, a
2013-05-27 20:28:21 -07:00
ld d, 0
2013-05-08 00:27:46 -07:00
add hl, de
add hl, de
2013-05-27 20:28:21 -07:00
ld a, BANK(PokedexDataPointerTable)
2013-05-08 00:27:46 -07:00
call GetFarHalfword
.SkipText:
2013-05-27 20:28:21 -07:00
call GetPokedexEntryBank
2013-05-08 00:27:46 -07:00
call GetFarByte
inc hl
2013-05-27 20:28:21 -07:00
cp "@"
jr nz, .SkipText
2013-05-08 00:27:46 -07:00
2013-05-27 20:28:21 -07:00
call GetPokedexEntryBank
2013-05-08 00:27:46 -07:00
push bc
inc hl
inc hl
2013-05-08 00:27:46 -07:00
call GetFarHalfword
srl h
rr l
ld b, h
ld c, l
rept 4
2013-05-08 00:27:46 -07:00
srl b
rr c
endr
call .subbc
2013-05-08 00:27:46 -07:00
srl b
rr c
call .subbc
2013-05-08 00:27:46 -07:00
ld a, h
pop bc
jr .compare
2013-05-08 00:27:46 -07:00
.subbc
; subtract bc from hl
2013-05-08 00:27:46 -07:00
push bc
ld a, b
cpl
ld b, a
ld a, c
cpl
ld c, a
inc bc
add hl, bc
pop bc
ret
.compare
2013-05-08 00:27:46 -07:00
ld c, a
cp HIGH(1024) ; 102.4 kg
jr c, .lightmon
2013-05-08 00:27:46 -07:00
ld hl, .WeightsTable
.lookup
2013-05-08 00:27:46 -07:00
ld a, c
cp [hl]
jr c, .heavymon
2013-05-08 00:27:46 -07:00
inc hl
inc hl
jr .lookup
2013-05-08 00:27:46 -07:00
.heavymon
2013-05-08 00:27:46 -07:00
inc hl
ld a, b
add [hl]
ld b, a
ret nc
ld b, $ff
ret
.lightmon
2013-05-08 00:27:46 -07:00
ld a, b
2013-05-27 20:28:21 -07:00
sub 20
2013-05-08 00:27:46 -07:00
ld b, a
ret nc
ld b, $1
ret
.WeightsTable:
; weight factor, boost
db HIGH(2048), 0
db HIGH(3072), 20
db HIGH(4096), 30
db HIGH(65280), 40
2013-05-08 00:27:46 -07:00
LureBallMultiplier:
; multiply catch rate by 3 if this is a fishing rod battle
2013-05-08 00:27:46 -07:00
ld a, [BattleType]
cp BATTLETYPE_FISH
2013-05-08 00:27:46 -07:00
ret nz
2013-05-08 00:27:46 -07:00
ld a, b
add a
jr c, .max
2013-05-08 00:27:46 -07:00
add b
jr nc, .done
.max
2013-05-08 00:27:46 -07:00
ld a, $ff
.done
2013-05-08 00:27:46 -07:00
ld b, a
ret
MoonBallMultiplier:
; This function is buggy.
; Intent: multiply catch rate by 4 if mon evolves with moon stone
; Reality: no boost
GLOBAL EvosAttacks
GLOBAL EvosAttacksPointers
2013-05-08 00:27:46 -07:00
push bc
ld a, [TempEnemyMonSpecies]
dec a
ld c, a
ld b, 0
ld hl, EvosAttacksPointers
2013-05-08 00:27:46 -07:00
add hl, bc
add hl, bc
ld a, BANK(EvosAttacksPointers)
2013-05-08 00:27:46 -07:00
call GetFarHalfword
pop bc
2013-05-08 00:27:46 -07:00
push bc
ld a, BANK(EvosAttacks)
2013-05-08 00:27:46 -07:00
call GetFarByte
cp EVOLVE_ITEM
2013-05-08 00:27:46 -07:00
pop bc
ret nz
2013-05-08 00:27:46 -07:00
inc hl
inc hl
inc hl
; Moon Stone's constant from Pokémon Red is used.
; No Pokémon evolve with Burn Heal,
; so Moon Balls always have a catch rate of 1×.
2013-05-08 00:27:46 -07:00
push bc
ld a, BANK(EvosAttacks)
2013-05-08 00:27:46 -07:00
call GetFarByte
2014-10-23 23:43:50 -07:00
cp MOON_STONE_RED ; BURN_HEAL
2013-05-08 00:27:46 -07:00
pop bc
ret nz
sla b
jr c, .max
sla b
jr nc, .done
.max
2013-05-08 00:27:46 -07:00
ld b, $ff
.done
2013-05-08 00:27:46 -07:00
ret
LoveBallMultiplier:
; This function is buggy.
; Intent: multiply catch rate by 8 if mons are of same species, different sex
; Reality: multiply catch rate by 8 if mons are of same species, same sex
2013-05-08 00:27:46 -07:00
; does species match?
2013-05-08 00:27:46 -07:00
ld a, [TempEnemyMonSpecies]
ld c, a
ld a, [TempBattleMonSpecies]
cp c
ret nz
2013-08-03 13:19:29 -07:00
; check player mon species
2013-05-08 00:27:46 -07:00
push bc
ld a, [TempBattleMonSpecies]
ld [CurPartySpecies], a
xor a ; PARTYMON
2013-05-08 00:27:46 -07:00
ld [MonType], a
ld a, [CurBattleMon]
ld [CurPartyMon], a
2017-12-24 09:47:30 -08:00
farcall GetGender
jr c, .done1 ; no effect on genderless
2013-05-08 00:27:46 -07:00
ld d, 0 ; male
jr nz, .playermale
inc d ; female
.playermale
2013-08-03 13:19:29 -07:00
; check wild mon species
2013-05-08 00:27:46 -07:00
push de
ld a, [TempEnemyMonSpecies]
ld [CurPartySpecies], a
ld a, WILDMON
2013-05-08 00:27:46 -07:00
ld [MonType], a
2017-12-24 09:47:30 -08:00
farcall GetGender
jr c, .done2 ; no effect on genderless
2013-05-08 00:27:46 -07:00
ld d, 0 ; male
jr nz, .wildmale
inc d ; female
.wildmale
2013-08-03 13:19:29 -07:00
2013-05-08 00:27:46 -07:00
ld a, d
pop de
cp d
pop bc
2017-12-12 17:15:07 -08:00
ret nz ; for the intended effect, this should be "ret z"
2013-08-03 13:19:29 -07:00
2013-05-08 00:27:46 -07:00
sla b
jr c, .max
2013-05-08 00:27:46 -07:00
sla b
jr c, .max
2013-05-08 00:27:46 -07:00
sla b
ret nc
.max
2013-05-08 00:27:46 -07:00
ld b, $ff
ret
.done2
2013-05-08 00:27:46 -07:00
pop de
.done1
2013-05-08 00:27:46 -07:00
pop bc
ret
FastBallMultiplier:
; This function is buggy.
; Intent: multiply catch rate by 4 if enemy mon is in one of the three
; FleeMons tables.
; Reality: multiply catch rate by 4 if enemy mon is one of the first three in
; the first FleeMons table.
2013-05-08 00:27:46 -07:00
ld a, [TempEnemyMonSpecies]
ld c, a
2013-12-24 14:19:39 -08:00
ld hl, FleeMons
ld d, 3
2013-05-08 00:27:46 -07:00
2013-12-24 14:19:39 -08:00
.loop
ld a, BANK(FleeMons)
2013-05-08 00:27:46 -07:00
call GetFarByte
inc hl
2013-12-24 14:19:39 -08:00
cp -1
jr z, .next
2013-05-08 00:27:46 -07:00
cp c
2017-12-12 17:15:07 -08:00
jr nz, .next ; for the intended effect, this should be "jr nz, .loop"
2013-05-08 00:27:46 -07:00
sla b
2013-12-24 14:19:39 -08:00
jr c, .max
2013-05-08 00:27:46 -07:00
sla b
ret nc
2013-12-24 14:19:39 -08:00
.max
2013-05-08 00:27:46 -07:00
ld b, $ff
ret
2013-12-24 14:19:39 -08:00
.next
2013-05-08 00:27:46 -07:00
dec d
2013-12-24 14:19:39 -08:00
jr nz, .loop
2013-05-08 00:27:46 -07:00
ret
LevelBallMultiplier:
; multiply catch rate by 8 if player mon level / 4 > enemy mon level
; multiply catch rate by 4 if player mon level / 2 > enemy mon level
; multiply catch rate by 2 if player mon level > enemy mon level
2013-05-08 00:27:46 -07:00
ld a, [BattleMonLevel]
ld c, a
ld a, [EnemyMonLevel]
cp c
ret nc ; if player is lower level, we're done here
2013-05-08 00:27:46 -07:00
sla b
jr c, .max
2013-05-08 00:27:46 -07:00
srl c
cp c
ret nc ; if player/2 is lower level, we're done here
2013-05-08 00:27:46 -07:00
sla b
jr c, .max
2013-05-08 00:27:46 -07:00
srl c
cp c
ret nc ; if player/4 is lower level, we're done here
2013-05-08 00:27:46 -07:00
sla b
ret nc
.max
2013-05-08 00:27:46 -07:00
ld b, $ff
ret
; These two texts were carried over from gen 1.
; They are not used in gen 2, and are dummied out.
Text_RBY_CatchMarowak: ; 0xedab
2013-12-24 14:11:52 -08:00
; It dodged the thrown BALL! This #MON can't be caught!
text_jump UnknownText_0x1c5a5a
db "@"
; 0xedb0
Text_RBY_NoShake: ; 0xedb0
2013-12-24 14:11:52 -08:00
; You missed the #MON!
text_jump UnknownText_0x1c5a90
db "@"
; 0xedb5
Text_NoShake: ; 0xedb5
2013-12-24 14:11:52 -08:00
; Oh no! The #MON broke free!
text_jump UnknownText_0x1c5aa6
db "@"
; 0xedba
Text_OneShake: ; 0xedba
2013-12-24 14:11:52 -08:00
; Aww! It appeared to be caught!
text_jump UnknownText_0x1c5ac3
db "@"
; 0xedbf
Text_TwoShakes: ; 0xedbf
2013-12-24 14:11:52 -08:00
; Aargh! Almost had it!
text_jump UnknownText_0x1c5ae3
db "@"
; 0xedc4
Text_ThreeShakes: ; 0xedc4
2013-12-24 14:11:52 -08:00
; Shoot! It was so close too!
text_jump UnknownText_0x1c5afa
db "@"
; 0xedc9
Text_GotchaMonWasCaught: ; 0xedc9
2013-12-24 14:11:52 -08:00
; Gotcha! @ was caught!@ @
text_jump UnknownText_0x1c5b17
start_asm
call WaitSFX
push bc
ld de, MUSIC_NONE
call PlayMusic
call DelayFrame
ld de, MUSIC_CAPTURE
call PlayMusic
pop bc
2015-10-10 04:45:39 -07:00
ld hl, TextJump_Waitbutton
2013-12-24 14:11:52 -08:00
ret
; ede6
2015-10-10 04:45:39 -07:00
TextJump_Waitbutton: ; 0xede6
2013-12-24 14:11:52 -08:00
; @
2015-10-10 04:45:39 -07:00
text_jump Text_Waitbutton_2
2013-12-24 14:11:52 -08:00
db "@"
; 0xedeb
Text_SentToBillsPC: ; 0xedeb
2013-12-24 14:11:52 -08:00
; was sent to BILL's PC.
text_jump UnknownText_0x1c5b38
db "@"
; 0xedf0
Text_AddedToPokedex: ; 0xedf0
2013-12-24 14:11:52 -08:00
; 's data was newly added to the #DEX.@ @
text_jump UnknownText_0x1c5b53
db "@"
; 0xedf5
Text_AskNicknameNewlyCaughtMon: ; 0xedf5
2013-12-24 14:11:52 -08:00
; Give a nickname to @ ?
text_jump UnknownText_0x1c5b7f
db "@"
; 0xedfa
2013-05-07 23:02:15 -07:00
ReturnToBattle_UseBall: ; edfa (3:6dfa)
2017-12-24 09:47:30 -08:00
farcall _ReturnToBattle_UseBall
2013-10-01 21:53:35 -07:00
ret
2013-05-07 23:02:15 -07:00
TownMap: ; ee01
2017-12-24 09:47:30 -08:00
farcall PokegearMap
2013-05-07 23:02:15 -07:00
ret
; ee08
Bicycle: ; ee08
2017-12-24 09:47:30 -08:00
farcall BikeFunction
2013-05-07 23:02:15 -07:00
ret
; ee0f
MoonStone:
FireStone:
Thunderstone:
WaterStone:
LeafStone:
SunStone: ; ee0f
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_EVO_STONE
call UseItem_SelectMon
2013-05-07 23:02:15 -07:00
jp c, .DecidedNotToUse
2013-05-07 23:02:15 -07:00
ld a, MON_ITEM
2013-05-07 23:02:15 -07:00
call GetPartyParamLocation
ld a, [hl]
2013-12-24 14:11:52 -08:00
cp EVERSTONE
jr z, .NoEffect
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
ld a, $1
ld [wForceEvolution], a
2017-12-24 09:47:30 -08:00
farcall EvolvePokemon
2013-05-07 23:02:15 -07:00
2015-11-23 13:04:53 -08:00
ld a, [wMonTriedToEvolve]
2013-05-07 23:02:15 -07:00
and a
jr z, .NoEffect
2013-12-24 14:11:52 -08:00
jp UseDisposableItem
2013-05-07 23:02:15 -07:00
.NoEffect:
call WontHaveAnyEffectMessage
2013-05-07 23:02:15 -07:00
.DecidedNotToUse:
2013-05-07 23:02:15 -07:00
xor a
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
2013-05-07 23:02:15 -07:00
ret
; ee3d
2015-12-15 07:55:56 -08:00
HPUp:
2013-05-07 23:02:15 -07:00
Protein:
Iron:
Carbos:
Calcium: ; ee3d
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
2013-05-07 23:02:15 -07:00
jp c, RareCandy_StatBooster_ExitMenu
2013-05-07 23:02:15 -07:00
call RareCandy_StatBooster_GetParameters
2013-05-07 23:02:15 -07:00
call GetStatExpRelativePointer
2013-05-07 23:02:15 -07:00
ld a, MON_STAT_EXP
2013-05-07 23:02:15 -07:00
call GetPartyParamLocation
add hl, bc
ld a, [hl]
2013-12-24 14:11:52 -08:00
cp 100
jr nc, NoEffectMessage
2013-12-24 14:11:52 -08:00
add 10
2013-05-07 23:02:15 -07:00
ld [hl], a
call UpdateStatsAfterItem
2013-05-07 23:02:15 -07:00
call GetStatExpRelativePointer
2013-05-07 23:02:15 -07:00
ld hl, StatStrings
2013-05-07 23:02:15 -07:00
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld de, StringBuffer2
2015-10-12 09:33:24 -07:00
ld bc, ITEM_NAME_LENGTH
2013-05-07 23:02:15 -07:00
call CopyBytes
2015-10-10 04:45:39 -07:00
call Play_SFX_FULL_HEAL
2013-05-07 23:02:15 -07:00
ld hl, Text_StatRose
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
2015-10-12 09:33:24 -07:00
ld c, HAPPINESS_USEDITEM
2017-12-24 09:47:30 -08:00
farcall ChangeHappiness
2013-05-07 23:02:15 -07:00
jp UseDisposableItem
2013-05-07 23:02:15 -07:00
NoEffectMessage: ; ee83
ld hl, WontHaveAnyEffectText
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
jp ClearPalettes
; ee8c
UpdateStatsAfterItem: ; ee8c
ld a, MON_MAXHP
2013-12-24 14:11:52 -08:00
call GetPartyParamLocation
ld d, h
ld e, l
2015-12-21 11:10:16 -08:00
ld a, MON_STAT_EXP - 1
2013-12-24 14:11:52 -08:00
call GetPartyParamLocation
ld b, $1
2015-10-08 11:53:39 -07:00
predef_jump CalcPkmnStats
2013-12-24 14:11:52 -08:00
; ee9f
RareCandy_StatBooster_ExitMenu: ; ee9f
2013-12-24 14:11:52 -08:00
xor a
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
2013-12-24 14:11:52 -08:00
jp ClearPalettes
; eea6
Text_StatRose: ; 0xeea6
2013-12-24 14:11:52 -08:00
; 's @ rose.
text_jump UnknownText_0x1c5b9a
db "@"
; 0xeeab
StatStrings: ; eeab
2013-12-24 14:11:52 -08:00
dw .health
dw .attack
dw .defense
dw .speed
dw .special
.health db "HEALTH@"
.attack db "ATTACK@"
.defense db "DEFENSE@"
.speed db "SPEED@"
.special db "SPECIAL@"
; eed9
GetStatExpRelativePointer: ; eed9
2013-12-24 14:11:52 -08:00
ld a, [CurItem]
ld hl, Table_eeeb
.next
cp [hl]
inc hl
jr z, .got_it
2013-12-24 14:11:52 -08:00
inc hl
jr .next
.got_it
2013-12-24 14:11:52 -08:00
ld a, [hl]
ld c, a
ld b, 0
ret
; eeeb
Table_eeeb: ; eeeb
db HP_UP, MON_HP_EXP - MON_STAT_EXP
db PROTEIN, MON_ATK_EXP - MON_STAT_EXP
db IRON, MON_DEF_EXP - MON_STAT_EXP
db CARBOS, MON_SPD_EXP - MON_STAT_EXP
db CALCIUM, MON_SPC_EXP - MON_STAT_EXP
2013-12-24 14:11:52 -08:00
; eef5
RareCandy_StatBooster_GetParameters: ; eef5
2013-12-24 14:11:52 -08:00
ld a, [CurPartySpecies]
ld [CurSpecies], a
ld [wd265], a
ld a, MON_LEVEL
2013-12-24 14:11:52 -08:00
call GetPartyParamLocation
ld a, [hl]
ld [CurPartyLevel], a
call GetBaseData
ld a, [CurPartyMon]
ld hl, PartyMonNicknames
2013-12-24 14:11:52 -08:00
call GetNick
ret
; 0xef14
2013-05-07 23:02:15 -07:00
RareCandy: ; ef14
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
2013-05-07 23:02:15 -07:00
jp c, RareCandy_StatBooster_ExitMenu
2013-05-07 23:02:15 -07:00
call RareCandy_StatBooster_GetParameters
2013-05-07 23:02:15 -07:00
ld a, MON_LEVEL
2013-05-07 23:02:15 -07:00
call GetPartyParamLocation
ld a, [hl]
2014-06-03 14:07:10 -07:00
cp MAX_LEVEL
jp nc, NoEffectMessage
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
inc a
ld [hl], a
ld [CurPartyLevel], a
push de
ld d, a
2017-12-24 09:47:30 -08:00
farcall CalcExpAtLevel
2013-05-07 23:02:15 -07:00
pop de
ld a, MON_EXP
2013-05-07 23:02:15 -07:00
call GetPartyParamLocation
ld a, [hMultiplicand]
ld [hli], a
ld a, [hMultiplicand + 1]
2013-05-07 23:02:15 -07:00
ld [hli], a
ld a, [hMultiplicand + 2]
2013-05-07 23:02:15 -07:00
ld [hl], a
2013-12-24 14:11:52 -08:00
ld a, MON_MAXHP
2013-05-07 23:02:15 -07:00
call GetPartyParamLocation
ld a, [hli]
ld b, a
ld c, [hl]
push bc
call UpdateStatsAfterItem
2013-05-07 23:02:15 -07:00
ld a, MON_MAXHP + 1
2013-05-07 23:02:15 -07:00
call GetPartyParamLocation
pop bc
ld a, [hld]
sub c
ld c, a
ld a, [hl]
sbc b
ld b, a
dec hl
ld a, [hl]
add c
ld [hld], a
ld a, [hl]
adc b
ld [hl], a
2017-12-24 09:47:30 -08:00
farcall LevelUpHappinessMod
2013-05-07 23:02:15 -07:00
2015-11-08 07:59:28 -08:00
ld a, PARTYMENUTEXT_LEVEL_UP
call ItemActionText
2013-05-07 23:02:15 -07:00
xor a ; PARTYMON
2013-05-07 23:02:15 -07:00
ld [MonType], a
2015-10-08 11:53:39 -07:00
predef CopyPkmnToTempMon
2013-05-07 23:02:15 -07:00
hlcoord 9, 0
ld b, 10
ld c, 9
call TextBox
2013-05-07 23:02:15 -07:00
hlcoord 11, 1
2018-01-09 12:39:48 -08:00
ld bc, 4
2015-02-11 13:15:38 -08:00
predef PrintTempMonStats
2013-05-07 23:02:15 -07:00
call WaitPressAorB_BlinkCursor
2013-05-07 23:02:15 -07:00
xor a ; PARTYMON
2013-05-07 23:02:15 -07:00
ld [MonType], a
ld a, [CurPartySpecies]
ld [wd265], a
predef LearnLevelMoves
2013-05-07 23:02:15 -07:00
xor a
ld [wForceEvolution], a
2017-12-24 09:47:30 -08:00
farcall EvolvePokemon
2013-05-07 23:02:15 -07:00
jp UseDisposableItem
2013-05-07 23:02:15 -07:00
; efad
HealPowder: ; efad
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
2013-05-07 23:02:15 -07:00
jp c, StatusHealer_ExitMenu
2013-05-07 23:02:15 -07:00
call UseStatusHealer
2013-05-07 23:02:15 -07:00
cp $0
jr nz, .asm_efc9
2015-10-12 09:33:24 -07:00
ld c, HAPPINESS_BITTERPOWDER
2017-12-24 09:47:30 -08:00
farcall ChangeHappiness
2013-05-07 23:02:15 -07:00
call LooksBitterMessage
2013-05-07 23:02:15 -07:00
ld a, $0
.asm_efc9
jp StatusHealer_Jumptable
2013-05-07 23:02:15 -07:00
; efcc
Antidote:
BurnHeal:
IceHeal:
Awakening:
ParlyzHeal:
FullHeal:
Psncureberry:
Przcureberry:
BurntBerry:
IceBerry:
MintBerry:
Miracleberry: ; efcc
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
jp c, StatusHealer_ExitMenu
2013-05-07 23:02:15 -07:00
FullyHealStatus: ; efd4
call UseStatusHealer
jp StatusHealer_Jumptable
2013-05-07 23:02:15 -07:00
; efda
UseStatusHealer: ; efda (3:6fda)
call IsMonFainted
ld a, $1
ret z
2015-11-08 07:59:28 -08:00
call GetItemHealingAction
ld a, MON_STATUS
call GetPartyParamLocation
ld a, [hl]
and c
2015-11-08 07:59:28 -08:00
jr nz, .good
call IsItemUsedOnConfusedMon
ld a, $1
ret nc
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUTEXT_HEAL_CONFUSION
.good
xor a
ld [hl], a
ld a, b
ld [PartyMenuActionText], a
2015-11-08 07:59:28 -08:00
call HealStatus
2015-10-10 04:45:39 -07:00
call Play_SFX_FULL_HEAL
call ItemActionTextWaitButton
call UseDisposableItem
ld a, $0
ret
IsItemUsedOnConfusedMon: ; f009 (3:7009)
call IsItemUsedOnBattleMon
2015-11-08 07:59:28 -08:00
jr nc, .nope
ld a, [PlayerSubStatus3]
2015-11-08 07:59:28 -08:00
bit SUBSTATUS_CONFUSED, a
jr z, .nope
ld a, c
cp $ff
2015-11-08 07:59:28 -08:00
jr nz, .nope
scf
ret
2015-11-08 07:59:28 -08:00
.nope
and a
ret
BattlemonRestoreHealth: ; f01e (3:701e)
call IsItemUsedOnBattleMon
ret nc
ld a, MON_HP
call GetPartyParamLocation
ld a, [hli]
ld [BattleMonHP], a
ld a, [hld]
ld [BattleMonHP + 1], a
ret
2015-11-08 07:59:28 -08:00
HealStatus: ; f030 (3:7030)
call IsItemUsedOnBattleMon
ret nc
xor a
ld [BattleMonStatus], a
ld hl, PlayerSubStatus5
2015-11-08 07:59:28 -08:00
res SUBSTATUS_TOXIC, [hl]
ld hl, PlayerSubStatus1
2015-11-08 07:59:28 -08:00
res SUBSTATUS_NIGHTMARE, [hl]
call GetItemHealingAction
ld a, c
2015-11-08 07:59:28 -08:00
cp %11111111
jr nz, .not_full_heal
ld hl, PlayerSubStatus3
2015-11-08 07:59:28 -08:00
res SUBSTATUS_CONFUSED, [hl]
.not_full_heal
push bc
2017-12-24 09:47:30 -08:00
farcall CalcPlayerStats
pop bc
ret
2015-11-08 07:59:28 -08:00
GetItemHealingAction: ; f058 (3:7058)
push hl
ld a, [CurItem]
2018-01-10 22:45:27 -08:00
ld hl, StatusHealingActions
2013-12-24 14:11:52 -08:00
ld bc, 3
.next
cp [hl]
2015-11-08 07:59:28 -08:00
jr z, .found_it
add hl, bc
2013-12-24 14:11:52 -08:00
jr .next
2015-11-08 07:59:28 -08:00
.found_it
inc hl
ld b, [hl]
inc hl
ld a, [hl]
ld c, a
2013-12-24 14:11:52 -08:00
cp %11111111
pop hl
ret
; f071 (3:7071)
2018-01-10 22:45:27 -08:00
INCLUDE "data/items/heal_status.asm"
StatusHealer_Jumptable: ; f09e (3:709e)
2015-12-26 18:59:03 -08:00
ld hl, .dw
2013-12-24 14:11:52 -08:00
rst JumpTable
ret
.dw ; f0a3 (3:70a3)
dw StatusHealer_ClearPalettes
dw StatusHealer_NoEffect
dw StatusHealer_ExitMenu
2013-05-07 23:02:15 -07:00
RevivalHerb: ; f0a9
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
jp c, StatusHealer_ExitMenu
2013-05-07 23:02:15 -07:00
call RevivePokemon
2013-12-24 14:11:52 -08:00
cp 0
2013-05-07 23:02:15 -07:00
jr nz, .asm_f0c5
2013-12-24 14:11:52 -08:00
2015-10-12 09:33:24 -07:00
ld c, HAPPINESS_REVIVALHERB
2017-12-24 09:47:30 -08:00
farcall ChangeHappiness
call LooksBitterMessage
2013-12-24 14:11:52 -08:00
ld a, 0
2013-05-07 23:02:15 -07:00
.asm_f0c5
jp StatusHealer_Jumptable
2013-05-07 23:02:15 -07:00
; f0c8
Revive:
MaxRevive: ; f0c8
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
jp c, StatusHealer_ExitMenu
2013-05-07 23:02:15 -07:00
call RevivePokemon
jp StatusHealer_Jumptable
2013-12-24 14:11:52 -08:00
; f0d6
2013-05-07 23:02:15 -07:00
RevivePokemon: ; f0d6
call IsMonFainted
2013-12-24 14:11:52 -08:00
ld a, 1
ret nz
ld a, [wBattleMode]
2013-12-24 14:11:52 -08:00
and a
jr z, .skip_to_revive
2013-12-24 14:11:52 -08:00
ld a, [CurPartyMon]
ld c, a
ld d, 0
2016-01-12 09:46:18 -08:00
ld hl, wBattleParticipantsIncludingFainted
2013-12-24 14:11:52 -08:00
ld b, CHECK_FLAG
predef FlagPredef
2013-12-24 14:11:52 -08:00
ld a, c
and a
jr z, .skip_to_revive
2013-05-07 23:02:15 -07:00
2013-12-24 14:11:52 -08:00
ld a, [CurPartyMon]
ld c, a
2015-11-07 18:04:54 -08:00
ld hl, wBattleParticipantsNotFainted
2013-12-24 14:11:52 -08:00
ld b, SET_FLAG
predef FlagPredef
2013-12-24 14:11:52 -08:00
.skip_to_revive
2013-12-24 14:11:52 -08:00
xor a
ld [Danger], a
ld a, [CurItem]
cp REVIVE
jr z, .revive_half_hp
2013-05-07 23:02:15 -07:00
call ReviveFullHP
jr .finish_revive
2013-05-07 23:02:15 -07:00
.revive_half_hp
call ReviveHalfHP
2013-05-07 23:02:15 -07:00
.finish_revive
call HealHP_SFX_GFX
2015-11-08 07:59:28 -08:00
ld a, PARTYMENUTEXT_REVIVE
2013-12-24 14:11:52 -08:00
ld [PartyMenuActionText], a
call ItemActionTextWaitButton
call UseDisposableItem
2013-12-24 14:11:52 -08:00
ld a, 0
ret
; f128
2013-05-07 23:02:15 -07:00
2013-12-24 14:11:52 -08:00
FullRestore: ; f128
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
jp c, StatusHealer_ExitMenu
2013-05-07 23:02:15 -07:00
call IsMonFainted
jp z, StatusHealer_NoEffect
2013-05-07 23:02:15 -07:00
call IsMonAtFullHealth
jr c, .NotAtFullHealth
2013-05-07 23:02:15 -07:00
jp FullyHealStatus
2013-05-07 23:02:15 -07:00
.NotAtFullHealth:
call .FullRestore
jp StatusHealer_Jumptable
2013-05-07 23:02:15 -07:00
; f144
.FullRestore: ; f144
2013-12-24 14:11:52 -08:00
xor a
ld [Danger], a
call ReviveFullHP
ld a, MON_STATUS
2013-12-24 14:11:52 -08:00
call GetPartyParamLocation
xor a
ld [hli], a
ld [hl], a
2015-11-08 07:59:28 -08:00
call HealStatus
call BattlemonRestoreHealth
call HealHP_SFX_GFX
2015-11-08 07:59:28 -08:00
ld a, PARTYMENUTEXT_HEAL_HP
2013-12-24 14:11:52 -08:00
ld [PartyMenuActionText], a
call ItemActionTextWaitButton
call UseDisposableItem
2013-12-24 14:11:52 -08:00
ld a, 0
ret
; f16a
2013-05-07 23:02:15 -07:00
BitterBerry: ; f16a
ld hl, PlayerSubStatus3
2013-12-24 14:11:52 -08:00
bit SUBSTATUS_CONFUSED, [hl]
ld a, 1
jr z, .done
res SUBSTATUS_CONFUSED, [hl]
2013-05-07 23:02:15 -07:00
xor a
ld [hBattleTurn], a
call UseItemText
2013-05-07 23:02:15 -07:00
2013-12-24 14:11:52 -08:00
ld hl, ConfusedNoMoreText
call StdBattleTextBox
2013-05-07 23:02:15 -07:00
2013-12-24 14:11:52 -08:00
ld a, 0
2013-05-07 23:02:15 -07:00
2013-12-24 14:11:52 -08:00
.done
jp StatusHealer_Jumptable
2013-05-07 23:02:15 -07:00
; f186
MaxPotion:
HyperPotion:
SuperPotion:
Potion:
FreshWater:
SodaPop:
Lemonade:
MoomooMilk:
Ragecandybar:
BerryJuice:
Berry:
GoldBerry: ; f186
call ItemRestoreHP
jp StatusHealer_Jumptable
2013-05-07 23:02:15 -07:00
; f18c
Energypowder: ; f18c
2015-10-12 09:33:24 -07:00
ld c, HAPPINESS_BITTERPOWDER
jr EnergypowderEnergyRootCommon
2013-05-07 23:02:15 -07:00
; f190
EnergyRoot: ; f190
2015-10-12 09:33:24 -07:00
ld c, HAPPINESS_ENERGYROOT
2013-05-07 23:02:15 -07:00
; f192
EnergypowderEnergyRootCommon: ; f192
2013-05-07 23:02:15 -07:00
push bc
call ItemRestoreHP
2013-05-07 23:02:15 -07:00
pop bc
2013-12-24 14:11:52 -08:00
cp 0
jr nz, .skip_happiness
2013-05-07 23:02:15 -07:00
2017-12-24 09:47:30 -08:00
farcall ChangeHappiness
call LooksBitterMessage
2013-12-24 14:11:52 -08:00
ld a, 0
2013-05-07 23:02:15 -07:00
.skip_happiness
jp StatusHealer_Jumptable
2013-05-07 23:02:15 -07:00
; f1a9
ItemRestoreHP: ; f1a9 (3:71a9)
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
2013-12-24 14:11:52 -08:00
ld a, 2
ret c
2013-12-24 14:11:52 -08:00
call IsMonFainted
2013-12-24 14:11:52 -08:00
ld a, 1
ret z
2013-12-24 14:11:52 -08:00
call IsMonAtFullHealth
2013-12-24 14:11:52 -08:00
ld a, 1
ret nc
2013-12-24 14:11:52 -08:00
xor a
ld [Danger], a
call GetHealingItemAmount
call RestoreHealth
call BattlemonRestoreHealth
call HealHP_SFX_GFX
2015-11-08 07:59:28 -08:00
ld a, PARTYMENUTEXT_HEAL_HP
ld [PartyMenuActionText], a
call ItemActionTextWaitButton
call UseDisposableItem
2013-12-24 14:11:52 -08:00
ld a, 0
ret
HealHP_SFX_GFX: ; f1db (3:71db)
push de
2013-12-24 14:11:52 -08:00
ld de, SFX_POTION
call WaitPlaySFX
pop de
ld a, [CurPartyMon]
hlcoord 11, 0
ld bc, SCREEN_WIDTH * 2
call AddNTimes
ld a, $2
ld [wWhichHPBar], a
predef_jump AnimateHPBar
2015-11-08 07:59:28 -08:00
UseItem_SelectMon: ; f1f9 (3:71f9)
call .SelectMon
ret c
2013-12-24 14:11:52 -08:00
ld a, [CurPartySpecies]
2013-12-24 14:11:52 -08:00
cp EGG
2015-11-08 07:59:28 -08:00
jr nz, .not_egg
2013-12-24 14:11:52 -08:00
call CantUseOnEggMessage
scf
ret
2013-12-24 14:11:52 -08:00
2015-11-08 07:59:28 -08:00
.not_egg
and a
ret
2015-11-08 07:59:28 -08:00
.SelectMon: ; f20b (3:720b)
ld a, b
ld [PartyMenuActionText], a
push hl
push de
push bc
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
call ChoosePkmnToUseItemOn
pop bc
pop de
pop hl
ret
ChoosePkmnToUseItemOn: ; f21c (3:721c)
2017-12-24 09:47:30 -08:00
farcall LoadPartyMenuGFX
farcall InitPartyMenuWithCancel
farcall InitPartyMenuGFX
farcall WritePartyMenuTilemap
farcall PrintPartyMenuText
call WaitBGMap
2015-09-09 16:27:07 -07:00
call SetPalettes
call DelayFrame
2017-12-24 09:47:30 -08:00
farcall PartyMenuSelect
ret
ItemActionText: ; f24a (3:724a)
ld [PartyMenuActionText], a
ld a, [CurPartySpecies]
push af
ld a, [CurPartyMon]
push af
push hl
push de
push bc
2017-12-24 09:47:30 -08:00
farcall WritePartyMenuTilemap
farcall PrintPartyMenuActionText
call WaitBGMap
2015-09-09 16:27:07 -07:00
call SetPalettes
call DelayFrame
pop bc
pop de
pop hl
pop af
ld [CurPartyMon], a
pop af
ld [CurPartySpecies], a
ret
ItemActionTextWaitButton: ; f279 (3:7279)
xor a
ld [hBGMapMode], a
hlcoord 0, 0
2013-12-24 14:11:52 -08:00
ld bc, TileMapEnd - TileMap
ld a, " "
call ByteFill
ld a, [PartyMenuActionText]
call ItemActionText
ld a, $1
ld [hBGMapMode], a
ld c, 50
call DelayFrames
jp WaitPressAorB_BlinkCursor
StatusHealer_NoEffect: ; f299 (3:7299)
call WontHaveAnyEffectMessage
jr StatusHealer_ClearPalettes
StatusHealer_ExitMenu: ; f29e (3:729e)
xor a
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
StatusHealer_ClearPalettes: ; f2a2 (3:72a2)
call ClearPalettes
ret
IsItemUsedOnBattleMon: ; f2a6 (3:72a6)
ld a, [wBattleMode]
and a
ret z
ld a, [CurPartyMon]
push hl
ld hl, CurBattleMon
cp [hl]
pop hl
jr nz, .nope
scf
ret
.nope
xor a
ret
ReviveHalfHP: ; f2ba (3:72ba)
call LoadHPFromBuffer1
srl d
rr e
jr ContinueRevive
ReviveFullHP: ; f2c3 (3:72c3)
call LoadHPFromBuffer1
ContinueRevive: ; f2c6 (3:72c6)
ld a, MON_HP
call GetPartyParamLocation
ld [hl], d
inc hl
ld [hl], e
jp LoadCurHPIntoBuffer5
RestoreHealth: ; f2d1 (3:72d1)
ld a, MON_HP + 1
call GetPartyParamLocation
ld a, [hl]
add e
ld [hld], a
ld a, [hl]
adc d
ld [hl], a
jr c, .full_hp
call LoadCurHPIntoBuffer5
ld a, MON_HP + 1
call GetPartyParamLocation
ld d, h
ld e, l
ld a, MON_MAXHP + 1
call GetPartyParamLocation
ld a, [de]
sub [hl]
dec de
dec hl
ld a, [de]
sbc [hl]
jr c, .finish
.full_hp
call ReviveFullHP
.finish
ret
RemoveHP: ; f2f9 (3:72f9)
ld a, MON_HP + 1
call GetPartyParamLocation
ld a, [hl]
sub e
ld [hld], a
ld a, [hl]
sbc d
ld [hl], a
jr nc, .okay
xor a
ld [hld], a
ld [hl], a
.okay
call LoadCurHPIntoBuffer5
ret
IsMonFainted: ; f30d (3:730d)
push de
call LoadMaxHPToBuffer1
call LoadCurHPToBuffer3
call LoadHPFromBuffer3
ld a, d
or e
pop de
ret
IsMonAtFullHealth: ; f31b (3:731b)
call LoadHPFromBuffer3
ld h, d
ld l, e
call LoadHPFromBuffer1
ld a, l
sub e
ld a, h
sbc d
ret
LoadCurHPIntoBuffer5: ; f328 (3:7328)
ld a, MON_HP
call GetPartyParamLocation
ld a, [hli]
ld [Buffer6], a
ld a, [hl]
ld [Buffer5], a
ret
; f336 (3:7336)
LoadHPIntoBuffer5: ; f336
2013-12-24 14:11:52 -08:00
ld a, d
ld [Buffer6], a
2013-12-24 14:11:52 -08:00
ld a, e
ld [Buffer5], a
2013-12-24 14:11:52 -08:00
ret
; f33f
LoadHPFromBuffer5: ; f33f
ld a, [Buffer6]
2013-12-24 14:11:52 -08:00
ld d, a
ld a, [Buffer5]
2013-12-24 14:11:52 -08:00
ld e, a
ret
; f348
LoadCurHPToBuffer3: ; f348 (3:7348)
ld a, MON_HP
call GetPartyParamLocation
ld a, [hli]
ld [Buffer4], a
ld a, [hl]
ld [Buffer3], a
ret
LoadHPFromBuffer3: ; f356 (3:7356)
ld a, [Buffer4]
ld d, a
ld a, [Buffer3]
ld e, a
ret
LoadMaxHPToBuffer1: ; f35f (3:735f)
push hl
ld a, MON_MAXHP
call GetPartyParamLocation
ld a, [hli]
ld [Buffer2], a
ld a, [hl]
ld [Buffer1], a
pop hl
ret
LoadHPFromBuffer1: ; f36f (3:736f)
ld a, [Buffer2]
ld d, a
ld a, [Buffer1]
ld e, a
ret
GetOneFifthMaxHP: ; f378 (3:7378)
push bc
ld a, MON_MAXHP
call GetPartyParamLocation
ld a, [hli]
ld [hDividend + 0], a
ld a, [hl]
ld [hDividend + 1], a
ld a, 5
ld [hDivisor], a
ld b, 2
call Divide
ld a, [hQuotient + 1]
ld d, a
ld a, [hQuotient + 2]
ld e, a
pop bc
ret
GetHealingItemAmount: ; f395 (3:7395)
push hl
ld a, [CurItem]
2018-01-10 22:45:27 -08:00
ld hl, HealingHPAmounts
ld d, a
2013-12-24 14:11:52 -08:00
.next
ld a, [hli]
2013-12-24 14:11:52 -08:00
cp -1
jr z, .NotFound
cp d
2013-12-24 14:11:52 -08:00
jr z, .done
inc hl
inc hl
2013-12-24 14:11:52 -08:00
jr .next
.NotFound:
scf
2013-12-24 14:11:52 -08:00
.done
ld e, [hl]
inc hl
ld d, [hl]
pop hl
ret
; f3af (3:73af)
2018-01-10 22:45:27 -08:00
INCLUDE "data/items/heal_hp.asm"
Softboiled_MilkDrinkFunction: ; f3df (3:73df)
; Softboiled/Milk Drink in the field
2015-12-23 11:00:29 -08:00
ld a, [wPartyMenuCursor]
dec a
ld b, a
call .SelectMilkDrinkRecipient ; select pokemon
jr c, .skip
ld a, b
ld [CurPartyMon], a
call IsMonFainted
call GetOneFifthMaxHP
call RemoveHP
push bc
call HealHP_SFX_GFX
pop bc
call GetOneFifthMaxHP
ld a, c
ld [CurPartyMon], a
call IsMonFainted
call RestoreHealth
call HealHP_SFX_GFX
2015-11-08 07:59:28 -08:00
ld a, PARTYMENUTEXT_HEAL_HP
call ItemActionText
call JoyWaitAorB
.skip
ld a, b
inc a
2015-12-23 11:00:29 -08:00
ld [wPartyMenuCursor], a
ret
.SelectMilkDrinkRecipient: ; f419 (3:7419)
2015-11-08 07:59:28 -08:00
.loop
push bc
2015-11-08 07:59:28 -08:00
ld a, PARTYMENUACTION_HEALING_ITEM
ld [PartyMenuActionText], a
call ChoosePkmnToUseItemOn
pop bc
2015-11-08 07:59:28 -08:00
jr c, .set_carry
2015-12-23 11:00:29 -08:00
ld a, [wPartyMenuCursor]
dec a
ld c, a
ld a, b
cp c
jr z, .cant_use ; chose the same mon as user
ld a, c
ld [CurPartyMon], a
call IsMonFainted
jr z, .cant_use
call IsMonAtFullHealth
jr nc, .cant_use
xor a
ret
2015-11-08 07:59:28 -08:00
.set_carry
scf
ret
2015-11-08 07:59:28 -08:00
.cant_use
push bc
ld hl, .Text_CantBeUsed
call MenuTextBoxBackup
pop bc
2015-11-08 07:59:28 -08:00
jr .loop
; f44a (3:744a)
2013-05-07 23:02:15 -07:00
.Text_CantBeUsed: ; 0xf44a
2013-12-24 14:11:52 -08:00
; That can't be used on this #MON.
text_jump UnknownText_0x1c5bac
db "@"
; 0xf44f
2013-05-07 23:02:15 -07:00
EscapeRope: ; f44f
xor a
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
2017-12-24 09:47:30 -08:00
farcall EscapeRopeFunction
2013-05-07 23:02:15 -07:00
2015-12-13 11:15:16 -08:00
ld a, [wItemEffectSucceeded]
2013-12-24 14:11:52 -08:00
cp 1
call z, UseDisposableItem
2013-05-07 23:02:15 -07:00
ret
; f462
SuperRepel: ; f462
2013-12-24 14:11:52 -08:00
ld b, 200
jr UseRepel
2013-05-07 23:02:15 -07:00
; f466
MaxRepel: ; f466
2013-12-24 14:11:52 -08:00
ld b, 250
jr UseRepel
2013-05-07 23:02:15 -07:00
; f466
Repel: ; f46a
2013-12-24 14:11:52 -08:00
ld b, 100
2013-05-07 23:02:15 -07:00
; f46c
UseRepel: ; f46c
2015-10-24 07:34:19 -07:00
ld a, [wRepelEffect]
2013-05-07 23:02:15 -07:00
and a
2015-09-09 16:27:07 -07:00
ld hl, TextJump_RepelUsedEarlierIsStillInEffect
2013-12-24 14:11:52 -08:00
jp nz, PrintText
2015-09-09 16:27:07 -07:00
2013-05-07 23:02:15 -07:00
ld a, b
2015-10-24 07:34:19 -07:00
ld [wRepelEffect], a
jp UseItemText
2013-05-07 23:02:15 -07:00
2015-09-09 16:27:07 -07:00
TextJump_RepelUsedEarlierIsStillInEffect: ; 0xf47d
2013-12-24 14:11:52 -08:00
; The REPEL used earlier is still in effect.
2015-09-09 16:27:07 -07:00
text_jump Text_RepelUsedEarlierIsStillInEffect
2013-12-24 14:11:52 -08:00
db "@"
; 0xf482
2013-05-07 23:02:15 -07:00
XAccuracy: ; f482
ld hl, PlayerSubStatus4
bit SUBSTATUS_X_ACCURACY, [hl]
jp nz, WontHaveAnyEffect_NotUsedMessage
set SUBSTATUS_X_ACCURACY, [hl]
jp UseItemText
2013-05-07 23:02:15 -07:00
; f48f
PokeDoll: ; f48f
ld a, [wBattleMode]
2013-05-07 23:02:15 -07:00
dec a
jr nz, .asm_f4a6
inc a
2015-11-08 16:09:36 -08:00
ld [wForcedSwitch], a
2015-10-24 07:34:19 -07:00
ld a, [wBattleResult]
2018-01-09 14:20:47 -08:00
and $c0
2013-05-07 23:02:15 -07:00
or $2
2015-10-24 07:34:19 -07:00
ld [wBattleResult], a
jp UseItemText
2013-05-07 23:02:15 -07:00
.asm_f4a6
xor a
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
2013-05-07 23:02:15 -07:00
ret
; f4ab
GuardSpec: ; f4ab
ld hl, PlayerSubStatus4
2015-11-08 07:59:28 -08:00
bit SUBSTATUS_MIST, [hl]
jp nz, WontHaveAnyEffect_NotUsedMessage
2015-11-08 07:59:28 -08:00
set SUBSTATUS_MIST, [hl]
jp UseItemText
2013-05-07 23:02:15 -07:00
; f4b8
DireHit: ; f4b8
ld hl, PlayerSubStatus4
2015-11-08 07:59:28 -08:00
bit SUBSTATUS_FOCUS_ENERGY, [hl]
jp nz, WontHaveAnyEffect_NotUsedMessage
2015-11-08 07:59:28 -08:00
set SUBSTATUS_FOCUS_ENERGY, [hl]
jp UseItemText
2013-05-07 23:02:15 -07:00
; f4c5
XAttack:
XDefend:
XSpeed:
XSpecial: ; f4c5
call UseItemText
2013-05-07 23:02:15 -07:00
ld a, [CurItem]
2018-01-10 22:45:27 -08:00
ld hl, XItemStats
2013-05-07 23:02:15 -07:00
2015-11-08 07:59:28 -08:00
.loop
2013-05-07 23:02:15 -07:00
cp [hl]
2015-11-08 07:59:28 -08:00
jr z, .got_it
2013-05-07 23:02:15 -07:00
inc hl
inc hl
2015-11-08 07:59:28 -08:00
jr .loop
2013-05-07 23:02:15 -07:00
2015-11-08 07:59:28 -08:00
.got_it
2013-05-07 23:02:15 -07:00
inc hl
ld b, [hl]
xor a
ld [hBattleTurn], a
ld [AttackMissed], a
ld [EffectFailed], a
2017-12-24 09:47:30 -08:00
farcall CheckIfStatCanBeRaised
2013-05-07 23:02:15 -07:00
call WaitSFX
2017-12-24 09:47:30 -08:00
farcall BattleCommand_StatUpMessage
farcall BattleCommand_StatUpFailText
2013-05-07 23:02:15 -07:00
ld a, [CurBattleMon]
ld [CurPartyMon], a
2015-10-12 09:33:24 -07:00
ld c, HAPPINESS_USEDXITEM
2017-12-24 09:47:30 -08:00
farcall ChangeHappiness
2013-05-07 23:02:15 -07:00
ret
; f504
2018-01-10 22:45:27 -08:00
INCLUDE "data/items/x_stats.asm"
2013-05-07 23:02:15 -07:00
PokeFlute: ; f50c
ld a, [wBattleMode]
2013-05-07 23:02:15 -07:00
and a
jr nz, .dummy
.dummy
2013-05-07 23:02:15 -07:00
xor a
2015-11-10 16:51:13 -08:00
ld [wd002], a
ld b, $ff ^ SLP
2013-05-07 23:02:15 -07:00
ld hl, PartyMon1Status
call .CureSleep
2013-05-07 23:02:15 -07:00
ld a, [wBattleMode]
cp WILD_BATTLE
jr z, .skip_otrainer
2013-05-07 23:02:15 -07:00
ld hl, OTPartyMon1Status
call .CureSleep
.skip_otrainer
2013-05-07 23:02:15 -07:00
ld hl, BattleMonStatus
ld a, [hl]
and b
ld [hl], a
ld hl, EnemyMonStatus
ld a, [hl]
and b
ld [hl], a
2015-11-10 16:51:13 -08:00
ld a, [wd002]
2013-05-07 23:02:15 -07:00
and a
ld hl, .CatchyTune
2013-12-24 14:11:52 -08:00
jp z, PrintText
ld hl, .PlayedTheFlute
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
ld a, [Danger]
and 1 << DANGER_ON_F
jr nz, .dummy2
.dummy2
ld hl, .AllSleepingMonWokeUp
2013-12-24 14:11:52 -08:00
jp PrintText
2013-05-07 23:02:15 -07:00
.CureSleep:
ld de, PARTYMON_STRUCT_LENGTH
ld c, PARTY_LENGTH
2013-05-08 00:27:46 -07:00
.loop
2013-05-08 00:27:46 -07:00
ld a, [hl]
push af
and SLP
jr z, .not_asleep
ld a, 1
2015-11-10 16:51:13 -08:00
ld [wd002], a
.not_asleep
2013-05-08 00:27:46 -07:00
pop af
and b
ld [hl], a
add hl, de
dec c
jr nz, .loop
2013-05-08 00:27:46 -07:00
ret
; f56c
.CatchyTune: ; 0xf56c
2013-12-24 14:11:52 -08:00
; Played the # FLUTE. Now, that's a catchy tune!
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c5bf9
2013-05-08 00:27:46 -07:00
db "@"
; 0xf571
.AllSleepingMonWokeUp: ; 0xf571
2013-12-24 14:11:52 -08:00
; All sleeping #MON woke up.
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c5c28
2013-05-08 00:27:46 -07:00
db "@"
; 0xf576
.PlayedTheFlute: ; 0xf576
2013-12-24 14:11:52 -08:00
; played the # FLUTE.@ @
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c5c44
2013-05-08 00:27:46 -07:00
start_asm
ld a, [wBattleMode]
2013-05-08 00:27:46 -07:00
and a
jr nz, .battle
2013-05-08 00:27:46 -07:00
push de
ld de, SFX_POKEFLUTE
call WaitPlaySFX
call WaitSFX
pop de
.battle
jp PokeFluteTerminatorCharacter
2013-05-08 00:27:46 -07:00
; f58f
2013-05-07 23:02:15 -07:00
BlueCard: ; f58f
2013-05-08 00:27:46 -07:00
ld hl, .bluecardtext
jp MenuTextBoxWaitButton
2013-05-07 23:02:15 -07:00
2013-05-08 00:27:46 -07:00
.bluecardtext
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c5c5e
2013-05-08 00:27:46 -07:00
db "@"
; f59a
2013-05-07 23:02:15 -07:00
CoinCase: ; f59a
2013-05-08 00:27:46 -07:00
ld hl, .coincasetext
jp MenuTextBoxWaitButton
2013-05-07 23:02:15 -07:00
2013-05-08 00:27:46 -07:00
.coincasetext
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c5c7b
2013-05-08 00:27:46 -07:00
db "@"
; f5a5
2013-05-07 23:02:15 -07:00
OldRod: ; f5a5
ld e, $0
2016-05-14 13:37:12 -07:00
jr UseRod
2013-05-07 23:02:15 -07:00
; f5a9
GoodRod: ; f5a9
ld e, $1
2016-05-14 13:37:12 -07:00
jr UseRod
2013-05-07 23:02:15 -07:00
; f5ad
SuperRod: ; f5ad
ld e, $2
2016-05-14 13:37:12 -07:00
jr UseRod
2013-05-07 23:02:15 -07:00
; f5b1
2016-05-14 13:37:12 -07:00
UseRod: ; f5b1
2017-12-24 09:47:30 -08:00
farcall FishFunction
2013-05-07 23:02:15 -07:00
ret
; f5b8
Itemfinder: ; f5b8
2017-12-24 09:47:30 -08:00
farcall ItemFinder
2013-05-07 23:02:15 -07:00
ret
; f5bf
MaxElixer:
2015-12-15 07:55:56 -08:00
PPUp:
2013-05-07 23:02:15 -07:00
Ether:
MaxEther:
Elixer:
Mysteryberry: ; f5bf
ld a, [CurItem]
2015-11-10 16:51:13 -08:00
ld [wd002], a
2013-05-07 23:02:15 -07:00
.loop
2016-06-07 05:13:08 -07:00
; Party Screen opens to choose on which Pkmn to use the Item
2015-11-08 07:59:28 -08:00
ld b, PARTYMENUACTION_HEALING_ITEM
call UseItem_SelectMon
jp c, PPRestoreItem_Cancel
2013-05-07 23:02:15 -07:00
.loop2
2015-11-10 16:51:13 -08:00
ld a, [wd002]
2013-12-24 14:11:52 -08:00
cp MAX_ELIXER
jp z, Elixer_RestorePPofAllMoves
2013-12-24 14:11:52 -08:00
cp ELIXER
jp z, Elixer_RestorePPofAllMoves
2013-12-24 14:11:52 -08:00
2015-10-10 04:45:39 -07:00
ld hl, TextJump_RaiseThePPOfWhichMove
2015-11-10 16:51:13 -08:00
ld a, [wd002]
2013-12-24 14:11:52 -08:00
cp PP_UP
jr z, .ppup
2015-10-10 04:45:39 -07:00
ld hl, TextJump_RestoreThePPOfWhichMove
2013-05-07 23:02:15 -07:00
.ppup
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
ld a, [CurMoveNum]
push af
xor a
ld [CurMoveNum], a
ld a, $2
2015-11-23 13:04:53 -08:00
ld [wMoveSelectionMenuType], a
2017-12-24 09:47:30 -08:00
farcall MoveSelectionScreen
2013-05-07 23:02:15 -07:00
pop bc
2015-10-11 09:39:00 -07:00
2013-05-07 23:02:15 -07:00
ld a, b
ld [CurMoveNum], a
jr nz, .loop
2013-12-24 14:11:52 -08:00
ld hl, PartyMon1Moves
ld bc, PARTYMON_STRUCT_LENGTH
call GetMthMoveOfNthPartymon
2013-05-07 23:02:15 -07:00
push hl
ld a, [hl]
ld [wd265], a
2013-12-24 14:11:52 -08:00
call GetMoveName
2013-05-07 23:02:15 -07:00
call CopyName1
pop hl
2015-10-11 09:39:00 -07:00
2015-11-10 16:51:13 -08:00
ld a, [wd002]
2013-12-24 14:11:52 -08:00
cp PP_UP
jp nz, Not_PP_Up
2013-12-24 14:11:52 -08:00
2013-05-07 23:02:15 -07:00
ld a, [hl]
cp SKETCH
jr z, .CantUsePPUpOnSketch
2013-12-24 14:11:52 -08:00
2018-01-09 12:39:48 -08:00
ld bc, MON_PP - MON_MOVES
2013-05-07 23:02:15 -07:00
add hl, bc
ld a, [hl]
2018-01-09 14:20:47 -08:00
cp PP_UP_MASK
jr c, .do_ppup
2013-05-07 23:02:15 -07:00
.CantUsePPUpOnSketch:
2015-10-10 04:45:39 -07:00
.pp_is_maxed_out
ld hl, TextJump_PPIsMaxedOut
2013-12-24 14:11:52 -08:00
call PrintText
jr .loop2
2013-05-07 23:02:15 -07:00
.do_ppup
2013-05-07 23:02:15 -07:00
ld a, [hl]
2018-01-09 14:20:47 -08:00
add PP_UP_ONE
2013-05-07 23:02:15 -07:00
ld [hl], a
ld a, $1
ld [wd265], a
call ApplyPPUp
2015-10-10 04:45:39 -07:00
call Play_SFX_FULL_HEAL
2013-05-07 23:02:15 -07:00
2015-10-10 04:45:39 -07:00
ld hl, TextJump_PPsIncreased
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
FinishPPRestore: ; f64c
2013-12-24 14:11:52 -08:00
call ClearPalettes
jp UseDisposableItem
2013-12-24 14:11:52 -08:00
; f652
BattleRestorePP: ; f652
ld a, [wBattleMode]
2013-12-24 14:11:52 -08:00
and a
jr z, .not_in_battle
2013-12-24 14:11:52 -08:00
ld a, [CurPartyMon]
ld b, a
ld a, [CurBattleMon]
cp b
jr nz, .not_in_battle
2013-12-24 14:11:52 -08:00
ld a, [PlayerSubStatus5]
2015-11-08 07:59:28 -08:00
bit SUBSTATUS_TRANSFORMED, a
jr nz, .not_in_battle
call .UpdateBattleMonPP
2013-05-07 23:02:15 -07:00
.not_in_battle
2015-10-10 04:45:39 -07:00
call Play_SFX_FULL_HEAL
2013-12-24 14:11:52 -08:00
ld hl, UnknownText_0xf739
call PrintText
jr FinishPPRestore
2013-12-24 14:11:52 -08:00
.UpdateBattleMonPP:
2013-12-24 14:11:52 -08:00
ld a, [CurPartyMon]
ld hl, PartyMon1Moves
ld bc, PARTYMON_STRUCT_LENGTH
2013-12-24 14:11:52 -08:00
call AddNTimes
ld de, BattleMonMoves
ld b, NUM_MOVES
.loop
2013-12-24 14:11:52 -08:00
ld a, [de]
and a
jr z, .done
2013-12-24 14:11:52 -08:00
cp [hl]
jr nz, .next
2013-12-24 14:11:52 -08:00
push hl
push de
push bc
rept NUM_MOVES + 2 ; BattleMonPP - BattleMonMoves
2013-12-24 14:11:52 -08:00
inc de
endr
ld bc, MON_PP - MON_MOVES
2013-12-24 14:11:52 -08:00
add hl, bc
ld a, [hl]
ld [de], a
pop bc
pop de
pop hl
.next
2013-12-24 14:11:52 -08:00
inc hl
inc de
dec b
jr nz, .loop
2013-12-24 14:11:52 -08:00
.done
2013-12-24 14:11:52 -08:00
ret
; f6a7
Not_PP_Up: ; f6a7
call RestorePP
jr nz, BattleRestorePP
jp PPRestoreItem_NoEffect
2013-12-24 14:11:52 -08:00
; f6af
Elixer_RestorePPofAllMoves: ; f6af
2013-12-24 14:11:52 -08:00
xor a
2015-12-15 15:59:49 -08:00
ld hl, wMenuCursorY
2013-12-24 14:11:52 -08:00
ld [hli], a
ld [hl], a
ld b, NUM_MOVES
.moveLoop
2013-12-24 14:11:52 -08:00
push bc
ld hl, PartyMon1Moves
ld bc, PARTYMON_STRUCT_LENGTH
call GetMthMoveOfNthPartymon
2013-12-24 14:11:52 -08:00
ld a, [hl]
and a
jr z, .next
call RestorePP
jr z, .next
2015-12-15 15:59:49 -08:00
ld hl, wMenuCursorX
2013-12-24 14:11:52 -08:00
inc [hl]
.next
2015-12-15 15:59:49 -08:00
ld hl, wMenuCursorY
2013-12-24 14:11:52 -08:00
inc [hl]
pop bc
dec b
jr nz, .moveLoop
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorX]
2013-12-24 14:11:52 -08:00
and a
jp nz, BattleRestorePP
2013-12-24 14:11:52 -08:00
PPRestoreItem_NoEffect: ; f6dd
call WontHaveAnyEffectMessage
2013-12-24 14:11:52 -08:00
PPRestoreItem_Cancel: ; f6e0
2013-05-07 23:02:15 -07:00
call ClearPalettes
2013-12-24 14:11:52 -08:00
xor a
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
2013-12-24 14:11:52 -08:00
ret
; f6e8
2013-05-07 23:02:15 -07:00
RestorePP: ; f6e8
xor a ; PARTYMON
2013-12-24 14:11:52 -08:00
ld [MonType], a
2015-11-08 07:59:28 -08:00
call GetMaxPPOfMove
2013-12-24 14:11:52 -08:00
ld hl, PartyMon1PP
ld bc, PARTYMON_STRUCT_LENGTH
call GetMthMoveOfNthPartymon
ld a, [wd265]
2013-12-24 14:11:52 -08:00
ld b, a
ld a, [hl]
2018-01-09 14:20:47 -08:00
and PP_MASK
2013-12-24 14:11:52 -08:00
cp b
jr nc, .dont_restore
2013-12-24 14:11:52 -08:00
2015-11-10 16:51:13 -08:00
ld a, [wd002]
2013-12-24 14:11:52 -08:00
cp MAX_ELIXER
jr z, .restore_all
2013-12-24 14:11:52 -08:00
cp MAX_ETHER
jr z, .restore_all
2013-12-24 14:11:52 -08:00
ld c, 5
cp MYSTERYBERRY
jr z, .restore_some
2013-12-24 14:11:52 -08:00
ld c, 10
.restore_some
2013-12-24 14:11:52 -08:00
ld a, [hl]
2018-01-09 14:20:47 -08:00
and PP_MASK
2013-12-24 14:11:52 -08:00
add c
cp b
jr nc, .restore_all
2013-12-24 14:11:52 -08:00
ld b, a
.restore_all
2013-12-24 14:11:52 -08:00
ld a, [hl]
2018-01-09 14:20:47 -08:00
and PP_UP_MASK
2013-12-24 14:11:52 -08:00
or b
ld [hl], a
ret
.dont_restore
2013-12-24 14:11:52 -08:00
xor a
ret
; f725
2013-05-07 23:02:15 -07:00
2015-10-10 04:45:39 -07:00
TextJump_RaiseThePPOfWhichMove: ; 0xf725
2013-12-24 14:11:52 -08:00
; Raise the PP of which move?
2015-10-10 04:45:39 -07:00
text_jump Text_RaiseThePPOfWhichMove
2013-12-24 14:11:52 -08:00
db "@"
; 0xf72a
2013-05-07 23:02:15 -07:00
2015-10-10 04:45:39 -07:00
TextJump_RestoreThePPOfWhichMove: ; 0xf72a
2013-12-24 14:11:52 -08:00
; Restore the PP of which move?
2015-10-10 04:45:39 -07:00
text_jump Text_RestoreThePPOfWhichMove
2013-12-24 14:11:52 -08:00
db "@"
; 0xf72f
2015-10-10 04:45:39 -07:00
TextJump_PPIsMaxedOut: ; 0xf72f
2013-12-24 14:11:52 -08:00
; 's PP is maxed out.
2015-10-10 04:45:39 -07:00
text_jump Text_PPIsMaxedOut
2013-12-24 14:11:52 -08:00
db "@"
; 0xf734
2015-10-10 04:45:39 -07:00
TextJump_PPsIncreased: ; 0xf734
2013-12-24 14:11:52 -08:00
; 's PP increased.
2015-10-10 04:45:39 -07:00
text_jump Text_PPsIncreased
2013-12-24 14:11:52 -08:00
db "@"
; 0xf739
UnknownText_0xf739: ; 0xf739
; PP was restored.
text_jump UnknownText_0x1c5cf1
db "@"
; 0xf73e
2013-05-07 23:02:15 -07:00
Squirtbottle: ; f73e
2017-12-24 09:47:30 -08:00
farcall _Squirtbottle
2013-05-07 23:02:15 -07:00
ret
; f745
CardKey: ; f745
2017-12-24 09:47:30 -08:00
farcall _CardKey
2013-05-07 23:02:15 -07:00
ret
; f74c
BasementKey: ; f74c
2017-12-24 09:47:30 -08:00
farcall _BasementKey
2013-05-07 23:02:15 -07:00
ret
; f753
SacredAsh: ; f753
2017-12-24 09:47:30 -08:00
farcall _SacredAsh
2015-12-13 11:15:16 -08:00
ld a, [wItemEffectSucceeded]
2013-05-07 23:02:15 -07:00
cp $1
ret nz
call UseDisposableItem
2013-05-07 23:02:15 -07:00
ret
; f763
NormalBox: ; f763
ld c, DECOFLAG_SILVER_TROPHY_DOLL
jr OpenBox
2013-05-07 23:02:15 -07:00
; f767
GorgeousBox: ; f767
ld c, DECOFLAG_GOLD_TROPHY_DOLL
OpenBox: ; f769
2017-12-24 09:47:30 -08:00
farcall SetSpecificDecorationFlag
2013-05-07 23:02:15 -07:00
ld hl, .text
2013-12-24 14:11:52 -08:00
call PrintText
2013-05-07 23:02:15 -07:00
jp UseDisposableItem
2013-05-07 23:02:15 -07:00
; f778
.text ; 0xf778
; There was a trophy inside!
2013-12-01 14:54:09 -08:00
text_jump UnknownText_0x1c5d03
2013-05-08 00:27:46 -07:00
db "@"
; 0xf77d
2013-05-07 23:02:15 -07:00
Brightpowder:
Item19:
LuckyPunch:
MetalPowder:
Nugget:
Item2D:
Item32:
ExpShare:
SilverLeaf:
RedScale:
Secretpotion:
SSTicket:
MysteryEgg:
ClearBell:
SilverWing:
QuickClaw:
GoldLeaf:
SoftSand:
SharpBeak:
PoisonBarb:
KingsRock:
RedApricorn:
Tinymushroom:
BigMushroom:
Silverpowder:
BluApricorn:
Item5A:
AmuletCoin:
YlwApricorn:
GrnApricorn:
CleanseTag:
MysticWater:
Twistedspoon:
WhtApricorn:
Blackbelt:
BlkApricorn:
Item64:
PnkApricorn:
Blackglasses:
Slowpoketail:
PinkBow:
Stick:
SmokeBall:
Nevermeltice:
Magnet:
Pearl:
BigPearl:
Everstone:
SpellTag:
GsBall:
MiracleSeed:
ThickClub:
FocusBand:
Item78:
HardStone:
LuckyEgg:
MachinePart:
EggTicket:
LostItem:
Stardust:
StarPiece:
Pass:
Item87:
Item88:
Item89:
Charcoal:
ScopeLens:
Item8D:
Item8E:
MetalCoat:
DragonFang:
Item91:
Leftovers:
Item93:
Item94:
Item95:
DragonScale:
BerserkGene:
Item99:
Item9A:
Item9B:
FlowerMail:
ItemA2:
LightBall:
PolkadotBow:
ItemAB:
UpGrade:
ItemB0:
RainbowWing:
ItemB3:
TeruSama: ; f77d
jp IsntTheTimeMessage
2013-05-07 23:02:15 -07:00
; f780
2015-10-10 04:45:39 -07:00
Play_SFX_FULL_HEAL: ; f780
push de
ld de, SFX_FULL_HEAL
call WaitPlaySFX
pop de
ret
; f789
2016-05-27 07:41:59 -07:00
UseItemText: ; f789
ld hl, UsedItemText
call PrintText
2015-10-10 04:45:39 -07:00
call Play_SFX_FULL_HEAL
call WaitPressAorB_BlinkCursor
UseDisposableItem: ; f795
ld hl, NumItems
ld a, 1
2015-11-01 15:13:31 -08:00
ld [wItemQuantityChangeBuffer], a
jp TossItem
; f7a0
UseBallInTrainerBattle: ; f7a0
call ReturnToBattle_UseBall
ld de, ANIM_THROW_POKE_BALL
ld a, e
2017-12-09 16:41:03 -08:00
ld [FXAnimID], a
ld a, d
2017-12-09 16:41:03 -08:00
ld [FXAnimID + 1], a
xor a
2016-01-27 09:25:12 -08:00
ld [wBattleAnimParam], a
ld [hBattleTurn], a
2015-12-23 11:00:29 -08:00
ld [wNumHits], a
predef PlayBattleAnim
ld hl, BlockedTheBallText
call PrintText
ld hl, DontBeAThiefText
call PrintText
jr UseDisposableItem
; f7ca
WontHaveAnyEffect_NotUsedMessage: ; f7ca
ld hl, WontHaveAnyEffectText
call PrintText
; Item wasn't used.
ld a, $2
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
ret
; f7d6
LooksBitterMessage: ; f7d6
ld hl, LooksBitterText
jp PrintText
; f7dc
Ball_BoxIsFullMessage: ; f7dc
ld hl, Ball_BoxIsFullText
call PrintText
; Item wasn't used.
ld a, $2
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
ret
; f7e8
CantUseOnEggMessage: ; f7e8
ld hl, CantUseOnEggText
jr CantUseItemMessage
IsntTheTimeMessage: ; f7ed
ld hl, IsntTheTimeText
jr CantUseItemMessage
WontHaveAnyEffectMessage: ; f7f2
ld hl, WontHaveAnyEffectText
jr CantUseItemMessage
BelongsToSomeoneElseMessage: ; f7f7
ld hl, BelongsToSomeoneElseText
jr CantUseItemMessage
CyclingIsntAllowedMessage: ; f7fc
ld hl, CyclingIsntAllowedText
jr CantUseItemMessage
CantGetOnYourBikeMessage: ; f801
ld hl, CantGetOnYourBikeText
CantUseItemMessage: ; f804
; Item couldn't be used.
xor a
2015-12-13 11:15:16 -08:00
ld [wItemEffectSucceeded], a
jp PrintText
; f80b
LooksBitterText: ; 0xf80b
; It looks bitter…
text_jump UnknownText_0x1c5d3e
db "@"
; 0xf810
CantUseOnEggText: ; 0xf810
; That can't be used on an EGG.
text_jump UnknownText_0x1c5d50
db "@"
; 0xf815
IsntTheTimeText: ; 0xf815
; OAK: ! This isn't the time to use that!
text_jump UnknownText_0x1c5d6e
db "@"
; 0xf81a
BelongsToSomeoneElseText: ; 0xf81a
; That belongs to someone else!
text_jump UnknownText_0x1c5d97
db "@"
; 0xf81f
WontHaveAnyEffectText: ; 0xf81f
; It won't have any effect.
text_jump UnknownText_0x1c5db6
db "@"
; 0xf824
BlockedTheBallText: ; 0xf824
; The trainer blocked the BALL!
text_jump UnknownText_0x1c5dd0
db "@"
; 0xf829
DontBeAThiefText: ; 0xf829
; Don't be a thief!
text_jump UnknownText_0x1c5def
db "@"
; 0xf82e
CyclingIsntAllowedText: ; 0xf82e
; Cycling isn't allowed here.
text_jump UnknownText_0x1c5e01
db "@"
; 0xf833
CantGetOnYourBikeText: ; 0xf833
; Can't get on your @ now.
text_jump UnknownText_0x1c5e1d
db "@"
; 0xf838
Ball_BoxIsFullText: ; 0xf838
; The #MON BOX is full. That can't be used now.
text_jump UnknownText_0x1c5e3a
db "@"
; 0xf83d
UsedItemText: ; 0xf83d
; used the@ .
text_jump UnknownText_0x1c5e68
db "@"
; 0xf842
GotOnTheItemText: ; 0xf842
; got on the@ .
text_jump UnknownText_0x1c5e7b
db "@"
; 0xf847
GotOffTheItemText: ; 0xf847
; got off@ the @ .
text_jump UnknownText_0x1c5e90
db "@"
; 0xf84c
ApplyPPUp: ; f84c
ld a, MON_MOVES
call GetPartyParamLocation
push hl
ld de, Buffer1
predef FillPP
pop hl
ld bc, MON_PP - MON_MOVES
add hl, bc
ld de, Buffer1
ld b, 0
.loop
inc b
ld a, b
cp NUM_MOVES + 1
ret z
ld a, [wd265]
dec a
jr nz, .use
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
inc a
cp b
jr nz, .skip
.use
ld a, [hl]
2018-01-09 14:20:47 -08:00
and PP_UP_MASK
ld a, [de] ; wasted cycle
call nz, ComputeMaxPP
.skip
inc hl
inc de
jr .loop
; f881
ComputeMaxPP: ; f881
push bc
; Divide the base PP by 5.
ld a, [de]
ld [hDividend + 3], a
xor a
ld [hDividend], a
ld [hDividend + 1], a
ld [hDividend + 2], a
ld a, 5
ld [hDivisor], a
ld b, 4
call Divide
; Get the number of PP, which are bits 6 and 7 of the PP value stored in RAM.
ld a, [hl]
ld b, a
swap a
and $f
srl a
srl a
ld c, a
; If this value is 0, we are done
and a
jr z, .NoPPUp
.loop
; Normally, a move with 40 PP would have 64 PP with three PP Ups.
; Since this would overflow into bit 6, we prevent that from happening
; by decreasing the extra amount of PP each PP Up provides, resulting
; in a maximum of 61.
ld a, [hQuotient + 2]
cp $8
jr c, .okay
ld a, $7
.okay
add b
ld b, a
ld a, [wd265]
dec a
jr z, .NoPPUp
dec c
jr nz, .loop
.NoPPUp:
ld [hl], b
pop bc
ret
; f8b9
RestoreAllPP: ; f8b9
ld a, MON_PP
call GetPartyParamLocation
push hl
ld a, MON_MOVES
call GetPartyParamLocation
pop de
xor a ; PARTYMON
2015-12-15 15:59:49 -08:00
ld [wMenuCursorY], a
ld [MonType], a
ld c, NUM_MOVES
.loop
ld a, [hli]
and a
ret z
push hl
push de
push bc
2015-11-08 07:59:28 -08:00
call GetMaxPPOfMove
pop bc
pop de
ld a, [de]
2018-01-09 14:20:47 -08:00
and PP_UP_MASK
ld b, a
ld a, [wd265]
add b
ld [de], a
inc de
2015-12-15 15:59:49 -08:00
ld hl, wMenuCursorY
inc [hl]
pop hl
dec c
jr nz, .loop
ret
; f8ec
2015-11-08 07:59:28 -08:00
GetMaxPPOfMove: ; f8ec
ld a, [StringBuffer1 + 0]
push af
ld a, [StringBuffer1 + 1]
push af
ld a, [MonType]
and a
ld hl, PartyMon1Moves
ld bc, PARTYMON_STRUCT_LENGTH
jr z, .got_partymon ; PARTYMON
ld hl, OTPartyMon1Moves
dec a
jr z, .got_partymon ; OTPARTYMON
ld hl, TempMonMoves
dec a
jr z, .got_nonpartymon ; BOXMON
ld hl, TempMonMoves ; Wasted cycles
dec a
2016-05-11 14:16:03 -07:00
jr z, .got_nonpartymon ; TEMPMON
ld hl, BattleMonMoves ; WILDMON
2016-05-11 14:16:03 -07:00
.got_nonpartymon ; BOXMON, TEMPMON, WILDMON
call GetMthMoveOfCurrentMon
jr .gotdatmove
.got_partymon ; PARTYMON, OTPARTYMON
call GetMthMoveOfNthPartymon
.gotdatmove
ld a, [hl]
dec a
push hl
ld hl, Moves + MOVE_PP
ld bc, MOVE_LENGTH
call AddNTimes
ld a, BANK(Moves)
call GetFarByte
ld b, a
ld de, StringBuffer1
ld [de], a
pop hl
push bc
ld bc, MON_PP - MON_MOVES
ld a, [MonType]
cp WILDMON
jr nz, .notwild
ld bc, EnemyMonPP - EnemyMonMoves
.notwild
add hl, bc
ld a, [hl]
2018-01-09 14:20:47 -08:00
and PP_UP_MASK
pop bc
or b
ld hl, StringBuffer1 + 1
ld [hl], a
xor a
ld [wd265], a
ld a, b ; this gets lost anyway
call ComputeMaxPP
ld a, [hl]
2018-01-09 14:20:47 -08:00
and PP_MASK
ld [wd265], a
pop af
ld [StringBuffer1 + 1], a
pop af
ld [StringBuffer1 + 0], a
ret
; f963
GetMthMoveOfNthPartymon: ; f963
ld a, [CurPartyMon]
call AddNTimes
GetMthMoveOfCurrentMon: ; f969
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
ld c, a
ld b, 0
add hl, bc
ret
; f971