2013-12-17 22:11:06 -08:00
|
|
|
|
; Core components of the battle engine.
|
2018-06-12 20:29:15 -07:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DoBattle:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld [wBattleParticipantsNotFainted], a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wBattleParticipantsIncludingFainted], a
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleEnded], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2016-08-07 15:14:20 -07:00
|
|
|
|
ld [wBattleHasJustStarted], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1HP
|
2015-11-06 06:04:27 -08:00
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - 1
|
|
|
|
|
ld d, BATTLEACTION_SWITCH1 - 1
|
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc d
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nz, .alive
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.alive
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld [wBattleAction], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .not_linked
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_INTERNAL_CLOCK
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .player_2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.not_linked
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .wild
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld [wEnemySwitchMonIndex], a
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewEnemyMonStatus
|
|
|
|
|
call ResetEnemyStatLevels
|
|
|
|
|
call BreakAttraction
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call EnemySwitch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.wild
|
2014-01-01 05:09:15 -08:00
|
|
|
|
ld c, 40
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.player_2
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call CheckPlayerPartyForFitMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
|
|
|
|
and a
|
|
|
|
|
jp z, LostBattle
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2015-09-09 16:27:07 -07:00
|
|
|
|
cp BATTLETYPE_DEBUG
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .tutorial_debug
|
2014-06-13 22:53:20 -07:00
|
|
|
|
cp BATTLETYPE_TUTORIAL
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .tutorial_debug
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.loop2
|
2016-03-01 19:31:21 -08:00
|
|
|
|
call CheckIfCurPartyMonIsFitToFight
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nz, .alive2
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wCurPartyMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc [hl]
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.alive2
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wLastPlayerMon], a
|
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurBattleMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartySpecies - 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2014-06-23 12:47:07 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartySpecies], a
|
|
|
|
|
ld [wTempBattleMonSpecies], a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 5
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld a, 9
|
|
|
|
|
call SlideBattlePicOut
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call ResetBattleParticipants
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call InitBattleMon
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call ResetPlayerStatLevels
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call SendOutMonText
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewBattleMonStatus
|
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
|
call SendOutPlayerMon
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call SpikesDamage
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .not_linked_2
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_INTERNAL_CLOCK
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nz, .not_linked_2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld [wEnemySwitchMonIndex], a
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewEnemyMonStatus
|
|
|
|
|
call ResetEnemyStatLevels
|
|
|
|
|
call BreakAttraction
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call EnemySwitch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call SpikesDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.not_linked_2
|
2015-11-28 12:13:40 -08:00
|
|
|
|
jp BattleTurn
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.tutorial_debug
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp BattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
WildFled_EnemyFled_LinkBattleCanceled:
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
|
add DRAW
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld [wBattleResult], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-08-24 16:56:30 -07:00
|
|
|
|
ld hl, BattleText_WildFled
|
2015-11-28 12:13:40 -08:00
|
|
|
|
jr z, .print_text
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
|
ld [wBattleResult], a ; WIN
|
2015-08-24 16:56:30 -07:00
|
|
|
|
ld hl, BattleText_EnemyFled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-28 12:13:40 -08:00
|
|
|
|
.print_text
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-28 12:13:40 -08:00
|
|
|
|
.skip_text
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call StopDangerSound
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, SFX_RUN
|
|
|
|
|
call PlaySFX
|
|
|
|
|
|
2015-11-28 12:13:40 -08:00
|
|
|
|
.skip_sfx
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleEnded], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleTurn:
|
2014-06-17 11:58:11 -07:00
|
|
|
|
.loop
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call CheckContestBattleOver
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp c, .quit
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld [wPlayerIsSwitching], a
|
|
|
|
|
ld [wEnemyIsSwitching], a
|
2016-08-07 15:14:20 -07:00
|
|
|
|
ld [wBattleHasJustStarted], a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld [wPlayerJustGotFrozen], a
|
|
|
|
|
ld [wEnemyJustGotFrozen], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurDamage], a
|
|
|
|
|
ld [wCurDamage + 1], a
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
call HandleBerserkGene
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleMonInParty
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall AIChooseMove
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
call CheckPlayerLockedIn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr c, .skip_iteration
|
|
|
|
|
.loop1
|
2014-06-17 11:58:11 -07:00
|
|
|
|
call BattleMenu
|
|
|
|
|
jr c, .quit
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleEnded]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr nz, .quit
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld a, [wForcedSwitch] ; roared/whirlwinded/teleported
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr nz, .quit
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.skip_iteration
|
2015-11-08 16:09:36 -08:00
|
|
|
|
call ParsePlayerAction
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .loop1
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
call EnemyTriesToFlee
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr c, .quit
|
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
call DetermineMoveOrder
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr c, .false
|
2015-11-08 16:09:36 -08:00
|
|
|
|
call Battle_EnemyFirst
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr .proceed
|
|
|
|
|
.false
|
2015-11-08 16:09:36 -08:00
|
|
|
|
call Battle_PlayerFirst
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.proceed
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld a, [wForcedSwitch]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr nz, .quit
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleEnded]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr nz, .quit
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleBetweenTurnEffects
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleEnded]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr nz, .quit
|
|
|
|
|
jp .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
|
.quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleBetweenTurnEffects:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr z, .CheckEnemyFirst
|
|
|
|
|
call CheckFaint_PlayerThenEnemy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleFutureSight
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_PlayerThenEnemy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
|
|
|
|
call HandleWeather
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_PlayerThenEnemy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleWrap
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_PlayerThenEnemy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandlePerishSong
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_PlayerThenEnemy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr .NoMoreFaintingConditions
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.CheckEnemyFirst:
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_EnemyThenPlayer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleFutureSight
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_EnemyThenPlayer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
|
|
|
|
call HandleWeather
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_EnemyThenPlayer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleWrap
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_EnemyThenPlayer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandlePerishSong
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckFaint_EnemyThenPlayer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.NoMoreFaintingConditions:
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleLeftovers
|
|
|
|
|
call HandleMysteryberry
|
2018-04-05 02:41:06 -07:00
|
|
|
|
call HandleDefrost
|
2015-09-06 14:38:01 -07:00
|
|
|
|
call HandleSafeguard
|
|
|
|
|
call HandleScreens
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleStatBoostingHeldItems
|
|
|
|
|
call HandleHealingItems
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleMonInParty
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jp HandleEncore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckFaint_PlayerThenEnemy:
|
2022-07-09 14:12:02 -07:00
|
|
|
|
; BUG: Perish Song and Spikes can leave a Pokemon with 0 HP and not faint (see docs/bugs_and_glitches.md)
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasPlayerFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .PlayerNotFainted
|
|
|
|
|
call HandlePlayerMonFaint
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleEnded]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PlayerNotFainted:
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasEnemyFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .BattleContinues
|
|
|
|
|
call HandleEnemyMonFaint
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleEnded]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.BattleContinues:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.BattleIsOver:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckFaint_EnemyThenPlayer:
|
2022-07-09 14:12:02 -07:00
|
|
|
|
; BUG: Perish Song and Spikes can leave a Pokemon with 0 HP and not faint (see docs/bugs_and_glitches.md)
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasEnemyFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .EnemyNotFainted
|
|
|
|
|
call HandleEnemyMonFaint
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleEnded]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.EnemyNotFainted:
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasPlayerFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .BattleContinues
|
|
|
|
|
call HandlePlayerMonFaint
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleEnded]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.BattleContinues:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.BattleIsOver:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleBerserkGene:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2014-01-19 21:07:51 -08:00
|
|
|
|
jr z, .reverse
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-01-19 21:07:51 -08:00
|
|
|
|
call .player
|
|
|
|
|
jr .enemy
|
|
|
|
|
|
|
|
|
|
.reverse
|
|
|
|
|
call .enemy
|
2018-08-26 19:34:59 -07:00
|
|
|
|
; fallthrough
|
2014-01-19 21:07:51 -08:00
|
|
|
|
|
|
|
|
|
.player
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wPartyMon1Item
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2014-01-19 21:07:51 -08:00
|
|
|
|
jr .go
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-01-19 21:07:51 -08:00
|
|
|
|
.enemy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wOTPartyMon1Item
|
|
|
|
|
ld a, [wCurOTMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-08-26 19:34:59 -07:00
|
|
|
|
; fallthrough
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-01-19 21:07:51 -08:00
|
|
|
|
.go
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetUserItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2014-01-19 21:07:51 -08:00
|
|
|
|
sub BERSERK_GENE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
ret nz
|
2014-01-19 21:07:51 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2014-01-19 21:07:51 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld h, d
|
|
|
|
|
ld l, e
|
|
|
|
|
ld a, b
|
|
|
|
|
call GetPartyLocation
|
|
|
|
|
xor a
|
|
|
|
|
ld [hl], a
|
2022-07-09 14:12:02 -07:00
|
|
|
|
; BUG: Berserk Gene's confusion lasts for 256 turns or the previous Pokémon's confusion count (see docs/bugs_and_glitches.md)
|
2014-01-19 21:07:51 -08:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2014-01-19 21:07:51 -08:00
|
|
|
|
set SUBSTATUS_CONFUSED, [hl]
|
|
|
|
|
ld a, BATTLE_VARS_MOVE_ANIM
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push af
|
|
|
|
|
xor a
|
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wAttackMissed], a
|
|
|
|
|
ld [wEffectFailed], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall BattleCommand_AttackUp2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
pop hl
|
|
|
|
|
ld [hl], a
|
|
|
|
|
call GetItemName
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_UsersStringBuffer1Activated
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar BattleCommand_StatUpMessage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2014-01-19 21:07:51 -08:00
|
|
|
|
bit SUBSTATUS_CONFUSED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_CONFUSED
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call Call_PlayBattleAnim_OnlyIfVisible
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2014-01-05 04:28:55 -08:00
|
|
|
|
ld hl, BecameConfusedText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EnemyTriesToFlee:
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .not_linked
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, [wBattleAction]
|
2015-11-06 06:04:27 -08:00
|
|
|
|
cp BATTLEACTION_FORFEIT
|
|
|
|
|
jr z, .forfeit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.not_linked
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.forfeit
|
2015-09-06 14:38:01 -07:00
|
|
|
|
call WildFled_EnemyFled_LinkBattleCanceled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DetermineMoveOrder:
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .use_move
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, [wBattleAction]
|
2018-10-20 21:52:10 -07:00
|
|
|
|
cp BATTLEACTION_STRUGGLE
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .use_move
|
2018-10-20 21:52:10 -07:00
|
|
|
|
cp BATTLEACTION_SKIPTURN
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .use_move
|
|
|
|
|
sub BATTLEACTION_SWITCH1
|
|
|
|
|
jr c, .use_move
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattlePlayerAction]
|
2018-07-28 16:27:34 -07:00
|
|
|
|
cp BATTLEPLAYERACTION_SWITCH
|
2015-11-05 16:13:09 -08:00
|
|
|
|
jr nz, .switch
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_INTERNAL_CLOCK
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .player_2
|
2015-11-05 16:13:09 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
|
cp 50 percent + 1
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp c, .player_first
|
|
|
|
|
jp .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.player_2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
|
cp 50 percent + 1
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp c, .enemy_first
|
|
|
|
|
jp .player_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
|
.switch
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar AI_Switch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call SpikesDamage
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.use_move
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattlePlayerAction]
|
2018-07-28 16:27:34 -07:00
|
|
|
|
and a ; BATTLEPLAYERACTION_USEMOVE?
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp nz, .player_first
|
2013-12-30 20:32:37 -08:00
|
|
|
|
call CompareMovePriority
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .equal_priority
|
|
|
|
|
jp c, .player_first ; player goes first
|
|
|
|
|
jp .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.equal_priority
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetUserItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetOpponentItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
ld a, d
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp HELD_QUICK_CLAW
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nz, .player_no_quick_claw
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp HELD_QUICK_CLAW
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .both_have_quick_claw
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
|
|
|
|
cp e
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nc, .speed_check
|
|
|
|
|
jp .player_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.player_no_quick_claw
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp HELD_QUICK_CLAW
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nz, .speed_check
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
|
|
|
|
cp c
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nc, .speed_check
|
|
|
|
|
jp .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.both_have_quick_claw
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_INTERNAL_CLOCK
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .player_2b
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
|
|
|
|
cp c
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp c, .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
|
|
|
|
cp e
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp c, .player_first
|
|
|
|
|
jr .speed_check
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.player_2b
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
|
|
|
|
cp e
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp c, .player_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
|
|
|
|
cp c
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp c, .enemy_first
|
|
|
|
|
jr .speed_check
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.speed_check
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonSpeed
|
|
|
|
|
ld hl, wEnemyMonSpeed
|
2015-11-06 06:04:27 -08:00
|
|
|
|
ld c, 2
|
2018-07-22 21:25:53 -07:00
|
|
|
|
call CompareBytes
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .speed_tie
|
|
|
|
|
jp nc, .player_first
|
|
|
|
|
jp .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.speed_tie
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_INTERNAL_CLOCK
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .player_2c
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
|
cp 50 percent + 1
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp c, .player_first
|
|
|
|
|
jp .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.player_2c
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
|
cp 50 percent + 1
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp c, .enemy_first
|
|
|
|
|
.player_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckContestBattleOver:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2014-06-17 11:58:11 -07:00
|
|
|
|
cp BATTLETYPE_CONTEST
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .contest_not_over
|
|
|
|
|
ld a, [wParkBallsRemaining]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .contest_not_over
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
|
add DRAW
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld [wBattleResult], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.contest_not_over
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckPlayerLockedIn:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerSubStatus4]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
and 1 << SUBSTATUS_RECHARGE
|
|
|
|
|
jp nz, .quit
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_FLINCHED, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_FLINCHED, [hl]
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_RAMPAGE
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jp nz, .quit
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus1
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_ROLLOUT, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jp nz, .quit
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ParsePlayerAction:
|
2015-11-08 16:09:36 -08:00
|
|
|
|
call CheckPlayerLockedIn
|
|
|
|
|
jp c, .locked_in
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr z, .not_encored
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wLastPlayerMove]
|
|
|
|
|
ld [wCurPlayerMove], a
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr .encored
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.not_encored
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattlePlayerAction]
|
2018-07-28 16:27:34 -07:00
|
|
|
|
cp BATTLEPLAYERACTION_SWITCH
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr z, .reset_rage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr nz, .reset_bide
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerSubStatus3]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
and 1 << SUBSTATUS_BIDE
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr nz, .locked_in
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld [wMoveSelectionMenuType], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
inc a ; POUND
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wFXAnimID], a
|
2015-10-10 04:45:39 -07:00
|
|
|
|
call MoveSelectionScreen
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleHuds
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPlayerMove]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp STRUGGLE
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr z, .struggle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PlayClickSFX
|
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.struggle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
ret nz
|
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.encored
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar UpdateMoveData
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld [wPlayerCharging], a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wPlayerMoveStruct + MOVE_EFFECT]
|
|
|
|
|
cp EFFECT_FURY_CUTTER
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr z, .continue_fury_cutter
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPlayerFuryCutterCount], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.continue_fury_cutter
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wPlayerMoveStruct + MOVE_EFFECT]
|
|
|
|
|
cp EFFECT_RAGE
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr z, .continue_rage
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus4
|
2014-06-12 18:32:42 -07:00
|
|
|
|
res SUBSTATUS_RAGE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
ld [wPlayerRageCounter], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.continue_rage
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wPlayerMoveStruct + MOVE_EFFECT]
|
|
|
|
|
cp EFFECT_PROTECT
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr z, .continue_protect
|
2014-06-12 18:32:42 -07:00
|
|
|
|
cp EFFECT_ENDURE
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr z, .continue_protect
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPlayerProtectCount], a
|
2015-11-08 16:09:36 -08:00
|
|
|
|
jr .continue_protect
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.reset_bide
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_BIDE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.locked_in
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPlayerFuryCutterCount], a
|
|
|
|
|
ld [wPlayerProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
ld [wPlayerRageCounter], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus4
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_RAGE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.continue_protect
|
|
|
|
|
call ParseEnemyAction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
|
.reset_rage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPlayerFuryCutterCount], a
|
|
|
|
|
ld [wPlayerProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
ld [wPlayerRageCounter], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus4
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_RAGE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleEncore:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .player_1
|
|
|
|
|
call .do_player
|
|
|
|
|
jr .do_enemy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.player_1
|
|
|
|
|
call .do_enemy
|
|
|
|
|
.do_player
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerEncoreCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPlayerEncoreCount], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .end_player_encore
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonPP
|
|
|
|
|
ld a, [wCurMoveNum]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
|
and PP_MASK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.end_player_encore
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
|
res SUBSTATUS_ENCORED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_TargetsEncoreEnded
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.do_enemy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyEncoreCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyEncoreCount], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .end_enemy_encore
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonPP
|
|
|
|
|
ld a, [wCurEnemyMoveNum]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
|
and PP_MASK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.end_enemy_encore
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
|
res SUBSTATUS_ENCORED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_TargetsEncoreEnded
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
TryEnemyFlee:
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
jr nz, .Stay
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .Stay
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
ld a, [wEnemyWrapCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
jr nz, .Stay
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonStatus]
|
2022-06-17 19:25:56 -07:00
|
|
|
|
and 1 << FRZ | SLP_MASK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .Stay
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, 1
|
2013-12-24 14:19:39 -08:00
|
|
|
|
ld hl, AlwaysFleeMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call IsInArray
|
|
|
|
|
jr c, .Flee
|
|
|
|
|
|
|
|
|
|
call BattleRandom
|
|
|
|
|
ld b, a
|
2018-02-04 18:21:34 -08:00
|
|
|
|
cp 50 percent + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nc, .Stay
|
|
|
|
|
|
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, 1
|
2013-12-24 14:19:39 -08:00
|
|
|
|
ld hl, OftenFleeMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call IsInArray
|
|
|
|
|
pop bc
|
|
|
|
|
jr c, .Flee
|
|
|
|
|
|
|
|
|
|
ld a, b
|
2018-02-04 18:21:34 -08:00
|
|
|
|
cp 10 percent + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nc, .Stay
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, 1
|
2013-12-24 14:19:39 -08:00
|
|
|
|
ld hl, SometimesFleeMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call IsInArray
|
|
|
|
|
jr c, .Flee
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Stay:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Flee:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2017-12-26 14:47:05 -08:00
|
|
|
|
INCLUDE "data/wild/flee_mons.asm"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CompareMovePriority:
|
2013-12-30 20:32:37 -08:00
|
|
|
|
; Compare the priority of the player and enemy's moves.
|
|
|
|
|
; Return carry if the player goes first, or z if they match.
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPlayerMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetMovePriority
|
|
|
|
|
ld b, a
|
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurEnemyMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetMovePriority
|
|
|
|
|
pop bc
|
|
|
|
|
cp b
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetMovePriority:
|
2013-12-30 20:32:37 -08:00
|
|
|
|
; Return the priority (0-3) of move a.
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2013-12-30 20:32:37 -08:00
|
|
|
|
|
2017-12-14 21:05:53 -08:00
|
|
|
|
; Vital Throw goes last.
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp VITAL_THROW
|
|
|
|
|
ld a, 0
|
|
|
|
|
ret z
|
2013-12-30 20:32:37 -08:00
|
|
|
|
|
|
|
|
|
call GetMoveEffect
|
|
|
|
|
ld hl, MoveEffectPriorities
|
2013-12-17 22:11:06 -08:00
|
|
|
|
.loop
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
cp b
|
2013-12-30 20:32:37 -08:00
|
|
|
|
jr z, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
2013-12-30 20:32:37 -08:00
|
|
|
|
cp -1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-30 20:32:37 -08:00
|
|
|
|
|
2018-01-09 12:39:48 -08:00
|
|
|
|
ld a, BASE_PRIORITY
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2013-12-30 20:32:37 -08:00
|
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
ret
|
|
|
|
|
|
2018-01-09 12:12:49 -08:00
|
|
|
|
INCLUDE "data/moves/effects_priorities.asm"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetMoveEffect:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
dec a
|
2013-12-30 20:22:27 -08:00
|
|
|
|
ld hl, Moves + MOVE_EFFECT
|
2014-06-10 23:23:55 -07:00
|
|
|
|
ld bc, MOVE_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call AddNTimes
|
2013-12-30 20:22:27 -08:00
|
|
|
|
ld a, BANK(Moves)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetFarByte
|
|
|
|
|
ld b, a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
Battle_EnemyFirst:
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call TryEnemyFlee
|
2015-09-06 14:38:01 -07:00
|
|
|
|
jp c, WildFled_EnemyFled_LinkBattleCanceled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
|
|
|
|
ld a, $1
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld [wEnemyGoesFirst], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar AI_SwitchOrTryItem
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr c, .switch_item
|
|
|
|
|
call EnemyTurn_EndOpponentProtectEndureDestinyBond
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld a, [wForcedSwitch]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasPlayerFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandlePlayerMonFaint
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasEnemyFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandleEnemyMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.switch_item
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call ResidualDamage
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandleEnemyMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call RefreshBattleHuds
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call PlayerTurn_EndOpponentProtectEndureDestinyBond
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld a, [wForcedSwitch]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasEnemyFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandleEnemyMonFaint
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasPlayerFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandlePlayerMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call ResidualDamage
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandlePlayerMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call RefreshBattleHuds
|
2018-07-28 16:27:34 -07:00
|
|
|
|
xor a ; BATTLEPLAYERACTION_USEMOVE
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
Battle_PlayerFirst:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld [wEnemyGoesFirst], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar AI_SwitchOrTryItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call PlayerTurn_EndOpponentProtectEndureDestinyBond
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld a, [wForcedSwitch]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasEnemyFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandleEnemyMonFaint
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasPlayerFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandlePlayerMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
call SetPlayerTurn
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call ResidualDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandlePlayerMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
call RefreshBattleHuds
|
|
|
|
|
pop af
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr c, .switched_or_used_item
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call TryEnemyFlee
|
2015-09-06 14:38:01 -07:00
|
|
|
|
jp c, WildFled_EnemyFled_LinkBattleCanceled
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call EnemyTurn_EndOpponentProtectEndureDestinyBond
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld a, [wForcedSwitch]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasPlayerFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandlePlayerMonFaint
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasEnemyFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandleEnemyMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.switched_or_used_item
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call ResidualDamage
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp z, HandleEnemyMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call RefreshBattleHuds
|
2018-07-28 16:27:34 -07:00
|
|
|
|
xor a ; BATTLEPLAYERACTION_USEMOVE
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PlayerTurn_EndOpponentProtectEndureDestinyBond:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call EndUserDestinyBond
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar DoPlayerTurn
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp EndOpponentProtectEndureDestinyBond
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EnemyTurn_EndOpponentProtectEndureDestinyBond:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call EndUserDestinyBond
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar DoEnemyTurn
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp EndOpponentProtectEndureDestinyBond
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EndOpponentProtectEndureDestinyBond:
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_PROTECT, [hl]
|
|
|
|
|
res SUBSTATUS_ENDURE, [hl]
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_DESTINY_BOND, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EndUserDestinyBond:
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_DESTINY_BOND, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HasUserFainted:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr z, HasPlayerFainted
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HasEnemyFainted:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2015-09-09 16:27:07 -07:00
|
|
|
|
jr CheckIfHPIsZero
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HasPlayerFainted:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckIfHPIsZero:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ResidualDamage:
|
2014-06-18 00:55:44 -07:00
|
|
|
|
; Return z if the user fainted before
|
|
|
|
|
; or as a result of residual damage.
|
|
|
|
|
; For Sandstorm damage, see HandleWeather.
|
|
|
|
|
|
|
|
|
|
call HasUserFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_STATUS
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
|
and 1 << PSN | 1 << BRN
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr z, .did_psn_brn
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld hl, HurtByPoisonText
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_PSN
|
|
|
|
|
and 1 << BRN
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr z, .got_anim
|
|
|
|
|
ld hl, HurtByBurnText
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_BRN
|
2014-06-18 00:55:44 -07:00
|
|
|
|
.got_anim
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call Call_PlayBattleAnim_OnlyIfVisible
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetEighthMaxHP
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wPlayerToxicCount
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .check_toxic
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyToxicCount
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.check_toxic
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TOXIC, a
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr z, .did_toxic
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call GetSixteenthMaxHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
inc a
|
|
|
|
|
ld [de], a
|
2014-06-17 12:52:32 -07:00
|
|
|
|
ld hl, 0
|
2014-06-18 00:55:44 -07:00
|
|
|
|
.add
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
dec a
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr nz, .add
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2014-06-18 00:55:44 -07:00
|
|
|
|
.did_toxic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHPFromUser
|
2014-06-18 00:55:44 -07:00
|
|
|
|
.did_psn_brn
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
|
call HasUserFainted
|
|
|
|
|
jp z, .fainted
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_LEECH_SEED, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .not_seeded
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
|
|
call SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_SAP
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call z, Call_PlayBattleAnim_OnlyIfVisible
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetEighthMaxHP
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHPFromUser
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call RestoreHP
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld hl, LeechSeedSapsText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.not_seeded
|
2014-06-18 00:55:44 -07:00
|
|
|
|
|
|
|
|
|
call HasUserFainted
|
|
|
|
|
jr z, .fainted
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_NIGHTMARE, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .not_nightmare
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_IN_NIGHTMARE
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call Call_PlayBattleAnim_OnlyIfVisible
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetQuarterMaxHP
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHPFromUser
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld hl, HasANightmareText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.not_nightmare
|
2014-06-18 00:55:44 -07:00
|
|
|
|
|
|
|
|
|
call HasUserFainted
|
|
|
|
|
jr z, .fainted
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_CURSE, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .not_cursed
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_IN_NIGHTMARE
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call Call_PlayBattleAnim_OnlyIfVisible
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetQuarterMaxHP
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHPFromUser
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld hl, HurtByCurseText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.not_cursed
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .check_fainted
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.check_fainted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
|
|
|
|
ret nz
|
|
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
|
.fainted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call RefreshBattleHuds
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld c, 20
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandlePerishSong:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .EnemyFirst
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jp .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.EnemyFirst:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
|
|
|
|
|
.do_it
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerPerishCount
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .got_count
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyPerishCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.got_count
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_PERISH, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
|
|
|
|
dec [hl]
|
|
|
|
|
ld a, [hl]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wTextDecimalByte], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld hl, PerishCountText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_PERISH, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr nz, .kill_enemy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1HP
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
xor a
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], a
|
|
|
|
|
ret
|
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
|
.kill_enemy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1HP
|
|
|
|
|
ld a, [wCurOTMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
xor a
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleWrap:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .EnemyFirst
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jp .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.EnemyFirst:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
|
|
|
|
|
.do_it
|
|
|
|
|
ld hl, wPlayerWrapCount
|
|
|
|
|
ld de, wPlayerTrappingMove
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .got_addrs
|
|
|
|
|
ld hl, wEnemyWrapCount
|
|
|
|
|
ld de, wEnemyTrappingMove
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.got_addrs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and a
|
|
|
|
|
ret z
|
2015-11-08 10:27:26 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
2015-11-08 10:27:26 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wFXAnimID], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetMoveName
|
|
|
|
|
dec [hl]
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .release_from_bounds
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .skip_anim
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wFXAnimID + 1], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PlayBattleAnim
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.skip_anim
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call GetSixteenthMaxHP
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHPFromUser
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_UsersHurtByStringBuffer1
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr .print_text
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.release_from_bounds
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_UserWasReleasedFromStringBuffer1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
|
.print_text
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SwitchTurnCore:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
xor 1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleLeftovers:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .DoEnemyFirst
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jp .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.DoEnemyFirst:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.do_it
|
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetUserItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetItemName
|
|
|
|
|
ld a, b
|
2014-01-19 21:07:51 -08:00
|
|
|
|
cp HELD_LEFTOVERS
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
2015-11-08 10:27:26 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .got_hp
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.got_hp
|
|
|
|
|
; Don't restore if we're already at max HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
cp b
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .restore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
cp c
|
|
|
|
|
ret z
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.restore
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call GetSixteenthMaxHP
|
|
|
|
|
call SwitchTurnCore
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call RestoreHP
|
2016-01-17 21:39:01 -08:00
|
|
|
|
ld hl, BattleText_TargetRecoveredWithItem
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleMysteryberry:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .DoEnemyFirst
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jp .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.DoEnemyFirst:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
|
|
|
|
|
.do_it
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetUserItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2014-06-10 23:08:07 -07:00
|
|
|
|
cp HELD_RESTORE_PP
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .quit
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1PP
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1Moves
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .wild
|
2015-11-29 18:34:59 -08:00
|
|
|
|
ld de, wWildMonPP
|
|
|
|
|
ld hl, wWildMonMoves
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .wild
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1PP
|
|
|
|
|
ld a, [wCurOTMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1Moves
|
|
|
|
|
ld a, [wCurOTMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.wild
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, $0
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
2018-01-11 09:00:01 -08:00
|
|
|
|
and PP_MASK
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .restore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
|
|
|
|
inc de
|
|
|
|
|
inc c
|
|
|
|
|
ld a, c
|
2014-06-10 23:08:07 -07:00
|
|
|
|
cp NUM_MOVES
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.restore
|
2014-06-10 23:08:07 -07:00
|
|
|
|
; lousy hack
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
cp SKETCH
|
|
|
|
|
ld b, 1
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .sketch
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, 5
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.sketch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
add b
|
|
|
|
|
ld [de], a
|
|
|
|
|
push bc
|
|
|
|
|
push bc
|
|
|
|
|
ld a, [hl]
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld [wTempByteValue], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonMoves - 1
|
|
|
|
|
ld hl, wBattleMonPP
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .player_pp
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonMoves - 1
|
|
|
|
|
ld hl, wEnemyMonPP
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.player_pp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc de
|
|
|
|
|
pop bc
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
push hl
|
|
|
|
|
ld h, d
|
|
|
|
|
ld l, e
|
|
|
|
|
add hl, bc
|
|
|
|
|
pop de
|
|
|
|
|
pop bc
|
2014-06-23 12:47:07 -07:00
|
|
|
|
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, [wTempByteValue]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp [hl]
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .skip_checks
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerSubStatus5]
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .check_transform
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus5]
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.check_transform
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .skip_checks
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
add b
|
|
|
|
|
ld [de], a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.skip_checks
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetUserItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld [hl], a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call GetPartymonItem
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .consume_item
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .skip_consumption
|
|
|
|
|
call GetOTPartymonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.consume_item
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld [hl], a
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.skip_consumption
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetItemName
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call ItemRecoveryAnim
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_UserRecoveredPPUsing
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleFutureSight:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jp .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .do_it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
|
|
|
|
|
.do_it
|
|
|
|
|
ld hl, wPlayerFutureSightCount
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .okay
|
|
|
|
|
ld hl, wEnemyFutureSightCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and a
|
|
|
|
|
ret z
|
|
|
|
|
dec a
|
|
|
|
|
ld [hl], a
|
|
|
|
|
cp $1
|
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
|
ld hl, BattleText_TargetWasHitByFutureSight
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld a, FUTURE_SIGHT
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar UpdateMoveData
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wAttackMissed], a
|
|
|
|
|
ld [wAlreadyDisobeyed], a
|
2018-03-09 13:09:03 -08:00
|
|
|
|
ld a, EFFECTIVE
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTypeModifier], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar DoMove
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurDamage], a
|
|
|
|
|
ld [wCurDamage + 1], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
ld [hl], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleMonInParty
|
|
|
|
|
jp UpdateEnemyMonInParty
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleDefrost:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .enemy_first
|
|
|
|
|
call .do_player_turn
|
|
|
|
|
jr .do_enemy_turn
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.enemy_first
|
|
|
|
|
call .do_enemy_turn
|
|
|
|
|
.do_player_turn
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit FRZ, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2015-11-10 13:53:37 -08:00
|
|
|
|
|
|
|
|
|
ld a, [wPlayerJustGotFrozen]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2015-11-10 13:53:37 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
2015-07-20 00:51:52 -07:00
|
|
|
|
cp 10 percent
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nc
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleMonStatus], a
|
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld hl, wPartyMon1Status
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2014-06-17 12:52:32 -07:00
|
|
|
|
ld [hl], 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleHuds
|
|
|
|
|
call SetEnemyTurn
|
2014-01-05 04:28:55 -08:00
|
|
|
|
ld hl, DefrostedOpponentText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.do_enemy_turn
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit FRZ, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld a, [wEnemyJustGotFrozen]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
|
|
|
|
call BattleRandom
|
2015-07-20 00:51:52 -07:00
|
|
|
|
cp 10 percent
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nc
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyMonStatus], a
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr z, .wild
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurOTMon]
|
|
|
|
|
ld hl, wOTPartyMon1Status
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2014-06-17 12:52:32 -07:00
|
|
|
|
ld [hl], 0
|
2016-01-17 21:39:01 -08:00
|
|
|
|
.wild
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleHuds
|
|
|
|
|
call SetPlayerTurn
|
2014-01-05 04:28:55 -08:00
|
|
|
|
ld hl, DefrostedOpponentText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleSafeguard:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr z, .player1
|
|
|
|
|
call .CheckPlayer
|
|
|
|
|
jr .CheckEnemy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
|
.player1
|
|
|
|
|
call .CheckEnemy
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.CheckPlayer:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerScreens]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
bit SCREENS_SAFEGUARD, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSafeguardCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec [hl]
|
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
res SCREENS_SAFEGUARD, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPlayerScreens], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr .print
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.CheckEnemy:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyScreens]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
bit SCREENS_SAFEGUARD, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySafeguardCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec [hl]
|
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
|
res SCREENS_SAFEGUARD, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyScreens], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
|
.print
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_SafeguardFaded
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleScreens:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr z, .Both
|
|
|
|
|
call .CheckPlayer
|
|
|
|
|
jr .CheckEnemy
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Both:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call .CheckEnemy
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.CheckPlayer:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
|
|
|
|
ld de, .Your
|
2014-06-10 23:08:07 -07:00
|
|
|
|
call .Copy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerScreens
|
|
|
|
|
ld de, wPlayerLightScreenCount
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr .TickScreens
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.CheckEnemy:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
|
|
|
|
ld de, .Enemy
|
2014-06-10 23:08:07 -07:00
|
|
|
|
call .Copy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyScreens
|
|
|
|
|
ld de, wEnemyLightScreenCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.TickScreens:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
bit SCREENS_LIGHT_SCREEN, [hl]
|
2016-01-17 21:39:01 -08:00
|
|
|
|
call nz, .LightScreenTick
|
2013-12-17 22:11:06 -08:00
|
|
|
|
bit SCREENS_REFLECT, [hl]
|
2016-01-17 21:39:01 -08:00
|
|
|
|
call nz, .ReflectTick
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Copy:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wStringBuffer1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp CopyName2
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Your:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "Your@"
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Enemy:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "Enemy@"
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.LightScreenTick:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
dec a
|
|
|
|
|
ld [de], a
|
|
|
|
|
ret nz
|
|
|
|
|
res SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
|
push hl
|
|
|
|
|
push de
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_MonsLightScreenFell
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.ReflectTick:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc de
|
|
|
|
|
ld a, [de]
|
|
|
|
|
dec a
|
|
|
|
|
ld [de], a
|
|
|
|
|
ret nz
|
|
|
|
|
res SCREENS_REFLECT, [hl]
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_MonsReflectFaded
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleWeather:
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattleWeather]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp WEATHER_NONE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wWeatherCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .ended
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
ld hl, .WeatherMessages
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call .PrintWeatherMessage
|
|
|
|
|
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattleWeather]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp WEATHER_SANDSTORM
|
|
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-10-26 12:45:57 -07:00
|
|
|
|
; player first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call .SandstormDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr .SandstormDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call .SandstormDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.SandstormDamage:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
|
call GetBattleVar
|
|
|
|
|
bit SUBSTATUS_UNDERGROUND, a
|
|
|
|
|
ret nz
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonType1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonType1
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
cp ROCK
|
|
|
|
|
ret z
|
|
|
|
|
cp GROUND
|
|
|
|
|
ret z
|
|
|
|
|
cp STEEL
|
|
|
|
|
ret z
|
|
|
|
|
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
cp ROCK
|
|
|
|
|
ret z
|
|
|
|
|
cp GROUND
|
|
|
|
|
ret z
|
|
|
|
|
cp STEEL
|
|
|
|
|
ret z
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_IN_SANDSTORM
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call Call_PlayBattleAnim
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetEighthMaxHP
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHPFromUser
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld hl, SandstormHitsText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.ended
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, .WeatherEndedMessages
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call .PrintWeatherMessage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattleWeather], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PrintWeatherMessage:
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattleWeather]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ld c, a
|
|
|
|
|
ld b, 0
|
|
|
|
|
add hl, bc
|
2015-12-26 18:59:03 -08:00
|
|
|
|
add hl, bc
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld h, [hl]
|
|
|
|
|
ld l, a
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.WeatherMessages:
|
2018-01-25 18:34:42 -08:00
|
|
|
|
; entries correspond to WEATHER_* constants
|
2015-09-06 14:38:01 -07:00
|
|
|
|
dw BattleText_RainContinuesToFall
|
|
|
|
|
dw BattleText_TheSunlightIsStrong
|
|
|
|
|
dw BattleText_TheSandstormRages
|
2018-01-25 18:34:42 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.WeatherEndedMessages:
|
2018-01-25 18:34:42 -08:00
|
|
|
|
; entries correspond to WEATHER_* constants
|
2015-09-06 14:38:01 -07:00
|
|
|
|
dw BattleText_TheRainStopped
|
|
|
|
|
dw BattleText_TheSunlightFaded
|
|
|
|
|
dw BattleText_TheSandstormSubsided
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SubtractHPFromTarget:
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHP
|
2015-11-07 05:05:57 -08:00
|
|
|
|
jp UpdateHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SubtractHPFromUser:
|
2018-02-22 08:13:29 -08:00
|
|
|
|
; Subtract HP from mon
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHP
|
2015-11-07 05:05:57 -08:00
|
|
|
|
jp UpdateHPBarBattleHuds
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SubtractHP:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
|
|
|
|
ld a, [hl]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sub c
|
|
|
|
|
ld [hld], a
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer2 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sbc b
|
|
|
|
|
ld [hl], a
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nc
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld a, [wHPBuffer2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld a, [wHPBuffer2 + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
xor a
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], a
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3], a
|
|
|
|
|
ld [wHPBuffer3 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetSixteenthMaxHP:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetQuarterMaxHP
|
2020-02-21 06:56:47 -08:00
|
|
|
|
; quarter result
|
2013-12-17 22:11:06 -08:00
|
|
|
|
srl c
|
|
|
|
|
srl c
|
2020-02-21 06:56:47 -08:00
|
|
|
|
; at least 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr nz, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc c
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetEighthMaxHP:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; output: bc
|
|
|
|
|
call GetQuarterMaxHP
|
|
|
|
|
; assumes nothing can have 1024 or more hp
|
|
|
|
|
; halve result
|
|
|
|
|
srl c
|
2020-02-21 06:56:47 -08:00
|
|
|
|
; at least 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
and a
|
|
|
|
|
jr nz, .end
|
|
|
|
|
inc c
|
|
|
|
|
.end
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetQuarterMaxHP:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; output: bc
|
|
|
|
|
call GetMaxHP
|
|
|
|
|
|
|
|
|
|
; quarter result
|
|
|
|
|
srl b
|
|
|
|
|
rr c
|
|
|
|
|
srl b
|
|
|
|
|
rr c
|
|
|
|
|
|
|
|
|
|
; assumes nothing can have 1024 or more hp
|
2020-02-21 06:56:47 -08:00
|
|
|
|
; at least 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
and a
|
|
|
|
|
jr nz, .end
|
|
|
|
|
inc c
|
|
|
|
|
.end
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetHalfMaxHP:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; output: bc
|
|
|
|
|
call GetMaxHP
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
; halve result
|
2013-12-17 22:11:06 -08:00
|
|
|
|
srl b
|
|
|
|
|
rr c
|
|
|
|
|
|
2020-02-21 06:56:47 -08:00
|
|
|
|
; at least 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
or b
|
|
|
|
|
jr nz, .end
|
|
|
|
|
inc c
|
|
|
|
|
.end
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetMaxHP:
|
2020-11-03 20:25:22 -08:00
|
|
|
|
; output: bc, wHPBuffer1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonMaxHP
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer1 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
|
|
ld a, [hl]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
ret
|
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
|
GetHalfHP: ; unreferenced
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld c, a
|
|
|
|
|
srl b
|
|
|
|
|
rr c
|
|
|
|
|
ld a, [hli]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer1 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckUserHasEnoughHP:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP + 1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP + 1
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
sub [hl]
|
|
|
|
|
dec hl
|
|
|
|
|
ld a, b
|
|
|
|
|
sbc [hl]
|
|
|
|
|
ret
|
|
|
|
|
|
2019-04-08 05:15:10 -07:00
|
|
|
|
RestoreHP:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonMaxHP
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer1 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec hl
|
|
|
|
|
ld a, [hl]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add c
|
|
|
|
|
ld [hld], a
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer2 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
adc b
|
|
|
|
|
ld [hli], a
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3 + 1], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld a, [wHPBuffer1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
sub c
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld a, [wHPBuffer1 + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
sbc b
|
2020-06-16 16:32:36 -07:00
|
|
|
|
jr c, .overflow
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
ld [hli], a
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
ld [hl], a
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3], a
|
2020-06-16 16:32:36 -07:00
|
|
|
|
.overflow
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
|
|
call SwitchTurnCore
|
2015-11-07 05:05:57 -08:00
|
|
|
|
call UpdateHPBarBattleHuds
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jp SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdateHPBarBattleHuds:
|
2015-11-07 05:05:57 -08:00
|
|
|
|
call UpdateHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp UpdateBattleHuds
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdateHPBar:
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 10, 9
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, 1
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr z, .ok
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 2, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2014-06-18 00:55:44 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2015-12-26 15:11:55 -08:00
|
|
|
|
ld [wWhichHPBar], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef AnimateHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleEnemyMonFaint:
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call FaintEnemyPokemon
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call z, FaintYourPokemon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wWhichMonFaintedFirst], a
|
|
|
|
|
call UpdateBattleStateAndExperienceAfterEnemyFaint
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call CheckPlayerPartyForFitMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
|
|
|
|
and a
|
|
|
|
|
jp z, LostBattle
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call nz, UpdatePlayerHUD
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld c, 60
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .trainer
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleEnded], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
|
.trainer
|
|
|
|
|
call CheckEnemyTrainerDefeated
|
|
|
|
|
jp z, WinTrainerBattle
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr nz, .player_mon_not_fainted
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call AskUseNextPokemon
|
|
|
|
|
jr nc, .dont_flee
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleEnded], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.dont_flee
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call ForcePlayerMonChoice
|
2014-06-13 21:18:14 -07:00
|
|
|
|
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, BATTLEPLAYERACTION_USEITEM
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call HandleEnemySwitch
|
2015-09-06 14:38:01 -07:00
|
|
|
|
jp z, WildFled_EnemyFled_LinkBattleCanceled
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr DoubleSwitch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.player_mon_not_fainted
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, BATTLEPLAYERACTION_USEITEM
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call HandleEnemySwitch
|
2015-09-06 14:38:01 -07:00
|
|
|
|
jp z, WildFled_EnemyFled_LinkBattleCanceled
|
2018-07-28 16:27:34 -07:00
|
|
|
|
xor a ; BATTLEPLAYERACTION_USEMOVE
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DoubleSwitch:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr z, .player_1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 0
|
2014-06-10 23:08:07 -07:00
|
|
|
|
lb bc, 4, 10
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call PlayerPartyMonEntrance
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call EnemyPartyMonEntrance
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr .done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.player_1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
ld a, $1
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call EnemyPartyMonEntrance
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call PlayerPartyMonEntrance
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.done
|
2018-07-28 16:27:34 -07:00
|
|
|
|
xor a ; BATTLEPLAYERACTION_USEMOVE
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdateBattleStateAndExperienceAfterEnemyFaint:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleMonInParty
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr z, .wild
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurOTMon]
|
|
|
|
|
ld hl, wOTPartyMon1HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
xor a
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], a
|
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.wild
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus3
|
2014-06-23 12:47:07 -07:00
|
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyDamageTaken
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], a
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewEnemyMonStatus
|
|
|
|
|
call BreakAttraction
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr z, .wild2
|
|
|
|
|
jr .trainer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.wild2
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call StopDangerSound
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattleLowHealthAlarm], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.trainer
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr nz, .player_mon_did_not_faint
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld a, [wWhichMonFaintedFirst]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr nz, .player_mon_did_not_faint
|
2019-03-03 14:55:24 -08:00
|
|
|
|
call UpdateFaintedPlayerMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.player_mon_did_not_faint
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call CheckPlayerPartyForFitMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
|
|
|
|
and a
|
|
|
|
|
ret z
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call z, PlayVictoryMusic
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
|
ld [wBattleResult], a ; WIN
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call IsAnyMonHoldingExpShare
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr z, .skip_exp
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonBaseStats
|
|
|
|
|
ld b, wEnemyMonEnd - wEnemyMonBaseStats
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
srl [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
dec b
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.skip_exp
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonBaseStats
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld de, wBackupEnemyMonBaseStats
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld bc, wEnemyMonEnd - wEnemyMonBaseStats
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
xor a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wGivingExperienceToExpShareHolders], a
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call GiveExperiencePoints
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call IsAnyMonHoldingExpShare
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2015-11-07 18:04:54 -08:00
|
|
|
|
|
|
|
|
|
ld a, [wBattleParticipantsNotFainted]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
ld a, d
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld [wBattleParticipantsNotFainted], a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld hl, wBackupEnemyMonBaseStats
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonBaseStats
|
|
|
|
|
ld bc, wEnemyMonEnd - wEnemyMonBaseStats
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
ld a, $1
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wGivingExperienceToExpShareHolders], a
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call GiveExperiencePoints
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld [wBattleParticipantsNotFainted], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
IsAnyMonHoldingExpShare:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1
|
2014-06-23 12:47:07 -07:00
|
|
|
|
ld c, 1
|
|
|
|
|
ld d, 0
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push bc
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld bc, MON_HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .next
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push bc
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld bc, MON_ITEM
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
pop bc
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
pop hl
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
|
|
cp EXP_SHARE
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .next
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
|
|
|
|
or c
|
|
|
|
|
ld d, a
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.next
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sla c
|
|
|
|
|
push de
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld de, PARTYMON_STRUCT_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
|
|
|
|
pop de
|
|
|
|
|
dec b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .loop
|
2014-06-23 12:47:07 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
2014-06-23 12:47:07 -07:00
|
|
|
|
ld e, 0
|
|
|
|
|
ld b, PARTY_LENGTH
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
srl a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nc, .okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc e
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, e
|
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
StopDangerSound:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wLowHealthAlarm], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
FaintYourPokemon:
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call StopDangerSound
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitSFX
|
|
|
|
|
ld a, $f0
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCryTracks], a
|
|
|
|
|
ld a, [wBattleMonSpecies]
|
2014-07-18 10:25:03 -07:00
|
|
|
|
call PlayStereoCry
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call PlayerMonFaintedAnimation
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 9, 7
|
2014-06-10 23:08:07 -07:00
|
|
|
|
lb bc, 5, 11
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_MonFainted
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
FaintEnemyPokemon:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitSFX
|
|
|
|
|
ld de, SFX_KINESIS
|
|
|
|
|
call PlaySFX
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call EnemyMonFaintedAnimation
|
2015-07-25 11:25:37 -07:00
|
|
|
|
ld de, SFX_FAINT
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PlaySFX
|
|
|
|
|
hlcoord 1, 0
|
2014-06-10 23:08:07 -07:00
|
|
|
|
lb bc, 4, 10
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_EnemyMonFainted
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckEnemyTrainerDefeated:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOTPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1HP
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld de, PARTYMON_STRUCT_LENGTH
|
2015-10-19 13:49:29 -07:00
|
|
|
|
|
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
or [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
or [hl]
|
|
|
|
|
dec hl
|
|
|
|
|
add hl, de
|
|
|
|
|
dec b
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleEnemySwitch:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyHPPal
|
2014-06-23 12:45:30 -07:00
|
|
|
|
ld e, HP_BAR_LENGTH_PX
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call UpdateHPPal
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitBGMap
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall EnemySwitch_TrainerHud
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .not_linked
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call LinkBattleSendReceiveAction
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, [wBattleAction]
|
2015-11-06 06:04:27 -08:00
|
|
|
|
cp BATTLEACTION_FORFEIT
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.not_linked
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
|
|
|
|
ld a, $0
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jr nz, EnemyPartyMonEntrance
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EnemyPartyMonEntrance:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
xor a
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld [wEnemySwitchMonIndex], a
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewEnemyMonStatus
|
|
|
|
|
call ResetEnemyStatLevels
|
|
|
|
|
call BreakAttraction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
and a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nz, .set
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call EnemySwitch
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr .done_switch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.set
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call EnemySwitch_SetMode
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.done_switch
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call ResetBattleParticipants
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call SpikesDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld [wEnemyMoveStruct + MOVE_ANIM], a
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
WinTrainerBattle:
|
2015-09-09 16:27:07 -07:00
|
|
|
|
; Player won the battle
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call StopDangerSound
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattleLowHealthAlarm], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleEnded], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ld a, b
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call z, PlayVictoryMusic
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar Battle_GetTrainerName
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_EnemyWasDefeated
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
2015-11-28 12:13:40 -08:00
|
|
|
|
call BattleWinSlideInEnemyTrainerFrontpic
|
|
|
|
|
ld c, 40
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2020-11-17 08:09:02 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2014-06-13 22:53:20 -07:00
|
|
|
|
cp BATTLETYPE_CANLOSE
|
2015-11-03 19:35:36 -08:00
|
|
|
|
jr nz, .skip_heal
|
2015-06-26 23:24:55 -07:00
|
|
|
|
predef HealParty
|
2015-11-03 19:35:36 -08:00
|
|
|
|
.skip_heal
|
2020-11-17 08:09:02 -08:00
|
|
|
|
|
2018-09-15 17:15:55 -07:00
|
|
|
|
ld a, [wDebugFlags]
|
|
|
|
|
bit DEBUG_BATTLE_F, a
|
2015-11-04 12:35:29 -08:00
|
|
|
|
jr nz, .skip_win_loss_text
|
|
|
|
|
call PrintWinLossText
|
|
|
|
|
.skip_win_loss_text
|
2020-11-17 08:09:02 -08:00
|
|
|
|
|
2023-09-02 14:16:35 -07:00
|
|
|
|
jp .give_coins
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2023-09-02 14:16:35 -07:00
|
|
|
|
.give_coins
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld a, [wAmuletCoin]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-22 21:21:21 -08:00
|
|
|
|
call nz, .DoubleReward
|
2023-09-02 14:16:35 -07:00
|
|
|
|
call .CheckMaxedOutMomCoins
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2018-01-22 10:57:44 -08:00
|
|
|
|
ld a, FALSE
|
2015-11-22 21:21:21 -08:00
|
|
|
|
jr nc, .okay
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld a, [wMomSavingCoins]
|
|
|
|
|
and MOM_SAVING_COINS_MASK
|
|
|
|
|
cp (1 << MOM_SAVING_SOME_COINS_F) | (1 << MOM_SAVING_HALF_COINS_F)
|
2015-11-22 21:21:21 -08:00
|
|
|
|
jr nz, .okay
|
2018-01-22 10:57:44 -08:00
|
|
|
|
inc a ; TRUE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-22 21:21:21 -08:00
|
|
|
|
.okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-01-22 10:57:44 -08:00
|
|
|
|
ld c, 4
|
2015-11-22 21:21:21 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
and a
|
2015-11-22 21:21:21 -08:00
|
|
|
|
jr z, .loop2
|
2023-09-02 14:16:35 -07:00
|
|
|
|
call .AddCoinsToMom
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec c
|
|
|
|
|
dec b
|
2015-11-22 21:21:21 -08:00
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-22 21:21:21 -08:00
|
|
|
|
.loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
and a
|
2015-11-22 21:21:21 -08:00
|
|
|
|
jr z, .done
|
2023-09-02 14:16:35 -07:00
|
|
|
|
call .AddCoinsToWallet
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec c
|
2015-11-22 21:21:21 -08:00
|
|
|
|
jr .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-22 21:21:21 -08:00
|
|
|
|
.done
|
|
|
|
|
call .DoubleReward
|
|
|
|
|
call .DoubleReward
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2015-06-11 09:57:45 -07:00
|
|
|
|
jr nc, .KeepItAll
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld a, [wMomSavingCoins]
|
|
|
|
|
and MOM_SAVING_COINS_MASK
|
2015-06-11 09:57:45 -07:00
|
|
|
|
jr z, .KeepItAll
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld hl, .SentToMomTexts
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ld c, a
|
|
|
|
|
ld b, 0
|
|
|
|
|
add hl, bc
|
2015-12-26 18:59:03 -08:00
|
|
|
|
add hl, bc
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld h, [hl]
|
|
|
|
|
ld l, a
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.KeepItAll:
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld hl, GotCoinsForWinningText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2023-09-02 14:16:35 -07:00
|
|
|
|
.AddCoinsToMom:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld hl, wBattleReward + 2
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld de, wMomsCoins + 2
|
|
|
|
|
call AddBattleCoinsToAccount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2023-09-02 14:16:35 -07:00
|
|
|
|
.AddCoinsToWallet:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld hl, wBattleReward + 2
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld de, wCoins + 2
|
|
|
|
|
call AddBattleCoinsToAccount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.DoubleReward:
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld hl, wBattleReward + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sla [hl]
|
|
|
|
|
dec hl
|
|
|
|
|
rl [hl]
|
|
|
|
|
dec hl
|
|
|
|
|
rl [hl]
|
|
|
|
|
ret nc
|
|
|
|
|
ld a, $ff
|
|
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
|
ld [hli], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.SentToMomTexts:
|
2018-01-25 18:34:42 -08:00
|
|
|
|
; entries correspond to MOM_SAVING_* constants
|
|
|
|
|
dw SentSomeToMomText
|
|
|
|
|
dw SentHalfToMomText
|
|
|
|
|
dw SentAllToMomText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2023-09-02 14:16:35 -07:00
|
|
|
|
.CheckMaxedOutMomCoins:
|
|
|
|
|
ld hl, wMomsCoins + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
2023-09-02 14:16:35 -07:00
|
|
|
|
cp LOW(MAX_COINS)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
2023-09-02 14:16:35 -07:00
|
|
|
|
sbc HIGH(MAX_COINS) ; mid
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2023-09-02 14:16:35 -07:00
|
|
|
|
sbc HIGH(MAX_COINS >> 8)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2023-09-02 14:16:35 -07:00
|
|
|
|
AddBattleCoinsToAccount:
|
2018-01-22 10:57:44 -08:00
|
|
|
|
ld c, 3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
push de
|
|
|
|
|
push hl
|
|
|
|
|
push bc
|
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
2015-11-22 21:21:21 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
adc [hl]
|
|
|
|
|
ld [de], a
|
|
|
|
|
dec de
|
|
|
|
|
dec hl
|
|
|
|
|
dec c
|
2015-11-22 21:21:21 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
|
|
|
|
ld a, [hld]
|
2023-09-02 14:16:35 -07:00
|
|
|
|
cp LOW(MAX_COINS)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
2023-09-02 14:16:35 -07:00
|
|
|
|
sbc HIGH(MAX_COINS) ; mid
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2023-09-02 14:16:35 -07:00
|
|
|
|
sbc HIGH(MAX_COINS >> 8)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld [hl], HIGH(MAX_COINS >> 8)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld [hl], HIGH(MAX_COINS) ; mid
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld [hl], LOW(MAX_COINS)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PlayVictoryMusic:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
|
|
|
|
ld de, MUSIC_NONE
|
|
|
|
|
call PlayMusic
|
|
|
|
|
call DelayFrame
|
|
|
|
|
ld de, MUSIC_WILD_VICTORY
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .trainer_victory
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call IsAnyMonHoldingExpShare
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .play_music
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld hl, wPayDayCoins
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .play_music
|
|
|
|
|
ld a, [wBattleParticipantsNotFainted]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .lost
|
|
|
|
|
jr .play_music
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.trainer_victory
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, MUSIC_GYM_VICTORY
|
2018-01-09 12:12:49 -08:00
|
|
|
|
call IsGymLeader
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr c, .play_music
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, MUSIC_TRAINER_VICTORY
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.play_music
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PlayMusic
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.lost
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
|
IsKantoGymLeader:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, KantoGymLeaders
|
|
|
|
|
jr IsGymLeaderCommon
|
|
|
|
|
|
2018-06-24 17:10:37 -07:00
|
|
|
|
IsGymLeader:
|
2018-01-09 12:12:49 -08:00
|
|
|
|
ld hl, GymLeaders
|
2013-12-17 22:11:06 -08:00
|
|
|
|
IsGymLeaderCommon:
|
|
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOtherTrainerClass]
|
2018-01-22 10:57:44 -08:00
|
|
|
|
ld de, 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call IsInArray
|
|
|
|
|
pop de
|
|
|
|
|
ret
|
|
|
|
|
|
2018-01-09 12:12:49 -08:00
|
|
|
|
INCLUDE "data/trainers/leaders.asm"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandlePlayerMonFaint:
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call FaintYourPokemon
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call z, FaintEnemyPokemon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wWhichMonFaintedFirst], a
|
2019-03-03 14:55:24 -08:00
|
|
|
|
call UpdateFaintedPlayerMon
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call CheckPlayerPartyForFitMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
|
|
|
|
and a
|
|
|
|
|
jp z, LostBattle
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .notfainted
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call UpdateBattleStateAndExperienceAfterEnemyFaint
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .trainer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleEnded], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
|
.trainer
|
|
|
|
|
call CheckEnemyTrainerDefeated
|
|
|
|
|
jp z, WinTrainerBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
|
.notfainted
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call AskUseNextPokemon
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr nc, .switch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleEnded], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.switch
|
|
|
|
|
call ForcePlayerMonChoice
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, BATTLEPLAYERACTION_USEITEM
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call HandleEnemySwitch
|
2015-09-06 14:38:01 -07:00
|
|
|
|
jp z, WildFled_EnemyFled_LinkBattleCanceled
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jp DoubleSwitch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2019-03-03 14:55:24 -08:00
|
|
|
|
UpdateFaintedPlayerMon:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, wBattleParticipantsNotFainted
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld b, RESET_FLAG
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef SmallFarFlagAction
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus3
|
2014-06-23 12:47:07 -07:00
|
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wLowHealthAlarm], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerDamageTaken
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleMonStatus], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleMonInParty
|
2015-10-12 09:33:24 -07:00
|
|
|
|
ld c, HAPPINESS_FAINTED
|
|
|
|
|
; If TheirLevel > (YourLevel + 30), use a different parameter
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonLevel]
|
2015-10-12 09:33:24 -07:00
|
|
|
|
add 30
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonLevel]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr c, .got_param
|
2015-10-12 09:33:24 -07:00
|
|
|
|
ld c, HAPPINESS_BEATENBYSTRONGFOE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.got_param
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wCurPartyMon], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar ChangeHappiness
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
|
add LOSE
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld [wBattleResult], a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld a, [wWhichMonFaintedFirst]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret z
|
2020-11-17 08:09:02 -08:00
|
|
|
|
; code was probably dummied out here
|
|
|
|
|
ret
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
AskUseNextPokemon:
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2015-11-07 18:04:54 -08:00
|
|
|
|
; We don't need to be here if we're in a Trainer battle,
|
|
|
|
|
; as that decision is made for us.
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
dec a
|
|
|
|
|
ret nz
|
2015-11-07 18:04:54 -08:00
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_UseNextMon
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
lb bc, 1, 7
|
|
|
|
|
call PlaceYesNoBox
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr c, .pressed_b
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.pressed_b
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
cp $1 ; YES
|
|
|
|
|
jr z, .loop
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1Speed
|
|
|
|
|
ld de, wEnemyMonSpeed
|
2015-09-09 16:27:07 -07:00
|
|
|
|
jp TryToRunAwayFromBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ForcePlayerMonChoice:
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2018-01-23 13:08:43 -08:00
|
|
|
|
call LoadStandardMenuHeader
|
2020-10-26 12:45:57 -07:00
|
|
|
|
call SetUpBattlePartyMenu
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call ForcePickPartyMonInBattle
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .skip_link
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, BATTLEPLAYERACTION_USEITEM
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call LinkBattleSendReceiveAction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.skip_link
|
2018-07-28 16:27:34 -07:00
|
|
|
|
xor a ; BATTLEPLAYERACTION_USEMOVE
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr nz, .send_out_pokemon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
call ClearSprites
|
2015-11-11 20:38:57 -08:00
|
|
|
|
call ClearBGPalettes
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadHPBar
|
2015-07-20 00:51:52 -07:00
|
|
|
|
call ExitMenu
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitBGMap
|
2023-07-26 08:01:20 -07:00
|
|
|
|
call GetMemCGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld c, a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.send_out_pokemon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wLastPlayerMon], a
|
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurBattleMon], a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call AddBattleParticipant
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call InitBattleMon
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call ResetPlayerStatLevels
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearPalettes
|
|
|
|
|
call DelayFrame
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadHPBar
|
2015-12-24 19:58:42 -08:00
|
|
|
|
call CloseWindow
|
2023-07-26 08:01:20 -07:00
|
|
|
|
call GetMemCGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call SendOutMonText
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewBattleMonStatus
|
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
|
call SendOutPlayerMon
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call SpikesDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
|
|
|
|
and a
|
|
|
|
|
ld c, a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PlayerPartyMonEntrance:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wLastPlayerMon], a
|
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurBattleMon], a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call AddBattleParticipant
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call InitBattleMon
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call ResetPlayerStatLevels
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call SendOutMonText
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewBattleMonStatus
|
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
|
call SendOutPlayerMon
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jp SpikesDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-10-26 12:45:57 -07:00
|
|
|
|
SetUpBattlePartyMenu:
|
2015-11-11 20:38:57 -08:00
|
|
|
|
call ClearBGPalettes
|
2020-10-26 12:45:57 -07:00
|
|
|
|
SetUpBattlePartyMenu_Loop: ; switch to fullscreen menu?
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall LoadPartyMenuGFX
|
|
|
|
|
farcall InitPartyMenuWithCancel
|
|
|
|
|
farcall InitPartyMenuBGPal7
|
|
|
|
|
farcall InitPartyMenuGFX
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
JumpToPartyMenuAndPrintText:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall WritePartyMenuTilemap
|
2023-08-11 03:28:14 -07:00
|
|
|
|
farcall PlacePartyMenuText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitBGMap
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrame
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SelectBattleMon:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall PartyMenuSelect
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PickPartyMonInBattle:
|
2014-06-17 11:58:11 -07:00
|
|
|
|
.loop
|
2017-11-30 11:27:25 -08:00
|
|
|
|
ld a, PARTYMENUACTION_SWITCH ; Which PKMN?
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPartyMenuActionText], a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call JumpToPartyMenuAndPrintText
|
|
|
|
|
call SelectBattleMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2016-03-01 19:31:21 -08:00
|
|
|
|
call CheckIfCurPartyMonIsFitToFight
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr z, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SwitchMonAlreadyOut:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wCurBattleMon
|
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jr nz, .notout
|
|
|
|
|
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_MonIsAlreadyOut
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
.notout
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ForcePickPartyMonInBattle:
|
2014-01-01 05:09:15 -08:00
|
|
|
|
; Can't back out.
|
|
|
|
|
|
|
|
|
|
.pick
|
|
|
|
|
call PickPartyMonInBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nc
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, SFX_WRONG
|
|
|
|
|
call PlaySFX
|
|
|
|
|
call WaitSFX
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jr .pick
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PickSwitchMonInBattle:
|
2014-01-01 05:09:15 -08:00
|
|
|
|
.pick
|
|
|
|
|
call PickPartyMonInBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call SwitchMonAlreadyOut
|
|
|
|
|
jr c, .pick
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ForcePickSwitchMonInBattle:
|
2014-01-01 05:09:15 -08:00
|
|
|
|
; Can't back out.
|
|
|
|
|
|
|
|
|
|
.pick
|
|
|
|
|
call ForcePickPartyMonInBattle
|
|
|
|
|
call SwitchMonAlreadyOut
|
|
|
|
|
jr c, .pick
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
LostBattle:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, 1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleEnded], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp BATTLETYPE_CANLOSE
|
2015-11-03 19:35:36 -08:00
|
|
|
|
jr nz, .not_canlose
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; Remove the enemy from the screen.
|
|
|
|
|
hlcoord 0, 0
|
2015-10-19 13:49:29 -07:00
|
|
|
|
lb bc, 8, 21
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
2015-11-28 12:13:40 -08:00
|
|
|
|
call BattleWinSlideInEnemyTrainerFrontpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
ld c, 40
|
|
|
|
|
call DelayFrames
|
|
|
|
|
|
2018-09-15 17:15:55 -07:00
|
|
|
|
ld a, [wDebugFlags]
|
|
|
|
|
bit DEBUG_BATTLE_F, a
|
2015-11-04 12:35:29 -08:00
|
|
|
|
jr nz, .skip_win_loss_text
|
|
|
|
|
call PrintWinLossText
|
|
|
|
|
.skip_win_loss_text
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-03 19:35:36 -08:00
|
|
|
|
.not_canlose
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
jr nz, .LostLinkBattle
|
|
|
|
|
|
2020-12-08 11:34:54 -08:00
|
|
|
|
; Grayscale
|
2023-07-26 08:01:20 -07:00
|
|
|
|
ld b, CGB_BATTLE_GRAYSCALE
|
|
|
|
|
call GetCGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr .end
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.LostLinkBattle:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateEnemyMonInParty
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call CheckEnemyTrainerDefeated
|
2015-11-03 19:35:36 -08:00
|
|
|
|
jr nz, .not_tied
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, TiedAgainstText
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
|
add DRAW
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld [wBattleResult], a
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr .text
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-03 19:35:36 -08:00
|
|
|
|
.not_tied
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, LostAgainstText
|
|
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
|
.text
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
.end
|
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EnemyMonFaintedAnimation:
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 12, 5
|
|
|
|
|
decoord 12, 6
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp MonFaintedAnimation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PlayerMonFaintedAnimation:
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 10
|
|
|
|
|
decoord 1, 11
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jp MonFaintedAnimation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
MonFaintedAnimation:
|
2020-10-28 10:35:39 -07:00
|
|
|
|
ld a, [wJoypadDisable]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2020-10-28 10:35:39 -07:00
|
|
|
|
set JOYPAD_DISABLE_MON_FAINT_F, a
|
|
|
|
|
ld [wJoypadDisable], a
|
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
|
ld b, 7
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.OuterLoop:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
push de
|
|
|
|
|
push hl
|
2015-10-19 13:49:29 -07:00
|
|
|
|
ld b, 6
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.InnerLoop:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
push hl
|
|
|
|
|
push de
|
2015-10-19 13:49:29 -07:00
|
|
|
|
ld bc, 7
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
2015-10-19 13:49:29 -07:00
|
|
|
|
ld bc, -SCREEN_WIDTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
push hl
|
|
|
|
|
ld h, d
|
|
|
|
|
ld l, e
|
|
|
|
|
add hl, bc
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
dec b
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .InnerLoop
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld bc, 20
|
|
|
|
|
add hl, bc
|
|
|
|
|
ld de, .Spaces
|
|
|
|
|
call PlaceString
|
|
|
|
|
ld c, 2
|
|
|
|
|
call DelayFrames
|
|
|
|
|
pop hl
|
|
|
|
|
pop de
|
|
|
|
|
pop bc
|
|
|
|
|
dec b
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .OuterLoop
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2020-10-28 10:35:39 -07:00
|
|
|
|
ld [wJoypadDisable], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Spaces:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db " @"
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SlideBattlePicOut:
|
2020-12-23 13:54:28 -08:00
|
|
|
|
ldh [hMapObjectIndex], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2015-11-28 12:13:40 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
push hl
|
|
|
|
|
ld b, $7
|
2015-11-28 12:13:40 -08:00
|
|
|
|
.loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
2015-11-28 12:13:40 -08:00
|
|
|
|
call .DoFrame
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, SCREEN_WIDTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
|
|
|
|
dec b
|
2015-11-28 12:13:40 -08:00
|
|
|
|
jr nz, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, 2
|
|
|
|
|
call DelayFrames
|
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
dec c
|
2015-11-28 12:13:40 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.DoFrame:
|
2020-12-23 13:54:28 -08:00
|
|
|
|
ldh a, [hMapObjectIndex]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
cp $8
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr nz, .back
|
|
|
|
|
.forward
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [hld], a
|
|
|
|
|
dec hl
|
|
|
|
|
dec c
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr nz, .forward
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.back
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld [hli], a
|
|
|
|
|
inc hl
|
|
|
|
|
dec c
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr nz, .back
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ForceEnemySwitch:
|
2015-09-11 19:21:00 -07:00
|
|
|
|
call ResetEnemyBattleVars
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld a, [wEnemySwitchMonIndex]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ld b, a
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call LoadEnemyMonToSwitchTo
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call ClearEnemyMonBox
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewEnemyMonStatus
|
|
|
|
|
call ResetEnemyStatLevels
|
2020-10-06 15:09:33 -07:00
|
|
|
|
call ShowSetEnemyMonAndSendOutAnimation
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call BreakAttraction
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call ResetBattleParticipants
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EnemySwitch:
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call CheckWhetherToAskSwitch
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nc, EnemySwitch_SetMode
|
|
|
|
|
; Shift Mode
|
2015-09-11 19:21:00 -07:00
|
|
|
|
call ResetEnemyBattleVars
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call CheckWhetherSwitchmonIsPredetermined
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr c, .skip
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call FindMonInOTPartyToSwitchIntoBattle
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.skip
|
2018-02-22 08:13:29 -08:00
|
|
|
|
; 'b' contains the PartyNr of the mon the AI will switch to
|
|
|
|
|
call LoadEnemyMonToSwitchTo
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call OfferSwitch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call ClearEnemyMonBox
|
2020-10-06 15:09:33 -07:00
|
|
|
|
call ShowBattleTextEnemySentOut
|
|
|
|
|
call ShowSetEnemyMonAndSendOutAnimation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
ret c
|
2015-11-07 18:04:54 -08:00
|
|
|
|
; If we're here, then we're switching too
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld [wBattleParticipantsNotFainted], a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wBattleParticipantsIncludingFainted], a
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld [wEnemyIsSwitching], a
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp PlayerSwitch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EnemySwitch_SetMode:
|
2015-09-11 19:21:00 -07:00
|
|
|
|
call ResetEnemyBattleVars
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call CheckWhetherSwitchmonIsPredetermined
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr c, .skip
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call FindMonInOTPartyToSwitchIntoBattle
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.skip
|
2018-02-22 08:13:29 -08:00
|
|
|
|
; 'b' contains the PartyNr of the mon the AI will switch to
|
|
|
|
|
call LoadEnemyMonToSwitchTo
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, 1
|
|
|
|
|
ld [wEnemyIsSwitching], a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call ClearEnemyMonBox
|
2020-10-06 15:09:33 -07:00
|
|
|
|
call ShowBattleTextEnemySentOut
|
|
|
|
|
jp ShowSetEnemyMonAndSendOutAnimation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckWhetherSwitchmonIsPredetermined:
|
2020-11-17 08:09:02 -08:00
|
|
|
|
; returns the enemy switchmon index in b, or
|
|
|
|
|
; returns carry if the index is not yet determined.
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .not_linked
|
2014-06-18 00:55:44 -07:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, [wBattleAction]
|
2015-11-06 06:04:27 -08:00
|
|
|
|
sub BATTLEACTION_SWITCH1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr .return_carry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.not_linked
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld a, [wEnemySwitchMonIndex]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2016-08-07 15:14:20 -07:00
|
|
|
|
jr z, .check_wBattleHasJustStarted
|
2015-09-11 19:21:00 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ld b, a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr .return_carry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-08-07 15:14:20 -07:00
|
|
|
|
.check_wBattleHasJustStarted
|
|
|
|
|
ld a, [wBattleHasJustStarted]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2020-11-17 08:09:02 -08:00
|
|
|
|
ld b, 0
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nz, .return_carry
|
2015-09-11 19:21:00 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.return_carry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ResetEnemyBattleVars:
|
2019-04-08 05:15:10 -07:00
|
|
|
|
; and draw empty Textbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wLastPlayerCounterMove], a
|
|
|
|
|
ld [wLastEnemyCounterMove], a
|
|
|
|
|
ld [wLastEnemyMove], a
|
|
|
|
|
ld [wCurEnemyMove], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wEnemyItemState], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
ld [wPlayerWrapCount], a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 18, 0
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld a, 8
|
|
|
|
|
call SlideBattlePicOut
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2018-01-23 13:08:43 -08:00
|
|
|
|
jp LoadStandardMenuHeader
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ResetBattleParticipants:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld [wBattleParticipantsNotFainted], a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wBattleParticipantsIncludingFainted], a
|
2018-06-24 07:09:41 -07:00
|
|
|
|
AddBattleParticipant:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, wBattleParticipantsNotFainted
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld b, SET_FLAG
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef SmallFarFlagAction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld hl, wBattleParticipantsIncludingFainted
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef_jump SmallFarFlagAction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
FindMonInOTPartyToSwitchIntoBattle:
|
2018-02-25 16:50:48 -08:00
|
|
|
|
ld b, -1
|
2020-11-03 19:45:12 -08:00
|
|
|
|
ld a, %000001
|
|
|
|
|
ld [wEnemyEffectivenessVsPlayerMons], a
|
|
|
|
|
ld [wPlayerEffectivenessVsEnemyMons], a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop
|
2020-11-03 19:45:12 -08:00
|
|
|
|
ld hl, wEnemyEffectivenessVsPlayerMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sla [hl]
|
2020-11-03 19:45:12 -08:00
|
|
|
|
inc hl ; wPlayerEffectivenessVsEnemyMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sla [hl]
|
|
|
|
|
inc b
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOTPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jp z, ScoreMonTypeMatchups
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurOTMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr z, .discourage
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
ld a, b
|
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
or c
|
|
|
|
|
pop bc
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr z, .discourage
|
2015-09-11 19:21:00 -07:00
|
|
|
|
call LookUpTheEffectivenessOfEveryMove
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call IsThePlayerMonTypesEffectiveAgainstOTMon
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.discourage
|
2020-11-03 19:45:12 -08:00
|
|
|
|
ld hl, wPlayerEffectivenessVsEnemyMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
set 0, [hl]
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
LookUpTheEffectivenessOfEveryMove:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1Moves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
call GetPartyLocation
|
|
|
|
|
pop bc
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld e, NUM_MOVES + 1
|
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec e
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr z, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
and a
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr z, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push de
|
|
|
|
|
push bc
|
|
|
|
|
dec a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, Moves
|
2014-06-10 23:23:55 -07:00
|
|
|
|
ld bc, MOVE_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call AddNTimes
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld de, wEnemyMoveStruct
|
2013-12-30 20:22:27 -08:00
|
|
|
|
ld a, BANK(Moves)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call FarCopyBytes
|
|
|
|
|
call SetEnemyTurn
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar BattleCheckTypeMatchup
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
|
cp EFFECTIVE + 1
|
2014-06-18 00:55:44 -07:00
|
|
|
|
jr c, .loop
|
2020-11-03 19:45:12 -08:00
|
|
|
|
ld hl, wEnemyEffectivenessVsPlayerMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
set 0, [hl]
|
|
|
|
|
ret
|
2014-06-18 00:55:44 -07:00
|
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
IsThePlayerMonTypesEffectiveAgainstOTMon:
|
2018-02-22 08:13:29 -08:00
|
|
|
|
; Calculates the effectiveness of the types of the PlayerMon
|
|
|
|
|
; against the OTMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
inc a
|
|
|
|
|
ld c, a
|
2014-06-23 12:47:07 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
dec a
|
2017-12-11 14:35:35 -08:00
|
|
|
|
ld hl, BaseData + BASE_TYPES
|
|
|
|
|
ld bc, BASE_DATA_SIZE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call AddNTimes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonType
|
2017-12-19 12:28:06 -08:00
|
|
|
|
ld bc, BASE_CATCH_RATE - BASE_TYPES
|
2014-01-05 04:28:55 -08:00
|
|
|
|
ld a, BANK(BaseData)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call FarCopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonType1]
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld [wPlayerMoveStruct + MOVE_TYPE], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar BattleCheckTypeMatchup
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
|
cp EFFECTIVE + 1
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nc, .super_effective
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonType2]
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld [wPlayerMoveStruct + MOVE_TYPE], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar BattleCheckTypeMatchup
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, [wTypeMatchup]
|
|
|
|
|
cp EFFECTIVE + 1
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nc, .super_effective
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.super_effective
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2020-11-03 19:45:12 -08:00
|
|
|
|
ld hl, wEnemyEffectivenessVsPlayerMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
bit 0, [hl]
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nz, .reset
|
2020-11-03 19:45:12 -08:00
|
|
|
|
inc hl ; wPlayerEffectivenessVsEnemyMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
set 0, [hl]
|
|
|
|
|
ret
|
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.reset
|
2013-12-17 22:11:06 -08:00
|
|
|
|
res 0, [hl]
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ScoreMonTypeMatchups:
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop1
|
2020-11-03 19:45:12 -08:00
|
|
|
|
ld hl, wEnemyEffectivenessVsPlayerMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sla [hl]
|
2020-11-03 19:45:12 -08:00
|
|
|
|
inc hl ; wPlayerEffectivenessVsEnemyMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sla [hl]
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nc, .loop1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOTPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
ld c, [hl]
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sla c
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nc, .okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec b
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr z, .loop5
|
|
|
|
|
jr .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.okay
|
2020-11-03 19:45:12 -08:00
|
|
|
|
ld a, [wEnemyEffectivenessVsPlayerMons]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr z, .okay2
|
2018-02-25 16:50:48 -08:00
|
|
|
|
ld b, -1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc b
|
|
|
|
|
sla c
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nc, .loop3
|
|
|
|
|
jr .quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.okay2
|
2018-02-25 16:50:48 -08:00
|
|
|
|
ld b, -1
|
2020-11-03 19:45:12 -08:00
|
|
|
|
ld a, [wPlayerEffectivenessVsEnemyMons]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc b
|
|
|
|
|
sla c
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr c, .loop4
|
|
|
|
|
jr .quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop5
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOTPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
call BattleRandom
|
|
|
|
|
and $7
|
|
|
|
|
cp b
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nc, .loop5
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurOTMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr z, .loop5
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
ld a, b
|
|
|
|
|
call GetPartyLocation
|
|
|
|
|
pop bc
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
or c
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr z, .loop5
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
LoadEnemyMonToSwitchTo:
|
2018-02-22 08:13:29 -08:00
|
|
|
|
; 'b' contains the PartyNr of the mon the AI will switch to
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
|
|
|
|
ld hl, wOTPartyMon1Level
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyLevel], a
|
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTempEnemyMonSpecies], a
|
|
|
|
|
ld [wCurPartySpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call LoadEnemyMon
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartySpecies]
|
2014-03-05 02:42:09 -08:00
|
|
|
|
cp UNOWN
|
2015-11-09 20:55:39 -08:00
|
|
|
|
jr nz, .skip_unown
|
2015-11-29 18:34:59 -08:00
|
|
|
|
ld a, [wFirstUnownSeen]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-09 20:55:39 -08:00
|
|
|
|
jr nz, .skip_unown
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonDVs
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetUnownLetter
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wUnownLetter]
|
2015-11-29 18:34:59 -08:00
|
|
|
|
ld [wFirstUnownSeen], a
|
2015-11-09 20:55:39 -08:00
|
|
|
|
.skip_unown
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld [wEnemyHPAtTimeOfPlayerSwitch], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld [wEnemyHPAtTimeOfPlayerSwitch + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckWhetherToAskSwitch:
|
2016-08-07 15:14:20 -07:00
|
|
|
|
ld a, [wBattleHasJustStarted]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jp z, .return_nc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jp z, .return_nc
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jp nz, .return_nc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOptions]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit BATTLE_SHIFT, a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr nz, .return_nc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wCurPartyMon], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall CheckCurPartyMonFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jr c, .return_nc
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.return_nc
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
OfferSwitch:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar Battle_GetTrainerName
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_EnemyIsAboutToUseWillPlayerChangeMon
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
lb bc, 1, 7
|
|
|
|
|
call PlaceYesNoBox
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .said_no
|
2020-10-26 12:45:57 -07:00
|
|
|
|
call SetUpBattlePartyMenu
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call PickSwitchMonInBattle
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr c, .canceled_switch
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wLastPlayerMon], a
|
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurBattleMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearPalettes
|
|
|
|
|
call DelayFrame
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurEnemyMove], a
|
|
|
|
|
ld [wCurPlayerMove], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.canceled_switch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearPalettes
|
|
|
|
|
call DelayFrame
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.said_no
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ClearEnemyMonBox:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2015-07-20 00:51:52 -07:00
|
|
|
|
call ExitMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 0
|
2014-06-18 00:55:44 -07:00
|
|
|
|
lb bc, 4, 10
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
|
|
|
|
call WaitBGMap
|
2015-11-09 13:41:09 -08:00
|
|
|
|
jp FinishBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-10-06 15:09:33 -07:00
|
|
|
|
ShowBattleTextEnemySentOut:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar Battle_GetTrainerName
|
2015-08-23 06:09:56 -07:00
|
|
|
|
ld hl, BattleText_EnemySentOut
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp WaitBGMap
|
|
|
|
|
|
2020-10-06 15:09:33 -07:00
|
|
|
|
ShowSetEnemyMonAndSendOutAnimation:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
|
|
|
|
ld [wCurPartySpecies], a
|
|
|
|
|
ld [wCurSpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld a, OTPARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2018-02-22 08:13:29 -08:00
|
|
|
|
predef CopyMonToTempMon
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call GetEnemyMonFrontpic
|
2014-06-18 00:55:44 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2015-12-23 17:46:23 -08:00
|
|
|
|
ld [wBattleAnimParam], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-06-13 22:53:20 -07:00
|
|
|
|
ld de, ANIM_SEND_OUT_MON
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call Call_PlayBattleAnim
|
2014-06-18 00:55:44 -07:00
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call BattleCheckEnemyShininess
|
2015-11-07 06:48:32 -08:00
|
|
|
|
jr nc, .not_shiny
|
2019-01-06 19:11:57 -08:00
|
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
|
ld a, 1 ; shiny anim
|
2015-12-23 17:46:23 -08:00
|
|
|
|
ld [wBattleAnimParam], a
|
2014-06-13 22:53:20 -07:00
|
|
|
|
ld de, ANIM_SEND_OUT_MON
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call Call_PlayBattleAnim
|
2014-06-18 00:55:44 -07:00
|
|
|
|
|
2019-01-06 19:11:57 -08:00
|
|
|
|
.not_shiny
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld bc, wTempMonSpecies
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall CheckFaintedFrzSlp
|
2015-11-07 06:48:32 -08:00
|
|
|
|
jr c, .skip_cry
|
2019-01-06 19:11:57 -08:00
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall CheckBattleScene
|
2015-11-07 06:48:32 -08:00
|
|
|
|
jr c, .cry_no_anim
|
2019-01-06 19:11:57 -08:00
|
|
|
|
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 12, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, $0
|
2015-11-07 06:48:32 -08:00
|
|
|
|
ld e, ANIM_MON_SLOW
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef AnimateFrontpic
|
2015-11-07 06:48:32 -08:00
|
|
|
|
jr .skip_cry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
|
.cry_no_anim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $f
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCryTracks], a
|
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2014-07-18 10:25:03 -07:00
|
|
|
|
call PlayStereoCry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
|
.skip_cry
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call UpdateEnemyHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
NewEnemyMonStatus:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wLastPlayerCounterMove], a
|
|
|
|
|
ld [wLastEnemyCounterMove], a
|
|
|
|
|
ld [wLastEnemyMove], a
|
|
|
|
|
ld hl, wEnemySubStatus1
|
2015-07-20 19:18:18 -07:00
|
|
|
|
rept 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
2015-07-20 19:18:18 -07:00
|
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyDisableCount], a
|
|
|
|
|
ld [wEnemyFuryCutterCount], a
|
|
|
|
|
ld [wEnemyProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
ld [wEnemyRageCounter], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyDisabledMove], a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld [wEnemyMinimized], a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
ld [wPlayerWrapCount], a
|
|
|
|
|
ld [wEnemyWrapCount], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyTurnsTaken], a
|
|
|
|
|
ld hl, wPlayerSubStatus5
|
2014-06-13 22:53:20 -07:00
|
|
|
|
res SUBSTATUS_CANT_RUN, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ResetEnemyStatLevels:
|
2015-11-06 17:55:16 -08:00
|
|
|
|
ld a, BASE_STAT_LEVEL
|
|
|
|
|
ld b, NUM_LEVEL_STATS
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyStatLevels
|
2014-01-01 05:09:15 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
|
|
|
|
dec b
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckPlayerPartyForFitMon:
|
2018-02-22 08:13:29 -08:00
|
|
|
|
; Has the player any mon in his Party that can fight?
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld e, a
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1HP
|
2018-07-16 12:58:07 -07:00
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - 1
|
2016-03-01 19:31:21 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
or [hl]
|
2018-07-16 12:58:07 -07:00
|
|
|
|
inc hl ; + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
or [hl]
|
|
|
|
|
add hl, bc
|
|
|
|
|
dec e
|
2016-03-01 19:31:21 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckIfCurPartyMonIsFitToFight:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld hl, wPartyMon1HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
|
|
|
|
ret nz
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
2016-08-07 15:14:20 -07:00
|
|
|
|
ld a, [wBattleHasJustStarted]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2016-03-01 19:31:21 -08:00
|
|
|
|
jr nz, .finish_fail
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartySpecies
|
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
ld b, 0
|
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
cp EGG
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_AnEGGCantBattle
|
2016-03-01 19:31:21 -08:00
|
|
|
|
jr z, .print_textbox
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
|
|
|
|
ld hl, BattleText_TheresNoWillToBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
|
.print_textbox
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-03-01 19:31:21 -08:00
|
|
|
|
.finish_fail
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
TryToRunAwayFromBattle:
|
2015-09-09 16:27:07 -07:00
|
|
|
|
; Run away from battle, with or without item
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2015-09-09 16:27:07 -07:00
|
|
|
|
cp BATTLETYPE_DEBUG
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .can_escape
|
2014-06-17 11:58:11 -07:00
|
|
|
|
cp BATTLETYPE_CONTEST
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .can_escape
|
2014-06-13 22:53:20 -07:00
|
|
|
|
cp BATTLETYPE_TRAP
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .cant_escape
|
2014-06-13 22:53:20 -07:00
|
|
|
|
cp BATTLETYPE_CELEBI
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .cant_escape
|
2023-07-26 17:50:16 -07:00
|
|
|
|
cp BATTLETYPE_FORCESHINY
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .cant_escape
|
2014-06-13 22:53:20 -07:00
|
|
|
|
cp BATTLETYPE_SUICUNE
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .cant_escape
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp nz, .can_escape
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp nz, .cant_run_from_trainer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus5]
|
2014-06-13 22:53:20 -07:00
|
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp nz, .cant_escape
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
ld a, [wPlayerWrapCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp nz, .cant_escape
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
push hl
|
|
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonItem]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetItemHeldEffect
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp HELD_ESCAPE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nz, .no_flee_item
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
call SetPlayerTurn
|
|
|
|
|
call GetItemName
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_UserFledUsingAStringBuffer1
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp .can_escape
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.no_flee_item
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wNumFleeAttempts]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld [wNumFleeAttempts], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh [hMultiplicand + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh [hMultiplicand + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
inc de
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hEnemyMonSpeed + 0], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hEnemyMonSpeed + 1], a
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ld de, hMultiplicand + 1
|
2018-07-22 21:25:53 -07:00
|
|
|
|
ld hl, hEnemyMonSpeed
|
|
|
|
|
ld c, 2
|
|
|
|
|
call CompareBytes
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nc, .can_escape
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh [hMultiplicand + 0], a
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, 32
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Multiply
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 2]
|
|
|
|
|
ldh [hDividend + 0], a
|
|
|
|
|
ldh a, [hProduct + 3]
|
|
|
|
|
ldh [hDividend + 1], a
|
|
|
|
|
ldh a, [hEnemyMonSpeed + 0]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hEnemyMonSpeed + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
srl b
|
|
|
|
|
rr a
|
|
|
|
|
srl b
|
|
|
|
|
rr a
|
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .can_escape
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDivisor], a
|
2016-01-17 21:39:01 -08:00
|
|
|
|
ld b, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Divide
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nz, .can_escape
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wNumFleeAttempts]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec c
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .cant_escape_2
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld b, 30
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add b
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh [hQuotient + 3], a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr c, .can_escape
|
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.cant_escape_2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
|
|
|
|
ld b, a
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr nc, .can_escape
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, BATTLEPLAYERACTION_USEITEM
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_CantEscape2
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr .print_inescapable_text
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.cant_escape
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_CantEscape
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr .print_inescapable_text
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.cant_run_from_trainer
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_TheresNoEscapeFromTrainerBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.print_inescapable_text
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, TRUE
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld [wFailedToFlee], a
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.can_escape
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
|
ld a, DRAW
|
|
|
|
|
jr z, .fled
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2018-07-28 16:27:34 -07:00
|
|
|
|
xor a ; BATTLEPLAYERACTION_USEMOVE
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2022-09-23 20:10:24 -07:00
|
|
|
|
ld a, BATTLEACTION_FORFEIT
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurMoveNum], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPlayerMove], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call LinkBattleSendReceiveAction
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
; Got away safely
|
|
|
|
|
ld a, [wBattleAction]
|
2015-11-06 06:04:27 -08:00
|
|
|
|
cp BATTLEACTION_FORFEIT
|
|
|
|
|
ld a, DRAW
|
|
|
|
|
jr z, .fled
|
2018-04-05 08:44:02 -07:00
|
|
|
|
dec a ; LOSE
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.fled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
|
and BATTLERESULT_BITMASK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add b
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld [wBattleResult], a
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call StopDangerSound
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
|
|
|
|
ld de, SFX_RUN
|
|
|
|
|
call WaitPlaySFX
|
|
|
|
|
pop de
|
|
|
|
|
call WaitSFX
|
2015-09-06 14:38:01 -07:00
|
|
|
|
ld hl, BattleText_GotAwaySafely
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitSFX
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
InitBattleMon:
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld a, MON_SPECIES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyParamLocation
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonSpecies
|
2015-11-06 06:04:27 -08:00
|
|
|
|
ld bc, MON_ID
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2015-11-07 10:05:58 -08:00
|
|
|
|
ld bc, MON_DVS - MON_ID
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonDVs
|
2021-06-07 17:00:21 -07:00
|
|
|
|
ld bc, MON_POKERUS - MON_DVS
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
inc hl
|
2016-05-10 09:31:49 -07:00
|
|
|
|
inc hl
|
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonLevel
|
2015-11-07 10:05:58 -08:00
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - MON_LEVEL
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonSpecies]
|
|
|
|
|
ld [wTempBattleMonSpecies], a
|
|
|
|
|
ld [wCurPartySpecies], a
|
|
|
|
|
ld [wCurSpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBaseType1]
|
|
|
|
|
ld [wBattleMonType1], a
|
|
|
|
|
ld a, [wBaseType2]
|
|
|
|
|
ld [wBattleMonType2], a
|
|
|
|
|
ld hl, wPartyMonNicknames
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SkipNames
|
2021-03-17 13:16:02 -07:00
|
|
|
|
ld de, wBattleMonNickname
|
2018-01-20 09:25:55 -08:00
|
|
|
|
ld bc, MON_NAME_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonAttack
|
|
|
|
|
ld de, wPlayerStats
|
2015-11-07 10:05:58 -08:00
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - MON_ATK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call ApplyStatusEffectOnPlayerStats
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BadgeStatBoosts
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleCheckPlayerShininess:
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call GetPartyMonDVs
|
|
|
|
|
jr BattleCheckShininess
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleCheckEnemyShininess:
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call GetEnemyMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleCheckShininess:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CheckShininess
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetPartyMonDVs:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonDVs
|
|
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1DVs
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp GetPartyLocation
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetEnemyMonDVs:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonDVs
|
|
|
|
|
ld a, [wEnemySubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2016-01-10 14:44:09 -08:00
|
|
|
|
ld hl, wEnemyBackupDVs
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1DVs
|
|
|
|
|
ld a, [wCurOTMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp GetPartyLocation
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ResetPlayerStatLevels:
|
2015-11-06 17:55:16 -08:00
|
|
|
|
ld a, BASE_STAT_LEVEL
|
|
|
|
|
ld b, NUM_LEVEL_STATS
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerStatLevels
|
2014-01-01 05:09:15 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
|
|
|
|
dec b
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
InitEnemyMon:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld hl, wOTPartyMon1Species
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonSpecies
|
2015-11-06 06:04:27 -08:00
|
|
|
|
ld bc, MON_ID
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2015-11-07 10:05:58 -08:00
|
|
|
|
ld bc, MON_DVS - MON_ID
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonDVs
|
2021-06-07 17:00:21 -07:00
|
|
|
|
ld bc, MON_POKERUS - MON_DVS
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
inc hl
|
2016-05-10 09:31:49 -07:00
|
|
|
|
inc hl
|
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonLevel
|
2015-11-07 10:05:58 -08:00
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - MON_LEVEL
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonSpecies]
|
|
|
|
|
ld [wCurSpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMonNicknames
|
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SkipNames
|
2021-03-17 13:16:02 -07:00
|
|
|
|
ld de, wEnemyMonNickname
|
2018-01-20 09:25:55 -08:00
|
|
|
|
ld bc, MON_NAME_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonAttack
|
|
|
|
|
ld de, wEnemyStats
|
2015-11-07 10:05:58 -08:00
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - MON_ATK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call ApplyStatusEffectOnEnemyStats
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBaseType1
|
|
|
|
|
ld de, wEnemyMonType1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
ld [de], a
|
2022-01-08 10:42:40 -08:00
|
|
|
|
; The enemy mon's base Sp. Def isn't needed since its base
|
|
|
|
|
; Sp. Atk is also used to calculate Sp. Def stat experience.
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBaseStats
|
|
|
|
|
ld de, wEnemyMonBaseStats
|
2022-01-08 10:42:40 -08:00
|
|
|
|
ld b, NUM_STATS - 1
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
dec b
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nz, .loop
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurOTMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SwitchPlayerMon:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wLastPlayerMon], a
|
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurBattleMon], a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call AddBattleParticipant
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call InitBattleMon
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call ResetPlayerStatLevels
|
|
|
|
|
call NewBattleMonStatus
|
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
|
call SendOutPlayerMon
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SendOutPlayerMon:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonDVs
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetUnownLetter
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 5
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld b, 7
|
|
|
|
|
ld c, 8
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
|
|
|
|
call WaitBGMap
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call GetBattleMonBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hGraphicStartTile], a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wBattleMenuCursorPosition], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurMoveNum], a
|
|
|
|
|
ld [wTypeModifier], a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld [wPlayerMoveStruct + MOVE_ANIM], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wLastPlayerCounterMove], a
|
|
|
|
|
ld [wLastEnemyCounterMove], a
|
|
|
|
|
ld [wLastPlayerMove], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call CheckAmuletCoin
|
2015-11-09 13:41:09 -08:00
|
|
|
|
call FinishBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
ld [wEnemyWrapCount], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2015-12-23 17:46:23 -08:00
|
|
|
|
ld [wBattleAnimParam], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_SEND_OUT_MON
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call Call_PlayBattleAnim
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call BattleCheckPlayerShininess
|
2015-11-07 06:48:32 -08:00
|
|
|
|
jr nc, .not_shiny
|
2015-12-23 17:46:23 -08:00
|
|
|
|
ld a, 1
|
|
|
|
|
ld [wBattleAnimParam], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_SEND_OUT_MON
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call Call_PlayBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
|
.not_shiny
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld a, MON_SPECIES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyParamLocation
|
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall CheckFaintedFrzSlp
|
2015-11-07 06:48:32 -08:00
|
|
|
|
jr c, .statused
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $f0
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCryTracks], a
|
|
|
|
|
ld a, [wCurPartySpecies]
|
2014-07-18 10:25:03 -07:00
|
|
|
|
call PlayStereoCry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
|
.statused
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call UpdatePlayerHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
NewBattleMonStatus:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wLastPlayerCounterMove], a
|
|
|
|
|
ld [wLastEnemyCounterMove], a
|
|
|
|
|
ld [wLastPlayerMove], a
|
|
|
|
|
ld hl, wPlayerSubStatus1
|
2015-07-20 19:18:18 -07:00
|
|
|
|
rept 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
2015-07-20 19:18:18 -07:00
|
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerUsedMoves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
2016-05-10 09:31:49 -07:00
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hli], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPlayerDisableCount], a
|
|
|
|
|
ld [wPlayerFuryCutterCount], a
|
|
|
|
|
ld [wPlayerProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
ld [wPlayerRageCounter], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wDisabledMove], a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld [wPlayerMinimized], a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
ld [wEnemyWrapCount], a
|
|
|
|
|
ld [wPlayerWrapCount], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPlayerTurnsTaken], a
|
|
|
|
|
ld hl, wEnemySubStatus5
|
2014-01-01 05:09:15 -08:00
|
|
|
|
res SUBSTATUS_CANT_RUN, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BreakAttraction:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus1
|
2014-01-01 05:09:15 -08:00
|
|
|
|
res SUBSTATUS_IN_LOVE, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus1
|
2014-01-01 05:09:15 -08:00
|
|
|
|
res SUBSTATUS_IN_LOVE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SpikesDamage:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerScreens
|
|
|
|
|
ld de, wBattleMonType
|
2018-01-16 11:30:10 -08:00
|
|
|
|
ld bc, UpdatePlayerHUD
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jr z, .ok
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyScreens
|
|
|
|
|
ld de, wEnemyMonType
|
2018-01-16 11:30:10 -08:00
|
|
|
|
ld bc, UpdateEnemyHUD
|
2014-01-01 05:09:15 -08:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
bit SCREENS_SPIKES, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
|
; Flying-types aren't affected by Spikes.
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
2014-01-01 05:09:15 -08:00
|
|
|
|
cp FLYING
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
|
|
|
|
inc de
|
|
|
|
|
ld a, [de]
|
2014-01-01 05:09:15 -08:00
|
|
|
|
cp FLYING
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_UserHurtBySpikes ; "hurt by SPIKES!"
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetEighthMaxHP
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call SubtractHPFromTarget
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call .hl
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp WaitBGMap
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
|
.hl
|
2017-06-09 14:01:10 -07:00
|
|
|
|
jp hl
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PursuitSwitch:
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBattleVar
|
|
|
|
|
ld b, a
|
2013-12-30 20:32:37 -08:00
|
|
|
|
call GetMoveEffect
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
cp EFFECT_PURSUIT
|
2015-11-05 16:13:09 -08:00
|
|
|
|
jr nz, .done
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, DoPlayerTurn
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
jr z, .do_turn
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, DoEnemyTurn
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wLastPlayerMon]
|
|
|
|
|
ld [wCurBattleMon], a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
.do_turn
|
2019-01-12 12:17:20 -08:00
|
|
|
|
ld a, BANK(DoPlayerTurn) ; aka BANK(DoEnemyTurn)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
rst FarCall
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
|
|
|
|
ld a, BATTLE_VARS_MOVE
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $ff
|
|
|
|
|
ld [hl], a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurBattleMon], a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
jr z, .check_enemy_fainted
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wLastPlayerMon]
|
2015-07-20 22:52:46 -07:00
|
|
|
|
call UpdateBattleMon
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-11-05 16:13:09 -08:00
|
|
|
|
jr nz, .done
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
2022-07-09 14:12:02 -07:00
|
|
|
|
; BUG: A Pokémon that fainted from Pursuit will have its old status condition when revived (see docs/bugs_and_glitches.md)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $f0
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCryTracks], a
|
|
|
|
|
ld a, [wBattleMonSpecies]
|
2014-07-18 10:25:03 -07:00
|
|
|
|
call PlayStereoCry
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wLastPlayerMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, wBattleParticipantsNotFainted
|
|
|
|
|
ld b, RESET_FLAG
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef SmallFarFlagAction
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call PlayerMonFaintedAnimation
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_MonFainted
|
2015-11-05 16:13:09 -08:00
|
|
|
|
jr .done_fainted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
|
.check_enemy_fainted
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-11-05 16:13:09 -08:00
|
|
|
|
jr nz, .done
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, SFX_KINESIS
|
|
|
|
|
call PlaySFX
|
|
|
|
|
call WaitSFX
|
2015-07-25 11:25:37 -07:00
|
|
|
|
ld de, SFX_FAINT
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PlaySFX
|
|
|
|
|
call WaitSFX
|
2015-10-19 13:49:29 -07:00
|
|
|
|
call EnemyMonFaintedAnimation
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_EnemyMonFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
|
.done_fainted
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
RecallPlayerMon:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_RETURN_MON
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call Call_PlayBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleHealingItems:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .player_1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleHPHealingItem
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call UseHeldStatusHealingItem
|
2015-11-28 12:13:40 -08:00
|
|
|
|
call UseConfusionHealingItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleHPHealingItem
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call UseHeldStatusHealingItem
|
2015-11-28 12:13:40 -08:00
|
|
|
|
jp UseConfusionHealingItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.player_1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleHPHealingItem
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call UseHeldStatusHealingItem
|
2015-11-28 12:13:40 -08:00
|
|
|
|
call UseConfusionHealingItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call HandleHPHealingItem
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call UseHeldStatusHealingItem
|
2015-11-28 12:13:40 -08:00
|
|
|
|
jp UseConfusionHealingItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleHPHealingItem:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetOpponentItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2017-12-14 09:19:26 -08:00
|
|
|
|
cp HELD_BERRY
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonHP + 1
|
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .go
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonHP + 1
|
|
|
|
|
ld hl, wBattleMonMaxHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.go
|
2016-03-01 19:31:21 -08:00
|
|
|
|
; If, and only if, Pokemon's HP is less than half max, use the item.
|
|
|
|
|
; Store current HP in Buffer 3/4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
ld a, [de]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add a
|
|
|
|
|
ld c, a
|
|
|
|
|
dec de
|
|
|
|
|
ld a, [de]
|
|
|
|
|
inc de
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer2 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
adc a
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, b
|
|
|
|
|
cp [hl]
|
|
|
|
|
ld a, c
|
|
|
|
|
pop bc
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .equal
|
|
|
|
|
jr c, .less
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.equal
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
|
|
|
|
cp [hl]
|
|
|
|
|
dec hl
|
|
|
|
|
ret nc
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.less
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call ItemRecoveryAnim
|
2020-11-03 20:25:22 -08:00
|
|
|
|
; store max HP in wHPBuffer1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer1 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
add c
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
dec de
|
|
|
|
|
ld a, [de]
|
2018-02-04 10:16:40 -08:00
|
|
|
|
adc 0
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
cp c
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
sbc b
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nc, .okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld [wHPBuffer3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.okay
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld a, [wHPBuffer3 + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
2020-11-03 20:25:22 -08:00
|
|
|
|
ld a, [wHPBuffer3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [de], a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2015-12-26 15:11:55 -08:00
|
|
|
|
ld [wWhichHPBar], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 2, 2
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .got_hp_bar_coords
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 10, 9
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.got_hp_bar_coords
|
2015-12-26 15:11:55 -08:00
|
|
|
|
ld [wWhichHPBar], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef AnimateHPBar
|
2015-11-06 19:36:06 -08:00
|
|
|
|
UseOpponentItem:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call RefreshBattleHuds
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetOpponentItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetItemName
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar ConsumeHeldItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, RecoveredUsingText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ItemRecoveryAnim:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push de
|
|
|
|
|
push bc
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, RECOVER
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wFXAnimID], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wFXAnimID + 1], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PlayBattleAnim
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UseHeldStatusHealingItem:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetOpponentItem
|
2018-01-25 18:34:42 -08:00
|
|
|
|
ld hl, HeldStatusHealingEffects
|
2015-11-06 19:36:06 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
cp $ff
|
|
|
|
|
ret z
|
|
|
|
|
inc hl
|
|
|
|
|
cp b
|
2015-11-06 19:36:06 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec hl
|
|
|
|
|
ld b, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_STATUS_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and b
|
|
|
|
|
ret z
|
|
|
|
|
xor a
|
|
|
|
|
ld [hl], a
|
|
|
|
|
push bc
|
|
|
|
|
call UpdateOpponentInParty
|
|
|
|
|
pop bc
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS5_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_TOXIC, [hl]
|
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS1_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_NIGHTMARE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2015-11-08 10:27:26 -08:00
|
|
|
|
cp ALL_STATUS
|
2015-11-06 19:36:06 -08:00
|
|
|
|
jr nz, .skip_confuse
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_CONFUSED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
|
.skip_confuse
|
2015-11-06 17:55:16 -08:00
|
|
|
|
ld hl, CalcEnemyStats
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 19:36:06 -08:00
|
|
|
|
jr z, .got_pointer
|
2015-11-06 17:55:16 -08:00
|
|
|
|
ld hl, CalcPlayerStats
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
|
.got_pointer
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2019-01-12 12:17:20 -08:00
|
|
|
|
ld a, BANK(CalcPlayerStats) ; aka BANK(CalcEnemyStats)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
rst FarCall
|
2014-06-13 21:18:14 -07:00
|
|
|
|
call SwitchTurnCore
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call ItemRecoveryAnim
|
|
|
|
|
call UseOpponentItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-01-25 18:34:42 -08:00
|
|
|
|
INCLUDE "data/battle/held_heal_status.asm"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UseConfusionHealingItem:
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBattleVar
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_CONFUSED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetOpponentItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp HELD_HEAL_CONFUSION
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .heal_status
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp HELD_HEAL_STATUS
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.heal_status
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3_OPP
|
2014-06-14 00:34:57 -07:00
|
|
|
|
call GetBattleVarAddr
|
2014-06-13 21:18:14 -07:00
|
|
|
|
res SUBSTATUS_CONFUSED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetItemName
|
2015-11-06 19:36:06 -08:00
|
|
|
|
call ItemRecoveryAnim
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld hl, BattleText_ItemHealedConfusion
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .do_partymon
|
|
|
|
|
call GetOTPartymonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld [bc], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ret z
|
|
|
|
|
ld [hl], $0
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.do_partymon
|
|
|
|
|
call GetPartymonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld [bc], a
|
|
|
|
|
ld [hl], a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
HandleStatBoostingHeldItems:
|
2015-11-08 10:27:26 -08:00
|
|
|
|
; The effects handled here are not used in-game.
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .player_1
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call .DoPlayer
|
|
|
|
|
jp .DoEnemy
|
2016-10-28 17:03:10 -07:00
|
|
|
|
|
|
|
|
|
.player_1
|
|
|
|
|
call .DoEnemy
|
|
|
|
|
jp .DoPlayer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.DoPlayer:
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call GetPartymonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $0
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jp .HandleItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.DoEnemy:
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call GetOTPartymonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.HandleItem:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
|
|
|
|
push de
|
|
|
|
|
push bc
|
|
|
|
|
ld a, [bc]
|
|
|
|
|
ld b, a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetItemHeldEffect
|
2018-01-25 18:34:42 -08:00
|
|
|
|
ld hl, HeldStatUpItems
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2018-01-25 18:34:42 -08:00
|
|
|
|
cp -1
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr z, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
|
inc hl
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2015-11-08 10:27:26 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ld a, [bc]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
dec hl
|
2015-12-26 18:59:03 -08:00
|
|
|
|
dec hl
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld h, [hl]
|
|
|
|
|
ld l, a
|
2015-11-06 11:45:10 -08:00
|
|
|
|
ld a, BANK(BattleCommand_AttackUp)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
rst FarCall
|
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wFailedMessage]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
|
|
|
|
xor a
|
|
|
|
|
ld [bc], a
|
|
|
|
|
ld [de], a
|
|
|
|
|
call GetItemName
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_UsersStringBuffer1Activated
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar BattleCommand_StatUpMessage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
|
.finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
ret
|
|
|
|
|
|
2018-01-25 18:34:42 -08:00
|
|
|
|
INCLUDE "data/battle/held_stat_up.asm"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetPartymonItem:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1Item
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld bc, wBattleMonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetOTPartymonItem:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1Item
|
|
|
|
|
ld a, [wCurOTMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld bc, wEnemyMonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdateBattleHUDs:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push de
|
|
|
|
|
push bc
|
|
|
|
|
call DrawPlayerHUD
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerHPPal
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetHPPal
|
|
|
|
|
call CheckDanger
|
2014-06-16 22:52:59 -07:00
|
|
|
|
call DrawEnemyHUD
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyHPPal
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetHPPal
|
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdatePlayerHUD::
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push de
|
|
|
|
|
push bc
|
|
|
|
|
call DrawPlayerHUD
|
|
|
|
|
call UpdatePlayerHPPal
|
|
|
|
|
call CheckDanger
|
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DrawPlayerHUD:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
; Clear the area
|
2013-12-17 22:11:06 -08:00
|
|
|
|
hlcoord 9, 7
|
2014-06-13 21:18:14 -07:00
|
|
|
|
lb bc, 5, 11
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall DrawPlayerHUDBorder
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
hlcoord 18, 9
|
|
|
|
|
ld [hl], $73 ; vertical bar
|
|
|
|
|
call PrintPlayerHUD
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
; HP bar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
hlcoord 10, 9
|
2014-06-16 22:52:59 -07:00
|
|
|
|
ld b, 1
|
2015-10-07 18:27:32 -07:00
|
|
|
|
xor a ; PARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef DrawPlayerHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
; Exp bar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld hl, wPartyMon1Exp + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
|
|
hlcoord 10, 11
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempMonLevel]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call FillInExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdatePlayerHPPal:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerHPPal
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jp UpdateHPPal
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckDanger:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .no_danger
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattleLowHealthAlarm]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr nz, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerHPPal]
|
2014-06-16 22:52:59 -07:00
|
|
|
|
cp HP_RED
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr z, .danger
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.no_danger
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld hl, wLowHealthAlarm
|
2017-12-15 21:50:03 -08:00
|
|
|
|
res DANGER_ON_F, [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
jr .done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.danger
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld hl, wLowHealthAlarm
|
2017-12-15 21:50:03 -08:00
|
|
|
|
set DANGER_ON_F, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PrintPlayerHUD:
|
2021-03-17 13:16:02 -07:00
|
|
|
|
ld de, wBattleMonNickname
|
2013-12-17 22:11:06 -08:00
|
|
|
|
hlcoord 10, 7
|
2020-10-28 10:35:39 -07:00
|
|
|
|
call Battle_DummyFunction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PlaceString
|
|
|
|
|
|
|
|
|
|
push bc
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld hl, wPartyMon1DVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wTempMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
ld [de], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonLevel
|
|
|
|
|
ld de, wTempMonLevel
|
2021-03-15 12:40:48 -07:00
|
|
|
|
ld bc, wTempMonStructEnd - wTempMonLevel
|
|
|
|
|
call CopyBytes ; battle_struct and party_struct end with the same data
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld hl, wPartyMon1Species
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartySpecies], a
|
|
|
|
|
ld [wCurSpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
|
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
|
dec hl
|
|
|
|
|
|
2016-05-11 14:16:03 -07:00
|
|
|
|
ld a, TEMPMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
callfar GetGender
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, " "
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr c, .got_gender_char
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, "♂"
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr nz, .got_gender_char
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, "♀"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
|
.got_gender_char
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 17, 8
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 14, 8
|
2016-01-17 21:39:01 -08:00
|
|
|
|
push af ; back up gender
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonStatus
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PlaceNonFaintStatus
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
ret nz
|
|
|
|
|
ld a, b
|
2014-06-17 12:52:32 -07:00
|
|
|
|
cp " "
|
2016-01-17 21:39:01 -08:00
|
|
|
|
jr nz, .copy_level ; male or female
|
|
|
|
|
dec hl ; genderless
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-01-17 21:39:01 -08:00
|
|
|
|
.copy_level
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonLevel]
|
|
|
|
|
ld [wTempMonLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp PrintLevel
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdateEnemyHUD::
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push de
|
|
|
|
|
push bc
|
2014-06-16 22:52:59 -07:00
|
|
|
|
call DrawEnemyHUD
|
|
|
|
|
call UpdateEnemyHPPal
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DrawEnemyHUD:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 0
|
2014-06-13 21:18:14 -07:00
|
|
|
|
lb bc, 4, 11
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall DrawEnemyHUDBorder
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
|
|
|
|
ld [wCurSpecies], a
|
|
|
|
|
ld [wCurPartySpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
2021-03-17 13:16:02 -07:00
|
|
|
|
ld de, wEnemyMonNickname
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 0
|
2020-10-28 10:35:39 -07:00
|
|
|
|
call Battle_DummyFunction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PlaceString
|
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
|
|
|
|
dec hl
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonDVs
|
|
|
|
|
ld de, wTempMonDVs
|
|
|
|
|
ld a, [wEnemySubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2014-06-16 22:52:59 -07:00
|
|
|
|
jr z, .ok
|
2016-01-10 14:44:09 -08:00
|
|
|
|
ld hl, wEnemyBackupDVs
|
2014-06-16 22:52:59 -07:00
|
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
ld [de], a
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2016-05-11 14:16:03 -07:00
|
|
|
|
ld a, TEMPMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
callfar GetGender
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, " "
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr c, .got_gender
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, "♂"
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .got_gender
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, "♀"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.got_gender
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 9, 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 6, 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonStatus
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PlaceNonFaintStatus
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .skip_level
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2014-06-16 22:52:59 -07:00
|
|
|
|
cp " "
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .print_level
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec hl
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.print_level
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonLevel]
|
|
|
|
|
ld [wTempMonLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintLevel
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.skip_level
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
or [hl]
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .not_fainted
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
ld e, a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld d, HP_BAR_LENGTH
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jp .draw_bar
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.not_fainted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh [hMultiplicand + 0], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, HP_BAR_LENGTH_PX
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Multiply
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
and a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .less_than_256_max
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hMultiplier]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
srl b
|
|
|
|
|
rr a
|
|
|
|
|
srl b
|
|
|
|
|
rr a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDivisor], a
|
|
|
|
|
ldh a, [hProduct + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
srl b
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
rr a
|
|
|
|
|
srl b
|
|
|
|
|
rr a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hProduct + 3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hProduct + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.less_than_256_max
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 2]
|
|
|
|
|
ldh [hDividend + 0], a
|
|
|
|
|
ldh a, [hProduct + 3]
|
|
|
|
|
ldh [hDividend + 1], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
call Divide
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld e, a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, HP_BAR_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, a
|
|
|
|
|
ld c, a
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.draw_bar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-26 15:11:55 -08:00
|
|
|
|
ld [wWhichHPBar], a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 2, 2
|
2014-06-16 22:52:59 -07:00
|
|
|
|
ld b, 0
|
2015-11-08 07:59:28 -08:00
|
|
|
|
call DrawBattleHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdateEnemyHPPal:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyHPPal
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call UpdateHPPal
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
UpdateHPPal:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, [hl]
|
|
|
|
|
call SetHPPal
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
cp b
|
|
|
|
|
ret z
|
2015-11-09 13:41:09 -08:00
|
|
|
|
jp FinishBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-10-28 10:35:39 -07:00
|
|
|
|
Battle_DummyFunction:
|
|
|
|
|
; called before placing either battler's nickname in the HUD
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleMenu:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTempTilemapToTilemap
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2015-09-09 16:27:07 -07:00
|
|
|
|
cp BATTLETYPE_DEBUG
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr z, .ok
|
2014-06-13 22:53:20 -07:00
|
|
|
|
cp BATTLETYPE_TUTORIAL
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr z, .ok
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call UpdateBattleHuds
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2014-06-17 11:58:11 -07:00
|
|
|
|
.ok
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
|
.loop
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2014-06-17 11:58:11 -07:00
|
|
|
|
cp BATTLETYPE_CONTEST
|
|
|
|
|
jr nz, .not_contest
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall ContestBattleMenu
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr .next
|
|
|
|
|
.not_contest
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
|
; Auto input: choose "ITEM"
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wInputType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
or a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .skip_dude_pack_select
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall _DudeAutoInput_DownA
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.skip_dude_pack_select
|
2014-06-17 11:58:11 -07:00
|
|
|
|
call LoadBattleMenu2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
|
.next
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wBattleMenuCursorPosition]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp $1
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp z, BattleMenu_Fight
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp $3
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp z, BattleMenu_Pack
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp $2
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp z, BattleMenu_PKMN
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp $4
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp z, BattleMenu_Run
|
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleMenu_Fight:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld [wNumFleeAttempts], a
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
LoadBattleMenu2:
|
2014-06-16 22:52:59 -07:00
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall LoadBattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleMenu_Pack:
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jp nz, .ItemsCantBeUsed
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2018-01-23 13:08:43 -08:00
|
|
|
|
call LoadStandardMenuHeader
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2014-06-13 22:53:20 -07:00
|
|
|
|
cp BATTLETYPE_TUTORIAL
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jr z, .tutorial
|
|
|
|
|
cp BATTLETYPE_CONTEST
|
|
|
|
|
jr z, .contest
|
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall BattlePack
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattlePlayerAction]
|
2018-07-28 16:27:34 -07:00
|
|
|
|
and a ; BATTLEPLAYERACTION_USEMOVE?
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .didnt_use_item
|
|
|
|
|
jr .got_item
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
|
.tutorial
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall TutorialPack
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, POKE_BALL
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurItem], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DoItemEffect
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr .got_item
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
|
.contest
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, PARK_BALL
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurItem], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DoItemEffect
|
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.got_item
|
2015-12-02 10:24:18 -08:00
|
|
|
|
call .UseItem
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.didnt_use_item
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearPalettes
|
|
|
|
|
call DelayFrame
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadBattleFontsHPBar
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call GetBattleMonBackpic
|
|
|
|
|
call GetEnemyMonFrontpic
|
2015-07-20 00:51:52 -07:00
|
|
|
|
call ExitMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitBGMap
|
2015-11-09 13:41:09 -08:00
|
|
|
|
call FinishBattleAnim
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp BattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.ItemsCantBeUsed:
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_ItemsCantBeUsedHere
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp BattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.UseItem:
|
2015-12-07 08:28:58 -08:00
|
|
|
|
ld a, [wWildMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jr nz, .run
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CheckItemPocket
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wItemAttributeValue]
|
2015-12-02 10:24:18 -08:00
|
|
|
|
cp BALL
|
|
|
|
|
jr z, .ball
|
2015-11-11 20:38:57 -08:00
|
|
|
|
call ClearBGPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-12-02 10:24:18 -08:00
|
|
|
|
.ball
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadBattleFontsHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2014-06-13 22:53:20 -07:00
|
|
|
|
cp BATTLETYPE_TUTORIAL
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jr z, .tutorial2
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call GetBattleMonBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-12-02 10:24:18 -08:00
|
|
|
|
.tutorial2
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call GetEnemyMonFrontpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld [wMenuCursorY], a
|
2015-07-20 00:51:52 -07:00
|
|
|
|
call ExitMenu
|
2015-11-08 10:27:26 -08:00
|
|
|
|
call UpdateBattleHUDs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitBGMap
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2023-08-11 03:28:14 -07:00
|
|
|
|
call ClearMenuAndWindowData
|
2015-11-09 13:41:09 -08:00
|
|
|
|
call FinishBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-12-02 10:24:18 -08:00
|
|
|
|
.run
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-07 08:28:58 -08:00
|
|
|
|
ld [wWildMon], a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2018-04-05 08:44:02 -07:00
|
|
|
|
and BATTLERESULT_BITMASK
|
|
|
|
|
ld [wBattleResult], a ; WIN
|
2023-08-11 03:28:14 -07:00
|
|
|
|
call ClearMenuAndWindowData
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleMenu_PKMN:
|
2018-01-23 13:08:43 -08:00
|
|
|
|
call LoadStandardMenuHeader
|
2016-01-12 21:39:41 -08:00
|
|
|
|
BattleMenuPKMN_ReturnFromStats:
|
2015-07-20 00:51:52 -07:00
|
|
|
|
call ExitMenu
|
2018-01-23 13:08:43 -08:00
|
|
|
|
call LoadStandardMenuHeader
|
2015-11-11 20:38:57 -08:00
|
|
|
|
call ClearBGPalettes
|
2015-12-02 10:24:18 -08:00
|
|
|
|
BattleMenuPKMN_Loop:
|
2020-10-26 12:45:57 -07:00
|
|
|
|
call SetUpBattlePartyMenu_Loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wPartyMenuActionText], a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call JumpToPartyMenuAndPrintText
|
|
|
|
|
call SelectBattleMon
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jr c, .Cancel
|
|
|
|
|
.loop
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall FreezeMonIcons
|
2015-12-02 10:24:18 -08:00
|
|
|
|
call .GetMenu
|
|
|
|
|
jr c, .PressedB
|
2015-12-17 19:31:16 -08:00
|
|
|
|
call PlaceHollowCursor
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2015-12-02 10:24:18 -08:00
|
|
|
|
cp $1 ; SWITCH
|
|
|
|
|
jp z, TryPlayerSwitch
|
|
|
|
|
cp $2 ; STATS
|
|
|
|
|
jr z, .Stats
|
|
|
|
|
cp $3 ; CANCEL
|
|
|
|
|
jr z, .Cancel
|
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PressedB:
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jr BattleMenuPKMN_Loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Stats:
|
2015-12-23 06:12:29 -08:00
|
|
|
|
call Battle_StatsScreen
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jp BattleMenuPKMN_ReturnFromStats
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Cancel:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
|
|
|
|
call ClearPalettes
|
|
|
|
|
call DelayFrame
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadHPBar
|
2015-12-24 19:58:42 -08:00
|
|
|
|
call CloseWindow
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2023-07-26 08:01:20 -07:00
|
|
|
|
call GetMemCGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp BattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.GetMenu:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall BattleMonMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
Battle_StatsScreen:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DisableLCD
|
2016-06-07 05:08:51 -07:00
|
|
|
|
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld hl, vTiles2 tile $31
|
|
|
|
|
ld de, vTiles0
|
2016-06-07 05:08:51 -07:00
|
|
|
|
ld bc, $11 tiles
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2016-06-07 05:08:51 -07:00
|
|
|
|
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld hl, vTiles2
|
|
|
|
|
ld de, vTiles0 tile $11
|
2015-12-02 10:24:18 -08:00
|
|
|
|
ld bc, $31 tiles
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2016-06-07 05:08:51 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call EnableLCD
|
2016-06-07 05:08:51 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
|
|
|
|
call LowVolume
|
2015-10-07 18:27:32 -07:00
|
|
|
|
xor a ; PARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall BattleStatsScreenInit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call MaxVolume
|
2016-06-07 05:08:51 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DisableLCD
|
2016-06-07 05:08:51 -07:00
|
|
|
|
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld hl, vTiles0
|
|
|
|
|
ld de, vTiles2 tile $31
|
2015-12-02 10:24:18 -08:00
|
|
|
|
ld bc, $11 tiles
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2016-06-07 05:08:51 -07:00
|
|
|
|
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld hl, vTiles0 tile $11
|
|
|
|
|
ld de, vTiles2
|
2015-12-02 10:24:18 -08:00
|
|
|
|
ld bc, $31 tiles
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2016-06-07 05:08:51 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call EnableLCD
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
TryPlayerSwitch:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp d
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jr nz, .check_trapped
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_MonIsAlreadyOut
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jp BattleMenuPKMN_Loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-12-02 10:24:18 -08:00
|
|
|
|
.check_trapped
|
2015-11-08 10:27:26 -08:00
|
|
|
|
ld a, [wPlayerWrapCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jr nz, .trapped
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jr z, .try_switch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-12-02 10:24:18 -08:00
|
|
|
|
.trapped
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_MonCantBeRecalled
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jp BattleMenuPKMN_Loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-12-02 10:24:18 -08:00
|
|
|
|
.try_switch
|
2016-03-01 19:31:21 -08:00
|
|
|
|
call CheckIfCurPartyMonIsFitToFight
|
2015-12-02 10:24:18 -08:00
|
|
|
|
jp z, BattleMenuPKMN_Loop
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wLastPlayerMon], a
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, BATTLEPLAYERACTION_SWITCH
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wBattlePlayerAction], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearPalettes
|
|
|
|
|
call DelayFrame
|
|
|
|
|
call ClearSprites
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadHPBar
|
2015-12-24 19:58:42 -08:00
|
|
|
|
call CloseWindow
|
2023-07-26 08:01:20 -07:00
|
|
|
|
call GetMemCGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurBattleMon], a
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PlayerSwitch:
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, 1
|
|
|
|
|
ld [wPlayerIsSwitching], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .not_linked
|
2018-01-23 13:08:43 -08:00
|
|
|
|
call LoadStandardMenuHeader
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call LinkBattleSendReceiveAction
|
2015-12-24 19:58:42 -08:00
|
|
|
|
call CloseWindow
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.not_linked
|
2015-11-08 16:09:36 -08:00
|
|
|
|
call ParseEnemyAction
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .linked
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.switch
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call BattleMonEntrance
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.linked
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, [wBattleAction]
|
2018-10-20 21:52:10 -07:00
|
|
|
|
cp BATTLEACTION_STRUGGLE
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .switch
|
2018-10-20 21:52:10 -07:00
|
|
|
|
cp BATTLEACTION_SKIPTURN
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jp z, .switch
|
|
|
|
|
cp BATTLEACTION_SWITCH1
|
|
|
|
|
jp c, .switch
|
|
|
|
|
cp BATTLEACTION_FORFEIT
|
|
|
|
|
jr nz, .dont_run
|
2015-09-06 14:38:01 -07:00
|
|
|
|
call WildFled_EnemyFled_LinkBattleCanceled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.dont_run
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hSerialConnectionStatus]
|
2018-01-19 16:31:45 -08:00
|
|
|
|
cp USING_EXTERNAL_CLOCK
|
2015-11-06 06:04:27 -08:00
|
|
|
|
jr z, .player_1
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call BattleMonEntrance
|
2015-11-06 06:04:27 -08:00
|
|
|
|
call EnemyMonEntrance
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
|
.player_1
|
|
|
|
|
call EnemyMonEntrance
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call BattleMonEntrance
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
EnemyMonEntrance:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar AI_Switch
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jp SpikesDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleMonEntrance:
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call WithdrawMonText
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
|
|
|
|
ld c, 50
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus4
|
2014-01-01 05:09:15 -08:00
|
|
|
|
res SUBSTATUS_RAGE, [hl]
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2015-11-05 16:13:09 -08:00
|
|
|
|
call PursuitSwitch
|
2014-06-12 18:32:42 -07:00
|
|
|
|
jr c, .ok
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call RecallPlayerMon
|
2014-06-12 18:32:42 -07:00
|
|
|
|
.ok
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
|
|
|
|
hlcoord 9, 7
|
|
|
|
|
lb bc, 5, 11
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wCurPartyMon], a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call AddBattleParticipant
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call InitBattleMon
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call ResetPlayerStatLevels
|
2018-02-22 08:13:29 -08:00
|
|
|
|
call SendOutMonText
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call NewBattleMonStatus
|
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
|
call SendOutPlayerMon
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
call SpikesDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $2
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld [wMenuCursorY], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PassedBattleMonEntrance:
|
2014-01-01 05:09:15 -08:00
|
|
|
|
ld c, 50
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
|
|
|
|
hlcoord 9, 7
|
|
|
|
|
lb bc, 5, 11
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
2014-01-01 05:09:15 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurBattleMon], a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
call AddBattleParticipant
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call InitBattleMon
|
2018-07-28 16:27:34 -07:00
|
|
|
|
xor a ; FALSE
|
|
|
|
|
ld [wApplyStatLevelMultipliersToEnemy], a
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call ApplyStatLevelMultiplierOnAllStats
|
2015-11-07 06:48:32 -08:00
|
|
|
|
call SendOutPlayerMon
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetPlayerTurn
|
2014-01-01 05:09:15 -08:00
|
|
|
|
jp SpikesDamage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleMenu_Run:
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $3
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld [wMenuCursorY], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonSpeed
|
|
|
|
|
ld de, wEnemyMonSpeed
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call TryToRunAwayFromBattle
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, FALSE
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld [wFailedToFlee], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattlePlayerAction]
|
2018-07-28 16:27:34 -07:00
|
|
|
|
and a ; BATTLEPLAYERACTION_USEMOVE?
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
2014-06-17 11:58:11 -07:00
|
|
|
|
jp BattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckAmuletCoin:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonItem]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetItemHeldEffect
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2014-06-13 21:18:14 -07:00
|
|
|
|
cp HELD_AMULET_COIN
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, 1
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld [wAmuletCoin], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
MoveSelectionScreen:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMoves
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wMoveSelectionMenuType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .got_menu_type
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .ether_elixer_menu
|
|
|
|
|
call CheckPlayerHasUsableMoves
|
|
|
|
|
ret z ; use Struggle
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonMoves
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr .got_menu_type
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.ether_elixer_menu
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld a, MON_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyParamLocation
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.got_menu_type
|
2015-10-17 14:18:52 -07:00
|
|
|
|
ld de, wListMoves_MoveIndicesBuffer
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld bc, NUM_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
|
|
hlcoord 4, 17 - NUM_MOVES - 1
|
|
|
|
|
ld b, 4
|
|
|
|
|
ld c, 14
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wMoveSelectionMenuType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp $2
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .got_dims
|
2014-06-10 23:08:07 -07:00
|
|
|
|
hlcoord 4, 17 - NUM_MOVES - 1 - 4
|
|
|
|
|
ld b, 4
|
|
|
|
|
ld c, 14
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.got_dims
|
2023-08-11 03:28:14 -07:00
|
|
|
|
call Textbox1bpp
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
|
|
hlcoord 6, 17 - NUM_MOVES
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wMoveSelectionMenuType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp $2
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .got_start_coord
|
2014-06-10 23:08:07 -07:00
|
|
|
|
hlcoord 6, 17 - NUM_MOVES - 4
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.got_start_coord
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld a, SCREEN_WIDTH
|
2020-11-03 16:53:07 -08:00
|
|
|
|
ld [wListMovesLineSpacing], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef ListMoves
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
|
|
ld b, 5
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wMoveSelectionMenuType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp $2
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld a, 17 - NUM_MOVES
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .got_default_coord
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, 5
|
|
|
|
|
ld a, 17 - NUM_MOVES - 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.got_default_coord
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld [w2DMenuCursorInitY], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld [w2DMenuCursorInitX], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wMoveSelectionMenuType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp $1
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .skip_inc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurMoveNum]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.skip_inc
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld [wMenuCursorY], a
|
2018-12-31 11:25:53 -08:00
|
|
|
|
ld a, 1
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld [wMenuCursorX], a
|
2015-12-04 05:46:11 -08:00
|
|
|
|
ld a, [wNumMoves]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld [w2DMenuNumRows], a
|
2018-12-31 11:25:53 -08:00
|
|
|
|
ld a, 1
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld [w2DMenuNumCols], a
|
2018-12-31 11:25:53 -08:00
|
|
|
|
ld c, STATICMENU_ENABLE_LEFT_RIGHT | STATICMENU_ENABLE_START | STATICMENU_WRAP
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wMoveSelectionMenuType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2016-03-01 19:31:21 -08:00
|
|
|
|
ld b, D_DOWN | D_UP | A_BUTTON
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2016-03-01 19:31:21 -08:00
|
|
|
|
ld b, D_DOWN | D_UP | A_BUTTON | B_BUTTON
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .okay
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .okay
|
2016-03-01 19:31:21 -08:00
|
|
|
|
ld b, D_DOWN | D_UP | A_BUTTON | B_BUTTON | SELECT
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2015-12-20 09:54:08 -08:00
|
|
|
|
ld [wMenuJoypadFilter], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld [w2DMenuFlags1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld [w2DMenuFlags2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $10
|
2015-12-21 11:10:16 -08:00
|
|
|
|
ld [w2DMenuCursorOffsets], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.menu_loop
|
|
|
|
|
ld a, [wMoveSelectionMenuType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .battle_player_moves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .interpret_joypad
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 11, 14
|
2020-06-20 19:44:01 -07:00
|
|
|
|
ld de, .empty_string
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PlaceString
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr .interpret_joypad
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.battle_player_moves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call MoveInfoBox
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wSwappingMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .interpret_joypad
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 5, 13
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld bc, SCREEN_WIDTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
call AddNTimes
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld [hl], "▷"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.interpret_joypad
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2015-12-15 15:59:49 -08:00
|
|
|
|
call ScrollingMenuJoypad
|
2015-11-23 13:04:53 -08:00
|
|
|
|
bit D_UP_F, a
|
|
|
|
|
jp nz, .pressed_up
|
|
|
|
|
bit D_DOWN_F, a
|
|
|
|
|
jp nz, .pressed_down
|
|
|
|
|
bit SELECT_F, a
|
|
|
|
|
jp nz, .pressed_select
|
|
|
|
|
bit B_BUTTON_F, a
|
2016-03-01 19:31:21 -08:00
|
|
|
|
; A button
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wSwappingMove], a
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld [wMenuCursorY], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld a, [wMoveSelectionMenuType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .not_enemy_moves_process_b
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.not_enemy_moves_process_b
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurMoveNum], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .use_move
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.use_move
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
|
|
|
|
ret nz
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonPP
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
|
and PP_MASK
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .no_pp_left
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerDisableCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
swap a
|
|
|
|
|
and $f
|
|
|
|
|
dec a
|
|
|
|
|
cp c
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .move_disabled
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld a, [wUnusedPlayerLockedMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .skip2
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonMoves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.skip2
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPlayerMove], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.move_disabled
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_TheMoveIsDisabled
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr .place_textbox_start_over
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.no_pp_left
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_TheresNoPPLeftForThisMove
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.place_textbox_start_over
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2015-10-10 04:45:39 -07:00
|
|
|
|
jp MoveSelectionScreen
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-06-20 19:44:01 -07:00
|
|
|
|
.empty_string
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "@"
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.pressed_up
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jp nz, .menu_loop
|
2015-12-04 05:46:11 -08:00
|
|
|
|
ld a, [wNumMoves]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld [wMenuCursorY], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jp .menu_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.pressed_down
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2015-12-04 05:46:11 -08:00
|
|
|
|
ld a, [wNumMoves]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2015-12-26 18:59:03 -08:00
|
|
|
|
inc a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jp nz, .menu_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld [wMenuCursorY], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jp .menu_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.pressed_select
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wSwappingMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .start_swap
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonMoves
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call .swap_bytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonPP
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call .swap_bytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerDisableCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
swap a
|
|
|
|
|
and $f
|
|
|
|
|
ld b, a
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .not_swapping_disabled_move
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and $f
|
|
|
|
|
ld b, a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wSwappingMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
swap a
|
|
|
|
|
add b
|
|
|
|
|
ld [hl], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr .swap_moves_in_party_struct
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.not_swapping_disabled_move
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wSwappingMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .swap_moves_in_party_struct
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and $f
|
|
|
|
|
ld b, a
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
swap a
|
|
|
|
|
add b
|
|
|
|
|
ld [hl], a
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.swap_moves_in_party_struct
|
|
|
|
|
; Fixes the COOLTRAINER glitch
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .transformed
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartyMon1Moves
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
push hl
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call .swap_bytes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
2015-11-07 10:05:58 -08:00
|
|
|
|
ld bc, MON_PP - MON_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call .swap_bytes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.transformed
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wSwappingMove], a
|
2015-10-10 04:45:39 -07:00
|
|
|
|
jp MoveSelectionScreen
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.swap_bytes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld a, [wSwappingMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ld c, a
|
|
|
|
|
ld b, 0
|
|
|
|
|
add hl, bc
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
|
|
|
|
pop hl
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ld c, a
|
|
|
|
|
ld b, 0
|
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [de]
|
|
|
|
|
ld b, [hl]
|
|
|
|
|
ld [hl], a
|
|
|
|
|
ld a, b
|
|
|
|
|
ld [de], a
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.start_swap
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wSwappingMove], a
|
2015-10-10 04:45:39 -07:00
|
|
|
|
jp MoveSelectionScreen
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
MoveInfoBox:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
hlcoord 0, 8
|
|
|
|
|
ld b, 3
|
|
|
|
|
ld c, 9
|
2023-08-11 03:28:14 -07:00
|
|
|
|
call Textbox1bpp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerDisableCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .not_disabled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
swap a
|
|
|
|
|
and $f
|
|
|
|
|
ld b, a
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .not_disabled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
hlcoord 1, 10
|
|
|
|
|
ld de, .Disabled
|
|
|
|
|
call PlaceString
|
|
|
|
|
jr .done
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.not_disabled
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld hl, wMenuCursorY
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec [hl]
|
|
|
|
|
call SetPlayerTurn
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonMoves
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld a, [wMenuCursorY]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
ld b, 0
|
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPlayerMove], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
|
|
|
|
ld [wCurPartyMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, WILDMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetMaxPPOfMove
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-12-15 15:59:49 -08:00
|
|
|
|
ld hl, wMenuCursorY
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, [hl]
|
|
|
|
|
inc [hl]
|
|
|
|
|
ld b, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonPP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
|
and PP_MASK
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wStringBuffer1], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call .PrintPP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
hlcoord 1, 9
|
|
|
|
|
ld de, .Type
|
|
|
|
|
call PlaceString
|
|
|
|
|
|
|
|
|
|
hlcoord 7, 11
|
|
|
|
|
ld [hl], "/"
|
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar UpdateMoveData
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wPlayerMoveStruct + MOVE_ANIM]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
hlcoord 2, 10
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PrintMoveType
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
.done
|
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Disabled:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "Disabled!@"
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Type:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "TYPE/@"
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.PrintPP:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
hlcoord 5, 11
|
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wStringBuffer1
|
2015-10-10 14:03:04 -07:00
|
|
|
|
lb bc, 1, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintNum
|
|
|
|
|
pop hl
|
|
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
|
inc hl
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], "/"
|
|
|
|
|
inc hl
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld de, wNamedObjectIndex
|
2015-10-10 14:03:04 -07:00
|
|
|
|
lb bc, 1, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintNum
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckPlayerHasUsableMoves:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, STRUGGLE
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPlayerMove], a
|
|
|
|
|
ld a, [wPlayerDisableCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonPP
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr nz, .disabled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
or [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
or [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
|
and PP_MASK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr .force_struggle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.disabled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
swap a
|
|
|
|
|
and $f
|
|
|
|
|
ld b, a
|
2017-12-12 19:58:20 -08:00
|
|
|
|
ld d, NUM_MOVES + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec d
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
dec b
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr z, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
or c
|
2015-11-23 13:04:53 -08:00
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.done
|
2022-07-09 14:12:02 -07:00
|
|
|
|
; BUG: A Disabled but PP Up–enhanced move may not trigger Struggle (see docs/bugs_and_glitches.md)
|
|
|
|
|
and a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
.force_struggle
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_MonHasNoMovesLeft
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, 60
|
|
|
|
|
call DelayFrames
|
|
|
|
|
xor a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ParseEnemyAction:
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wEnemyIsSwitching]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .not_linked
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld a, [wBattlePlayerAction]
|
2018-07-28 16:27:34 -07:00
|
|
|
|
and a ; BATTLEPLAYERACTION_USEMOVE?
|
2015-11-23 13:04:53 -08:00
|
|
|
|
call z, LinkBattleSendReceiveAction
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld a, [wBattleAction]
|
2018-10-20 21:52:10 -07:00
|
|
|
|
cp BATTLEACTION_STRUGGLE
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp z, .struggle
|
2018-10-20 21:52:10 -07:00
|
|
|
|
cp BATTLEACTION_SKIPTURN
|
|
|
|
|
jp z, .skip_turn
|
2015-11-06 06:04:27 -08:00
|
|
|
|
cp BATTLEACTION_SWITCH1
|
2015-09-09 16:27:07 -07:00
|
|
|
|
jp nc, ResetVarsForSubstatusRage
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurEnemyMoveNum], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus1]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_ROLLOUT, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp nz, .skip_load
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus3]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp nz, .skip_load
|
2014-06-12 18:32:42 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wLastEnemyMove]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp nz, .finish
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMoves
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.not_linked
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .skip_encore
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wLastEnemyMove]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.skip_encore
|
2016-03-01 19:31:21 -08:00
|
|
|
|
call CheckEnemyLockedIn
|
2015-09-09 16:27:07 -07:00
|
|
|
|
jp nz, ResetVarsForSubstatusRage
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr .continue
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-10-20 21:52:10 -07:00
|
|
|
|
.skip_turn
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $ff
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.continue
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMoves
|
|
|
|
|
ld de, wEnemyMonPP
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, NUM_MOVES
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp z, .struggle
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyDisabledMove]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .disabled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
2018-01-11 09:00:01 -08:00
|
|
|
|
and PP_MASK
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .enough_pp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.disabled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
|
|
|
|
inc de
|
|
|
|
|
dec b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .loop
|
|
|
|
|
jr .struggle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.enough_pp
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .skip_load
|
|
|
|
|
; wild
|
|
|
|
|
.loop2
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMoves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
2018-01-16 14:27:50 -08:00
|
|
|
|
maskbits NUM_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyDisableCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
swap a
|
|
|
|
|
and $f
|
|
|
|
|
dec a
|
|
|
|
|
cp c
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .loop2
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonPP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hl]
|
2018-01-11 09:00:01 -08:00
|
|
|
|
and PP_MASK
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurEnemyMoveNum], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.finish
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurEnemyMove], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.skip_load
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call SetEnemyTurn
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar UpdateMoveData
|
2016-03-01 19:31:21 -08:00
|
|
|
|
call CheckEnemyLockedIn
|
2015-11-06 17:55:16 -08:00
|
|
|
|
jr nz, .raging
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld [wEnemyCharging], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
|
.raging
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
cp EFFECT_FURY_CUTTER
|
2015-11-06 17:55:16 -08:00
|
|
|
|
jr z, .fury_cutter
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyFuryCutterCount], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
|
.fury_cutter
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
cp EFFECT_RAGE
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .no_rage
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus4
|
2014-06-10 23:08:07 -07:00
|
|
|
|
res SUBSTATUS_RAGE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
ld [wEnemyRageCounter], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.no_rage
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wEnemyMoveStruct + MOVE_EFFECT]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
cp EFFECT_PROTECT
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-10 23:08:07 -07:00
|
|
|
|
cp EFFECT_ENDURE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyProtectCount], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.struggle
|
2014-06-17 12:52:32 -07:00
|
|
|
|
ld a, STRUGGLE
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ResetVarsForSubstatusRage:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyFuryCutterCount], a
|
|
|
|
|
ld [wEnemyProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
|
ld [wEnemyRageCounter], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus4
|
2014-06-10 23:08:07 -07:00
|
|
|
|
res SUBSTATUS_RAGE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckEnemyLockedIn:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus4]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
and 1 << SUBSTATUS_RECHARGE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
and 1 << SUBSTATUS_CHARGED | 1 << SUBSTATUS_RAMPAGE | 1 << SUBSTATUS_BIDE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nz
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemySubStatus1
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_ROLLOUT, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
LinkBattleSendReceiveAction:
|
2023-07-24 12:13:11 -07:00
|
|
|
|
call .StageForSend
|
|
|
|
|
ld [wLinkBattleSentAction], a
|
|
|
|
|
farcall PlaceWaitingText
|
|
|
|
|
call .LinkBattle_SendReceiveAction
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.StageForSend:
|
|
|
|
|
ld a, [wBattlePlayerAction]
|
|
|
|
|
and a ; BATTLEPLAYERACTION_USEMOVE?
|
|
|
|
|
jr nz, .switch
|
|
|
|
|
ld a, [wCurPlayerMove]
|
|
|
|
|
ld b, BATTLEACTION_STRUGGLE
|
|
|
|
|
cp STRUGGLE
|
|
|
|
|
jr z, .struggle
|
|
|
|
|
ld b, BATTLEACTION_SKIPTURN
|
|
|
|
|
cp $ff
|
|
|
|
|
jr z, .struggle
|
|
|
|
|
ld a, [wCurMoveNum]
|
|
|
|
|
jr .use_move
|
|
|
|
|
|
|
|
|
|
.switch
|
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
add BATTLEACTION_SWITCH1
|
|
|
|
|
jr .use_move
|
|
|
|
|
|
|
|
|
|
.struggle
|
|
|
|
|
ld a, b
|
|
|
|
|
|
|
|
|
|
.use_move
|
|
|
|
|
and $0f
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.LinkBattle_SendReceiveAction:
|
|
|
|
|
ld a, [wLinkBattleSentAction]
|
|
|
|
|
ld [wPlayerLinkAction], a
|
|
|
|
|
ld a, $ff
|
|
|
|
|
ld [wOtherPlayerLinkAction], a
|
|
|
|
|
.waiting
|
|
|
|
|
call LinkTransfer
|
|
|
|
|
call DelayFrame
|
|
|
|
|
ld a, [wOtherPlayerLinkAction]
|
|
|
|
|
inc a
|
|
|
|
|
jr z, .waiting
|
|
|
|
|
|
|
|
|
|
vc_hook Wireless_end_exchange
|
|
|
|
|
vc_patch Wireless_net_delay_3
|
|
|
|
|
if DEF(_CRYSTAL11_VC)
|
|
|
|
|
ld b, 26
|
|
|
|
|
else
|
|
|
|
|
ld b, 10
|
|
|
|
|
endc
|
|
|
|
|
vc_patch_end
|
|
|
|
|
.receive
|
|
|
|
|
call DelayFrame
|
|
|
|
|
call LinkTransfer
|
|
|
|
|
dec b
|
|
|
|
|
jr nz, .receive
|
|
|
|
|
|
|
|
|
|
if DEF(_CRYSTAL11_VC)
|
|
|
|
|
ld b, 26
|
|
|
|
|
else
|
|
|
|
|
ld b, 10
|
|
|
|
|
endc
|
|
|
|
|
vc_patch_end
|
|
|
|
|
.acknowledge
|
|
|
|
|
call DelayFrame
|
|
|
|
|
call LinkDataReceived
|
|
|
|
|
dec b
|
|
|
|
|
jr nz, .acknowledge
|
|
|
|
|
|
|
|
|
|
vc_hook Wireless_end_send_zero_bytes
|
|
|
|
|
ld a, [wOtherPlayerLinkAction]
|
|
|
|
|
ld [wBattleAction], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
LoadEnemyMon:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Initialize enemy monster parameters
|
2018-01-23 14:39:09 -08:00
|
|
|
|
; To do this we pull the species from wTempEnemyMonSpecies
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; Notes:
|
|
|
|
|
; BattleRandom is used to ensure sync between Game Boys
|
|
|
|
|
|
2018-01-30 11:05:25 -08:00
|
|
|
|
; Clear the whole enemy mon struct (wEnemyMon)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonSpecies
|
|
|
|
|
ld bc, wEnemyMonEnd - wEnemyMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ByteFill
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; We don't need to be here if we're in a link battle
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jp nz, InitEnemyMon
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Make sure everything knows what species we're working with
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
|
|
|
|
ld [wEnemyMonSpecies], a
|
|
|
|
|
ld [wCurSpecies], a
|
|
|
|
|
ld [wCurPartySpecies], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Grab the BaseData for this species
|
|
|
|
|
call GetBaseData
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Let's get the item:
|
|
|
|
|
|
|
|
|
|
; Is the item predetermined?
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
jr z, .WildItem
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; If we're in a trainer battle, the item is in the party struct
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld hl, wOTPartyMon1Item
|
|
|
|
|
call GetPartyLocation ; bc = PartyMon[wCurPartyMon] - wPartyMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
jr .UpdateItem
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.WildItem:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; In a wild battle, we pull from the item slots in BaseData
|
|
|
|
|
|
|
|
|
|
; Force Item1
|
|
|
|
|
; Used for Ho-Oh, Lugia and Snorlax encounters
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp BATTLETYPE_FORCEITEM
|
2018-07-28 22:40:23 -07:00
|
|
|
|
ld a, [wBaseItem1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr z, .UpdateItem
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Failing that, it's all up to chance
|
|
|
|
|
; Effective chances:
|
|
|
|
|
; 75% None
|
|
|
|
|
; 23% Item1
|
|
|
|
|
; 2% Item2
|
|
|
|
|
|
|
|
|
|
; 25% chance of getting an item
|
|
|
|
|
call BattleRandom
|
2018-02-04 18:21:34 -08:00
|
|
|
|
cp 75 percent + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, NO_ITEM
|
|
|
|
|
jr c, .UpdateItem
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; From there, an 8% chance for Item2
|
|
|
|
|
call BattleRandom
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp 8 percent ; 8% of 25% = 2% Item2
|
2018-07-28 22:40:23 -07:00
|
|
|
|
ld a, [wBaseItem1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nc, .UpdateItem
|
2018-07-28 22:40:23 -07:00
|
|
|
|
ld a, [wBaseItem2]
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.UpdateItem:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyMonItem], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Initialize DVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; If we're in a trainer battle, DVs are predetermined
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
jr z, .InitDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr z, .InitDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Unknown
|
2016-01-10 14:44:09 -08:00
|
|
|
|
ld hl, wEnemyBackupDVs
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
ld [de], a
|
|
|
|
|
jp .Happiness
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.InitDVs:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Trainer DVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; All trainers have preset DVs, determined by class
|
|
|
|
|
; See GetTrainerDVs for more on that
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall GetTrainerDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; These are the DVs we'll use if we're actually in a trainer battle
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
jr nz, .UpdateDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Wild DVs
|
|
|
|
|
; Here's where the fun starts
|
|
|
|
|
|
|
|
|
|
; Roaming monsters (Entei, Raikou) work differently
|
|
|
|
|
; They have their own structs, which are shorter than normal
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp BATTLETYPE_ROAMING
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .NotRoaming
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Grab HP
|
|
|
|
|
call GetRoamMonHP
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
; Check if the HP has been initialized
|
|
|
|
|
and a
|
|
|
|
|
; We'll do something with the result in a minute
|
|
|
|
|
push af
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Grab DVs
|
|
|
|
|
call GetRoamMonDVs
|
|
|
|
|
inc hl
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld c, a
|
|
|
|
|
ld b, [hl]
|
|
|
|
|
|
|
|
|
|
; Get back the result of our check
|
|
|
|
|
pop af
|
|
|
|
|
; If the RoamMon struct has already been initialized, we're done
|
|
|
|
|
jr nz, .UpdateDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; If it hasn't, we need to initialize the DVs
|
|
|
|
|
; (HP is initialized at the end of the battle)
|
|
|
|
|
call GetRoamMonDVs
|
|
|
|
|
inc hl
|
|
|
|
|
call BattleRandom
|
|
|
|
|
ld [hld], a
|
|
|
|
|
ld c, a
|
|
|
|
|
call BattleRandom
|
|
|
|
|
ld [hl], a
|
|
|
|
|
ld b, a
|
|
|
|
|
; We're done with DVs
|
|
|
|
|
jr .UpdateDVs
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.NotRoaming:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
; Register a contains wBattleType
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; Forced shiny battle type
|
|
|
|
|
; Used by Red Gyarados at Lake of Rage
|
2023-07-26 17:50:16 -07:00
|
|
|
|
cp BATTLETYPE_FORCESHINY
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .GenerateDVs
|
|
|
|
|
|
|
|
|
|
ld b, ATKDEFDV_SHINY ; $ea
|
|
|
|
|
ld c, SPDSPCDV_SHINY ; $aa
|
|
|
|
|
jr .UpdateDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.GenerateDVs:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Generate new random DVs
|
|
|
|
|
call BattleRandom
|
|
|
|
|
ld b, a
|
|
|
|
|
call BattleRandom
|
|
|
|
|
ld c, a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.UpdateDVs:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Input DVs in register bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hl], c
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; We've still got more to do if we're dealing with a wild monster
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
jr nz, .Happiness
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Species-specfic:
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Unown
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp UNOWN
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .Magikarp
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Get letter based on DVs
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonDVs
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetUnownLetter
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Can't use any letters that haven't been unlocked
|
|
|
|
|
; If combined with forced shiny battletype, causes an infinite loop
|
|
|
|
|
call CheckUnownLetter
|
|
|
|
|
jr c, .GenerateDVs ; try again
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Magikarp:
|
2017-12-28 10:38:15 -08:00
|
|
|
|
; These filters are untranslated.
|
2017-12-28 07:42:57 -08:00
|
|
|
|
; They expect at wMagikarpLength a 2-byte value in mm,
|
2017-12-28 10:38:15 -08:00
|
|
|
|
; but the value is in feet and inches (one byte each).
|
2017-12-28 07:42:57 -08:00
|
|
|
|
|
|
|
|
|
; The first filter is supposed to make very large Magikarp even rarer,
|
2018-01-02 08:50:08 -08:00
|
|
|
|
; by targeting those 1600 mm (= 5'3") or larger.
|
2017-12-28 10:38:15 -08:00
|
|
|
|
; After the conversion to feet, it is unable to target any,
|
2018-01-02 08:50:08 -08:00
|
|
|
|
; since the largest possible Magikarp is 5'3", and $0503 = 1283 mm.
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp MAGIKARP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .Happiness
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Get Magikarp's length
|
2022-07-09 14:12:02 -07:00
|
|
|
|
; BUG: Magikarp length limits have a unit conversion error (see docs/bugs_and_glitches.md)
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonDVs
|
|
|
|
|
ld bc, wPlayerID
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CalcMagikarpLength
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2018-01-02 08:53:06 -08:00
|
|
|
|
; No reason to keep going if length > 1536 mm (i.e. if HIGH(length) > 6 feet)
|
2017-12-09 16:41:03 -08:00
|
|
|
|
ld a, [wMagikarpLength]
|
2022-07-09 14:12:02 -07:00
|
|
|
|
cp HIGH(1536)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .CheckMagikarpArea
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2017-12-25 10:40:10 -08:00
|
|
|
|
; 5% chance of skipping both size checks
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Random
|
2017-12-25 10:40:10 -08:00
|
|
|
|
cp 5 percent
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr c, .CheckMagikarpArea
|
2019-02-17 10:18:38 -08:00
|
|
|
|
; Try again if length >= 1616 mm (i.e. if LOW(length) >= 4 inches)
|
2017-12-09 16:41:03 -08:00
|
|
|
|
ld a, [wMagikarpLength + 1]
|
2022-07-09 14:12:02 -07:00
|
|
|
|
cp LOW(1616)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nc, .GenerateDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; 20% chance of skipping this check
|
|
|
|
|
call Random
|
2017-12-25 10:40:10 -08:00
|
|
|
|
cp 20 percent - 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr c, .CheckMagikarpArea
|
2019-02-17 10:18:38 -08:00
|
|
|
|
; Try again if length >= 1600 mm (i.e. if LOW(length) >= 3 inches)
|
2017-12-09 16:41:03 -08:00
|
|
|
|
ld a, [wMagikarpLength + 1]
|
2022-07-09 14:12:02 -07:00
|
|
|
|
cp LOW(1600)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nc, .GenerateDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.CheckMagikarpArea:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; 40% chance of not flooring
|
|
|
|
|
call Random
|
2020-05-07 08:09:41 -07:00
|
|
|
|
cp 39 percent + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr c, .Happiness
|
2018-01-02 08:53:06 -08:00
|
|
|
|
; Try again if length < 1024 mm (i.e. if HIGH(length) < 3 feet)
|
2017-12-09 16:41:03 -08:00
|
|
|
|
ld a, [wMagikarpLength]
|
2022-07-09 14:12:02 -07:00
|
|
|
|
cp HIGH(1024)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr c, .GenerateDVs ; try again
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Finally done with DVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Happiness:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Set happiness
|
|
|
|
|
ld a, BASE_HAPPINESS
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyMonHappiness], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Set level
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyLevel]
|
|
|
|
|
ld [wEnemyMonLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Fill stats
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonMaxHP
|
2015-12-21 11:10:16 -08:00
|
|
|
|
ld b, FALSE
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld hl, wEnemyMonDVs - (MON_DVS - MON_STAT_EXP + 1)
|
2018-02-22 08:13:29 -08:00
|
|
|
|
predef CalcMonStats
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; If we're in a trainer battle,
|
|
|
|
|
; get the rest of the parameters from the party struct
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp TRAINER_BATTLE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr z, .OpponentParty
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; If we're in a wild battle, check wild-specific stuff
|
|
|
|
|
and a
|
|
|
|
|
jr z, .TreeMon
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp nz, .Moves
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.TreeMon:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; If we're headbutting trees, some monsters enter battle asleep
|
|
|
|
|
call CheckSleepingTreeMon
|
2017-12-25 10:40:10 -08:00
|
|
|
|
ld a, TREEMON_SLEEP_TURNS
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr c, .UpdateStatus
|
|
|
|
|
; Otherwise, no status
|
|
|
|
|
xor a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.UpdateStatus:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonStatus
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Unused byte
|
|
|
|
|
xor a
|
|
|
|
|
ld [hli], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
; Full HP..
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonMaxHP]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonMaxHP + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2015-11-23 13:04:53 -08:00
|
|
|
|
; ..unless it's a RoamMon
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp BATTLETYPE_ROAMING
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .Moves
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Grab HP
|
|
|
|
|
call GetRoamMonHP
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
; Check if it's been initialized again
|
|
|
|
|
and a
|
|
|
|
|
jr z, .InitRoamHP
|
|
|
|
|
; Update from the struct if it has
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyMonHP + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr .Moves
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.InitRoamHP:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; HP only uses the lo byte in the RoamMon struct since
|
2018-05-05 00:19:04 -07:00
|
|
|
|
; Raikou and Entei will have < 256 hp at level 40
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonHP + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
|
|
|
|
jr .Moves
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.OpponentParty:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Get HP from the party struct
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, (wOTPartyMon1HP + 1)
|
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld a, [hld]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyMonHP + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyMonHP], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Make sure everything knows which monster the opponent is using
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld [wCurOTMon], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Get status from the party struct
|
|
|
|
|
dec hl
|
|
|
|
|
ld a, [hl] ; OTPartyMonStatus
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyMonStatus], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Moves:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBaseType1
|
|
|
|
|
ld de, wEnemyMonType1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
ld [de], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Get moves
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonMoves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Are we in a trainer battle?
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp TRAINER_BATTLE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .WildMoves
|
|
|
|
|
; Then copy moves from the party struct
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1Moves
|
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
|
|
|
|
ld bc, NUM_MOVES
|
|
|
|
|
call CopyBytes
|
|
|
|
|
jr .PP
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.WildMoves:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
; Clear wEnemyMonMoves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld h, d
|
|
|
|
|
ld l, e
|
|
|
|
|
ld [hli], a
|
2016-05-10 09:31:49 -07:00
|
|
|
|
ld [hli], a
|
|
|
|
|
ld [hli], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2020-11-03 16:53:07 -08:00
|
|
|
|
ld [wSkipMovesBeforeLevelUp], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Fill moves based on level
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef FillMoves
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PP:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Trainer battle?
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp TRAINER_BATTLE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr z, .TrainerPP
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Fill wild PP
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMoves
|
|
|
|
|
ld de, wEnemyMonPP
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef FillPP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr .Finish
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.TrainerPP:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Copy PP from the party struct
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPartyMon1PP
|
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wEnemyMonPP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld bc, NUM_MOVES
|
|
|
|
|
call CopyBytes
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Finish:
|
2022-01-08 10:42:40 -08:00
|
|
|
|
; Copy the first five base stats (the enemy mon's base Sp. Atk
|
|
|
|
|
; is also used to calculate Sp. Def stat experience)
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBaseStats
|
|
|
|
|
ld de, wEnemyMonBaseStats
|
2022-01-08 10:42:40 -08:00
|
|
|
|
ld b, NUM_STATS - 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
.loop
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
dec b
|
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBaseCatchRate]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBaseExp]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [de], a
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wNamedObjectIndex], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
call GetPokemonName
|
|
|
|
|
|
|
|
|
|
; Did we catch it?
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret z
|
|
|
|
|
|
2021-04-27 09:11:39 -07:00
|
|
|
|
; Update enemy nickname
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wStringBuffer1
|
2021-03-17 13:16:02 -07:00
|
|
|
|
ld de, wEnemyMonNickname
|
2018-01-20 09:25:55 -08:00
|
|
|
|
ld bc, MON_NAME_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
|
2015-11-29 18:34:59 -08:00
|
|
|
|
; Saw this mon
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
|
|
|
|
ld c, a
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld b, SET_FLAG
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPokedexSeen
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef SmallFarFlagAction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonStats
|
|
|
|
|
ld de, wEnemyStats
|
2020-06-29 09:25:58 -07:00
|
|
|
|
ld bc, NUM_EXP_STATS * 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
|
2022-12-01 13:54:01 -08:00
|
|
|
|
; BUG: PRZ and BRN stat reductions don't apply to switched Pokémon (see docs/bugs_and_glitches.md)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckSleepingTreeMon:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Return carry if species is in the list
|
|
|
|
|
; for the current time of day
|
|
|
|
|
|
|
|
|
|
; Don't do anything if this isn't a tree encounter
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2017-12-09 21:06:20 -08:00
|
|
|
|
cp BATTLETYPE_TREE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .NotSleeping
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Get list for the time of day
|
2018-01-09 12:12:49 -08:00
|
|
|
|
ld hl, AsleepTreeMonsMorn
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTimeOfDay]
|
2017-12-10 22:02:28 -08:00
|
|
|
|
cp DAY_F
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr c, .Check
|
2018-01-09 12:12:49 -08:00
|
|
|
|
ld hl, AsleepTreeMonsDay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr z, .Check
|
2018-01-09 12:12:49 -08:00
|
|
|
|
ld hl, AsleepTreeMonsNite
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Check:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, 1 ; length of species id
|
|
|
|
|
call IsInArray
|
|
|
|
|
; If it's a match, the opponent is asleep
|
|
|
|
|
ret c
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.NotSleeping:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-01-09 12:12:49 -08:00
|
|
|
|
INCLUDE "data/wild/treemons_asleep.asm"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckUnownLetter:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Return carry if the Unown letter hasn't been unlocked yet
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2017-12-28 04:15:46 -08:00
|
|
|
|
ld a, [wUnlockedUnowns]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
ld de, 0
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
.loop
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Don't check this set unless it's been unlocked
|
|
|
|
|
srl c
|
|
|
|
|
jr nc, .next
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Is our letter in the set?
|
2018-01-22 10:00:35 -08:00
|
|
|
|
ld hl, UnlockedUnownLetterSets
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld h, [hl]
|
|
|
|
|
ld l, a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wUnownLetter]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, 1
|
|
|
|
|
push bc
|
|
|
|
|
call IsInArray
|
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr c, .match
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
.next
|
|
|
|
|
; Make sure we haven't gone past the end of the table
|
|
|
|
|
inc e
|
2015-12-26 18:59:03 -08:00
|
|
|
|
inc e
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, e
|
2022-12-26 10:14:10 -08:00
|
|
|
|
cp NUM_UNLOCKED_UNOWN_SETS * 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr c, .loop
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Hasn't been unlocked, or the letter is invalid
|
|
|
|
|
scf
|
|
|
|
|
ret
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
.match
|
|
|
|
|
; Valid letter
|
|
|
|
|
and a
|
|
|
|
|
ret
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2018-01-22 10:00:35 -08:00
|
|
|
|
INCLUDE "data/wild/unlocked_unowns.asm"
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
|
SwapBattlerLevels: ; unreferenced
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonLevel]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonLevel]
|
|
|
|
|
ld [wBattleMonLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wEnemyMonLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleWinSlideInEnemyTrainerFrontpic:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTempEnemyMonSpecies], a
|
2015-11-09 13:41:09 -08:00
|
|
|
|
call FinishBattleAnim
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOtherTrainerClass]
|
|
|
|
|
ld [wTrainerClass], a
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld de, vTiles2
|
2018-01-16 11:30:10 -08:00
|
|
|
|
callfar GetTrainerPic
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 19, 0
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld c, 0
|
2015-10-19 13:49:29 -07:00
|
|
|
|
|
|
|
|
|
.outer_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc c
|
|
|
|
|
ld a, c
|
2015-11-28 12:13:40 -08:00
|
|
|
|
cp 7
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
|
|
|
|
ldh [hBGMapThird], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, $0
|
|
|
|
|
push bc
|
|
|
|
|
push hl
|
2015-10-19 13:49:29 -07:00
|
|
|
|
|
|
|
|
|
.inner_loop
|
2015-11-28 12:13:40 -08:00
|
|
|
|
call .CopyColumn
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld a, 7
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add d
|
|
|
|
|
ld d, a
|
|
|
|
|
dec c
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .inner_loop
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld c, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
dec hl
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr .outer_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.CopyColumn:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push de
|
|
|
|
|
push bc
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld e, 7
|
2015-10-19 13:49:29 -07:00
|
|
|
|
|
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], d
|
2015-10-19 13:49:29 -07:00
|
|
|
|
ld bc, SCREEN_WIDTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
inc d
|
|
|
|
|
dec e
|
2015-10-19 13:49:29 -07:00
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ApplyStatusEffectOnPlayerStats:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, 1
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr ApplyStatusEffectOnStats
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ApplyStatusEffectOnEnemyStats:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ApplyStatusEffectOnStats:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2015-11-06 17:55:16 -08:00
|
|
|
|
call ApplyPrzEffectOnSpeed
|
|
|
|
|
jp ApplyBrnEffectOnAttack
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ApplyPrzEffectOnSpeed:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .enemy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
and 1 << PAR
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonSpeed + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
ld [hli], a
|
|
|
|
|
or b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .player_ok
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld b, $1 ; min speed
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.player_ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], b
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.enemy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
and 1 << PAR
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonSpeed + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
ld [hli], a
|
|
|
|
|
or b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .enemy_ok
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld b, $1 ; min speed
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.enemy_ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], b
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ApplyBrnEffectOnAttack:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .enemy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
and 1 << BRN
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonAttack + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
ld [hli], a
|
|
|
|
|
or b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .player_ok
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld b, $1 ; min attack
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.player_ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], b
|
|
|
|
|
ret
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.enemy
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
and 1 << BRN
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonAttack + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
ld [hli], a
|
|
|
|
|
or b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .enemy_ok
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld b, $1 ; min attack
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.enemy_ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], b
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ApplyStatLevelMultiplierOnAllStats:
|
2015-09-09 16:27:07 -07:00
|
|
|
|
; Apply StatLevelMultipliers on all 5 Stats
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, 0
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.stat_loop
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call ApplyStatLevelMultiplier
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc c
|
|
|
|
|
ld a, c
|
2018-07-28 16:27:34 -07:00
|
|
|
|
cp NUM_BATTLE_STATS
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .stat_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ApplyStatLevelMultiplier:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
push bc
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, [wApplyStatLevelMultipliersToEnemy]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ld a, c
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonAttack
|
|
|
|
|
ld de, wPlayerStats
|
|
|
|
|
ld bc, wPlayerAtkLevel
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .got_pointers
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonAttack
|
|
|
|
|
ld de, wEnemyStats
|
|
|
|
|
ld bc, wEnemyAtkLevel
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.got_pointers
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add c
|
|
|
|
|
ld c, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nc, .okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [bc]
|
|
|
|
|
pop bc
|
|
|
|
|
ld b, a
|
|
|
|
|
push bc
|
|
|
|
|
sla c
|
|
|
|
|
ld b, 0
|
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, c
|
|
|
|
|
add e
|
|
|
|
|
ld e, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nc, .okay2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc d
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.okay2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
push hl
|
2018-01-25 18:34:42 -08:00
|
|
|
|
ld hl, StatLevelMultipliers_Applied
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec b
|
|
|
|
|
sla b
|
|
|
|
|
ld c, b
|
|
|
|
|
ld b, 0
|
|
|
|
|
add hl, bc
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 0], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc de
|
|
|
|
|
ld a, [de]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Multiply
|
|
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDivisor], a
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld b, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Divide
|
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
|
|
; Cap at 999.
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2017-12-25 10:40:10 -08:00
|
|
|
|
sub LOW(MAX_STAT_VALUE)
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 2]
|
2017-12-25 10:40:10 -08:00
|
|
|
|
sbc HIGH(MAX_STAT_VALUE)
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp c, .okay3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2017-12-25 10:40:10 -08:00
|
|
|
|
ld a, HIGH(MAX_STAT_VALUE)
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hQuotient + 2], a
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ld a, LOW(MAX_STAT_VALUE)
|
|
|
|
|
ldh [hQuotient + 3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.okay3
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
|
|
|
|
ld b, a
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
|
|
|
|
or b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .okay4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc [hl]
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.okay4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2018-01-25 18:34:42 -08:00
|
|
|
|
INCLUDE "data/battle/stat_multipliers_2.asm"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BadgeStatBoosts:
|
2018-01-30 11:05:25 -08:00
|
|
|
|
; Raise the stats of the battle mon in wBattleMon
|
|
|
|
|
; depending on which badges have been obtained.
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; Every other badge boosts a stat, starting from the first.
|
2019-10-20 15:25:34 -07:00
|
|
|
|
; GlacierBadge also boosts Special Defense, although the relevant code is buggy (see below).
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; ZephyrBadge: Attack
|
|
|
|
|
; PlainBadge: Speed
|
|
|
|
|
; MineralBadge: Defense
|
2019-10-20 15:25:34 -07:00
|
|
|
|
; GlacierBadge: Special Attack and Special Defense
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; The boosted stats are in order, except PlainBadge and MineralBadge's boosts are swapped.
|
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
|
|
|
|
|
2017-12-28 04:15:46 -08:00
|
|
|
|
ld a, [wJohtoBadges]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; Swap badges 3 (PlainBadge) and 5 (MineralBadge).
|
|
|
|
|
ld d, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
and (1 << PLAINBADGE)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add a
|
2015-12-26 18:59:03 -08:00
|
|
|
|
add a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
ld a, d
|
2015-11-07 18:04:54 -08:00
|
|
|
|
and (1 << MINERALBADGE)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
rrca
|
|
|
|
|
rrca
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, d
|
2015-11-07 18:04:54 -08:00
|
|
|
|
and ((1 << ZEPHYRBADGE) | (1 << HIVEBADGE) | (1 << FOGBADGE) | (1 << STORMBADGE) | (1 << GLACIERBADGE) | (1 << RISINGBADGE))
|
2013-12-17 22:11:06 -08:00
|
|
|
|
or b
|
|
|
|
|
or c
|
|
|
|
|
ld b, a
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wBattleMonAttack
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, 4
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.CheckBadge:
|
2022-07-09 14:12:02 -07:00
|
|
|
|
; BUG: Glacier Badge may not boost Special Defense depending on the value of Special Attack (see docs/bugs_and_glitches.md)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
srl b
|
|
|
|
|
call c, BoostStat
|
|
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
|
inc hl
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Check every other badge.
|
|
|
|
|
srl b
|
|
|
|
|
dec c
|
|
|
|
|
jr nz, .CheckBadge
|
|
|
|
|
srl a
|
|
|
|
|
call c, BoostStat
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BoostStat:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; Raise stat at hl by 1/8.
|
|
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld d, a
|
|
|
|
|
ld e, [hl]
|
|
|
|
|
srl d
|
|
|
|
|
rr e
|
|
|
|
|
srl d
|
|
|
|
|
rr e
|
|
|
|
|
srl d
|
|
|
|
|
rr e
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
add e
|
|
|
|
|
ld [hld], a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
adc d
|
|
|
|
|
ld [hli], a
|
|
|
|
|
|
|
|
|
|
; Cap at 999.
|
|
|
|
|
ld a, [hld]
|
2017-12-25 10:40:10 -08:00
|
|
|
|
sub LOW(MAX_STAT_VALUE)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2017-12-25 10:40:10 -08:00
|
|
|
|
sbc HIGH(MAX_STAT_VALUE)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2017-12-25 10:40:10 -08:00
|
|
|
|
ld a, HIGH(MAX_STAT_VALUE)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
2017-12-25 10:40:10 -08:00
|
|
|
|
ld a, LOW(MAX_STAT_VALUE)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hld], a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
_LoadBattleFontsHPBar:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar LoadBattleFontsHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
_LoadHPBar:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar LoadHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
|
LoadHPExpBarGFX: ; unreferenced
|
2015-11-04 12:35:29 -08:00
|
|
|
|
ld de, EnemyHPBarBorderGFX
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld hl, vTiles2 tile $6c
|
2015-11-04 12:35:29 -08:00
|
|
|
|
lb bc, BANK(EnemyHPBarBorderGFX), 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Get1bpp
|
2015-11-04 12:35:29 -08:00
|
|
|
|
ld de, HPExpBarBorderGFX
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld hl, vTiles2 tile $73
|
2015-11-04 12:35:29 -08:00
|
|
|
|
lb bc, BANK(HPExpBarBorderGFX), 6
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Get1bpp
|
2015-11-04 11:02:11 -08:00
|
|
|
|
ld de, ExpBarGFX
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld hl, vTiles2 tile $55
|
2015-11-04 11:02:11 -08:00
|
|
|
|
lb bc, BANK(ExpBarGFX), 8
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jp Get2bpp
|
|
|
|
|
|
2019-04-08 05:15:10 -07:00
|
|
|
|
EmptyBattleTextbox:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, .empty
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp BattleTextbox
|
2018-11-17 10:33:03 -08:00
|
|
|
|
|
|
|
|
|
.empty:
|
|
|
|
|
text_end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
_BattleRandom::
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; If the normal RNG is used in a link battle it'll desync.
|
|
|
|
|
; To circumvent this a shared PRNG is used instead.
|
|
|
|
|
|
|
|
|
|
; But if we're in a non-link battle we're safe to use it
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
jp z, Random
|
|
|
|
|
|
|
|
|
|
; The PRNG operates in streams of 10 values.
|
|
|
|
|
|
|
|
|
|
; Which value are we trying to pull?
|
|
|
|
|
push hl
|
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wLinkBattleRNCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
|
|
|
|
ld b, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wLinkBattleRNs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wLinkBattleRNCount], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; If we haven't hit the end yet, we're good
|
|
|
|
|
cp 10 - 1 ; Exclude last value. See the closing comment
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
|
|
|
|
ret c
|
|
|
|
|
|
|
|
|
|
; If we have, we have to generate new pseudorandom data
|
|
|
|
|
; Instead of having multiple PRNGs, ten seeds are used
|
|
|
|
|
push hl
|
|
|
|
|
push bc
|
|
|
|
|
push af
|
|
|
|
|
|
|
|
|
|
; Reset count to 0
|
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wLinkBattleRNCount], a
|
|
|
|
|
ld hl, wLinkBattleRNs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, 10 ; number of seeds
|
|
|
|
|
|
|
|
|
|
; Generate next number in the sequence for each seed
|
2017-12-25 10:40:10 -08:00
|
|
|
|
; a[n+1] = (a[n] * 5 + 1) % 256
|
2013-12-17 22:11:06 -08:00
|
|
|
|
.loop
|
|
|
|
|
; get last #
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
|
|
|
|
|
; a * 5 + 1
|
|
|
|
|
ld c, a
|
|
|
|
|
add a
|
2015-12-26 18:59:03 -08:00
|
|
|
|
add a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add c
|
|
|
|
|
inc a
|
|
|
|
|
|
|
|
|
|
; update #
|
|
|
|
|
ld [hli], a
|
|
|
|
|
dec b
|
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
|
|
; This has the side effect of pulling the last value first,
|
|
|
|
|
; then wrapping around. As a result, when we check to see if
|
|
|
|
|
; we've reached the end, we check the one before it.
|
|
|
|
|
|
|
|
|
|
pop af
|
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
Call_PlayBattleAnim_OnlyIfVisible:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
|
call GetBattleVar
|
|
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
|
|
|
|
ret nz
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
Call_PlayBattleAnim:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, e
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wFXAnimID], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wFXAnimID + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitBGMap
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef_jump PlayBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
FinishBattleAnim:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
push bc
|
|
|
|
|
push de
|
|
|
|
|
push hl
|
2023-07-26 08:01:20 -07:00
|
|
|
|
ld b, CGB_BATTLE_COLORS
|
|
|
|
|
call GetCGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrame
|
|
|
|
|
pop hl
|
|
|
|
|
pop de
|
|
|
|
|
pop bc
|
|
|
|
|
pop af
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GiveExperiencePoints:
|
2014-06-03 14:07:10 -07:00
|
|
|
|
; Give experience.
|
2023-07-24 12:13:11 -07:00
|
|
|
|
; Don't give experience if linked.
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
2015-08-24 16:56:30 -07:00
|
|
|
|
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call .EvenlyDivideExpAmongParticipants
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
|
|
|
|
ld bc, wPartyMon1Species
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.loop
|
|
|
|
|
ld hl, MON_HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jp z, .next_mon ; fainted
|
2015-11-07 18:04:54 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, wBattleParticipantsNotFainted
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld b, CHECK_FLAG
|
2020-01-19 11:10:10 -08:00
|
|
|
|
ld d, 0
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef SmallFarFlagAction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
|
|
|
|
and a
|
|
|
|
|
pop bc
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jp z, .next_mon
|
2015-11-28 12:13:40 -08:00
|
|
|
|
|
2016-01-12 09:46:18 -08:00
|
|
|
|
; give stat exp
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, MON_STAT_EXP + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonBaseStats - 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2018-07-11 12:40:09 -07:00
|
|
|
|
ld c, NUM_EXP_STATS
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.stat_exp_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
|
|
|
|
ld a, [de]
|
|
|
|
|
add [hl]
|
|
|
|
|
ld [de], a
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr nc, .no_carry_stat_exp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec de
|
|
|
|
|
ld a, [de]
|
|
|
|
|
inc a
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr z, .stat_exp_maxed_out
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.no_carry_stat_exp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push bc
|
2021-06-07 17:00:21 -07:00
|
|
|
|
ld a, MON_POKERUS
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyParamLocation
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
and a
|
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr z, .stat_exp_awarded
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
add [hl]
|
|
|
|
|
ld [de], a
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr nc, .stat_exp_awarded
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec de
|
|
|
|
|
ld a, [de]
|
|
|
|
|
inc a
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr z, .stat_exp_maxed_out
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr .stat_exp_awarded
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.stat_exp_maxed_out
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $ff
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld [de], a
|
|
|
|
|
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.stat_exp_awarded
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc de
|
2015-12-26 18:59:03 -08:00
|
|
|
|
inc de
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec c
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr nz, .stat_exp_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 0], a
|
|
|
|
|
ldh [hMultiplicand + 1], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonBaseExp]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 2], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonLevel]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Multiply
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld a, 7
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDivisor], a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld b, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Divide
|
2016-01-12 09:46:18 -08:00
|
|
|
|
; Boost Experience for traded Pokemon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, MON_ID
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerID]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .boosted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerID + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp [hl]
|
2018-12-23 00:45:41 -08:00
|
|
|
|
ld a, 0
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .no_boost
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.boosted
|
2015-11-11 11:12:46 -08:00
|
|
|
|
call BoostExp
|
2018-12-23 00:45:41 -08:00
|
|
|
|
ld a, 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.no_boost
|
2016-01-12 09:46:18 -08:00
|
|
|
|
; Boost experience for a Trainer Battle
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wStringBuffer2 + 2], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-11 11:12:46 -08:00
|
|
|
|
call nz, BoostExp
|
2016-01-12 09:46:18 -08:00
|
|
|
|
; Boost experience for Lucky Egg
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld a, MON_ITEM
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyParamLocation
|
|
|
|
|
ld a, [hl]
|
2014-06-03 14:07:10 -07:00
|
|
|
|
cp LUCKY_EGG
|
2015-11-11 11:12:46 -08:00
|
|
|
|
call z, BoostExp
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wStringBuffer2 + 1], a
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 2]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wStringBuffer2], a
|
|
|
|
|
ld a, [wCurPartyMon]
|
|
|
|
|
ld hl, wPartyMonNicknames
|
2021-03-17 13:16:02 -07:00
|
|
|
|
call GetNickname
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, Text_MonGainedExpPoint
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call BattleTextbox
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wStringBuffer2 + 1]
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh [hQuotient + 3], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wStringBuffer2]
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh [hQuotient + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call AnimateExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2018-07-24 11:14:04 -07:00
|
|
|
|
ld hl, MON_EXP + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld d, [hl]
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add d
|
|
|
|
|
ld [hld], a
|
|
|
|
|
ld d, [hl]
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
adc d
|
|
|
|
|
ld [hl], a
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr nc, .no_exp_overflow
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec hl
|
|
|
|
|
inc [hl]
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr nz, .no_exp_overflow
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $ff
|
|
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
|
ld [hli], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
|
|
|
|
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.no_exp_overflow
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld e, a
|
2018-12-23 00:45:41 -08:00
|
|
|
|
ld d, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPartySpecies
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurSpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
|
|
|
|
push bc
|
2014-06-03 14:07:10 -07:00
|
|
|
|
ld d, MAX_LEVEL
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CalcExpAtLevel
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2018-07-24 11:14:04 -07:00
|
|
|
|
ld hl, MON_EXP + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
push bc
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hQuotient + 1]
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hQuotient + 2]
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ld c, a
|
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, a
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
sub d
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
sbc c
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
sbc b
|
2015-12-17 10:49:26 -08:00
|
|
|
|
jr c, .not_max_exp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld a, c
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld a, d
|
|
|
|
|
ld [hld], a
|
|
|
|
|
|
2015-12-17 10:49:26 -08:00
|
|
|
|
.not_max_exp
|
2018-12-23 00:45:41 -08:00
|
|
|
|
; Check if the mon leveled up
|
2015-10-07 18:27:32 -07:00
|
|
|
|
xor a ; PARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2018-02-22 08:13:29 -08:00
|
|
|
|
predef CopyMonToTempMon
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CalcLevel
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld hl, MON_LEVEL
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2014-06-03 14:07:10 -07:00
|
|
|
|
cp MAX_LEVEL
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jp nc, .next_mon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp d
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jp z, .next_mon
|
2015-11-07 18:04:54 -08:00
|
|
|
|
; <NICKNAME> grew to level ##!
|
2015-12-17 10:49:26 -08:00
|
|
|
|
ld [wTempLevel], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyLevel]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
ld a, d
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld hl, MON_SPECIES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurSpecies], a
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld [wTempSpecies], a ; unused?
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, MON_MAXHP + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld e, a
|
|
|
|
|
ld d, [hl]
|
|
|
|
|
push de
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, MON_MAXHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
2015-12-21 11:10:16 -08:00
|
|
|
|
ld hl, MON_STAT_EXP - 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
push bc
|
2015-12-21 11:10:16 -08:00
|
|
|
|
ld b, TRUE
|
2018-02-22 08:13:29 -08:00
|
|
|
|
predef CalcMonStats
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, MON_MAXHP + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
sub e
|
|
|
|
|
ld e, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
sbc d
|
|
|
|
|
ld d, a
|
|
|
|
|
dec hl
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
add e
|
|
|
|
|
ld [hld], a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
adc d
|
|
|
|
|
ld [hl], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp d
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr nz, .skip_active_mon_update
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wBattleMonMaxHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - MON_MAXHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
pop bc
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld hl, MON_LEVEL
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld a, [hl]
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleMonLevel], a
|
|
|
|
|
ld a, [wPlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .transformed
|
|
|
|
|
ld hl, MON_ATK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wPlayerStats
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH - MON_ATK
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.transformed
|
2018-07-28 16:27:34 -07:00
|
|
|
|
xor a ; FALSE
|
|
|
|
|
ld [wApplyStatLevelMultipliersToEnemy], a
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call ApplyStatLevelMultiplierOnAllStats
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar ApplyStatusEffectOnPlayerStats
|
|
|
|
|
callfar BadgeStatBoosts
|
2018-01-16 11:30:10 -08:00
|
|
|
|
callfar UpdatePlayerHUD
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.skip_active_mon_update
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall LevelUpHappinessMod
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr z, .skip_exp_bar_animation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, SFX_HIT_END_OF_EXP_BAR
|
|
|
|
|
call PlaySFX
|
|
|
|
|
call WaitSFX
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_StringBuffer1GrewToLevel
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call LoadTilemapToTempTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.skip_exp_bar_animation
|
2015-10-07 18:27:32 -07:00
|
|
|
|
xor a ; PARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2018-02-22 08:13:29 -08:00
|
|
|
|
predef CopyMonToTempMon
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 9, 0
|
2018-07-11 12:40:09 -07:00
|
|
|
|
ld b, 10
|
|
|
|
|
ld c, 9
|
2023-08-11 03:28:14 -07:00
|
|
|
|
call Textbox1bpp
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 11, 1
|
2015-12-17 10:49:26 -08:00
|
|
|
|
ld bc, 4
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PrintTempMonStats
|
2018-07-11 12:40:09 -07:00
|
|
|
|
ld c, 30
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2015-11-10 20:23:28 -08:00
|
|
|
|
call WaitPressAorB_BlinkCursor
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2015-10-07 18:27:32 -07:00
|
|
|
|
xor a ; PARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
|
|
|
|
ld a, [wCurSpecies]
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld [wTempSpecies], a ; unused?
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyLevel]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
ld c, a
|
2015-12-17 10:49:26 -08:00
|
|
|
|
ld a, [wTempLevel]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.level_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc b
|
|
|
|
|
ld a, b
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef LearnLevelMoves
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ld a, b
|
|
|
|
|
cp c
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr nz, .level_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyLevel], a
|
|
|
|
|
ld hl, wEvolvableFlags
|
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld b, SET_FLAG
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef SmallFarFlagAction
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.next_mon
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartyMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
|
|
|
|
cp b
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jr z, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld a, MON_SPECIES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyParamLocation
|
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2015-11-07 18:04:54 -08:00
|
|
|
|
jp .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
|
.done
|
|
|
|
|
jp ResetBattleParticipants
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.EvenlyDivideExpAmongParticipants:
|
2015-11-28 12:13:40 -08:00
|
|
|
|
; count number of battle participants
|
2015-11-07 18:04:54 -08:00
|
|
|
|
ld a, [wBattleParticipantsNotFainted]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld c, PARTY_LENGTH
|
|
|
|
|
ld d, 0
|
2016-01-12 09:46:18 -08:00
|
|
|
|
.count_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
srl b
|
|
|
|
|
adc d
|
|
|
|
|
ld d, a
|
|
|
|
|
dec c
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr nz, .count_loop
|
2015-11-28 12:13:40 -08:00
|
|
|
|
cp 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-11-28 12:13:40 -08:00
|
|
|
|
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld [wTempByteValue], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonBaseStats
|
|
|
|
|
ld c, wEnemyMonEnd - wEnemyMonBaseStats
|
2018-12-23 00:45:41 -08:00
|
|
|
|
.base_stat_division_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDividend + 0], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDividend + 1], a
|
2018-07-28 16:27:34 -07:00
|
|
|
|
ld a, [wTempByteValue]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDivisor], a
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld b, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Divide
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
|
|
|
|
dec c
|
2018-12-23 00:45:41 -08:00
|
|
|
|
jr nz, .base_stat_division_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BoostExp:
|
2015-11-11 11:12:46 -08:00
|
|
|
|
; Multiply experience by 1.5x
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2015-11-11 11:12:46 -08:00
|
|
|
|
; load experience value
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2015-11-11 11:12:46 -08:00
|
|
|
|
; halve it
|
2013-12-17 22:11:06 -08:00
|
|
|
|
srl b
|
|
|
|
|
rr c
|
2015-11-11 11:12:46 -08:00
|
|
|
|
; add it back to the whole exp value
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add c
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hProduct + 3], a
|
|
|
|
|
ldh a, [hProduct + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
adc b
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hProduct + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
Text_MonGainedExpPoint:
|
2018-10-28 09:16:55 -07:00
|
|
|
|
text_far Text_Gained
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_asm
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ld hl, ExpPointsText
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wStringBuffer2 + 2] ; IsTradedMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ld hl, BoostedExpPointsText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
BoostedExpPointsText:
|
|
|
|
|
text_far _BoostedExpPointsText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ExpPointsText:
|
|
|
|
|
text_far _ExpPointsText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
AnimateExpBar:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wCurPartyMon
|
|
|
|
|
ld a, [wCurBattleMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp [hl]
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jp nz, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonLevel]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp MAX_LEVEL
|
2015-11-10 16:51:13 -08:00
|
|
|
|
jp nc, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 3]
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld [wExperienceGained + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 2]
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld [wExperienceGained + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
xor a
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld [wExperienceGained], a
|
2015-10-07 18:27:32 -07:00
|
|
|
|
xor a ; PARTYMON
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wMonType], a
|
2018-02-22 08:13:29 -08:00
|
|
|
|
predef CopyMonToTempMon
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempMonLevel]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
ld e, a
|
|
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wTempMonExp + 2
|
2015-11-10 13:53:37 -08:00
|
|
|
|
call CalcExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wTempMonExp + 2
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld a, [wExperienceGained + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add [hl]
|
|
|
|
|
ld [hld], a
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld a, [wExperienceGained + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
adc [hl]
|
|
|
|
|
ld [hld], a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr nc, .NoOverflow
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc [hl]
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr nz, .NoOverflow
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $ff
|
|
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
|
ld [hli], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.NoOverflow:
|
2014-06-03 14:07:10 -07:00
|
|
|
|
ld d, MAX_LEVEL
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CalcExpAtLevel
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hProduct + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wTempMonExp + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
|
|
|
|
sub d
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
sbc c
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
sbc b
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr c, .AlreadyAtMaxExp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld a, c
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld a, d
|
|
|
|
|
ld [hld], a
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.AlreadyAtMaxExp:
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CalcLevel
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
|
|
|
|
ld d, a
|
|
|
|
|
cp e
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr nc, .LoopLevels
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, e
|
|
|
|
|
ld d, a
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.LoopLevels:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, e
|
2014-03-05 02:42:09 -08:00
|
|
|
|
cp MAX_LEVEL
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr nc, .FinishExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp d
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr z, .FinishExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTempMonLevel], a
|
|
|
|
|
ld [wCurPartyLevel], a
|
|
|
|
|
ld [wBattleMonLevel], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call .PlayExpBarSound
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, $40
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call .LoopBarAnimation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintPlayerHUD
|
2021-03-17 13:16:02 -07:00
|
|
|
|
ld hl, wBattleMonNickname
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wStringBuffer1
|
2018-01-20 09:25:55 -08:00
|
|
|
|
ld bc, MON_NAME_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call TerminateExpBarSound
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, SFX_HIT_END_OF_EXP_BAR
|
|
|
|
|
call PlaySFX
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall AnimateEndOfExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitSFX
|
2015-09-09 16:27:07 -07:00
|
|
|
|
ld hl, BattleText_StringBuffer1GrewToLevel
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
inc e
|
|
|
|
|
ld b, $0
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr .LoopLevels
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.FinishExpBar:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
ld b, d
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wTempMonExp + 2
|
2015-11-10 13:53:37 -08:00
|
|
|
|
call CalcExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
pop bc
|
|
|
|
|
ld c, a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
call .PlayExpBarSound
|
|
|
|
|
call .LoopBarAnimation
|
|
|
|
|
call TerminateExpBarSound
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hProduct + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hProduct + 3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
|
.finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PlayExpBarSound:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
call WaitSFX
|
|
|
|
|
ld de, SFX_EXP_BAR
|
|
|
|
|
call PlaySFX
|
|
|
|
|
ld c, 10
|
|
|
|
|
call DelayFrames
|
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.LoopBarAnimation:
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld d, 3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec b
|
2016-01-12 09:46:18 -08:00
|
|
|
|
.anim_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc b
|
|
|
|
|
push bc
|
|
|
|
|
push de
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 17, 11
|
2015-11-10 13:53:37 -08:00
|
|
|
|
call PlaceExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, d
|
|
|
|
|
call DelayFrames
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ld a, c
|
|
|
|
|
cp b
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr z, .end_animation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc b
|
|
|
|
|
push bc
|
|
|
|
|
push de
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 17, 11
|
2015-11-10 13:53:37 -08:00
|
|
|
|
call PlaceExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld c, d
|
|
|
|
|
call DelayFrames
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec d
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr nz, .min_number_of_frames
|
|
|
|
|
ld d, 1
|
|
|
|
|
.min_number_of_frames
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
ld a, c
|
|
|
|
|
cp b
|
2016-01-12 09:46:18 -08:00
|
|
|
|
jr nz, .anim_loop
|
|
|
|
|
.end_animation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
SendOutMonText:
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .not_linked
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
2020-11-03 16:53:07 -08:00
|
|
|
|
; If we're in a LinkBattle print just "Go <PlayerMon>"
|
|
|
|
|
; unless DoBattle already set [wBattleHasJustStarted]
|
|
|
|
|
ld hl, GoMonText
|
|
|
|
|
ld a, [wBattleHasJustStarted]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr nz, .skip_to_textbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.not_linked
|
2018-02-22 08:13:29 -08:00
|
|
|
|
; Depending on the HP of the enemy mon, the game prints a different text
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2020-11-01 09:36:38 -08:00
|
|
|
|
ld hl, GoMonText
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .skip_to_textbox
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
2022-07-09 14:12:02 -07:00
|
|
|
|
; BUG: Switching out or switching against a Pokémon with max HP below 4 freezes the game (see docs/bugs_and_glitches.md)
|
2022-01-10 18:25:43 -08:00
|
|
|
|
; compute enemy health remaining as a percentage
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 0], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld [wEnemyHPAtTimeOfPlayerSwitch], a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld [wEnemyHPAtTimeOfPlayerSwitch + 1], a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 2], a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld a, 25
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Multiply
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld b, [hl]
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
ld a, b
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld b, 4
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDivisor], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Divide
|
2015-11-10 13:53:37 -08:00
|
|
|
|
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2020-11-01 09:36:38 -08:00
|
|
|
|
ld hl, GoMonText
|
2015-11-10 13:53:37 -08:00
|
|
|
|
cp 70
|
|
|
|
|
jr nc, .skip_to_textbox
|
|
|
|
|
|
2020-11-01 09:36:38 -08:00
|
|
|
|
ld hl, DoItMonText
|
2015-11-10 13:53:37 -08:00
|
|
|
|
cp 40
|
|
|
|
|
jr nc, .skip_to_textbox
|
|
|
|
|
|
2020-11-01 09:36:38 -08:00
|
|
|
|
ld hl, GoForItMonText
|
2015-11-10 13:53:37 -08:00
|
|
|
|
cp 10
|
|
|
|
|
jr nc, .skip_to_textbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-11-01 09:36:38 -08:00
|
|
|
|
ld hl, YourFoesWeakGetmMonText
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.skip_to_textbox
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp BattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-11-01 09:36:38 -08:00
|
|
|
|
GoMonText:
|
|
|
|
|
text_far _GoMonText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_asm
|
2020-11-01 09:36:38 -08:00
|
|
|
|
jr PrepareBattleMonNicknameText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-11-01 09:36:38 -08:00
|
|
|
|
DoItMonText:
|
|
|
|
|
text_far _DoItMonText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_asm
|
2020-11-01 09:36:38 -08:00
|
|
|
|
jr PrepareBattleMonNicknameText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-11-01 09:36:38 -08:00
|
|
|
|
GoForItMonText:
|
|
|
|
|
text_far _GoForItMonText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_asm
|
2020-11-01 09:36:38 -08:00
|
|
|
|
jr PrepareBattleMonNicknameText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-11-01 09:36:38 -08:00
|
|
|
|
YourFoesWeakGetmMonText:
|
|
|
|
|
text_far _YourFoesWeakGetmMonText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_asm
|
2020-11-01 09:36:38 -08:00
|
|
|
|
PrepareBattleMonNicknameText:
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ld hl, BattleMonNicknameText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
BattleMonNicknameText:
|
|
|
|
|
text_far _BattleMonNicknameText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
WithdrawMonText:
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, .WithdrawMonText
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp BattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-02-22 08:13:29 -08:00
|
|
|
|
.WithdrawMonText:
|
2020-11-01 09:36:38 -08:00
|
|
|
|
text_far _BattleMonNickCommaText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_asm
|
2022-01-10 18:25:43 -08:00
|
|
|
|
; Depending on the HP lost since the enemy mon was sent out, the game prints a different text
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
|
|
|
|
push bc
|
2022-01-10 18:25:43 -08:00
|
|
|
|
; compute enemy health lost as a percentage
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonHP + 1
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld de, wEnemyHPAtTimeOfPlayerSwitch + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, [hl]
|
|
|
|
|
dec hl
|
|
|
|
|
ld a, [de]
|
|
|
|
|
sub b
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec de
|
|
|
|
|
ld b, [hl]
|
|
|
|
|
ld a, [de]
|
|
|
|
|
sbc b
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplicand + 1], a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld a, 25
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Multiply
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMaxHP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld b, [hl]
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
srl a
|
|
|
|
|
rr b
|
|
|
|
|
ld a, b
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld b, 4
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDivisor], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Divide
|
|
|
|
|
pop bc
|
|
|
|
|
pop de
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ld hl, ThatsEnoughComeBackText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ld hl, ComeBackText
|
2015-11-10 13:53:37 -08:00
|
|
|
|
cp 30
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ld hl, OKComeBackText
|
2015-11-10 13:53:37 -08:00
|
|
|
|
cp 70
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ld hl, GoodComeBackText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ThatsEnoughComeBackText:
|
|
|
|
|
text_far _ThatsEnoughComeBackText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
OKComeBackText:
|
|
|
|
|
text_far _OKComeBackText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
GoodComeBackText:
|
|
|
|
|
text_far _GoodComeBackText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
|
TextJump_ComeBack: ; unreferenced
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ld hl, ComeBackText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
|
ComeBackText:
|
|
|
|
|
text_far _ComeBackText
|
2018-11-17 10:33:03 -08:00
|
|
|
|
text_end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
|
HandleSafariAngerEatingStatus: ; unreferenced
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld hl, wSafariMonEating
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .angry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec [hl]
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_WildMonIsEating
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.angry
|
2020-10-26 19:24:38 -07:00
|
|
|
|
dec hl
|
|
|
|
|
assert wSafariMonEating - 1 == wSafariMonAngerCount
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
and a
|
|
|
|
|
ret z
|
|
|
|
|
dec [hl]
|
2018-02-22 08:13:29 -08:00
|
|
|
|
ld hl, BattleText_WildMonIsAngry
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr nz, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonSpecies]
|
|
|
|
|
ld [wCurSpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBaseCatchRate]
|
|
|
|
|
ld [wEnemyMonCatchRate], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call SafeLoadTempTilemapToTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
2019-04-08 05:15:10 -07:00
|
|
|
|
jp StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
FillInExpBar:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
2015-11-10 13:53:37 -08:00
|
|
|
|
call CalcExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld de, 7
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jp PlaceExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CalcExpBar:
|
2015-11-10 13:53:37 -08:00
|
|
|
|
; Calculate the percent exp between this level and the next
|
|
|
|
|
; Level in b
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
|
|
|
|
ld d, b
|
|
|
|
|
push de
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CalcExpAtLevel
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
2015-11-10 13:53:37 -08:00
|
|
|
|
; exp at current level gets pushed to the stack
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, hMultiplicand
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
push af
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
push af
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
push af
|
2015-11-10 13:53:37 -08:00
|
|
|
|
; next level
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc d
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar CalcExpAtLevel
|
2015-11-10 13:53:37 -08:00
|
|
|
|
; back up the next level exp, and subtract the two levels
|
|
|
|
|
ld hl, hMultiplicand + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMathBuffer + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
sub b
|
|
|
|
|
ld [hld], a
|
|
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMathBuffer + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
sbc b
|
|
|
|
|
ld [hld], a
|
|
|
|
|
ld a, [hl]
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMathBuffer], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
sbc b
|
|
|
|
|
ld [hl], a
|
|
|
|
|
pop de
|
2015-11-10 13:53:37 -08:00
|
|
|
|
|
|
|
|
|
ld hl, hMultiplicand + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
push af
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
push af
|
2015-11-10 13:53:37 -08:00
|
|
|
|
|
|
|
|
|
; get the amount of exp remaining to the next level
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
dec de
|
|
|
|
|
ld c, a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hMathBuffer + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sub c
|
|
|
|
|
ld [hld], a
|
|
|
|
|
ld a, [de]
|
|
|
|
|
dec de
|
|
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hMathBuffer + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sbc b
|
|
|
|
|
ld [hld], a
|
|
|
|
|
ld a, [de]
|
|
|
|
|
ld c, a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hMathBuffer]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sbc c
|
|
|
|
|
ld [hld], a
|
|
|
|
|
xor a
|
|
|
|
|
ld [hl], a
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ld a, 64
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMultiplier], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Multiply
|
|
|
|
|
pop af
|
|
|
|
|
ld c, a
|
|
|
|
|
pop af
|
|
|
|
|
ld b, a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
and a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
srl b
|
|
|
|
|
rr c
|
|
|
|
|
ld hl, hProduct
|
|
|
|
|
srl [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
rr [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
rr [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
rr [hl]
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, c
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hDivisor], a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld b, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Divide
|
2018-08-26 10:49:38 -07:00
|
|
|
|
ldh a, [hQuotient + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
|
|
|
|
ld a, $40
|
|
|
|
|
sub b
|
|
|
|
|
ld b, a
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
PlaceExpBar:
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld c, $8 ; number of tiles
|
|
|
|
|
.loop1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
sub $8
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr c, .next
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld a, $6a ; full bar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hld], a
|
|
|
|
|
dec c
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .finish
|
|
|
|
|
jr .loop1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.next
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add $8
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr z, .loop2
|
|
|
|
|
add $54 ; tile to the left of small exp bar tile
|
|
|
|
|
jr .skip
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.loop2
|
|
|
|
|
ld a, $62 ; empty bar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.skip
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hld], a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld a, $62 ; empty bar
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec c
|
2015-11-10 13:53:37 -08:00
|
|
|
|
jr nz, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
|
.finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetBattleMonBackpic:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPlayerSubStatus4]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld hl, BattleAnimCmd_RaiseSub
|
2017-12-24 12:03:20 -08:00
|
|
|
|
jr nz, GetBattleMonBackpic_DoAnim ; substitute
|
2014-06-17 12:52:32 -07:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DropPlayerSub:
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld a, [wPlayerMinimized]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld hl, BattleAnimCmd_MinimizeOpp
|
2017-12-24 12:03:20 -08:00
|
|
|
|
jr nz, GetBattleMonBackpic_DoAnim
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartySpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleMonSpecies]
|
|
|
|
|
ld [wCurPartySpecies], a
|
|
|
|
|
ld hl, wBattleMonDVs
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetUnownLetter
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld de, vTiles2 tile $31
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetMonBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartySpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetBattleMonBackpic_DoAnim:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, BANK(BattleAnimCommands)
|
|
|
|
|
rst FarCall
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetEnemyMonFrontpic:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemySubStatus4]
|
2014-06-17 12:52:32 -07:00
|
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld hl, BattleAnimCmd_RaiseSub
|
2017-12-24 12:03:20 -08:00
|
|
|
|
jr nz, GetEnemyMonFrontpic_DoAnim
|
2014-06-18 00:55:44 -07:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DropEnemySub:
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld a, [wEnemyMinimized]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-10 13:53:37 -08:00
|
|
|
|
ld hl, BattleAnimCmd_MinimizeOpp
|
2017-12-24 12:03:20 -08:00
|
|
|
|
jr nz, GetEnemyMonFrontpic_DoAnim
|
2014-06-18 00:55:44 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartySpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonSpecies]
|
|
|
|
|
ld [wCurSpecies], a
|
|
|
|
|
ld [wCurPartySpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetBaseData
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonDVs
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetUnownLetter
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld de, vTiles2
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetAnimatedFrontpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartySpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetEnemyMonFrontpic_DoAnim:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hBattleTurn]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
call SetEnemyTurn
|
|
|
|
|
ld a, BANK(BattleAnimCommands)
|
|
|
|
|
rst FarCall
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
StartBattle:
|
2015-10-24 07:34:19 -07:00
|
|
|
|
; This check prevents you from entering a battle without any Pokemon.
|
|
|
|
|
; Those using walk-through-walls to bypass getting a Pokemon experience
|
|
|
|
|
; the effects of this check.
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret z
|
2015-10-24 07:34:19 -07:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTimeOfDayPal]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2015-11-10 17:18:49 -08:00
|
|
|
|
call BattleIntro
|
2015-11-28 12:13:40 -08:00
|
|
|
|
call DoBattle
|
2015-11-10 20:23:28 -08:00
|
|
|
|
call ExitBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTimeOfDayPal], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
|
CallDoBattle: ; unreferenced
|
2015-11-28 12:13:40 -08:00
|
|
|
|
call DoBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleIntro:
|
2015-10-24 07:34:19 -07:00
|
|
|
|
call LoadTrainerOrWildMonPic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTempBattleMonSpecies], a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wBattleMenuCursorPosition], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMapAnims], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall PlayBattleMusic
|
|
|
|
|
farcall ShowLinkBattleParticipants
|
|
|
|
|
farcall FindFirstAliveMonAndStartBattle
|
2015-10-24 07:34:19 -07:00
|
|
|
|
call DisableSpriteUpdates
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall ClearBattleRAM
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call InitEnemy
|
2017-12-28 04:32:33 -08:00
|
|
|
|
call BackUpBGMap2
|
2023-07-26 08:01:20 -07:00
|
|
|
|
ld b, CGB_BATTLE_GRAYSCALE
|
|
|
|
|
call GetCGBLayout
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, rLCDC
|
2020-06-21 09:21:47 -07:00
|
|
|
|
res rLCDC_WINDOW_TILEMAP, [hl] ; select vBGMap0/vBGMap2
|
2015-11-10 17:18:49 -08:00
|
|
|
|
call InitBattleDisplay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleStartMessage
|
|
|
|
|
ld hl, rLCDC
|
2020-06-21 09:21:47 -07:00
|
|
|
|
set rLCDC_WINDOW_TILEMAP, [hl] ; select vBGMap1/vBGMap3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call EmptyBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
hlcoord 9, 7
|
2015-11-05 16:13:09 -08:00
|
|
|
|
lb bc, 5, 11
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
|
|
|
|
hlcoord 1, 0
|
2015-11-05 16:13:09 -08:00
|
|
|
|
lb bc, 4, 10
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
|
|
|
|
call ClearSprites
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2015-11-29 18:34:59 -08:00
|
|
|
|
cp WILD_BATTLE
|
2018-01-16 11:30:10 -08:00
|
|
|
|
call z, UpdateEnemyHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
LoadTrainerOrWildMonPic:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOtherTrainerClass]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
jr nz, .Trainer
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempWildMonSpecies]
|
|
|
|
|
ld [wCurPartySpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Trainer:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTempEnemyMonSpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
InitEnemy:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wOtherTrainerClass]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jp nz, InitEnemyTrainer ; trainer
|
|
|
|
|
jp InitEnemyWildmon ; wild
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BackUpBGMap2:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [rSVBK]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2018-01-02 13:46:40 -08:00
|
|
|
|
ld a, BANK(wDecompressScratch)
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rSVBK], a
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld hl, wDecompressScratch
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld bc, $40 tiles ; vBGMap3 - vBGMap2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $2
|
|
|
|
|
call ByteFill
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [rVBK]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rVBK], a
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld de, wDecompressScratch
|
2017-12-28 04:32:33 -08:00
|
|
|
|
hlbgcoord 0, 0 ; vBGMap2
|
|
|
|
|
lb bc, BANK(BackUpBGMap2), $40
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Request2bpp
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rVBK], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rSVBK], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
InitEnemyTrainer:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTrainerClass], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTempEnemyMonSpecies], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar GetTrainerAttributes
|
|
|
|
|
callfar ReadTrainerParty
|
2014-06-14 22:33:23 -07:00
|
|
|
|
|
2018-01-18 09:03:58 -08:00
|
|
|
|
; RIVAL1's first mon has no held item
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTrainerClass]
|
2014-06-14 22:33:23 -07:00
|
|
|
|
cp RIVAL1
|
|
|
|
|
jr nz, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wOTPartyMon1Item], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-06-16 16:32:36 -07:00
|
|
|
|
.ok
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld de, vTiles2
|
2018-01-16 11:30:10 -08:00
|
|
|
|
callfar GetTrainerPic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hGraphicStartTile], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2016-01-12 09:46:18 -08:00
|
|
|
|
ld [wEnemyItemState], a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 12, 0
|
2014-06-14 22:33:23 -07:00
|
|
|
|
lb bc, 7, 7
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PlaceGraphic
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, -1
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurOTMon], a
|
2014-06-14 22:33:23 -07:00
|
|
|
|
ld a, TRAINER_BATTLE
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld [wBattleMode], a
|
2014-06-14 22:33:23 -07:00
|
|
|
|
|
2018-01-09 12:12:49 -08:00
|
|
|
|
call IsGymLeader
|
2015-10-12 09:33:24 -07:00
|
|
|
|
jr nc, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurPartyMon], a
|
|
|
|
|
ld a, [wPartyCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2015-10-12 09:33:24 -07:00
|
|
|
|
.partyloop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
2015-11-04 08:19:58 -08:00
|
|
|
|
ld a, MON_HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyParamLocation
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
2015-10-12 09:33:24 -07:00
|
|
|
|
jr z, .skipfaintedmon
|
|
|
|
|
ld c, HAPPINESS_GYMBATTLE
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar ChangeHappiness
|
2015-10-12 09:33:24 -07:00
|
|
|
|
.skipfaintedmon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
|
|
|
|
dec b
|
2015-10-12 09:33:24 -07:00
|
|
|
|
jr z, .done
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wCurPartyMon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc [hl]
|
2015-10-12 09:33:24 -07:00
|
|
|
|
jr .partyloop
|
|
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
InitEnemyWildmon:
|
2015-11-29 18:34:59 -08:00
|
|
|
|
ld a, WILD_BATTLE
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld [wBattleMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call LoadEnemyMon
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMoves
|
2015-11-29 18:34:59 -08:00
|
|
|
|
ld de, wWildMonMoves
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld bc, NUM_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonPP
|
2015-11-29 18:34:59 -08:00
|
|
|
|
ld de, wWildMonPP
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld bc, NUM_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonDVs
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetUnownLetter
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurPartySpecies]
|
2014-06-10 23:08:07 -07:00
|
|
|
|
cp UNOWN
|
2015-11-09 20:55:39 -08:00
|
|
|
|
jr nz, .skip_unown
|
2015-11-29 18:34:59 -08:00
|
|
|
|
ld a, [wFirstUnownSeen]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-09 20:55:39 -08:00
|
|
|
|
jr nz, .skip_unown
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wUnownLetter]
|
2015-11-29 18:34:59 -08:00
|
|
|
|
ld [wFirstUnownSeen], a
|
2015-11-09 20:55:39 -08:00
|
|
|
|
.skip_unown
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld de, vTiles2
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef GetAnimatedFrontpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wTrainerClass], a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hGraphicStartTile], a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 12, 0
|
2014-06-14 22:33:23 -07:00
|
|
|
|
lb bc, 7, 7
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PlaceGraphic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2020-10-05 13:15:57 -07:00
|
|
|
|
FillEnemyMovesFromMoveIndicesBuffer: ; unreferenced
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wEnemyMonMoves
|
2015-10-17 14:18:52 -07:00
|
|
|
|
ld de, wListMoves_MoveIndicesBuffer
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld b, NUM_MOVES
|
2014-01-05 04:28:55 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [de]
|
|
|
|
|
inc de
|
|
|
|
|
ld [hli], a
|
|
|
|
|
and a
|
2014-01-05 04:28:55 -08:00
|
|
|
|
jr z, .clearpp
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
push hl
|
2014-01-05 04:28:55 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
dec a
|
2014-01-05 04:28:55 -08:00
|
|
|
|
ld hl, Moves + MOVE_PP
|
2014-06-10 23:23:55 -07:00
|
|
|
|
ld bc, MOVE_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call AddNTimes
|
2014-01-05 04:28:55 -08:00
|
|
|
|
ld a, BANK(Moves)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetFarByte
|
|
|
|
|
pop hl
|
2014-01-05 04:28:55 -08:00
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld bc, wEnemyMonPP - (wEnemyMonMoves + 1)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld [hl], a
|
2014-01-05 04:28:55 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
2014-01-05 04:28:55 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec b
|
2014-01-05 04:28:55 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2014-01-05 04:28:55 -08:00
|
|
|
|
.clear
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
|
|
|
|
ld [hli], a
|
|
|
|
|
|
2014-01-05 04:28:55 -08:00
|
|
|
|
.clearpp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
push hl
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld bc, wEnemyMonPP - (wEnemyMonMoves + 1)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
xor a
|
|
|
|
|
ld [hl], a
|
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
dec b
|
2014-01-05 04:28:55 -08:00
|
|
|
|
jr nz, .clear
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ExitBattle:
|
2015-12-29 13:44:37 -08:00
|
|
|
|
call .HandleEndOfBattle
|
2015-11-10 20:23:28 -08:00
|
|
|
|
call CleanUpBattleRAM
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.HandleEndOfBattle:
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-10-24 07:34:19 -07:00
|
|
|
|
jr z, .not_linked
|
2015-11-10 20:23:28 -08:00
|
|
|
|
call ShowLinkBattleParticipantsAfterEnd
|
2014-06-10 23:08:07 -07:00
|
|
|
|
ld c, 150
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2017-11-19 02:54:34 -08:00
|
|
|
|
call DisplayLinkBattleResult
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
|
.not_linked
|
|
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and $f
|
|
|
|
|
ret nz
|
2015-11-10 20:23:28 -08:00
|
|
|
|
call CheckPayDay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-28 12:13:40 -08:00
|
|
|
|
ld [wForceEvolution], a
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef EvolveAfterBattle
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall GivePokerusAndConvertBerries
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CleanUpBattleRAM:
|
2015-12-29 13:44:37 -08:00
|
|
|
|
call BattleEnd_HandleRoamMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-01-23 13:45:34 -08:00
|
|
|
|
ld [wLowHealthAlarm], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld [wBattleMode], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wBattleType], a
|
|
|
|
|
ld [wAttackMissed], a
|
|
|
|
|
ld [wTempWildMonSpecies], a
|
|
|
|
|
ld [wOtherTrainerClass], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld [wFailedToFlee], a
|
|
|
|
|
ld [wNumFleeAttempts], a
|
2015-11-08 16:09:36 -08:00
|
|
|
|
ld [wForcedSwitch], a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wPartyMenuCursor], a
|
2015-10-24 16:49:19 -07:00
|
|
|
|
ld [wKeyItemsPocketCursor], a
|
|
|
|
|
ld [wItemsPocketCursor], a
|
2020-12-23 13:29:30 -08:00
|
|
|
|
ld [wBattleMenuCursorPosition], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCurMoveNum], a
|
2015-10-24 16:49:19 -07:00
|
|
|
|
ld [wBallsPocketCursor], a
|
2015-11-23 13:04:53 -08:00
|
|
|
|
ld [wLastPocket], a
|
|
|
|
|
ld [wMenuScrollPosition], a
|
|
|
|
|
ld [wKeyItemsPocketScrollPosition], a
|
|
|
|
|
ld [wItemsPocketScrollPosition], a
|
|
|
|
|
ld [wBallsPocketScrollPosition], a
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wPlayerSubStatus1
|
|
|
|
|
ld b, wEnemyFuryCutterCount - wPlayerSubStatus1
|
2014-06-17 12:52:32 -07:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hli], a
|
|
|
|
|
dec b
|
2014-06-17 12:52:32 -07:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitSFX
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CheckPayDay:
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld hl, wPayDayCoins
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
or [hl]
|
|
|
|
|
inc hl
|
|
|
|
|
or [hl]
|
|
|
|
|
ret z
|
2015-11-22 21:21:21 -08:00
|
|
|
|
ld a, [wAmuletCoin]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-10 20:23:28 -08:00
|
|
|
|
jr z, .okay
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld hl, wPayDayCoins + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
sla [hl]
|
|
|
|
|
dec hl
|
|
|
|
|
rl [hl]
|
|
|
|
|
dec hl
|
|
|
|
|
rl [hl]
|
2015-11-10 20:23:28 -08:00
|
|
|
|
jr nc, .okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $ff
|
|
|
|
|
ld [hli], a
|
2015-12-26 18:59:03 -08:00
|
|
|
|
ld [hli], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
|
.okay
|
2023-09-02 14:16:35 -07:00
|
|
|
|
ld hl, wPayDayCoins + 2
|
|
|
|
|
ld de, wCoins + 2
|
|
|
|
|
call AddBattleCoinsToAccount
|
|
|
|
|
ld hl, BattleText_PlayerPickedUpPayDayCoins
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ShowLinkBattleParticipantsAfterEnd:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wCurOTMon]
|
|
|
|
|
ld hl, wOTPartyMon1Status
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetPartyLocation
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonStatus]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call ClearTilemap
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall _ShowLinkBattleParticipants
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
DisplayLinkBattleResult:
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and $f
|
2018-04-05 08:44:02 -07:00
|
|
|
|
cp LOSE
|
2020-06-16 16:32:36 -07:00
|
|
|
|
jr c, .win ; WIN
|
|
|
|
|
jr z, .lose ; LOSE
|
2018-04-05 08:44:02 -07:00
|
|
|
|
; DRAW
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, .Draw
|
2015-11-10 15:17:04 -08:00
|
|
|
|
jr .store_result
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-06-16 16:32:36 -07:00
|
|
|
|
.win
|
|
|
|
|
ld de, .YouWin
|
2015-11-10 15:17:04 -08:00
|
|
|
|
jr .store_result
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2020-06-16 16:32:36 -07:00
|
|
|
|
.lose
|
|
|
|
|
ld de, .YouLose
|
2015-11-10 15:17:04 -08:00
|
|
|
|
jr .store_result
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
|
.store_result
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 6, 8
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PlaceString
|
2015-11-10 15:17:04 -08:00
|
|
|
|
ld c, 200
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2015-11-10 15:17:04 -08:00
|
|
|
|
|
2015-10-04 11:14:51 -07:00
|
|
|
|
ld a, BANK(sLinkBattleStats)
|
2020-06-17 14:03:38 -07:00
|
|
|
|
call OpenSRAM
|
2015-11-10 15:17:04 -08:00
|
|
|
|
|
2020-04-23 13:10:46 -07:00
|
|
|
|
call AddLastLinkBattleToLinkRecord
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call ReadAndPrintLinkBattleRecord
|
2015-11-10 15:17:04 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CloseSRAM
|
2015-11-10 15:17:04 -08:00
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
|
call WaitPressAorB_BlinkCursor
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call ClearTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2020-06-16 16:32:36 -07:00
|
|
|
|
.YouWin:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "YOU WIN@"
|
2020-06-16 16:32:36 -07:00
|
|
|
|
.YouLose:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "YOU LOSE@"
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Draw:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db " DRAW@"
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
_DisplayLinkRecord:
|
2015-08-19 21:21:38 -07:00
|
|
|
|
ld a, BANK(sLinkBattleStats)
|
2020-06-17 14:03:38 -07:00
|
|
|
|
call OpenSRAM
|
2015-11-10 20:23:28 -08:00
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call ReadAndPrintLinkBattleRecord
|
2015-11-10 20:23:28 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CloseSRAM
|
2020-02-13 09:30:13 -08:00
|
|
|
|
hlcoord 0, 0, wAttrmap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-07-22 12:57:02 -07:00
|
|
|
|
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ByteFill
|
2015-12-11 13:59:40 -08:00
|
|
|
|
call WaitBGMap2
|
2023-07-26 08:01:20 -07:00
|
|
|
|
ld b, CGB_DIPLOMA
|
|
|
|
|
call GetCGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld c, 8
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call DelayFrames
|
2015-11-10 20:23:28 -08:00
|
|
|
|
call WaitPressAorB_BlinkCursor
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
ReadAndPrintLinkBattleRecord:
|
2020-02-13 09:30:13 -08:00
|
|
|
|
call ClearTilemap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearSprites
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .PrintBattleRecord
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 0, 8
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld b, NUM_LINK_BATTLE_RECORDS
|
2020-10-21 21:53:54 -07:00
|
|
|
|
ld de, sLinkBattleRecord1Name
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
push hl
|
|
|
|
|
push de
|
|
|
|
|
ld a, [de]
|
|
|
|
|
and a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr z, .PrintFormatString
|
2015-10-16 10:35:43 -07:00
|
|
|
|
ld a, [wSavedAtLeastOnce]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr z, .PrintFormatString
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
push hl
|
|
|
|
|
ld h, d
|
|
|
|
|
ld l, e
|
2020-10-21 21:53:54 -07:00
|
|
|
|
ld de, wLinkBattleRecordName
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, NAME_LENGTH - 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld a, "@"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [de], a
|
2020-10-21 21:53:54 -07:00
|
|
|
|
inc de ; wLinkBattleRecordWins
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld bc, 6
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2020-10-21 21:53:54 -07:00
|
|
|
|
ld de, wLinkBattleRecordName
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
|
|
|
|
call PlaceString
|
|
|
|
|
pop hl
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld de, 26
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
|
|
|
|
push hl
|
2020-10-21 21:53:54 -07:00
|
|
|
|
ld de, wLinkBattleRecordWins
|
2015-10-10 14:03:04 -07:00
|
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintNum
|
|
|
|
|
pop hl
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld de, 5
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
|
|
|
|
push hl
|
2020-10-21 21:53:54 -07:00
|
|
|
|
ld de, wLinkBattleRecordLosses
|
2015-10-10 14:03:04 -07:00
|
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintNum
|
|
|
|
|
pop hl
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld de, 5
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
2020-10-21 21:53:54 -07:00
|
|
|
|
ld de, wLinkBattleRecordDraws
|
2015-10-10 14:03:04 -07:00
|
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintNum
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr .next
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PrintFormatString:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, .Format
|
|
|
|
|
call PlaceString
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.next
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
|
|
|
|
pop hl
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
pop bc
|
|
|
|
|
dec b
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PrintBattleRecord:
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, .Record
|
|
|
|
|
call PlaceString
|
|
|
|
|
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 0, 6
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, .Result
|
|
|
|
|
call PlaceString
|
|
|
|
|
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 0, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld de, .Total
|
|
|
|
|
call PlaceString
|
|
|
|
|
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 6, 4
|
2015-08-19 21:21:38 -07:00
|
|
|
|
ld de, sLinkBattleWins
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .PrintZerosIfNoSaveFileExists
|
|
|
|
|
jr c, .quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-10-10 14:03:04 -07:00
|
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintNum
|
|
|
|
|
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 11, 4
|
2015-08-19 21:21:38 -07:00
|
|
|
|
ld de, sLinkBattleLosses
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .PrintZerosIfNoSaveFileExists
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-10-10 14:03:04 -07:00
|
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintNum
|
|
|
|
|
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 16, 4
|
2015-08-19 21:21:38 -07:00
|
|
|
|
ld de, sLinkBattleDraws
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .PrintZerosIfNoSaveFileExists
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-10-10 14:03:04 -07:00
|
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call PrintNum
|
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.quit
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PrintZerosIfNoSaveFileExists:
|
2015-10-16 10:35:43 -07:00
|
|
|
|
ld a, [wSavedAtLeastOnce]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
|
|
|
|
ret nz
|
|
|
|
|
ld de, .Scores
|
|
|
|
|
call PlaceString
|
|
|
|
|
scf
|
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Scores:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db " 0 0 0@"
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.Format:
|
2018-07-17 14:08:04 -07:00
|
|
|
|
db " --- <LF>"
|
2016-01-12 21:39:41 -08:00
|
|
|
|
db " - - -@"
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.Record:
|
2015-10-16 10:35:43 -07:00
|
|
|
|
db "<PLAYER>'s RECORD@"
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.Result:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "RESULT WIN LOSE DRAW@"
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.Total:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
db "TOTAL WIN LOSE DRAW@"
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleEnd_HandleRoamMons:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp BATTLETYPE_ROAMING
|
2015-12-29 13:44:37 -08:00
|
|
|
|
jr nz, .not_roaming
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and $f
|
2018-04-05 08:44:02 -07:00
|
|
|
|
jr z, .caught_or_defeated_roam_mon ; WIN
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetRoamMonHP
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wEnemyMonHP + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [hl], a
|
2015-12-29 13:44:37 -08:00
|
|
|
|
jr .update_roam_mons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-12-29 13:44:37 -08:00
|
|
|
|
.caught_or_defeated_roam_mon
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetRoamMonHP
|
2018-02-25 16:50:48 -08:00
|
|
|
|
ld [hl], 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetRoamMonMapGroup
|
2018-02-25 16:50:48 -08:00
|
|
|
|
ld [hl], GROUP_N_A
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetRoamMonMapNumber
|
2018-02-25 16:50:48 -08:00
|
|
|
|
ld [hl], MAP_N_A
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call GetRoamMonSpecies
|
2018-02-25 16:50:48 -08:00
|
|
|
|
ld [hl], 0
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2015-12-29 13:44:37 -08:00
|
|
|
|
.not_roaming
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call BattleRandom
|
|
|
|
|
and $f
|
|
|
|
|
ret nz
|
|
|
|
|
|
2015-12-29 13:44:37 -08:00
|
|
|
|
.update_roam_mons
|
2017-12-24 09:47:30 -08:00
|
|
|
|
callfar UpdateRoamMons
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetRoamMonMapGroup:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wRoamMon1Species]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon1MapGroup
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wRoamMon2Species]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon2MapGroup
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon3MapGroup
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetRoamMonMapNumber:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wRoamMon1Species]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon1MapNumber
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wRoamMon2Species]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon2MapNumber
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon3MapNumber
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetRoamMonHP:
|
2014-06-12 18:32:42 -07:00
|
|
|
|
; output: hl = wRoamMonHP
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wRoamMon1Species]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon1HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wRoamMon2Species]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon2HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon3HP
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetRoamMonDVs:
|
2014-06-12 18:32:42 -07:00
|
|
|
|
; output: hl = wRoamMonDVs
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wRoamMon1Species]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon1DVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld a, [wRoamMon2Species]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp b
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon2DVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon3DVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetRoamMonSpecies:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon1Species
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp [hl]
|
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon2Species
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp [hl]
|
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
|
ld hl, wRoamMon3Species
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2020-04-23 13:10:46 -07:00
|
|
|
|
AddLastLinkBattleToLinkRecord:
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPlayerID
|
|
|
|
|
ld de, wStringBuffer1
|
2015-11-10 15:17:04 -08:00
|
|
|
|
ld bc, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wOTPlayerName
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld bc, NAME_LENGTH - 1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld hl, sLinkBattleStats - (LINK_BATTLE_RECORD_LENGTH - 6)
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .StoreResult
|
|
|
|
|
ld hl, sLinkBattleRecord
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld d, NUM_LINK_BATTLE_RECORDS
|
2015-11-10 15:17:04 -08:00
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
|
|
|
|
inc hl
|
2015-12-26 18:59:03 -08:00
|
|
|
|
inc hl
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hl]
|
|
|
|
|
dec hl
|
2015-12-26 18:59:03 -08:00
|
|
|
|
dec hl
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and a
|
2015-11-10 15:17:04 -08:00
|
|
|
|
jr z, .copy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push de
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH - 6
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld de, wStringBuffer1
|
2018-07-22 21:25:53 -07:00
|
|
|
|
call CompareBytesLong
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
2015-11-10 15:17:04 -08:00
|
|
|
|
jr c, .done
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
dec d
|
2015-11-10 15:17:04 -08:00
|
|
|
|
jr nz, .loop
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, -LINK_BATTLE_RECORD_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
push hl
|
|
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
|
.copy
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld hl, wStringBuffer1
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH - 6
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2015-11-10 15:17:04 -08:00
|
|
|
|
ld b, 6
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2015-11-10 15:17:04 -08:00
|
|
|
|
.loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
dec b
|
2015-11-10 15:17:04 -08:00
|
|
|
|
jr nz, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
|
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
|
.done
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .StoreResult
|
|
|
|
|
call .FindOpponentAndAppendRecord
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
2020-04-23 13:10:46 -07:00
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.StoreResult:
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
and $f
|
2018-04-05 08:44:02 -07:00
|
|
|
|
cp LOSE
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, (sLinkBattleRecord1Wins - sLinkBattleRecord1) + 1
|
2018-04-05 08:44:02 -07:00
|
|
|
|
jr c, .okay ; WIN
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, (sLinkBattleRecord1Losses - sLinkBattleRecord1) + 1
|
2018-04-05 08:44:02 -07:00
|
|
|
|
jr z, .okay ; LOSE
|
|
|
|
|
; DRAW
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, (sLinkBattleRecord1Draws - sLinkBattleRecord1) + 1
|
2015-11-10 15:17:04 -08:00
|
|
|
|
.okay
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .CheckOverflow
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret nc
|
|
|
|
|
inc [hl]
|
|
|
|
|
ret nz
|
|
|
|
|
dec hl
|
|
|
|
|
inc [hl]
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.CheckOverflow:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec hl
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
inc hl
|
2017-12-25 10:40:10 -08:00
|
|
|
|
cp HIGH(MAX_LINK_RECORD)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret c
|
|
|
|
|
ld a, [hl]
|
2017-12-25 10:40:10 -08:00
|
|
|
|
cp LOW(MAX_LINK_RECORD)
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.FindOpponentAndAppendRecord:
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld b, NUM_LINK_BATTLE_RECORDS
|
|
|
|
|
ld hl, sLinkBattleRecord1End - 1
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld de, wLinkBattleRecordBuffer
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
push de
|
|
|
|
|
push hl
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .LoadPointer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
|
|
|
|
ld a, e
|
|
|
|
|
pop de
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld a, b
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
|
|
|
|
ld a, c
|
|
|
|
|
ld [de], a
|
|
|
|
|
inc de
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, bc
|
|
|
|
|
pop bc
|
|
|
|
|
dec b
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nz, .loop3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, $0
|
|
|
|
|
ld c, $1
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.loop4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, b
|
|
|
|
|
add b
|
2015-12-26 18:59:03 -08:00
|
|
|
|
add b
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld e, a
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld d, 0
|
|
|
|
|
ld hl, wLinkBattleRecordBuffer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
|
|
|
|
push hl
|
|
|
|
|
ld a, c
|
|
|
|
|
add c
|
2015-12-26 18:59:03 -08:00
|
|
|
|
add c
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld e, a
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld d, 0
|
|
|
|
|
ld hl, wLinkBattleRecordBuffer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add hl, de
|
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
|
|
|
|
pop hl
|
|
|
|
|
push bc
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld c, 3
|
2018-07-22 21:25:53 -07:00
|
|
|
|
call CompareBytes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop bc
|
2015-11-10 15:17:04 -08:00
|
|
|
|
jr z, .equal
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nc, .done2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
|
.equal
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc c
|
|
|
|
|
ld a, c
|
|
|
|
|
cp $5
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nz, .loop4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc b
|
|
|
|
|
ld c, b
|
|
|
|
|
inc c
|
|
|
|
|
ld a, b
|
|
|
|
|
cp $4
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nz, .loop4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.done2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push bc
|
|
|
|
|
ld a, b
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld hl, sLinkBattleRecord
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call AddNTimes
|
|
|
|
|
push hl
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld de, wLinkBattleRecordBuffer
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
push hl
|
|
|
|
|
ld a, c
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH
|
2016-01-12 21:39:41 -08:00
|
|
|
|
ld hl, sLinkBattleRecord
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call AddNTimes
|
|
|
|
|
pop de
|
|
|
|
|
push hl
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call CopyBytes
|
2020-10-29 11:45:40 -07:00
|
|
|
|
ld hl, wLinkBattleRecordBuffer
|
2020-04-23 13:10:46 -07:00
|
|
|
|
ld bc, LINK_BATTLE_RECORD_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop de
|
|
|
|
|
call CopyBytes
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.LoadPointer:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld e, $0
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
add c
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, [hld]
|
|
|
|
|
adc b
|
|
|
|
|
ld b, a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
jr nc, .okay2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc e
|
|
|
|
|
|
2016-01-12 21:39:41 -08:00
|
|
|
|
.okay2
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, [hld]
|
|
|
|
|
add c
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, [hl]
|
|
|
|
|
adc b
|
|
|
|
|
ld b, a
|
|
|
|
|
ret nc
|
|
|
|
|
inc e
|
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
InitBattleDisplay:
|
2015-11-10 17:18:49 -08:00
|
|
|
|
call .InitBackPic
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 0, 12
|
2015-11-06 13:42:38 -08:00
|
|
|
|
ld b, 4
|
|
|
|
|
ld c, 18
|
2023-08-11 03:28:14 -07:00
|
|
|
|
call Textbox1bpp
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 1, 5
|
2015-11-01 06:38:48 -08:00
|
|
|
|
lb bc, 3, 7
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ClearBox
|
2015-11-04 13:14:27 -08:00
|
|
|
|
call LoadStandardFont
|
2015-11-10 16:51:13 -08:00
|
|
|
|
call _LoadBattleFontsHPBar
|
2015-11-10 17:18:49 -08:00
|
|
|
|
call .BlankBGMap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hMapAnims], a
|
|
|
|
|
ldh [hSCY], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $90
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hWY], a
|
|
|
|
|
ldh [rWY], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitBGMap
|
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall BattleIntroSlidingPics
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBGMapMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $31
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hGraphicStartTile], a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 2, 6
|
2015-11-06 13:42:38 -08:00
|
|
|
|
lb bc, 6, 6
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PlaceGraphic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hWY], a
|
2022-06-06 14:22:48 -07:00
|
|
|
|
vc_hook Unknown_InitBattleDisplay
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rWY], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call WaitBGMap
|
|
|
|
|
call HideSprites
|
2023-07-26 08:01:20 -07:00
|
|
|
|
ld b, CGB_BATTLE_COLORS
|
|
|
|
|
call GetCGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $90
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hWY], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hSCX], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.BlankBGMap:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [rSVBK]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
|
ld a, BANK(wDecompressScratch)
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rSVBK], a
|
2015-11-10 15:17:04 -08:00
|
|
|
|
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld hl, wDecompressScratch
|
2020-10-26 12:45:57 -07:00
|
|
|
|
ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT
|
2015-11-10 15:17:04 -08:00
|
|
|
|
ld a, " "
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call ByteFill
|
2015-11-10 15:17:04 -08:00
|
|
|
|
|
2015-12-19 11:48:30 -08:00
|
|
|
|
ld de, wDecompressScratch
|
2015-11-20 08:47:52 -08:00
|
|
|
|
hlbgcoord 0, 0
|
2020-10-26 12:45:57 -07:00
|
|
|
|
lb bc, BANK(@), (BG_MAP_WIDTH * BG_MAP_HEIGHT) / LEN_2BPP_TILE
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Request2bpp
|
2015-11-10 15:17:04 -08:00
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rSVBK], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.InitBackPic:
|
2015-11-06 13:42:38 -08:00
|
|
|
|
call GetTrainerBackpic
|
|
|
|
|
call CopyBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
GetTrainerBackpic:
|
2017-12-28 04:32:33 -08:00
|
|
|
|
; Load the player character's backpic (6x6) into VRAM starting from vTiles2 tile $31.
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
; Special exception for Dude.
|
|
|
|
|
ld b, BANK(DudeBackpic)
|
|
|
|
|
ld hl, DudeBackpic
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp BATTLETYPE_TUTORIAL
|
|
|
|
|
jr z, .Decompress
|
|
|
|
|
|
|
|
|
|
; What gender are we?
|
2015-10-24 07:34:19 -07:00
|
|
|
|
ld a, [wPlayerSpriteSetupFlags]
|
2018-01-22 11:34:55 -08:00
|
|
|
|
bit PLAYERSPRITESETUP_FEMALE_TO_MALE_F, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr nz, .Chris
|
2017-12-28 04:15:46 -08:00
|
|
|
|
ld a, [wPlayerGender]
|
2018-01-22 11:34:55 -08:00
|
|
|
|
bit PLAYERGENDER_FEMALE_F, a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
jr z, .Chris
|
|
|
|
|
|
|
|
|
|
; It's a girl.
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall GetKrisBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Chris:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
; It's a boy.
|
|
|
|
|
ld b, BANK(ChrisBackpic)
|
|
|
|
|
ld hl, ChrisBackpic
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.Decompress:
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld de, vTiles2 tile $31
|
2018-01-16 11:30:10 -08:00
|
|
|
|
ld c, 7 * 7
|
|
|
|
|
predef DecompressGet2bpp
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
CopyBackpic:
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [rSVBK]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
|
ld a, BANK(wDecompressScratch)
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rSVBK], a
|
2017-12-28 04:32:33 -08:00
|
|
|
|
ld hl, vTiles0
|
|
|
|
|
ld de, vTiles2 tile $31
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh a, [hROMBank]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld b, a
|
2020-06-16 16:32:36 -07:00
|
|
|
|
ld c, 7 * 7
|
2013-12-17 22:11:06 -08:00
|
|
|
|
call Get2bpp
|
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [rSVBK], a
|
2016-01-12 21:39:41 -08:00
|
|
|
|
call .LoadTrainerBackpicAsOAM
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, $31
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hGraphicStartTile], a
|
2014-06-04 01:10:56 -07:00
|
|
|
|
hlcoord 2, 6
|
2015-11-06 13:42:38 -08:00
|
|
|
|
lb bc, 6, 6
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef PlaceGraphic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
.LoadTrainerBackpicAsOAM:
|
2022-07-09 14:18:22 -07:00
|
|
|
|
ld hl, wShadowOAMSprite00
|
2013-12-17 22:11:06 -08:00
|
|
|
|
xor a
|
2020-12-23 13:54:28 -08:00
|
|
|
|
ldh [hMapObjectIndex], a
|
2018-01-10 10:47:57 -08:00
|
|
|
|
ld b, 6
|
|
|
|
|
ld e, (SCREEN_WIDTH + 1) * TILE_WIDTH
|
2015-11-06 13:42:38 -08:00
|
|
|
|
.outer_loop
|
2018-01-10 10:47:57 -08:00
|
|
|
|
ld c, 3
|
|
|
|
|
ld d, 8 * TILE_WIDTH
|
2015-11-06 13:42:38 -08:00
|
|
|
|
.inner_loop
|
2018-01-10 10:47:57 -08:00
|
|
|
|
ld [hl], d ; y
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
2018-01-10 10:47:57 -08:00
|
|
|
|
ld [hl], e ; x
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc hl
|
2020-12-23 13:54:28 -08:00
|
|
|
|
ldh a, [hMapObjectIndex]
|
2018-01-10 10:47:57 -08:00
|
|
|
|
ld [hli], a ; tile id
|
2013-12-17 22:11:06 -08:00
|
|
|
|
inc a
|
2020-12-23 13:54:28 -08:00
|
|
|
|
ldh [hMapObjectIndex], a
|
2018-01-10 10:47:57 -08:00
|
|
|
|
ld a, PAL_BATTLE_OB_PLAYER
|
|
|
|
|
ld [hli], a ; attributes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, d
|
2018-01-10 10:47:57 -08:00
|
|
|
|
add 1 * TILE_WIDTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld d, a
|
|
|
|
|
dec c
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr nz, .inner_loop
|
2020-12-23 13:54:28 -08:00
|
|
|
|
ldh a, [hMapObjectIndex]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
add $3
|
2020-12-23 13:54:28 -08:00
|
|
|
|
ldh [hMapObjectIndex], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, e
|
2018-01-10 10:47:57 -08:00
|
|
|
|
add 1 * TILE_WIDTH
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld e, a
|
|
|
|
|
dec b
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr nz, .outer_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
|
BattleStartMessage:
|
2015-10-19 07:23:58 -07:00
|
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
dec a
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr z, .wild
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
ld de, SFX_SHINE
|
|
|
|
|
call PlaySFX
|
|
|
|
|
call WaitSFX
|
|
|
|
|
|
|
|
|
|
ld c, 20
|
|
|
|
|
call DelayFrames
|
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall Battle_GetTrainerName
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
ld hl, WantsToBattleText
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr .PlaceBattleStartText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
|
.wild
|
|
|
|
|
call BattleCheckEnemyShininess
|
|
|
|
|
jr nc, .not_shiny
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
xor a
|
2015-12-23 11:00:29 -08:00
|
|
|
|
ld [wNumHits], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
|
ldh [hBattleTurn], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld a, 1
|
2015-12-23 17:46:23 -08:00
|
|
|
|
ld [wBattleAnimParam], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
ld de, ANIM_SEND_OUT_MON
|
2015-09-09 16:27:07 -07:00
|
|
|
|
call Call_PlayBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
|
.not_shiny
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall CheckSleepingTreeMon
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr c, .skip_cry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall CheckBattleScene
|
2015-11-07 06:48:32 -08:00
|
|
|
|
jr c, .cry_no_anim
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
hlcoord 12, 0
|
|
|
|
|
ld d, $0
|
2015-11-07 06:48:32 -08:00
|
|
|
|
ld e, ANIM_MON_NORMAL
|
2018-01-16 11:30:10 -08:00
|
|
|
|
predef AnimateFrontpic
|
2015-12-13 11:15:16 -08:00
|
|
|
|
jr .skip_cry ; cry is played during the animation
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
|
.cry_no_anim
|
2018-07-22 20:42:50 -07:00
|
|
|
|
ld a, $f
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld [wCryTracks], a
|
|
|
|
|
ld a, [wTempEnemyMonSpecies]
|
2014-07-18 10:25:03 -07:00
|
|
|
|
call PlayStereoCry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
|
.skip_cry
|
2018-01-23 14:39:09 -08:00
|
|
|
|
ld a, [wBattleType]
|
2013-12-17 22:11:06 -08:00
|
|
|
|
cp BATTLETYPE_FISH
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr nz, .NotFishing
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
|
ld hl, HookedPokemonAttackedText
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr .PlaceBattleStartText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.NotFishing:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, PokemonFellFromTreeText
|
|
|
|
|
cp BATTLETYPE_TREE
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr z, .PlaceBattleStartText
|
2014-06-13 22:53:20 -07:00
|
|
|
|
ld hl, WildCelebiAppearedText
|
|
|
|
|
cp BATTLETYPE_CELEBI
|
2015-11-06 13:42:38 -08:00
|
|
|
|
jr z, .PlaceBattleStartText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ld hl, WildPokemonAppearedText
|
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
|
.PlaceBattleStartText:
|
2013-12-17 22:11:06 -08:00
|
|
|
|
push hl
|
2017-12-24 09:47:30 -08:00
|
|
|
|
farcall BattleStart_TrainerHuds
|
2013-12-17 22:11:06 -08:00
|
|
|
|
pop hl
|
2019-04-08 05:15:10 -07:00
|
|
|
|
call StdBattleTextbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
ret
|