2013-12-31 00:25:38 -08:00
|
|
|
BattleCore:
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; Core components of the battle engine.
|
|
|
|
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
SendOutFirstMons: ; 3c000
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld [wBattleParticipantsNotFainted], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6fc], a
|
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [BattleEnded], a
|
|
|
|
inc a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd264], a
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, OTPartyMon1HP
|
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
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
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
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
|
|
|
call CheckPlayerPartyForFitPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, d
|
|
|
|
and a
|
|
|
|
jp z, LostBattle
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleType]
|
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
|
|
|
|
ld [CurPartyMon], a
|
2015-11-06 06:04:27 -08:00
|
|
|
.loop2
|
2015-09-06 14:38:01 -07:00
|
|
|
call CheckIfPartyHasPkmnToBattleWith
|
2015-11-06 06:04:27 -08:00
|
|
|
jr nz, .alive2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, CurPartyMon
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [LastPlayerMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurBattleMon], a
|
|
|
|
inc a
|
2014-06-23 12:47:07 -07:00
|
|
|
ld hl, PartySpecies - 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]
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
ld [TempBattleMonSpecies], a
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 1, 5
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $9
|
|
|
|
call Function3d490
|
2015-09-09 16:27:07 -07: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
|
2015-09-06 14:38:01 -07:00
|
|
|
call SendOutPkmnText
|
2014-01-01 05:09:15 -08:00
|
|
|
call NewBattleMonStatus
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
call SendOutPlayerMon
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07: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
|
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp Function3c12f
|
|
|
|
|
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
|
|
|
; 3c0e5
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $c0
|
|
|
|
add $2
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jr z, .asm_3c115
|
2015-09-06 14:38:01 -07:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $c0
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wBattleResult], a
|
2015-08-24 16:56:30 -07:00
|
|
|
ld hl, BattleText_EnemyFled
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nc, .asm_3c115
|
2015-09-06 14:38:01 -07:00
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wcd2a
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 4, [hl]
|
|
|
|
jr nz, .asm_3c118
|
2015-09-06 14:38:01 -07:00
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
ld hl, BattleText_LinkErrorBattleCanceled
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3c115
|
|
|
|
call StdBattleTextBox
|
|
|
|
|
|
|
|
.asm_3c118
|
2015-10-19 13:49:29 -07:00
|
|
|
call StopDangerSound
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
jr c, .asm_3c126
|
|
|
|
|
|
|
|
ld de, SFX_RUN
|
|
|
|
call PlaySFX
|
|
|
|
|
|
|
|
.asm_3c126
|
|
|
|
call SetPlayerTurn
|
|
|
|
ld a, 1
|
|
|
|
ld [BattleEnded], a
|
|
|
|
ret
|
|
|
|
; 3c12f
|
|
|
|
|
2015-08-24 16:56:30 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
Function3c12f: ; 3c12f
|
2014-06-17 11:58:11 -07:00
|
|
|
.loop
|
2015-11-08 10:27:26 -08:00
|
|
|
call MobileFn_3c1bf
|
|
|
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd264], a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [wPlayerJustGotFrozen], a
|
|
|
|
ld [wEnemyJustGotFrozen], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurDamage], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [CurDamage + 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
|
|
|
|
callba AIChooseMove
|
2014-06-17 11:58:11 -07:00
|
|
|
|
|
|
|
call IsMobileBattle
|
|
|
|
jr nz, .not_disconnected
|
2013-12-17 22:11:06 -08:00
|
|
|
callba Function100da5
|
|
|
|
callba Function100641
|
|
|
|
callba Function100dd8
|
2014-06-17 11:58:11 -07:00
|
|
|
jp c, .quit
|
|
|
|
.not_disconnected
|
2013-12-17 22:11:06 -08: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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleEnded]
|
|
|
|
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
|
|
|
call CheckMobileBattleError
|
2014-06-17 11:58:11 -07:00
|
|
|
jr c, .quit
|
|
|
|
|
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
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleEnded]
|
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
jr nz, .quit
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
call HandleBetweenTurnEffects
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleEnded]
|
|
|
|
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
|
|
|
|
; 3c1bf
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
MobileFn_3c1bf: mobile
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $5
|
|
|
|
call GetSRAMBank
|
2015-11-10 16:51:13 -08:00
|
|
|
ld hl, $a89b ; s5_a89b
|
2013-12-17 22:11:06 -08:00
|
|
|
inc [hl]
|
2015-11-08 10:27:26 -08:00
|
|
|
jr nz, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
dec hl
|
|
|
|
inc [hl]
|
2015-11-08 10:27:26 -08:00
|
|
|
jr nz, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
dec [hl]
|
|
|
|
inc hl
|
|
|
|
dec [hl]
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
.finish
|
2013-12-17 22:11:06 -08:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
; 3c1d6
|
|
|
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleBetweenTurnEffects: ; 3c1d6
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
.CheckEnemyFirst
|
|
|
|
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
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
.NoMoreFaintingConditions
|
2015-11-08 10:27:26 -08:00
|
|
|
call HandleLeftovers
|
|
|
|
call HandleMysteryberry
|
2015-09-06 14:38:01 -07:00
|
|
|
call HanleDefrost
|
|
|
|
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
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
jp Function3c4df
|
|
|
|
; 3c23c
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
CheckFaint_PlayerThenEnemy: ; 3c23c
|
2014-06-18 00:55:44 -07:00
|
|
|
call HasPlayerFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
jr nz, .PlayerNotFainted
|
|
|
|
call HandlePlayerMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleEnded]
|
|
|
|
and a
|
2015-10-19 13:49:29 -07:00
|
|
|
jr nz, .BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-10-19 13:49:29 -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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleEnded]
|
|
|
|
and a
|
2015-10-19 13:49:29 -07:00
|
|
|
jr nz, .BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
.BattleContinues
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
.BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3c25c
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
CheckFaint_EnemyThenPlayer: ; 3c25c
|
2014-06-18 00:55:44 -07:00
|
|
|
call HasEnemyFainted
|
2015-10-19 13:49:29 -07:00
|
|
|
jr nz, .EnemyNotFainted
|
|
|
|
call HandleEnemyMonFaint
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleEnded]
|
|
|
|
and a
|
2015-10-19 13:49:29 -07:00
|
|
|
jr nz, .BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-10-19 13:49:29 -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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleEnded]
|
|
|
|
and a
|
2015-10-19 13:49:29 -07:00
|
|
|
jr nz, .BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
.BattleContinues
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
.BattleIsOver
|
2013-12-17 22:11:06 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3c27c
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
HandleBerserkGene: ; 3c27c
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
|
|
|
; jr .player
|
|
|
|
|
|
|
|
.player
|
2013-12-17 22:11:06 -08:00
|
|
|
call SetPlayerTurn
|
|
|
|
ld de, PartyMon1Item
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
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
|
|
|
|
ld de, OTPartyMon1Item
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
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
|
|
|
.go
|
2013-12-17 22:11:06 -08:00
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
callab GetUserItem
|
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], 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
|
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
|
|
|
|
ld [AttackMissed], a
|
|
|
|
ld [EffectFailed], a
|
2015-11-06 11:45:10 -08:00
|
|
|
callba 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
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
2015-11-06 17:55:16 -08:00
|
|
|
callab 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-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3c300
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
EnemyTriesToFlee: ; 3c300
|
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
|
|
|
|
; 3c314
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
DetermineMoveOrder: ; 3c314
|
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]
|
2015-11-06 06:04:27 -08:00
|
|
|
cp BATTLEACTION_E
|
|
|
|
jr z, .use_move
|
|
|
|
cp BATTLEACTION_D
|
|
|
|
jr z, .use_move
|
|
|
|
sub BATTLEACTION_SWITCH1
|
|
|
|
jr c, .use_move
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0ec]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
2015-11-05 16:13:09 -08:00
|
|
|
jr nz, .switch
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
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
|
2015-07-20 00:51:52 -07:00
|
|
|
cp 1 + (50 percent)
|
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
|
2015-07-20 00:51:52 -07:00
|
|
|
cp 1 + (50 percent)
|
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
|
2014-08-13 19:44:56 -07:00
|
|
|
callab 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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0ec]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
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
|
|
|
|
callab GetUserItem
|
|
|
|
push bc
|
|
|
|
callab GetOpponentItem
|
|
|
|
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
|
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, BattleMonSpeed
|
|
|
|
ld hl, EnemyMonSpeed
|
2015-11-06 06:04:27 -08:00
|
|
|
ld c, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
call StringCmp
|
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
|
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
2015-11-06 06:04:27 -08:00
|
|
|
jr z, .player_2c
|
2013-12-17 22:11:06 -08:00
|
|
|
call BattleRandom
|
2015-07-20 00:51:52 -07:00
|
|
|
cp 1 + (50 percent)
|
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
|
2015-07-20 00:51:52 -07:00
|
|
|
cp 1 + (50 percent)
|
2015-11-06 06:04:27 -08:00
|
|
|
jp c, .enemy_first
|
|
|
|
.player_first
|
2013-12-17 22:11:06 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3c3f3
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
.enemy_first: ; 3c3f3
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 3c3f5
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
CheckContestBattleOver: ; 3c3f5
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleType]
|
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]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $c0
|
|
|
|
add $2
|
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
|
|
|
|
; 3c410
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
CheckPlayerLockedIn: ; 3c410
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PlayerSubStatus4]
|
2014-06-13 21:18:14 -07:00
|
|
|
and 1 << SUBSTATUS_RECHARGE
|
|
|
|
jp nz, .quit
|
2014-06-17 11:58:11 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus3
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_FLINCHED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus3
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus1
|
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
|
|
|
|
; 3c434
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
ParsePlayerAction: ; 3c434
|
|
|
|
call CheckPlayerLockedIn
|
|
|
|
jp c, .locked_in
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2015-11-08 16:09:36 -08:00
|
|
|
jr z, .not_encored
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [LastPlayerMove]
|
|
|
|
ld [CurPlayerMove], 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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0ec]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PlayerSubStatus3]
|
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-02-08 00:03:32 -08:00
|
|
|
ld [wd235], a
|
2014-06-13 21:18:14 -07:00
|
|
|
inc a ; POUND
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [FXAnimIDLo], a
|
2015-10-10 04:45:39 -07:00
|
|
|
call MoveSelectionScreen
|
2013-12-17 22:11:06 -08:00
|
|
|
push af
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
call UpdateBattleHuds
|
|
|
|
ld a, [CurPlayerMove]
|
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
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
pop af
|
|
|
|
ret nz
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
.encored
|
2013-12-17 22:11:06 -08:00
|
|
|
call SetPlayerTurn
|
|
|
|
callab UpdateMoveData
|
|
|
|
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
|
|
|
|
ld [PlayerFuryCutterCount], a
|
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus4
|
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
|
2014-01-01 05:09:15 -08:00
|
|
|
ld [PlayerProtectCount], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus3
|
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
|
|
|
|
ld [PlayerFuryCutterCount], a
|
2014-01-01 05:09:15 -08:00
|
|
|
ld [PlayerProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld [wPlayerRageCounter], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus4
|
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
|
|
|
|
ld [PlayerFuryCutterCount], a
|
2014-01-01 05:09:15 -08:00
|
|
|
ld [PlayerProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld [wPlayerRageCounter], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus4
|
2014-06-13 21:18:14 -07:00
|
|
|
res SUBSTATUS_RAGE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 3c4df
|
|
|
|
|
|
|
|
Function3c4df: ; 3c4df
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
|
|
|
jr z, .asm_3c4ea
|
|
|
|
call .asm_3c4ed
|
|
|
|
jr .asm_3c518
|
|
|
|
|
|
|
|
.asm_3c4ea
|
|
|
|
call .asm_3c518
|
|
|
|
.asm_3c4ed
|
|
|
|
ld hl, PlayerSubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
|
|
|
ld a, [PlayerEncoreCount]
|
|
|
|
dec a
|
|
|
|
ld [PlayerEncoreCount], a
|
|
|
|
jr z, .asm_3c50a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, BattleMonPP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurMoveNum]
|
|
|
|
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]
|
|
|
|
and $3f
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
.asm_3c50a
|
|
|
|
ld hl, PlayerSubStatus5
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
|
|
|
|
.asm_3c518
|
|
|
|
ld hl, EnemySubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
|
|
|
ld a, [EnemyEncoreCount]
|
|
|
|
dec a
|
|
|
|
ld [EnemyEncoreCount], a
|
|
|
|
jr z, .asm_3c535
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonPP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurEnemyMoveNum]
|
|
|
|
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]
|
|
|
|
and $3f
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
.asm_3c535
|
|
|
|
ld hl, EnemySubStatus5
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3c543
|
|
|
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
TryEnemyFlee: ; 3c543
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
|
|
|
jr nz, .Stay
|
|
|
|
|
|
|
|
ld a, [PlayerSubStatus5]
|
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
|
|
|
|
|
|
|
|
ld a, [EnemyMonStatus]
|
|
|
|
and 1 << FRZ | SLP
|
|
|
|
jr nz, .Stay
|
|
|
|
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
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
|
2015-07-20 00:51:52 -07:00
|
|
|
cp 1 + (50 percent)
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nc, .Stay
|
|
|
|
|
|
|
|
push bc
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
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
|
2015-07-20 00:51:52 -07:00
|
|
|
cp 1 + (10 percent)
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nc, .Stay
|
|
|
|
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
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
|
|
|
|
|
|
|
|
.Stay
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.Flee
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3c59a
|
|
|
|
|
2013-12-24 14:19:39 -08:00
|
|
|
FleeMons:
|
|
|
|
|
|
|
|
SometimesFleeMons: ; 3c59a
|
2013-12-17 22:11:06 -08:00
|
|
|
db MAGNEMITE
|
|
|
|
db GRIMER
|
|
|
|
db TANGELA
|
|
|
|
db MR__MIME
|
|
|
|
db EEVEE
|
|
|
|
db PORYGON
|
|
|
|
db DRATINI
|
|
|
|
db DRAGONAIR
|
|
|
|
db TOGETIC
|
|
|
|
db UMBREON
|
|
|
|
db UNOWN
|
|
|
|
db SNUBBULL
|
|
|
|
db HERACROSS
|
2013-12-24 14:19:39 -08:00
|
|
|
db -1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2013-12-24 14:19:39 -08:00
|
|
|
OftenFleeMons: ; 3c5a8
|
2013-12-17 22:11:06 -08:00
|
|
|
db CUBONE
|
|
|
|
db ARTICUNO
|
|
|
|
db ZAPDOS
|
|
|
|
db MOLTRES
|
|
|
|
db QUAGSIRE
|
|
|
|
db DELIBIRD
|
|
|
|
db PHANPY
|
|
|
|
db TEDDIURSA
|
2013-12-24 14:19:39 -08:00
|
|
|
db -1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2013-12-24 14:19:39 -08:00
|
|
|
AlwaysFleeMons: ; 3c5b1
|
2013-12-17 22:11:06 -08:00
|
|
|
db RAIKOU
|
|
|
|
db ENTEI
|
|
|
|
; db SUICUNE
|
2013-12-24 14:19:39 -08:00
|
|
|
db -1
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3c5b4
|
|
|
|
|
|
|
|
|
2013-12-30 20:32:37 -08:00
|
|
|
CompareMovePriority: ; 3c5b4
|
|
|
|
; Compare the priority of the player and enemy's moves.
|
|
|
|
; Return carry if the player goes first, or z if they match.
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPlayerMove]
|
|
|
|
call GetMovePriority
|
|
|
|
ld b, a
|
|
|
|
push bc
|
|
|
|
ld a, [CurEnemyMove]
|
|
|
|
call GetMovePriority
|
|
|
|
pop bc
|
|
|
|
cp b
|
|
|
|
ret
|
|
|
|
; 3c5c5
|
|
|
|
|
|
|
|
GetMovePriority: ; 3c5c5
|
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
|
|
|
|
|
|
|
; 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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, 1
|
|
|
|
ret
|
|
|
|
|
2013-12-30 20:32:37 -08:00
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
; 3c5df
|
|
|
|
|
2013-12-30 20:32:37 -08:00
|
|
|
MoveEffectPriorities: ; 3c5df
|
2013-12-17 22:11:06 -08:00
|
|
|
db EFFECT_PROTECT, 3
|
|
|
|
db EFFECT_ENDURE, 3
|
|
|
|
db EFFECT_PRIORITY_HIT, 2
|
|
|
|
db EFFECT_WHIRLWIND, 0
|
|
|
|
db EFFECT_COUNTER, 0
|
|
|
|
db EFFECT_MIRROR_COAT, 0
|
2013-12-30 20:32:37 -08:00
|
|
|
db -1
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3c5ec
|
|
|
|
|
|
|
|
|
2013-12-30 20:32:37 -08:00
|
|
|
GetMoveEffect: ; 3c5ec
|
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
|
|
|
|
; 3c5fe
|
|
|
|
|
2013-12-30 20:32:37 -08:00
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
Battle_EnemyFirst: ; 3c5fe
|
2015-09-09 16:27:07 -07: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
|
2015-08-24 16:56:30 -07:00
|
|
|
callab 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
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
ret c
|
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
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
ret c
|
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
|
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3c664
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
Battle_PlayerFirst: ; 3c664
|
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
|
2015-08-24 16:56:30 -07:00
|
|
|
callab 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
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
ret c
|
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
|
2015-09-09 16:27:07 -07: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
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
ret c
|
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
|
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3c6cf
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
PlayerTurn_EndOpponentProtectEndureDestinyBond: ; 3c6cf
|
2013-12-17 22:11:06 -08:00
|
|
|
call SetPlayerTurn
|
2015-11-07 18:04:54 -08:00
|
|
|
call EndUserDestinyBond
|
2013-12-17 22:11:06 -08:00
|
|
|
callab DoPlayerTurn
|
2015-11-07 18:04:54 -08:00
|
|
|
jp EndOpponentProtectEndureDestinyBond
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3c6de
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
EnemyTurn_EndOpponentProtectEndureDestinyBond: ; 3c6de
|
2013-12-17 22:11:06 -08:00
|
|
|
call SetEnemyTurn
|
2015-11-07 18:04:54 -08:00
|
|
|
call EndUserDestinyBond
|
2013-12-17 22:11:06 -08:00
|
|
|
callab DoEnemyTurn
|
2015-11-07 18:04:54 -08:00
|
|
|
jp EndOpponentProtectEndureDestinyBond
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3c6ed
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
EndOpponentProtectEndureDestinyBond: ; 3c6ed
|
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
|
|
|
|
; 3c6fe
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
EndUserDestinyBond: ; 3c6fe
|
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
|
|
|
|
; 3c706
|
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
HasUserFainted: ; 3c706
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-18 00:55:44 -07:00
|
|
|
jr z, HasPlayerFainted
|
|
|
|
HasEnemyFainted: ; 3c70b
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
2015-09-09 16:27:07 -07:00
|
|
|
jr CheckIfHPIsZero
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
HasPlayerFainted: ; 3c710
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
CheckIfHPIsZero: ; 3c713
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
ret
|
|
|
|
; 3c716
|
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
ResidualDamage: ; 3c716
|
|
|
|
; 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
|
|
|
|
call StdBattleTextBox
|
|
|
|
pop de
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], a
|
2015-11-07 18:04:54 -08:00
|
|
|
call Call_PlayBattleAnim_OnlyIfVisible
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetEighthMaxHP
|
2014-06-17 12:52:32 -07:00
|
|
|
ld de, PlayerToxicCount
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .check_toxic
|
2014-06-17 12:52:32 -07:00
|
|
|
ld de, EnemyToxicCount
|
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-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], 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
|
|
|
|
ld [hBGMapMode], a
|
2015-11-06 19:36:06 -08:00
|
|
|
call RestoreHP
|
2014-06-18 00:55:44 -07:00
|
|
|
ld hl, LeechSeedSapsText
|
2013-12-17 22:11:06 -08: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-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], 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
|
2013-12-17 22:11:06 -08: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-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.not_cursed
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .check_fainted
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
|
|
|
; 3c801
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandlePerishSong: ; 3c801
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
|
|
|
2015-11-08 10:27:26 -08: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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerPerishCount
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
jr z, .got_count
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyPerishCount
|
|
|
|
|
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]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2013-12-17 22:11:06 -08:00
|
|
|
push af
|
2014-06-18 00:55:44 -07:00
|
|
|
ld hl, PerishCountText
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
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]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
jr nz, .asm_3c85c
|
|
|
|
ld hl, BattleMonHP
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, PartyMon1HP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3c85c
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, OTPartyMon1HP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurOTMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
; 3c874
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleWrap: ; 3c874
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
|
|
|
2015-11-08 10:27:26 -08: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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
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]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [FXAnimIDLo], a
|
|
|
|
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-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [FXAnimIDHi], a
|
2014-06-16 11:20:01 -07: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
|
2013-12-17 22:11:06 -08:00
|
|
|
jr .asm_3c8e1
|
|
|
|
|
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
|
|
|
|
|
|
|
.asm_3c8e1
|
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3c8e4
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
SwitchTurnCore: ; 3c8e4
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
2014-06-13 21:18:14 -07:00
|
|
|
xor 1
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hBattleTurn], a
|
|
|
|
ret
|
|
|
|
; 3c8eb
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleLeftovers: ; 3c8eb
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
|
|
|
2015-11-08 10:27:26 -08: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
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
callab GetUserItem
|
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], 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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
jr z, .got_hp
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
2014-01-05 04:28:55 -08:00
|
|
|
ld hl, BattleText_0x80880
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3c93c
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleMysteryberry: ; 3c93c
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
|
|
|
2015-11-08 10:27:26 -08: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
|
2013-12-17 22:11:06 -08:00
|
|
|
callab GetUserItem
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PartyMon1PP
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, PartyMon1Moves
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
jr z, .wild
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, wc739
|
|
|
|
ld hl, wc735
|
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
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, OTPartyMon1PP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurOTMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, OTPartyMon1Moves
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurOTMon]
|
|
|
|
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]
|
|
|
|
and $3f
|
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]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, BattleMonMoves - 1
|
|
|
|
ld hl, BattleMonPP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
jr z, .player_pp
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, EnemyMonMoves - 1
|
|
|
|
ld hl, EnemyMonPP
|
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
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd265]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp [hl]
|
2015-11-08 10:27:26 -08:00
|
|
|
jr nz, .skip_checks
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
|
|
|
ld a, [PlayerSubStatus5]
|
2015-11-08 10:27:26 -08:00
|
|
|
jr z, .check_transform
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemySubStatus5]
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
callab GetUserItem
|
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2015-11-08 10:27:26 -08:00
|
|
|
call GetPartymonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3ca26
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleFutureSight: ; 3ca26
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
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
|
|
|
|
2014-01-05 04:28:55 -08:00
|
|
|
ld hl, BattleText_0x808b6
|
2013-12-17 22:11:06 -08: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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
callab UpdateMoveData
|
|
|
|
xor a
|
|
|
|
ld [AttackMissed], a
|
|
|
|
ld [AlreadyDisobeyed], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 10
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [TypeModifier], a
|
|
|
|
callab DoMove
|
|
|
|
xor a
|
|
|
|
ld [CurDamage], a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [CurDamage + 1], a
|
|
|
|
|
|
|
|
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
|
|
|
|
; 3ca8f
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
HanleDefrost: ; 3ca8f
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleMonStatus]
|
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
|
|
|
|
ld [BattleMonStatus], a
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld hl, PartyMon1Status
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
.do_enemy_turn
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemyMonStatus]
|
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
|
|
|
|
ld [EnemyMonStatus], 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
|
|
|
|
jr z, .asm_3caef
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
ld hl, OTPartyMon1Status
|
|
|
|
call GetPartyLocation
|
2014-06-17 12:52:32 -07:00
|
|
|
ld [hl], 0
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3caef
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3cafb
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
HandleSafeguard: ; 3cafb
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
|
|
|
jr z, .asm_3cb06
|
|
|
|
call .asm_3cb09
|
|
|
|
jr .asm_3cb1c
|
|
|
|
|
|
|
|
.asm_3cb06
|
|
|
|
call .asm_3cb1c
|
|
|
|
.asm_3cb09
|
|
|
|
ld a, [PlayerScreens]
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SCREENS_SAFEGUARD, a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, PlayerSafeguardCount
|
2013-12-17 22:11:06 -08:00
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
res SCREENS_SAFEGUARD, a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [PlayerScreens], a
|
|
|
|
xor a
|
|
|
|
jr .asm_3cb2e
|
|
|
|
|
|
|
|
.asm_3cb1c
|
|
|
|
ld a, [EnemyScreens]
|
2014-06-10 23:08:07 -07:00
|
|
|
bit SCREENS_SAFEGUARD, a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, EnemySafeguardCount
|
2013-12-17 22:11:06 -08:00
|
|
|
dec [hl]
|
|
|
|
ret nz
|
2014-06-10 23:08:07 -07:00
|
|
|
res SCREENS_SAFEGUARD, a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [EnemyScreens], a
|
|
|
|
ld a, $1
|
|
|
|
|
|
|
|
.asm_3cb2e
|
|
|
|
ld [hBattleTurn], a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, BattleText_SafeguardFaded
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
HandleScreens: ; 3cb36
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp 1
|
|
|
|
jr z, .Both
|
|
|
|
call .CheckPlayer
|
|
|
|
jr .CheckEnemy
|
|
|
|
|
|
|
|
.Both
|
|
|
|
call .CheckEnemy
|
|
|
|
|
|
|
|
.CheckPlayer
|
|
|
|
call SetPlayerTurn
|
|
|
|
ld de, .Your
|
2014-06-10 23:08:07 -07:00
|
|
|
call .Copy
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerScreens
|
|
|
|
ld de, PlayerLightScreenCount
|
|
|
|
jr .FadeScreens
|
|
|
|
|
|
|
|
.CheckEnemy
|
|
|
|
call SetEnemyTurn
|
|
|
|
ld de, .Enemy
|
2014-06-10 23:08:07 -07:00
|
|
|
call .Copy
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyScreens
|
|
|
|
ld de, EnemyLightScreenCount
|
|
|
|
|
|
|
|
.FadeScreens
|
|
|
|
bit SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
call nz, FadeLightScreen
|
|
|
|
bit SCREENS_REFLECT, [hl]
|
|
|
|
call nz, FadeReflect
|
|
|
|
ret
|
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
.Copy
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, StringBuffer1
|
|
|
|
jp CopyName2
|
|
|
|
; 3cb75
|
|
|
|
|
|
|
|
.Your
|
|
|
|
db "Your@"
|
|
|
|
.Enemy
|
|
|
|
db "Enemy@"
|
|
|
|
; 3cb80
|
|
|
|
|
|
|
|
|
|
|
|
FadeLightScreen: ; 3cb80
|
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
|
|
|
ret nz
|
|
|
|
res SCREENS_LIGHT_SCREEN, [hl]
|
|
|
|
push hl
|
|
|
|
push de
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, BattleText_PkmnnLightScreenFell
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 3cb91
|
|
|
|
|
|
|
|
FadeReflect: ; 3cb91
|
|
|
|
inc de
|
|
|
|
ld a, [de]
|
|
|
|
dec a
|
|
|
|
ld [de], a
|
|
|
|
ret nz
|
|
|
|
res SCREENS_REFLECT, [hl]
|
|
|
|
ld hl, BattleText_0x80905
|
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3cb9e
|
|
|
|
|
|
|
|
HandleWeather: ; 3cb9e
|
|
|
|
ld a, [Weather]
|
2014-06-13 21:18:14 -07:00
|
|
|
cp WEATHER_NONE
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
|
|
|
|
|
|
|
ld hl, WeatherCount
|
|
|
|
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
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [Weather]
|
|
|
|
cp WEATHER_SANDSTORM
|
|
|
|
ret nz
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp 1
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .enemy_first
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2014-06-13 21:18:14 -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
|
|
|
|
|
2014-06-13 21:18: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
|
|
|
|
|
|
|
|
ld hl, BattleMonType1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyMonType1
|
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-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
|
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
|
|
|
|
ld [Weather], a
|
|
|
|
ret
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.PrintWeatherMessage
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [Weather]
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3cc2d
|
|
|
|
|
|
|
|
.WeatherMessages
|
2015-09-06 14:38:01 -07:00
|
|
|
dw BattleText_RainContinuesToFall
|
|
|
|
dw BattleText_TheSunlightIsStrong
|
|
|
|
dw BattleText_TheSandstormRages
|
2013-12-17 22:11:06 -08:00
|
|
|
.WeatherEndedMessages
|
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
|
|
|
; 3cc39
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
SubtractHPFromTarget: ; 3cc39
|
|
|
|
call SubtractHP
|
2015-11-07 05:05:57 -08:00
|
|
|
jp UpdateHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3cc3f
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
SubtractHPFromUser: ; 3cc3f
|
2015-09-09 16:27:07 -07:00
|
|
|
; Subtract HP from Pkmn
|
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
|
|
|
; 3cc45
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
SubtractHP: ; 3cc45
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .ok
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonHP
|
2014-06-13 21:18:14 -07:00
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
sub c
|
|
|
|
ld [hld], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ee], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ed], a
|
2013-12-17 22:11:06 -08:00
|
|
|
sbc b
|
|
|
|
ld [hl], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ef], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret nc
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd1ec]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd1ed]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
|
|
|
xor a
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ee], a
|
|
|
|
ld [wd1ef], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3cc76
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
GetSixteenthMaxHP: ; 3cc76
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetQuarterMaxHP
|
2014-06-13 21:18:14 -07:00
|
|
|
; quarter result
|
2013-12-17 22:11:06 -08:00
|
|
|
srl c
|
|
|
|
srl c
|
2014-06-13 21:18:14 -07:00
|
|
|
; round up
|
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
|
|
|
|
; 3cc83
|
|
|
|
|
|
|
|
|
|
|
|
GetEighthMaxHP: ; 3cc83
|
|
|
|
; output: bc
|
|
|
|
call GetQuarterMaxHP
|
|
|
|
; assumes nothing can have 1024 or more hp
|
|
|
|
; halve result
|
|
|
|
srl c
|
|
|
|
; round up
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
jr nz, .end
|
|
|
|
inc c
|
|
|
|
.end
|
|
|
|
ret
|
|
|
|
; 3cc8e
|
|
|
|
|
|
|
|
|
|
|
|
GetQuarterMaxHP: ; 3cc8e
|
|
|
|
; output: bc
|
|
|
|
call GetMaxHP
|
|
|
|
|
|
|
|
; quarter result
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
srl b
|
|
|
|
rr c
|
|
|
|
|
|
|
|
; assumes nothing can have 1024 or more hp
|
|
|
|
; round up
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
jr nz, .end
|
|
|
|
inc c
|
|
|
|
.end
|
|
|
|
ret
|
|
|
|
; 3cc9f
|
|
|
|
|
|
|
|
|
|
|
|
GetHalfMaxHP: ; 3cc9f
|
|
|
|
; 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
|
|
|
|
|
|
|
|
; floor = 1
|
|
|
|
ld a, c
|
|
|
|
or b
|
|
|
|
jr nz, .end
|
|
|
|
inc c
|
|
|
|
.end
|
|
|
|
ret
|
|
|
|
; 3ccac
|
|
|
|
|
|
|
|
|
|
|
|
GetMaxHP: ; 3ccac
|
|
|
|
; output: bc, Buffer1-2
|
|
|
|
|
|
|
|
ld hl, BattleMonMaxHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyMonMaxHP
|
2014-06-13 21:18:14 -07:00
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [Buffer2], a
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
ld a, [hl]
|
|
|
|
ld [Buffer1], a
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
; 3ccc2
|
|
|
|
|
|
|
|
Function3ccc2: ; 3ccc2
|
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyMonHP
|
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]
|
|
|
|
ld [Buffer2], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [Buffer1], a
|
|
|
|
ret
|
|
|
|
; 3ccde
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
CheckUserHasEnoughHP: ; 3ccde
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP + 1
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyMonHP + 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
|
|
|
|
; 3ccef
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
RestoreHP ; 3ccef
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyMonMaxHP
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonMaxHP
|
2014-06-13 21:18:14 -07:00
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hld]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
dec hl
|
|
|
|
ld a, [hl]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
add c
|
|
|
|
ld [hld], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer4], a
|
2013-12-17 22:11:06 -08:00
|
|
|
adc b
|
|
|
|
ld [hli], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer6], a
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [Buffer1]
|
|
|
|
ld c, a
|
|
|
|
ld a, [hld]
|
|
|
|
sub c
|
|
|
|
ld a, [Buffer2]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
jr c, .asm_3cd2d
|
|
|
|
ld a, b
|
|
|
|
ld [hli], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer6], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, c
|
|
|
|
ld [hl], a
|
2015-11-07 05:05:57 -08:00
|
|
|
ld [Buffer5], a
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3cd2d
|
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
|
|
|
; 3cd36
|
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
UpdateHPBarBattleHuds: ; 3cd36
|
|
|
|
call UpdateHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
jp UpdateBattleHuds
|
|
|
|
; 3cd3c
|
|
|
|
|
2015-11-07 05:05:57 -08:00
|
|
|
UpdateHPBar: ; 3cd3c
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 10, 9
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
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-02-08 00:03:32 -08:00
|
|
|
ld [wd10a], a
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3cd55
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
HandleEnemyMonFaint: ; 3cd55
|
|
|
|
call FaintEnemyPokemon
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6f7], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3ce01
|
2015-09-09 16:27:07 -07:00
|
|
|
call CheckPlayerPartyForFitPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, d
|
|
|
|
and a
|
|
|
|
jp z, LostBattle
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2014-06-16 22:52:59 -07:00
|
|
|
call nz, UpdatePlayerHUD
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [BattleEnded], a
|
|
|
|
ret
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
.trainer
|
|
|
|
call CheckEnemyTrainerDefeated
|
|
|
|
jp z, WinTrainerBattle
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [BattleEnded], a
|
|
|
|
ret
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.dont_flee
|
2015-11-10 16:51:13 -08:00
|
|
|
call ForcePlayerMonChoice
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2015-09-06 14:38:01 -07:00
|
|
|
jp c, WildFled_EnemyFled_LinkBattleCanceled
|
2014-06-13 21:18:14 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3cf4a
|
2015-09-06 14:38:01 -07:00
|
|
|
jp z, WildFled_EnemyFled_LinkBattleCanceled
|
2013-12-31 01:09:00 -08:00
|
|
|
jr Function3cdca
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
.player_mon_not_fainted
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3cf4a
|
2015-09-06 14:38:01 -07:00
|
|
|
jp z, WildFled_EnemyFled_LinkBattleCanceled
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
2013-12-31 01:09:00 -08:00
|
|
|
; 3cdca
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2013-12-31 01:09:00 -08:00
|
|
|
Function3cdca: ; 3cdca
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
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
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
|
|
|
ld [CurPartyMon], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3ce01
|
|
|
|
|
|
|
|
Function3ce01: ; 3ce01
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurOTMon]
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, OTPartyMon1HP
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus3
|
2014-06-23 12:47:07 -07:00
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld hl, EnemyDamageTaken
|
|
|
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6fd], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
.trainer
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2015-11-10 16:51:13 -08:00
|
|
|
jr nz, .player_mon_did_not_faint
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc6f7]
|
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
|
|
|
|
call PlayerMonFaintHappinessMod
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
.player_mon_did_not_faint
|
2015-09-09 16:27:07 -07:00
|
|
|
call CheckPlayerPartyForFitPkmn
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $c0
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wBattleResult], a
|
2015-11-07 18:04:54 -08:00
|
|
|
call DoOthersShareExperience
|
2015-11-10 16:51:13 -08:00
|
|
|
jr z, .skip_exp
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyMonBaseStats
|
|
|
|
ld b, $7
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyMonBaseStats
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, wc720
|
2015-11-07 18:04:54 -08:00
|
|
|
ld bc, EnemyMonEnd - EnemyMonBaseStats
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc71f], a
|
2015-09-09 16:27:07 -07:00
|
|
|
call GiveExperiencePoints
|
2015-11-07 18:04:54 -08:00
|
|
|
call DoOthersShareExperience
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wc720
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, EnemyMonBaseStats
|
2015-11-07 18:04:54 -08:00
|
|
|
ld bc, EnemyMonEnd - EnemyMonBaseStats
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc71f], 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
|
|
|
|
; 3ceaa
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
DoOthersShareExperience: ; 3ceaa
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PartyCount]
|
|
|
|
ld b, a
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, PartyMon1
|
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
|
|
|
|
; 3ceec
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
StopDangerSound: ; 3ceec
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [Danger], a
|
|
|
|
ret
|
|
|
|
; 3cef1
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
FaintYourPokemon: ; 3cef1
|
|
|
|
call StopDangerSound
|
2013-12-17 22:11:06 -08:00
|
|
|
call WaitSFX
|
|
|
|
ld a, $f0
|
|
|
|
ld [CryTracks], a
|
|
|
|
ld a, [BattleMonSpecies]
|
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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, BattleText_PkmnFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3cf14
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
FaintEnemyPokemon: ; 3cf14
|
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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, BattleText_EnemyPkmnFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3cf35
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
CheckEnemyTrainerDefeated: ; 3cf35
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [OTPartyCount]
|
|
|
|
ld b, a
|
|
|
|
xor a
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, OTPartyMon1HP
|
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
|
|
|
|
; 3cf4a
|
|
|
|
|
|
|
|
Function3cf4a: ; 3cf4a
|
|
|
|
ld hl, EnemyHPPal
|
2014-06-23 12:45:30 -07:00
|
|
|
ld e, HP_BAR_LENGTH_PX
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3e12e
|
|
|
|
call WaitBGMap
|
|
|
|
callba Function2c012
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3e8e4
|
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
|
|
|
|
|
|
|
call Call_LoadTempTileMapToTileMap
|
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
|
|
|
ld hl, BattleMonHP
|
|
|
|
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
|
2013-12-31 01:09:00 -08:00
|
|
|
; 3cf78
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
EnemyPartyMonEntrance: ; 3cf78
|
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
|
|
|
|
jr nz, .asm_3cf8f
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
call EnemySwitch
|
2013-12-17 22:11:06 -08:00
|
|
|
jr .asm_3cf92
|
|
|
|
|
|
|
|
.asm_3cf8f
|
2015-11-07 18:04:54 -08:00
|
|
|
call EnemySwitch_SetMode
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3cf92
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
inc a
|
|
|
|
ret
|
|
|
|
; 3cfa4
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
WinTrainerBattle: ; 3cfa4
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6fd], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [BattleEnded], 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
|
2015-07-15 12:48:44 -07:00
|
|
|
callab Battle_GetTrainerName
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, BattleText_EnemyWasDefeated
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
call IsMobileBattle
|
2015-11-03 19:35:36 -08:00
|
|
|
jr z, .mobile
|
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-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 0, a
|
2015-11-03 19:35:36 -08:00
|
|
|
jr nz, .battle_tower
|
2015-09-06 14:38:01 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3ebd8
|
|
|
|
ld c, $28
|
|
|
|
call DelayFrames
|
|
|
|
ld a, [BattleType]
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc2cc]
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 0, a
|
2015-11-04 12:35:29 -08:00
|
|
|
jr nz, .skip_win_loss_text
|
|
|
|
call PrintWinLossText
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-04 12:35:29 -08:00
|
|
|
.skip_win_loss_text
|
2013-12-17 22:11:06 -08:00
|
|
|
jp Function3d02b
|
|
|
|
|
2015-11-03 19:35:36 -08:00
|
|
|
.mobile
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3ebd8
|
2015-11-10 20:23:28 -08:00
|
|
|
ld c, 40
|
2013-12-17 22:11:06 -08:00
|
|
|
call DelayFrames
|
|
|
|
ld c, $4
|
|
|
|
callba Function4ea0a
|
|
|
|
ret
|
|
|
|
|
2015-11-03 19:35:36 -08:00
|
|
|
.battle_tower
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3ebd8
|
2015-11-10 20:23:28 -08:00
|
|
|
ld c, 40
|
2013-12-17 22:11:06 -08:00
|
|
|
call DelayFrames
|
|
|
|
call EmptyBattleTextBox
|
|
|
|
ld c, $3
|
2015-11-03 19:35:36 -08:00
|
|
|
callba BattleTowerText
|
2015-11-10 20:23:28 -08:00
|
|
|
call WaitPressAorB_BlinkCursor
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, wPayDayMoney
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
inc hl
|
|
|
|
or [hl]
|
|
|
|
ret nz
|
|
|
|
call ClearTileMap
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3d02b
|
|
|
|
|
|
|
|
Function3d02b: ; 3d02b
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc73d]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
call nz, Function3d099
|
|
|
|
call Function3d0b1
|
|
|
|
push af
|
|
|
|
ld a, $0
|
|
|
|
jr nc, .asm_3d044
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, [wMomSavingMoney]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $7
|
|
|
|
cp $3
|
|
|
|
jr nz, .asm_3d044
|
|
|
|
inc a
|
|
|
|
|
|
|
|
.asm_3d044
|
|
|
|
ld b, a
|
|
|
|
ld c, $4
|
|
|
|
.asm_3d047
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr z, .asm_3d052
|
|
|
|
call Function3d081
|
|
|
|
dec c
|
|
|
|
dec b
|
|
|
|
jr .asm_3d047
|
|
|
|
|
|
|
|
.asm_3d052
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
jr z, .asm_3d05c
|
|
|
|
call Function3d08d
|
|
|
|
dec c
|
|
|
|
jr .asm_3d052
|
|
|
|
|
|
|
|
.asm_3d05c
|
|
|
|
call Function3d099
|
|
|
|
call Function3d099
|
|
|
|
pop af
|
2015-06-11 09:57:45 -07:00
|
|
|
jr nc, .KeepItAll
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, [wMomSavingMoney]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $7
|
2015-06-11 09:57:45 -07:00
|
|
|
jr z, .KeepItAll
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, SentToMomTexts
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
jp StdBattleTextBox
|
|
|
|
|
2015-06-11 09:57:45 -07:00
|
|
|
.KeepItAll
|
|
|
|
ld hl, GotMoneyForWinningText
|
2013-12-17 22:11:06 -08:00
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3d081
|
|
|
|
|
|
|
|
Function3d081: ; 3d081
|
|
|
|
push bc
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wc688
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, wMomsMoney + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3d0be
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3d08d
|
|
|
|
|
|
|
|
Function3d08d: ; 3d08d
|
|
|
|
push bc
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wc688
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, Money + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3d0be
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3d099
|
|
|
|
|
|
|
|
Function3d099: ; 3d099
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wc688
|
2013-12-17 22:11:06 -08:00
|
|
|
sla [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
|
|
|
dec hl
|
|
|
|
rl [hl]
|
|
|
|
ret nc
|
|
|
|
ld a, $ff
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
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
|
|
|
|
ret
|
|
|
|
; 3d0ab
|
|
|
|
|
|
|
|
SentToMomTexts: ; 3d0ab
|
2015-06-11 09:57:45 -07:00
|
|
|
dw SentSomeToMomText
|
|
|
|
dw SentHalfToMomText
|
|
|
|
dw SentAllToMomText
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3d0b1
|
|
|
|
|
|
|
|
|
|
|
|
Function3d0b1: ; 3d0b1
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, wMomsMoney + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hld]
|
2014-06-10 23:08:07 -07:00
|
|
|
cp 999999 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hld]
|
2014-06-10 23:08:07 -07:00
|
|
|
sbc 999999 / $100 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
sbc 999999 / $10000 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3d0be
|
|
|
|
|
|
|
|
Function3d0be: ; 3d0be
|
|
|
|
ld c, $3
|
|
|
|
and a
|
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
2015-10-24 07:34:19 -07:00
|
|
|
callba MobileFn_106008
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
.asm_3d0ce
|
|
|
|
ld a, [de]
|
|
|
|
adc [hl]
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
dec hl
|
|
|
|
dec c
|
|
|
|
jr nz, .asm_3d0ce
|
|
|
|
pop hl
|
|
|
|
ld a, [hld]
|
2014-06-10 23:08:07 -07:00
|
|
|
cp 999999 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hld]
|
2014-06-10 23:08:07 -07:00
|
|
|
sbc 999999 / $100 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
2014-06-10 23:08:07 -07:00
|
|
|
sbc 999999 / $10000 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
ret c
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hl], 999999 / $10000 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hl], 999999 / $100 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2014-06-10 23:08:07 -07:00
|
|
|
ld [hl], 999999 % $100
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3d0ea
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
PlayVictoryMusic: ; 3d0ea
|
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
|
2015-11-07 18:04:54 -08:00
|
|
|
call DoOthersShareExperience
|
2013-12-17 22:11:06 -08:00
|
|
|
pop de
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nz, .play_music
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, wPayDayMoney
|
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
|
|
|
|
call IsJohtoGymLeader
|
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
|
|
|
|
; 3d123
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; These functions check if the current opponent is a gym leader or one of a
|
|
|
|
; few other special trainers.
|
|
|
|
|
|
|
|
; Note: KantoGymLeaders is a subset of JohtoGymLeaders. If you wish to
|
|
|
|
; differentiate between the two, call IsKantoGymLeader first.
|
|
|
|
|
|
|
|
; The Lance and Red entries are unused for music checks; those trainers are
|
|
|
|
; accounted for elsewhere.
|
|
|
|
|
|
|
|
IsKantoGymLeader: ; 0x3d123
|
|
|
|
ld hl, KantoGymLeaders
|
|
|
|
jr IsGymLeaderCommon
|
|
|
|
|
|
|
|
IsJohtoGymLeader: ; 0x3d128
|
|
|
|
ld hl, JohtoGymLeaders
|
|
|
|
IsGymLeaderCommon:
|
|
|
|
push de
|
|
|
|
ld a, [OtherTrainerClass]
|
|
|
|
ld de, $0001
|
|
|
|
call IsInArray
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 0x3d137
|
|
|
|
|
|
|
|
JohtoGymLeaders:
|
|
|
|
db FALKNER
|
|
|
|
db WHITNEY
|
|
|
|
db BUGSY
|
|
|
|
db MORTY
|
|
|
|
db PRYCE
|
|
|
|
db JASMINE
|
|
|
|
db CHUCK
|
|
|
|
db CLAIR
|
|
|
|
db WILL
|
|
|
|
db BRUNO
|
|
|
|
db KAREN
|
|
|
|
db KOGA
|
|
|
|
; fallthrough
|
|
|
|
; these two entries are unused
|
|
|
|
db CHAMPION
|
|
|
|
db RED
|
|
|
|
; fallthrough
|
|
|
|
KantoGymLeaders:
|
|
|
|
db BROCK
|
|
|
|
db MISTY
|
|
|
|
db LT_SURGE
|
|
|
|
db ERIKA
|
|
|
|
db JANINE
|
|
|
|
db SABRINA
|
|
|
|
db BLAINE
|
|
|
|
db BLUE
|
2015-10-19 07:23:58 -07:00
|
|
|
db -1
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
HandlePlayerMonFaint: ; 3d14e
|
|
|
|
call FaintYourPokemon
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6f7], a
|
2015-11-10 16:51:13 -08:00
|
|
|
call PlayerMonFaintHappinessMod
|
2015-09-09 16:27:07 -07:00
|
|
|
call CheckPlayerPartyForFitPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, d
|
|
|
|
and a
|
|
|
|
jp z, LostBattle
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2015-10-19 13:49:29 -07:00
|
|
|
jr nz, .notfainted
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3ce01
|
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
|
|
|
|
ld [BattleEnded], a
|
|
|
|
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
|
|
|
|
ld [BattleEnded], a
|
|
|
|
ret
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
.switch
|
|
|
|
call ForcePlayerMonChoice
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2015-09-06 14:38:01 -07:00
|
|
|
jp c, WildFled_EnemyFled_LinkBattleCanceled
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3cf4a
|
2015-09-06 14:38:01 -07:00
|
|
|
jp z, WildFled_EnemyFled_LinkBattleCanceled
|
2013-12-31 01:09:00 -08:00
|
|
|
jp Function3cdca
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3d1aa
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
PlayerMonFaintHappinessMod: ; 3d1aa
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld c, a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld hl, wBattleParticipantsNotFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $0
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FlagPredef
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus3
|
2014-06-23 12:47:07 -07:00
|
|
|
res SUBSTATUS_IN_LOOP, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [Danger], a
|
|
|
|
ld hl, PlayerDamageTaken
|
|
|
|
ld [hli], a
|
|
|
|
ld [hl], a
|
|
|
|
ld [BattleMonStatus], a
|
|
|
|
call UpdateBattleMonInParty
|
2015-10-12 09:33:24 -07:00
|
|
|
ld c, HAPPINESS_FAINTED
|
|
|
|
; If TheirLevel > (YourLevel + 30), use a different parameter
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleMonLevel]
|
2015-10-12 09:33:24 -07:00
|
|
|
add 30
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
|
|
|
ld a, [EnemyMonLevel]
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld [CurPartyMon], a
|
|
|
|
callab ChangeHappiness
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2015-10-12 09:33:24 -07:00
|
|
|
and %11000000
|
2013-12-17 22:11:06 -08:00
|
|
|
add $1
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wBattleResult], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc6f7]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret z
|
2015-11-10 16:51:13 -08:00
|
|
|
ret ; ??????????
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3d1f8
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
AskUseNextPokemon: ; 3d1f8
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07: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
|
2013-12-17 22:11:06 -08: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-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
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-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2015-11-07 18:04:54 -08:00
|
|
|
cp $1 ; YES
|
|
|
|
jr z, .loop
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, PartyMon1Speed
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, EnemyMonSpeed
|
2015-09-09 16:27:07 -07:00
|
|
|
jp TryToRunAwayFromBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3d227
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
ForcePlayerMonChoice: ; 3d227
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-11-11 13:11:08 -08:00
|
|
|
call LoadStandardMenuDataHeader
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3d2f7
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3e8e4
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip_link
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2015-11-10 16:51:13 -08:00
|
|
|
jr c, .enemy_fainted_mobile_error
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
.enemy_fainted_mobile_error
|
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
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
call WaitBGMap
|
|
|
|
call ClearSGB
|
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
|
|
|
|
ld a, [CurBattleMon]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [LastPlayerMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurBattleMon], 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-07-15 12:48:44 -07:00
|
|
|
call WriteBackup
|
2013-12-17 22:11:06 -08:00
|
|
|
call ClearSGB
|
2015-09-09 16:27:07 -07:00
|
|
|
call SetPalettes
|
2015-09-06 14:38:01 -07:00
|
|
|
call SendOutPkmnText
|
2014-01-01 05:09:15 -08:00
|
|
|
call NewBattleMonStatus
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
call SendOutPlayerMon
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07: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
|
|
|
|
; 3d2b3
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
PlayerPartyMonEntrance: ; 3d2b3
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [LastPlayerMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurBattleMon], 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
|
2015-09-06 14:38:01 -07:00
|
|
|
call SendOutPkmnText
|
2014-01-01 05:09:15 -08:00
|
|
|
call NewBattleMonStatus
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
call SendOutPlayerMon
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07: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
|
|
|
; 3d2e0
|
|
|
|
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
CheckMobileBattleError: ; 3d2e0
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
|
|
|
cp LINK_MOBILE
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nz, .not_mobile ; It's not a mobile battle
|
2015-09-06 14:38:01 -07:00
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wcd2b]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .not_mobile
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
|
|
; We have a mobile battle and something else happened
|
2013-12-17 22:11:06 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.not_mobile
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 3d2f1
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
IsMobileBattle: ; 3d2f1
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
|
|
|
cp LINK_MOBILE
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3d2f7
|
|
|
|
|
|
|
|
Function3d2f7: ; 3d2f7
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
2015-11-11 13:11:08 -08:00
|
|
|
Function3d2fa: ; switch to fullscreen menu?
|
2013-12-17 22:11:06 -08:00
|
|
|
callba Function5004f
|
|
|
|
callba Function50405
|
|
|
|
callba Function8e85
|
|
|
|
callba Function503e0
|
|
|
|
ret
|
|
|
|
; 3d313
|
|
|
|
|
|
|
|
Function3d313: ; 3d313
|
|
|
|
callba WritePartyMenuTilemap
|
|
|
|
callba PrintPartyMenuText
|
|
|
|
call WaitBGMap
|
2015-09-09 16:27:07 -07:00
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
call DelayFrame
|
|
|
|
ret
|
|
|
|
; 3d329
|
|
|
|
|
|
|
|
Function3d329: ; 3d329
|
2014-06-17 11:58:11 -07:00
|
|
|
call IsMobileBattle
|
|
|
|
jr z, .mobile
|
2013-12-17 22:11:06 -08:00
|
|
|
callba PartyMenuSelect
|
|
|
|
ret
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
.mobile
|
2013-12-17 22:11:06 -08:00
|
|
|
callba Function100cb5
|
|
|
|
ret
|
|
|
|
; 3d33c
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
PickPartyMonInBattle: ; 3d33c
|
2014-06-17 11:58:11 -07:00
|
|
|
.loop
|
2014-01-01 05:09:15 -08:00
|
|
|
ld a, $2 ; Which PKMN?
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [PartyMenuActionText], a
|
|
|
|
call Function3d313
|
|
|
|
call Function3d329
|
|
|
|
ret c
|
2015-09-06 14:38:01 -07:00
|
|
|
call CheckIfPartyHasPkmnToBattleWith
|
2014-06-17 11:58:11 -07:00
|
|
|
jr z, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 3d34f
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
SwitchMonAlreadyOut: ; 3d34f
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, CurBattleMon
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
cp [hl]
|
2014-01-01 05:09:15 -08:00
|
|
|
jr nz, .notout
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_PkmnIsAlreadyOut
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
.notout
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 3d362
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ForcePickPartyMonInBattle: ; 3d362
|
|
|
|
; Can't back out.
|
|
|
|
|
|
|
|
.pick
|
|
|
|
call PickPartyMonInBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
ret nc
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
ret c
|
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
|
|
|
; 3d375
|
|
|
|
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
PickSwitchMonInBattle: ; 3d375
|
|
|
|
.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
|
|
|
|
; 3d380
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ForcePickSwitchMonInBattle: ; 3d380
|
|
|
|
; Can't back out.
|
|
|
|
|
|
|
|
.pick
|
|
|
|
call ForcePickPartyMonInBattle
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
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
|
|
|
|
; 3d38e
|
|
|
|
|
|
|
|
|
|
|
|
LostBattle: ; 3d38e
|
|
|
|
ld a, 1
|
|
|
|
ld [BattleEnded], a
|
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 0, a
|
2015-11-03 19:35:36 -08:00
|
|
|
jr nz, .battle_tower
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
ld a, [BattleType]
|
|
|
|
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
|
|
|
|
call Function3ebd8
|
|
|
|
|
|
|
|
ld c, 40
|
|
|
|
call DelayFrames
|
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc2cc]
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 0, 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
|
|
|
.battle_tower
|
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
|
|
|
|
call Function3ebd8
|
|
|
|
|
|
|
|
ld c, 40
|
|
|
|
call DelayFrames
|
|
|
|
|
|
|
|
call EmptyBattleTextBox
|
|
|
|
ld c, 2
|
2015-11-03 19:35:36 -08:00
|
|
|
callba BattleTowerText
|
2015-11-10 20:23:28 -08:00
|
|
|
call WaitPressAorB_BlinkCursor
|
2013-12-17 22:11:06 -08:00
|
|
|
call ClearTileMap
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
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
|
|
|
|
|
|
|
|
; Greyscale
|
2015-11-16 13:01:45 -08:00
|
|
|
ld b, SCGB_00
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetSGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
jr .end
|
|
|
|
|
|
|
|
.LostLinkBattle
|
|
|
|
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]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $c0
|
|
|
|
add 2
|
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-17 11:58:11 -07:00
|
|
|
call IsMobileBattle
|
2015-11-03 19:35:36 -08:00
|
|
|
jr z, .mobile
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2014-06-18 00:55:44 -07:00
|
|
|
.text
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
|
|
|
|
.end
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-03 19:35:36 -08:00
|
|
|
.mobile
|
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
|
|
|
|
call Function3ebd8
|
|
|
|
|
|
|
|
ld c, 40
|
|
|
|
call DelayFrames
|
|
|
|
|
|
|
|
ld c, $3
|
|
|
|
callba Function4ea0a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3d432
|
|
|
|
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
EnemyMonFaintedAnimation: ; 3d432
|
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
|
|
|
; 3d43b
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
PlayerMonFaintedAnimation: ; 3d43b
|
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
|
|
|
; 3d444
|
|
|
|
|
2015-10-19 13:49:29 -07:00
|
|
|
MonFaintedAnimation: ; 3d444
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wcfbe]
|
2013-12-17 22:11:06 -08:00
|
|
|
push af
|
|
|
|
set 6, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfbe], a
|
2015-10-19 13:49:29 -07:00
|
|
|
ld b, 7
|
|
|
|
|
|
|
|
.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
|
|
|
|
|
|
|
|
.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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfbe], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3d488
|
|
|
|
|
|
|
|
.Spaces
|
|
|
|
db " @"
|
|
|
|
; 3d490
|
|
|
|
|
|
|
|
|
|
|
|
Function3d490: ; 3d490
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [hMapObjectIndexBuffer], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, a
|
|
|
|
.asm_3d493
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
ld b, $7
|
|
|
|
.asm_3d497
|
|
|
|
push hl
|
|
|
|
call Function3d4ae
|
|
|
|
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
|
|
|
|
jr nz, .asm_3d497
|
|
|
|
ld c, 2
|
|
|
|
call DelayFrames
|
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
dec c
|
|
|
|
jr nz, .asm_3d493
|
|
|
|
ret
|
|
|
|
; 3d4ae
|
|
|
|
|
|
|
|
Function3d4ae: ; 3d4ae
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [hMapObjectIndexBuffer]
|
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
|
|
|
|
; 3d4c3
|
|
|
|
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
ForceEnemySwitch: ; 3d4c3
|
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
|
2015-09-11 19:21:00 -07:00
|
|
|
call LoadEnemyPkmnToSwitchTo
|
2015-11-10 16:51:13 -08:00
|
|
|
call ClearEnemyMonBox
|
2014-01-01 05:09:15 -08:00
|
|
|
call NewEnemyMonStatus
|
|
|
|
call ResetEnemyStatLevels
|
2015-08-23 06:09:56 -07:00
|
|
|
call Function_SetEnemyPkmnAndSendOutAnimation
|
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
|
|
|
|
; 3d4e1
|
|
|
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
EnemySwitch: ; 3d4e1
|
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
|
2015-09-11 19:21:00 -07:00
|
|
|
call FindPkmnInOTPartyToSwitchIntoBattle
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip
|
|
|
|
; 'b' contains the PartyNr of the Pkmn the AI will switch to
|
2015-09-11 19:21:00 -07:00
|
|
|
call LoadEnemyPkmnToSwitchTo
|
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
|
2015-08-23 06:09:56 -07:00
|
|
|
call Function_BattleTextEnemySentOut
|
|
|
|
call Function_SetEnemyPkmnAndSendOutAnimation
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6fc], a
|
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
inc a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [wEnemyIsSwitching], a
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2015-11-07 18:04:54 -08:00
|
|
|
jp PlayerSwitch
|
2013-12-31 01:09:00 -08:00
|
|
|
; 3d517
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
EnemySwitch_SetMode: ; 3d517
|
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
|
2015-09-11 19:21:00 -07:00
|
|
|
call FindPkmnInOTPartyToSwitchIntoBattle
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip
|
2015-09-11 19:21:00 -07:00
|
|
|
; 'b' contains the PartyNr of the Pkmn the AI will switch to
|
|
|
|
call LoadEnemyPkmnToSwitchTo
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, 1
|
|
|
|
ld [wEnemyIsSwitching], a
|
2015-11-10 16:51:13 -08:00
|
|
|
call ClearEnemyMonBox
|
2015-08-23 06:09:56 -07:00
|
|
|
call Function_BattleTextEnemySentOut
|
|
|
|
jp Function_SetEnemyPkmnAndSendOutAnimation
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3d533
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
CheckWhetherSwitchmonIsPredetermined: ; 3d533
|
2015-09-11 19:21:00 -07:00
|
|
|
; returns carry if: ???
|
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
|
2015-11-06 06:04:27 -08:00
|
|
|
jr z, .check_wd264
|
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
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
.check_wd264
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd264]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
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
|
|
|
|
; 3d557
|
|
|
|
|
2015-09-11 19:21:00 -07:00
|
|
|
ResetEnemyBattleVars: ; 3d557
|
|
|
|
; and draw empty TextBox
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [LastEnemyCounterMove], a
|
|
|
|
ld [LastPlayerCounterMove], a
|
|
|
|
ld [LastEnemyMove], a
|
|
|
|
ld [CurEnemyMove], a
|
|
|
|
dec a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6e6], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $8
|
|
|
|
call Function3d490
|
|
|
|
call EmptyBattleTextBox
|
2015-11-11 13:11:08 -08:00
|
|
|
jp LoadStandardMenuDataHeader
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3d57a
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
ResetBattleParticipants: ; 3d57a
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld [wBattleParticipantsNotFainted], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6fc], a
|
2015-11-07 18:04:54 -08:00
|
|
|
AddBattleParticipant: ; 3d581
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
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
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FlagPredef
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wc6fc
|
2014-06-16 11:20:01 -07:00
|
|
|
predef_jump FlagPredef
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3d599
|
|
|
|
|
2015-09-11 19:21:00 -07:00
|
|
|
FindPkmnInOTPartyToSwitchIntoBattle: ; 3d599
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $ff
|
|
|
|
ld a, $1
|
|
|
|
ld [Buffer1], a
|
|
|
|
ld [Buffer2], a
|
|
|
|
.asm_3d5a3
|
|
|
|
ld hl, Buffer1
|
|
|
|
sla [hl]
|
|
|
|
inc hl
|
|
|
|
sla [hl]
|
|
|
|
inc b
|
|
|
|
ld a, [OTPartyCount]
|
|
|
|
cp b
|
|
|
|
jp z, Function3d672
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
cp b
|
|
|
|
jr z, .asm_3d5d0
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, OTPartyMon1HP
|
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
|
|
|
|
jr z, .asm_3d5d0
|
2015-09-11 19:21:00 -07:00
|
|
|
call LookUpTheEffectivenessOfEveryMove
|
|
|
|
call IsThePlayerPkmnTypesEffectiveAgainstOTPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
jr .asm_3d5a3
|
|
|
|
|
|
|
|
.asm_3d5d0
|
|
|
|
ld hl, Buffer2
|
|
|
|
set 0, [hl]
|
|
|
|
jr .asm_3d5a3
|
|
|
|
; 3d5d7
|
|
|
|
|
2015-09-11 19:21:00 -07:00
|
|
|
LookUpTheEffectivenessOfEveryMove: ; 3d5d7
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, OTPartyMon1Moves
|
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
|
2015-11-06 17:55:16 -08:00
|
|
|
callab BattleCheckTypeMatchup
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
2015-09-11 19:21:00 -07:00
|
|
|
ld a, [wd265] ; Get The Effectiveness Modifier
|
2014-06-18 00:55:44 -07:00
|
|
|
cp 10 + 1 ; 1.0 + 0.1
|
|
|
|
jr c, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, Buffer1
|
|
|
|
set 0, [hl]
|
|
|
|
ret
|
2014-06-18 00:55:44 -07:00
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3d618
|
|
|
|
|
2015-09-11 19:21:00 -07:00
|
|
|
IsThePlayerPkmnTypesEffectiveAgainstOTPkmn: ; 3d618
|
|
|
|
; Calculates the effectiveness of the types of the PlayerPkmn
|
|
|
|
; against the OTPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
|
|
|
ld hl, OTPartyCount
|
|
|
|
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
|
2014-01-05 04:28:55 -08:00
|
|
|
ld hl, BaseData + 7 ; type
|
|
|
|
ld bc, $20
|
2013-12-17 22:11:06 -08:00
|
|
|
call AddNTimes
|
2014-06-23 12:47:07 -07:00
|
|
|
ld de, EnemyMonType
|
2014-01-05 04:28:55 -08:00
|
|
|
ld bc, 2
|
|
|
|
ld a, BANK(BaseData)
|
2013-12-17 22:11:06 -08:00
|
|
|
call FarCopyBytes
|
|
|
|
ld a, [BattleMonType1]
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [wPlayerMoveStruct + MOVE_TYPE], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call SetPlayerTurn
|
2015-11-06 17:55:16 -08:00
|
|
|
callab BattleCheckTypeMatchup
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd265]
|
2014-06-23 12:47:07 -07:00
|
|
|
cp 10 + 1 ; 1.0 + 0.1
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nc, .asm_3d663
|
|
|
|
ld a, [BattleMonType2]
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [wPlayerMoveStruct + MOVE_TYPE], a
|
2015-11-06 17:55:16 -08:00
|
|
|
callab BattleCheckTypeMatchup
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd265]
|
2014-06-23 12:47:07 -07:00
|
|
|
cp 10 + 1 ; 1.0 + 0.1
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nc, .asm_3d663
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3d663
|
|
|
|
pop bc
|
|
|
|
ld hl, Buffer1
|
|
|
|
bit 0, [hl]
|
|
|
|
jr nz, .asm_3d66f
|
|
|
|
inc hl
|
|
|
|
set 0, [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3d66f
|
|
|
|
res 0, [hl]
|
|
|
|
ret
|
|
|
|
; 3d672
|
|
|
|
|
|
|
|
Function3d672: ; 3d672
|
|
|
|
.asm_3d672
|
|
|
|
ld hl, Buffer1
|
|
|
|
sla [hl]
|
|
|
|
inc hl
|
|
|
|
sla [hl]
|
|
|
|
jr nc, .asm_3d672
|
|
|
|
ld a, [OTPartyCount]
|
|
|
|
ld b, a
|
|
|
|
ld c, [hl]
|
|
|
|
.asm_3d681
|
|
|
|
sla c
|
|
|
|
jr nc, .asm_3d68a
|
|
|
|
dec b
|
|
|
|
jr z, .asm_3d6a7
|
|
|
|
jr .asm_3d681
|
|
|
|
|
|
|
|
.asm_3d68a
|
|
|
|
ld a, [Buffer1]
|
|
|
|
and a
|
|
|
|
jr z, .asm_3d69a
|
|
|
|
ld b, $ff
|
|
|
|
ld c, a
|
|
|
|
.asm_3d693
|
|
|
|
inc b
|
|
|
|
sla c
|
|
|
|
jr nc, .asm_3d693
|
|
|
|
jr .asm_3d6c9
|
|
|
|
|
|
|
|
.asm_3d69a
|
|
|
|
ld b, $ff
|
|
|
|
ld a, [Buffer2]
|
|
|
|
ld c, a
|
|
|
|
.asm_3d6a0
|
|
|
|
inc b
|
|
|
|
sla c
|
|
|
|
jr c, .asm_3d6a0
|
|
|
|
jr .asm_3d6c9
|
|
|
|
|
|
|
|
.asm_3d6a7
|
|
|
|
ld a, [OTPartyCount]
|
|
|
|
ld b, a
|
|
|
|
call BattleRandom
|
|
|
|
and $7
|
|
|
|
cp b
|
|
|
|
jr nc, .asm_3d6a7
|
|
|
|
ld b, a
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
cp b
|
|
|
|
jr z, .asm_3d6a7
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, OTPartyMon1HP
|
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
|
|
|
|
jr z, .asm_3d6a7
|
|
|
|
|
|
|
|
.asm_3d6c9
|
|
|
|
ret
|
|
|
|
; 3d6ca
|
|
|
|
|
2015-09-11 19:21:00 -07:00
|
|
|
LoadEnemyPkmnToSwitchTo: ; 3d6ca
|
|
|
|
; 'b' contains the PartyNr of the Pkmn the AI will switch to
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, b
|
|
|
|
ld [CurPartyMon], a
|
|
|
|
ld hl, OTPartyMon1Level
|
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [hl]
|
|
|
|
ld [CurPartyLevel], a
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
inc a
|
|
|
|
ld hl, OTPartyCount
|
|
|
|
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]
|
|
|
|
ld [TempEnemyMonSpecies], a
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
call LoadEnemyMon
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartySpecies]
|
2014-03-05 02:42:09 -08:00
|
|
|
cp UNOWN
|
2015-11-09 20:55:39 -08:00
|
|
|
jr nz, .skip_unown
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wdef4]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
2015-11-09 20:55:39 -08:00
|
|
|
jr nz, .skip_unown
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonDVs
|
2014-06-16 11:20:01 -07:00
|
|
|
predef GetUnownLetter
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [UnownLetter]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wdef4], a
|
2015-11-09 20:55:39 -08:00
|
|
|
.skip_unown
|
2015-09-09 16:27:07 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
|
|
|
; 3d714
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
CheckWhetherToAskSwitch: ; 3d714
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd264]
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
2015-11-10 16:51:13 -08:00
|
|
|
jp z, .return_nc
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PartyCount]
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [Options]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit BATTLE_SHIFT, a
|
2015-11-10 16:51:13 -08:00
|
|
|
jr nz, .return_nc
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
push af
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld [CurPartyMon], a
|
2015-10-29 20:32:11 -07:00
|
|
|
callba CheckCurPartyMonFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
|
|
|
ld a, b
|
|
|
|
ld [CurPartyMon], 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
|
|
|
|
; 3d74b
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
OfferSwitch: ; 3d74b
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
push af
|
2015-07-15 12:48:44 -07:00
|
|
|
callab Battle_GetTrainerName
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, BattleText_EnemyIsAboutToUseWillPlayerChangePkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
lb bc, 1, 7
|
|
|
|
call PlaceYesNoBox
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nz, .said_no
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3d2f7
|
2014-01-01 05:09:15 -08:00
|
|
|
call PickSwitchMonInBattle
|
2015-11-07 18:04:54 -08:00
|
|
|
jr c, .canceled_switch
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [LastPlayerMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurBattleMon], a
|
|
|
|
call ClearPalettes
|
|
|
|
call DelayFrame
|
2015-11-10 16:51:13 -08:00
|
|
|
call _LoadHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
|
|
|
ld [CurPartyMon], a
|
|
|
|
xor a
|
|
|
|
ld [CurEnemyMove], a
|
|
|
|
ld [CurPlayerMove], a
|
|
|
|
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
|
|
|
|
ld [CurPartyMon], a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3d7a0
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
ClearEnemyMonBox: ; 3d7a0
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [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
|
|
|
; 3d7b8
|
|
|
|
|
2015-08-23 06:09:56 -07:00
|
|
|
Function_BattleTextEnemySentOut: ; 3d7b8
|
2015-07-15 12:48:44 -07:00
|
|
|
callab Battle_GetTrainerName
|
2015-08-23 06:09:56 -07:00
|
|
|
ld hl, BattleText_EnemySentOut
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
jp WaitBGMap
|
|
|
|
; 3d7c7
|
|
|
|
|
2015-08-23 06:09:56 -07:00
|
|
|
Function_SetEnemyPkmnAndSendOutAnimation: ; 3d7c7
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
ld [CurSpecies], a
|
|
|
|
call GetBaseData
|
2014-06-18 00:55:44 -07:00
|
|
|
ld a, OTPARTYMON
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
2015-10-08 11:53:39 -07:00
|
|
|
predef CopyPkmnToTempMon
|
2015-11-06 13:42:38 -08:00
|
|
|
call GetMonFrontpic
|
2014-06-18 00:55:44 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], 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
|
2014-06-18 00:55:44 -07:00
|
|
|
ld a, 1 ; shiny anim
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], 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
|
2015-11-07 06:48:32 -08:00
|
|
|
.not_shiny
|
2014-06-18 00:55:44 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld bc, TempMonSpecies
|
2015-11-07 06:48:32 -08:00
|
|
|
callba CheckFaintedFrzSlp
|
|
|
|
jr c, .skip_cry
|
2013-12-17 22:11:06 -08:00
|
|
|
callba CheckBattleScene
|
2015-11-07 06:48:32 -08:00
|
|
|
jr c, .cry_no_anim
|
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
|
|
|
|
predef AnimateFrontpic
|
|
|
|
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
|
|
|
|
ld [CryTracks], a
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
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
|
2014-06-16 22:52:59 -07:00
|
|
|
call UpdateEnemyHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ret
|
|
|
|
; 3d834
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
NewEnemyMonStatus: ; 3d834
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [LastEnemyCounterMove], a
|
|
|
|
ld [LastPlayerCounterMove], a
|
|
|
|
ld [LastEnemyMove], a
|
|
|
|
ld hl, EnemySubStatus1
|
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
|
|
|
|
ld [EnemyDisableCount], a
|
|
|
|
ld [EnemyFuryCutterCount], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [EnemyProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld [wEnemyRageCounter], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [EnemyDisabledMove], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [EnemyTurnsTaken], a
|
|
|
|
ld hl, PlayerSubStatus5
|
2014-06-13 22:53:20 -07:00
|
|
|
res SUBSTATUS_CANT_RUN, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3d867
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ResetEnemyStatLevels: ; 3d867
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, BASE_STAT_LEVEL
|
|
|
|
ld b, NUM_LEVEL_STATS
|
2014-01-01 05:09:15 -08:00
|
|
|
ld hl, EnemyStatLevels
|
|
|
|
.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
|
|
|
|
; 3d873
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
CheckPlayerPartyForFitPkmn: ; 3d873
|
|
|
|
; Has the player any Pkmn in his Party that can fight?
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PartyCount]
|
|
|
|
ld e, a
|
|
|
|
xor a
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, PartyMon1HP
|
2014-06-13 22:53:20 -07:00
|
|
|
ld bc, PartyMon2 - (PartyMon1 + 1)
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3d87e
|
|
|
|
or [hl]
|
|
|
|
inc hl
|
|
|
|
or [hl]
|
|
|
|
add hl, bc
|
|
|
|
dec e
|
|
|
|
jr nz, .asm_3d87e
|
|
|
|
ld d, a
|
|
|
|
ret
|
|
|
|
; 3d887
|
|
|
|
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
CheckIfPartyHasPkmnToBattleWith: ; 3d887
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
2014-02-22 21:37:09 -08:00
|
|
|
ld hl, PartyMon1HP
|
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
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd264]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr nz, .asm_3d8b1
|
|
|
|
ld hl, PartySpecies
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jr z, .asm_3d8ae
|
2015-09-06 14:38:01 -07:00
|
|
|
|
|
|
|
ld hl, BattleText_TheresNoWillToBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3d8ae
|
|
|
|
call StdBattleTextBox
|
|
|
|
|
|
|
|
.asm_3d8b1
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 3d8b3
|
|
|
|
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
TryToRunAwayFromBattle: ; 3d8b3
|
|
|
|
; Run away from battle, with or without item
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleType]
|
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
|
2014-06-13 22:53:20 -07:00
|
|
|
cp BATTLETYPE_SHINY
|
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
|
|
|
|
|
|
|
ld a, [EnemySubStatus5]
|
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
|
|
|
|
ld a, [BattleMonItem]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
2015-11-10 08:05:26 -08:00
|
|
|
callab 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
|
2013-12-17 22:11:06 -08: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-02-08 00:03:32 -08:00
|
|
|
ld a, [wd267]
|
2013-12-17 22:11:06 -08:00
|
|
|
inc a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd267], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hStringCmpString2 + 0], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hStringCmpString2 + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hStringCmpString1 + 0], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [de]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hStringCmpString1 + 1], a
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2015-09-06 14:38:01 -07:00
|
|
|
ld de, hStringCmpString2
|
|
|
|
ld hl, hStringCmpString1
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, $2
|
|
|
|
call StringCmp
|
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
|
|
|
|
ld [hMultiplicand], a
|
|
|
|
ld a, $20
|
|
|
|
ld [hMultiplier], a
|
|
|
|
call Multiply
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hProduct + 2]
|
|
|
|
ld [hDividend + 0], a
|
|
|
|
ld a, [hProduct + 3]
|
|
|
|
ld [hDividend + 1], a
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hStringCmpString1 + 0]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hStringCmpString1 + 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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $2
|
|
|
|
call Divide
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
2015-11-06 06:04:27 -08:00
|
|
|
jr nz, .can_escape
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd267]
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $1e
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
add b
|
2015-11-06 06:04:27 -08:00
|
|
|
ld [hQuotient + 2], a
|
|
|
|
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
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp b
|
2015-11-06 06:04:27 -08:00
|
|
|
jr nc, .can_escape
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd266], a
|
2015-09-09 16:27:07 -07: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
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $f
|
|
|
|
ld [CurMoveNum], a
|
|
|
|
xor a
|
|
|
|
ld [CurPlayerMove], a
|
|
|
|
call Function3e8e4
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
|
|
|
jr c, .mobile
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
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]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $c0
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
call WaitSFX
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
.mobile
|
2015-10-19 13:49:29 -07:00
|
|
|
call StopDangerSound
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wcd2a
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 4, [hl]
|
2015-11-08 16:09:36 -08:00
|
|
|
jr nz, .skip_link_error
|
2015-08-24 16:56:30 -07:00
|
|
|
ld hl, BattleText_LinkErrorBattleCanceled
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
.skip_link_error
|
2013-12-17 22:11:06 -08:00
|
|
|
call WaitSFX
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3da0d
|
|
|
|
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
InitBattleMon: ; 3da0d
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_SPECIES
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetPartyParamLocation
|
|
|
|
ld de, BattleMonSpecies
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, BattleMonDVs
|
2015-11-07 10:05:58 -08:00
|
|
|
ld bc, MON_PKRUS - MON_DVS
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 3
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, BattleMonLevel
|
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
|
|
|
|
ld a, [BattleMonSpecies]
|
|
|
|
ld [TempBattleMonSpecies], a
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
ld [CurSpecies], a
|
|
|
|
call GetBaseData
|
|
|
|
ld a, [BaseType1]
|
|
|
|
ld [BattleMonType1], a
|
|
|
|
ld a, [BaseType2]
|
|
|
|
ld [BattleMonType2], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, PartyMonNicknames
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
call SkipNames
|
|
|
|
ld de, BattleMonNick
|
2014-06-12 18:32:42 -07:00
|
|
|
ld bc, PKMN_NAME_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonAttack
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, PlayerStats
|
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
|
|
|
|
; 3da74
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BattleCheckPlayerShininess: ; 3da74
|
|
|
|
call GetPartyMonDVs
|
|
|
|
jr BattleCheckShininess
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BattleCheckEnemyShininess: ; 3da79
|
|
|
|
call GetEnemyMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BattleCheckShininess: ; 3da7c
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
callab CheckShininess
|
|
|
|
ret
|
|
|
|
; 3da85
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
GetPartyMonDVs: ; 3da85
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
|
|
|
ld hl, PartyMon1DVs
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
jp GetPartyLocation
|
|
|
|
; 3da97
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
GetEnemyMonDVs: ; 3da97
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemySubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wc6f2
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
|
|
|
ret z
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, OTPartyMon1DVs
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurOTMon]
|
|
|
|
jp GetPartyLocation
|
|
|
|
; 3dab1
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
ResetPlayerStatLevels: ; 3dab1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, BASE_STAT_LEVEL
|
|
|
|
ld b, NUM_LEVEL_STATS
|
2014-01-01 05:09:15 -08:00
|
|
|
ld hl, PlayerStatLevels
|
|
|
|
.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
|
|
|
|
; 3dabd
|
|
|
|
|
|
|
|
|
|
|
|
Function3dabd: ; 3dabd
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld hl, OTPartyMon1Species
|
|
|
|
call GetPartyLocation
|
|
|
|
ld de, EnemyMonSpecies
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, EnemyMonDVs
|
2015-11-07 10:05:58 -08:00
|
|
|
ld bc, MON_PKRUS - MON_DVS
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 3
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, EnemyMonLevel
|
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
|
|
|
|
ld a, [EnemyMonSpecies]
|
|
|
|
ld [CurSpecies], a
|
|
|
|
call GetBaseData
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, OTPartyMonNicknames
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
call SkipNames
|
|
|
|
ld de, EnemyMonNick
|
2014-06-12 18:32:42 -07:00
|
|
|
ld bc, PKMN_NAME_LENGTH
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonAttack
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, EnemyStats
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BaseType1
|
|
|
|
ld de, EnemyMonType1
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BaseStats
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, EnemyMonBaseStats
|
2014-06-12 18:32:42 -07:00
|
|
|
ld b, 5
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3db25
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_3db25
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurOTMon], a
|
|
|
|
ret
|
|
|
|
; 3db32
|
|
|
|
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
SwitchPlayerMon: ; 3db32
|
2013-12-17 22:11:06 -08:00
|
|
|
call ClearSprites
|
|
|
|
ld a, [CurBattleMon]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [LastPlayerMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurBattleMon], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
ret
|
|
|
|
; 3db5f
|
|
|
|
|
|
|
|
|
2015-11-07 06:48:32 -08:00
|
|
|
SendOutPlayerMon: ; 3db5f
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonDVs
|
2014-06-16 11:20:01 -07: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
|
|
|
|
ld [hBGMapMode], a
|
2015-11-06 11:45:10 -08:00
|
|
|
call GetMonBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hFillBox], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0d2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurMoveNum], a
|
|
|
|
ld [TypeModifier], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [wPlayerMoveStruct + MOVE_ANIM], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [LastEnemyCounterMove], a
|
|
|
|
ld [LastPlayerCounterMove], a
|
|
|
|
ld [LastPlayerMove], 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-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], a
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], 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
|
2015-11-07 06:48:32 -08:00
|
|
|
callba CheckFaintedFrzSlp
|
|
|
|
jr c, .statused
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $f0
|
|
|
|
ld [CryTracks], a
|
|
|
|
ld a, [CurPartySpecies]
|
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
|
2014-06-16 22:52:59 -07:00
|
|
|
call UpdatePlayerHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ret
|
|
|
|
; 3dbde
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
NewBattleMonStatus: ; 3dbde
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [LastEnemyCounterMove], a
|
|
|
|
ld [LastPlayerCounterMove], a
|
|
|
|
ld [LastPlayerMove], a
|
|
|
|
ld hl, PlayerSubStatus1
|
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
|
|
|
|
ld hl, PlayerUsedMoves
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 3
|
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
|
|
|
|
ld [PlayerDisableCount], a
|
|
|
|
ld [PlayerFuryCutterCount], a
|
2014-01-01 05:09:15 -08:00
|
|
|
ld [PlayerProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld [wPlayerRageCounter], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [DisabledMove], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [PlayerTurnsTaken], a
|
|
|
|
ld hl, EnemySubStatus5
|
2014-01-01 05:09:15 -08:00
|
|
|
res SUBSTATUS_CANT_RUN, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3dc18
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
BreakAttraction: ; 3dc18
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus1
|
2014-01-01 05:09:15 -08:00
|
|
|
res SUBSTATUS_IN_LOVE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus1
|
2014-01-01 05:09:15 -08:00
|
|
|
res SUBSTATUS_IN_LOVE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3dc23
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
SpikesDamage: ; 3dc23
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerScreens
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, BattleMonType
|
2014-06-16 22:52:59 -07:00
|
|
|
ld bc, UpdatePlayerHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2014-01-01 05:09:15 -08:00
|
|
|
jr z, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyScreens
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, EnemyMonType
|
2014-06-16 22:52:59 -07: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!"
|
2013-12-17 22:11:06 -08: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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp [hl]
|
|
|
|
; 3dc5b
|
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
PursuitSwitch: ; 3dc5b
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
push af
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, DoPlayerTurn
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [LastPlayerMon]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurBattleMon], a
|
2015-11-05 16:13:09 -08:00
|
|
|
.do_turn
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, BANK(DoPlayerTurn)
|
|
|
|
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
|
|
|
|
ld [CurBattleMon], a
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-05 16:13:09 -08:00
|
|
|
jr z, .check_enemy_fainted
|
2014-06-12 18:32:42 -07:00
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [LastPlayerMon]
|
2015-07-20 22:52:46 -07:00
|
|
|
call UpdateBattleMon
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonHP
|
|
|
|
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 a, $f0
|
|
|
|
ld [CryTracks], a
|
|
|
|
ld a, [BattleMonSpecies]
|
2014-07-18 10:25:03 -07:00
|
|
|
call PlayStereoCry
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc71a]
|
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
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FlagPredef
|
2015-10-19 13:49:29 -07:00
|
|
|
call PlayerMonFaintedAnimation
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, BattleText_PkmnFainted
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, BattleText_EnemyPkmnFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
.done_fainted
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2015-11-05 16:13:09 -08:00
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 3dce6
|
|
|
|
|
|
|
|
Function3dce6: ; 3dce6
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
push af
|
|
|
|
xor a
|
|
|
|
ld [hBattleTurn], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], 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
|
|
|
|
ld [hBattleTurn], a
|
|
|
|
ret
|
|
|
|
; 3dcf9
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleHealingItems: ; 3dcf9
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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-08 10:27:26 -08:00
|
|
|
call HandleStatusHealingItem
|
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-08 10:27:26 -08:00
|
|
|
jp HandleStatusHealingItem
|
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-08 10:27:26 -08:00
|
|
|
call HandleStatusHealingItem
|
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-08 10:27:26 -08:00
|
|
|
jp HandleStatusHealingItem
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3dd2f
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleHPHealingItem: ; 3dd2f
|
2013-12-17 22:11:06 -08:00
|
|
|
callab GetOpponentItem
|
|
|
|
ld a, b
|
|
|
|
cp $1
|
|
|
|
ret nz
|
2014-06-12 18:32:42 -07:00
|
|
|
ld de, EnemyMonHP + 1
|
|
|
|
ld hl, EnemyMonMaxHP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-08 10:27:26 -08:00
|
|
|
jr z, .go
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, BattleMonHP + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleMonMaxHP
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
.go
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
|
|
|
ld a, [de]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ec], a
|
2013-12-17 22:11:06 -08:00
|
|
|
add a
|
|
|
|
ld c, a
|
|
|
|
dec de
|
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ed], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [Buffer2], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [Buffer1], a
|
|
|
|
ld a, [de]
|
|
|
|
add c
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ee], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, a
|
|
|
|
dec de
|
|
|
|
ld a, [de]
|
|
|
|
adc $0
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ef], 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]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ef], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd1ee], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
.okay
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd1ef]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd1ee]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [de], a
|
|
|
|
ld a, [hBattleTurn]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd10a], 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-02-08 00:03:32 -08:00
|
|
|
ld [wd10a], a
|
2015-11-07 05:05:57 -08:00
|
|
|
predef AnimateHPBar
|
2015-11-06 19:36:06 -08:00
|
|
|
UseOpponentItem:
|
2013-12-17 22:11:06 -08:00
|
|
|
call RefreshBattleHuds
|
|
|
|
callab GetOpponentItem
|
|
|
|
ld a, [hl]
|
2015-11-10 08:05:26 -08:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetItemName
|
2015-11-10 08:05:26 -08:00
|
|
|
callab ConsumeHeldItem
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, RecoveredUsingText
|
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3ddc8
|
|
|
|
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
ItemRecoveryAnim: ; 3ddc8
|
2013-12-17 22:11:06 -08:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
call EmptyBattleTextBox
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, RECOVER
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [FXAnimIDLo], a
|
2014-06-13 21:18:14 -07:00
|
|
|
call SwitchTurnCore
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [FXAnimIDHi], a
|
2014-06-16 11:20:01 -07: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
|
|
|
|
; 3dde9
|
|
|
|
|
2015-11-06 19:36:06 -08:00
|
|
|
UseHeldStatusHealingItem: ; 3dde9
|
2013-12-17 22:11:06 -08:00
|
|
|
callab GetOpponentItem
|
|
|
|
ld hl, .Statuses
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
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
|
2015-11-06 17:55:16 -08:00
|
|
|
ld a, 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
|
|
|
|
; 3de44
|
|
|
|
|
|
|
|
.Statuses ; 3de44
|
|
|
|
db HELD_HEAL_POISON, 1 << PSN
|
|
|
|
db HELD_HEAL_FREEZE, 1 << FRZ
|
|
|
|
db HELD_HEAL_BURN, 1 << BRN
|
|
|
|
db HELD_HEAL_SLEEP, SLP
|
|
|
|
db HELD_HEAL_PARALYZE, 1 << PAR
|
2015-11-08 10:27:26 -08:00
|
|
|
db HELD_HEAL_STATUS, ALL_STATUS
|
2013-12-17 22:11:06 -08:00
|
|
|
db $ff
|
|
|
|
; 3de51
|
|
|
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleStatusHealingItem: ; 3de51
|
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
|
|
|
|
callab GetOpponentItem
|
|
|
|
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]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, BattleText_0x80dab
|
|
|
|
call StdBattleTextBox
|
|
|
|
ld a, [hBattleTurn]
|
|
|
|
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
|
|
|
|
; 3de97
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
HandleStatBoostingHeldItems: ; 3de97
|
|
|
|
; The effects handled here are not used in-game.
|
2015-11-06 06:04:27 -08:00
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
2015-11-06 06:04:27 -08:00
|
|
|
jr z, .player_1
|
2015-11-08 10:27:26 -08:00
|
|
|
call .DoEnemy
|
|
|
|
jp .DoPlayer
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
.player_1
|
2015-11-08 10:27:26 -08:00
|
|
|
call .DoPlayer
|
|
|
|
jp .DoEnemy
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3dea9
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
.DoEnemy: ; 3dea9
|
|
|
|
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
|
|
|
; 3deb1
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
.DoPlayer: ; 3deb1
|
|
|
|
call GetOTPartymonItem
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-11-08 10:27:26 -08:00
|
|
|
.HandleItem: ; 3deb6
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hBattleTurn], a
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld a, [bc]
|
|
|
|
ld b, a
|
2015-11-10 08:05:26 -08:00
|
|
|
callab GetItemHeldEffect
|
2015-11-08 10:27:26 -08:00
|
|
|
ld hl, .StatUpItems
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
cp $ff
|
2015-11-08 10:27:26 -08:00
|
|
|
jr z, .finish
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
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]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
dec hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
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
|
|
|
|
ld a, [FailedMessage]
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
2015-11-06 17:55:16 -08:00
|
|
|
callab 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
|
|
|
|
; 3defc
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
.StatUpItems
|
2015-11-06 11:45:10 -08:00
|
|
|
dbw HELD_ATTACK_UP, BattleCommand_AttackUp
|
|
|
|
dbw HELD_DEFENSE_UP, BattleCommand_DefenseUp
|
|
|
|
dbw HELD_SPEED_UP, BattleCommand_SpeedUp
|
|
|
|
dbw HELD_SP_ATTACK_UP, BattleCommand_SpecialAttackUp
|
|
|
|
dbw HELD_SP_DEFENSE_UP, BattleCommand_SpecialDefenseUp
|
|
|
|
dbw HELD_ACCURACY_UP, BattleCommand_AccuracyUp
|
|
|
|
dbw HELD_EVASION_UP, BattleCommand_EvasionUp
|
2013-12-17 22:11:06 -08:00
|
|
|
db $ff
|
|
|
|
; 3df12
|
|
|
|
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
GetPartymonItem: ; 3df12
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PartyMon1Item
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
ld bc, BattleMonItem
|
|
|
|
ret
|
|
|
|
; 3df1f
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
GetOTPartymonItem: ; 3df1f
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, OTPartyMon1Item
|
|
|
|
ld a, [CurOTMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
ld bc, EnemyMonItem
|
|
|
|
ret
|
|
|
|
; 3df2c
|
|
|
|
|
2015-11-08 10:27:26 -08:00
|
|
|
UpdateBattleHUDs: ; 3df2c
|
2013-12-17 22:11:06 -08:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
call DrawPlayerHUD
|
|
|
|
ld hl, PlayerHPPal
|
|
|
|
call SetHPPal
|
|
|
|
call CheckDanger
|
2014-06-16 22:52:59 -07:00
|
|
|
call DrawEnemyHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyHPPal
|
|
|
|
call SetHPPal
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 3df48
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-06-16 22:52:59 -07:00
|
|
|
UpdatePlayerHUD:: ; 3df48
|
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
|
|
|
|
; 3df58
|
|
|
|
|
|
|
|
DrawPlayerHUD: ; 3df58
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
|
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
|
|
|
|
|
|
|
|
callba DrawPlayerExpBar
|
|
|
|
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
2014-06-16 11:20:01 -07: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
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld hl, PartyMon1Exp + 2
|
|
|
|
call GetPartyLocation
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
|
|
|
|
hlcoord 10, 11
|
|
|
|
ld a, [TempMonLevel]
|
|
|
|
ld b, a
|
|
|
|
call FillInExpBar
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
; 3df98
|
|
|
|
|
|
|
|
UpdatePlayerHPPal: ; 3df98
|
|
|
|
ld hl, PlayerHPPal
|
|
|
|
jp Function3e12e
|
|
|
|
; 3df9e
|
|
|
|
|
|
|
|
CheckDanger: ; 3df9e
|
|
|
|
ld hl, BattleMonHP
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2014-06-13 21:18:14 -07:00
|
|
|
jr z, .no_danger
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc6fd]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
2014-06-13 21:18:14 -07:00
|
|
|
jr nz, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PlayerHPPal]
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, Danger
|
|
|
|
res 7, [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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, Danger
|
|
|
|
set 7, [hl]
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3dfbf
|
|
|
|
|
|
|
|
PrintPlayerHUD: ; 3dfbf
|
|
|
|
ld de, BattleMonNick
|
|
|
|
hlcoord 10, 7
|
|
|
|
call Function3e138
|
|
|
|
call PlaceString
|
|
|
|
|
|
|
|
push bc
|
|
|
|
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld hl, PartyMon1DVs
|
|
|
|
call GetPartyLocation
|
|
|
|
ld de, TempMonDVs
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
ld hl, BattleMonLevel
|
|
|
|
ld de, TempMonLevel
|
|
|
|
ld bc, $0011
|
|
|
|
call CopyBytes
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld hl, PartyMon1Species
|
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [hl]
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
ld [CurSpecies], a
|
|
|
|
call GetBaseData
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
dec hl
|
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
ld a, BREEDMON
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
|
|
|
callab GetGender
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, " "
|
2013-12-17 22:11:06 -08:00
|
|
|
jr c, .asm_3e013
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, "♂"
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nz, .asm_3e013
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, "♀"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3e013
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
ld de, BattleMonStatus
|
2015-11-03 06:45:25 -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 " "
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nz, .asm_3e02d
|
|
|
|
dec hl
|
|
|
|
|
|
|
|
.asm_3e02d
|
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
ld [TempMonLevel], a
|
|
|
|
jp PrintLevel
|
|
|
|
; 3e036
|
|
|
|
|
2014-06-16 22:52:59 -07:00
|
|
|
UpdateEnemyHUD:: ; 3e036
|
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
|
|
|
|
; 3e043
|
|
|
|
|
2014-06-16 22:52:59 -07:00
|
|
|
DrawEnemyHUD: ; 3e043
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
callba Function2c0c5
|
2014-06-16 22:52:59 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
ld [CurSpecies], a
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
call GetBaseData
|
|
|
|
ld de, EnemyMonNick
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 1, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3e138
|
|
|
|
call PlaceString
|
|
|
|
ld h, b
|
|
|
|
ld l, c
|
|
|
|
dec hl
|
2014-06-16 22:52:59 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, TempMonDVs
|
|
|
|
ld a, [EnemySubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2014-06-16 22:52:59 -07:00
|
|
|
jr z, .ok
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wc6f2
|
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
|
|
|
|
2015-10-07 18:27:32 -07:00
|
|
|
ld a, BREEDMON
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
|
|
|
callab GetGender
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, " "
|
2013-12-17 22:11:06 -08:00
|
|
|
jr c, .asm_3e09a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, "♂"
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nz, .asm_3e09a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, "♀"
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3e09a
|
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
|
|
|
|
ld de, EnemyMonStatus
|
2015-11-03 06:45:25 -08:00
|
|
|
predef PlaceNonFaintStatus
|
2013-12-17 22:11:06 -08:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
jr nz, .asm_3e0be
|
|
|
|
ld a, b
|
2014-06-16 22:52:59 -07:00
|
|
|
cp " "
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nz, .asm_3e0b5
|
|
|
|
dec hl
|
|
|
|
.asm_3e0b5
|
|
|
|
ld a, [EnemyMonLevel]
|
|
|
|
ld [TempMonLevel], a
|
|
|
|
call PrintLevel
|
|
|
|
.asm_3e0be
|
2014-06-16 22:52:59 -07:00
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hld]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
or [hl]
|
|
|
|
jr nz, .asm_3e0d1
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
jp .asm_3e11a
|
2014-06-16 22:52:59 -07:00
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
.asm_3e0d1
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [hMultiplicand], a
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, HP_BAR_LENGTH_PX
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hMultiplier], a
|
|
|
|
call Multiply
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonMaxHP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [hMultiplier], a
|
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
jr z, .asm_3e105
|
|
|
|
ld a, [hMultiplier]
|
|
|
|
srl b
|
|
|
|
rr a
|
|
|
|
srl b
|
|
|
|
rr a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
|
|
|
ld a, [hProduct + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
|
|
|
srl b
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hProduct + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
rr a
|
|
|
|
srl b
|
|
|
|
rr a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, b
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3e105
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 2]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDividend + 0], a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 3]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDividend + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $2
|
|
|
|
ld b, a
|
|
|
|
call Divide
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3e11a
|
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd10a], 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
|
|
|
|
; 3e127
|
|
|
|
|
2014-06-16 22:52:59 -07:00
|
|
|
UpdateEnemyHPPal: ; 3e127
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyHPPal
|
|
|
|
call Function3e12e
|
|
|
|
ret
|
|
|
|
; 3e12e
|
|
|
|
|
|
|
|
Function3e12e: ; 3e12e
|
|
|
|
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
|
|
|
; 3e138
|
|
|
|
|
|
|
|
Function3e138: ; 3e138
|
|
|
|
ret
|
|
|
|
; 3e139
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
BattleMenu: ; 3e139
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTempTileMapToTileMap
|
2014-06-16 22:52:59 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleType]
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
|
|
|
call UpdateBattleHuds
|
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07: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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleType]
|
2014-06-17 11:58:11 -07:00
|
|
|
cp BATTLETYPE_CONTEST
|
|
|
|
jr nz, .not_contest
|
|
|
|
callba ContestBattleMenu
|
|
|
|
jr .next
|
|
|
|
.not_contest
|
2014-06-16 22:52:59 -07:00
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
; Auto input: choose "ITEM"
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [InputType]
|
|
|
|
or a
|
2015-11-10 13:53:37 -08:00
|
|
|
jr z, .skip_dude_pack_select
|
2015-10-19 07:23:58 -07:00
|
|
|
callba _DudeAutoInput_DownA
|
2015-11-10 13:53:37 -08:00
|
|
|
.skip_dude_pack_select
|
2014-06-16 22:52:59 -07:00
|
|
|
|
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
|
|
|
|
ld [hBGMapMode], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0d2]
|
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
|
|
|
; 3e192
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
BattleMenu_Fight: ; 3e192
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd267], a
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
; 3e19b
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
LoadBattleMenu2: ; 3e19b
|
|
|
|
call IsMobileBattle
|
|
|
|
jr z, .mobile
|
2014-06-16 22:52:59 -07:00
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
callba LoadBattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
.mobile
|
2013-12-17 22:11:06 -08:00
|
|
|
callba Function100b12
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wcd2b]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret z
|
2014-06-16 22:52:59 -07:00
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wcd2a
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 4, [hl]
|
2014-06-17 11:58:11 -07:00
|
|
|
jr nz, .error
|
2015-08-24 16:56:30 -07:00
|
|
|
ld hl, BattleText_LinkErrorBattleCanceled
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
2014-06-16 22:52:59 -07:00
|
|
|
ld c, 60
|
2013-12-17 22:11:06 -08:00
|
|
|
call DelayFrames
|
2014-06-17 11:58:11 -07:00
|
|
|
.error
|
2013-12-17 22:11:06 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3e1c7
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
BattleMenu_Pack: ; 3e1c7
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
jp nz, ItemsCantBeUsed
|
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
2014-06-17 11:58:11 -07:00
|
|
|
jp nz, ItemsCantBeUsed
|
|
|
|
|
2015-11-11 13:11:08 -08:00
|
|
|
call LoadStandardMenuDataHeader
|
2014-06-17 11:58:11 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleType]
|
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
|
|
|
|
|
|
|
|
callba BattlePack
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0ec]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
callba Function107bb
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, POKE_BALL
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurItem], a
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurItem], a
|
|
|
|
call DoItemEffect
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
.got_item
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3e234
|
|
|
|
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
|
2015-11-06 11:45:10 -08:00
|
|
|
call GetMonBackpic
|
2015-11-06 13:42:38 -08:00
|
|
|
call GetMonFrontpic
|
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
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2014-06-17 11:58:11 -07:00
|
|
|
jp BattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3e22b
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
ItemsCantBeUsed: ; 3e22b
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_ItemsCantBeUsedHere
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
2014-06-17 11:58:11 -07:00
|
|
|
jp BattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3e234
|
|
|
|
|
|
|
|
Function3e234: ; 3e234
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc64e]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr nz, .asm_3e279
|
|
|
|
callab CheckItemPocket
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wItemAttributeParamBuffer]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $3
|
|
|
|
jr z, .asm_3e24a
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3e24a
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
2015-11-10 16:51:13 -08:00
|
|
|
call _LoadBattleFontsHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
call ClearSprites
|
|
|
|
ld a, [BattleType]
|
2014-06-13 22:53:20 -07:00
|
|
|
cp BATTLETYPE_TUTORIAL
|
2013-12-17 22:11:06 -08:00
|
|
|
jr z, .asm_3e25d
|
2015-11-06 11:45:10 -08:00
|
|
|
call GetMonBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3e25d
|
2015-11-06 13:42:38 -08:00
|
|
|
call GetMonFrontpic
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-11-04 11:02:11 -08:00
|
|
|
ld [MenuSelection2], 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
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2015-10-17 17:49:34 -07:00
|
|
|
call ResetTextRelatedRAM
|
2015-11-09 13:41:09 -08:00
|
|
|
call FinishBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3e279
|
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc64e], a
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $c0
|
2015-10-24 07:34:19 -07:00
|
|
|
ld [wBattleResult], a
|
2015-10-17 17:49:34 -07:00
|
|
|
call ResetTextRelatedRAM
|
2015-09-09 16:27:07 -07:00
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3e28d
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
BattleMenu_PKMN: ; 3e28d
|
2015-11-11 13:11:08 -08:00
|
|
|
call LoadStandardMenuDataHeader
|
2013-12-17 22:11:06 -08:00
|
|
|
Function3e290:
|
2015-07-20 00:51:52 -07:00
|
|
|
call ExitMenu
|
2015-11-11 13:11:08 -08:00
|
|
|
call LoadStandardMenuDataHeader
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
Function3e299:
|
|
|
|
call Function3d2fa
|
|
|
|
xor a
|
|
|
|
ld [PartyMenuActionText], a
|
|
|
|
call Function3d313
|
|
|
|
call Function3d329
|
|
|
|
jr c, .asm_3e2da
|
|
|
|
.asm_3e2a8
|
|
|
|
callba Function8ea4a
|
|
|
|
call Function3e2f5
|
|
|
|
jr c, .asm_3e2c8
|
|
|
|
call Function1bee
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
|
|
|
jp z, Function3e358
|
|
|
|
cp $2
|
|
|
|
jr z, .asm_3e2cf
|
|
|
|
cp $3
|
|
|
|
jr z, .asm_3e2da
|
|
|
|
jr .asm_3e2a8
|
|
|
|
|
|
|
|
.asm_3e2c8
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
jr c, .asm_3e2da
|
|
|
|
jr Function3e299
|
|
|
|
|
|
|
|
.asm_3e2cf
|
|
|
|
call Function3e308
|
2015-11-08 16:09:36 -08:00
|
|
|
call CheckMobileBattleError
|
2013-12-17 22:11:06 -08:00
|
|
|
jr c, .asm_3e2da
|
|
|
|
jp Function3e290
|
|
|
|
|
|
|
|
.asm_3e2da
|
|
|
|
call ClearSprites
|
|
|
|
call ClearPalettes
|
|
|
|
call DelayFrame
|
2015-11-10 16:51:13 -08:00
|
|
|
call _LoadHPBar
|
2015-07-15 12:48:44 -07:00
|
|
|
call WriteBackup
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
call ClearSGB
|
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
|
|
|
; 3e2f5
|
|
|
|
|
|
|
|
Function3e2f5: ; 3e2f5
|
2014-06-17 11:58:11 -07:00
|
|
|
call IsMobileBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
jr z, .asm_3e301
|
|
|
|
callba Function24e99
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3e301
|
|
|
|
callba Function100d22
|
|
|
|
ret
|
|
|
|
; 3e308
|
|
|
|
|
|
|
|
Function3e308: ; 3e308
|
|
|
|
call DisableLCD
|
2015-10-14 06:29:15 -07:00
|
|
|
ld hl, VTiles2 tile $31
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, VTiles0
|
|
|
|
ld bc, $0110
|
|
|
|
call CopyBytes
|
|
|
|
ld hl, VTiles2
|
2015-10-14 06:29:15 -07:00
|
|
|
ld de, VTiles0 tile $11
|
2013-12-17 22:11:06 -08:00
|
|
|
ld bc, $0310
|
|
|
|
call CopyBytes
|
|
|
|
call EnableLCD
|
|
|
|
call ClearSprites
|
|
|
|
call LowVolume
|
2015-10-07 18:27:32 -07:00
|
|
|
xor a ; PARTYMON
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
|
|
|
callba Function4dc7b
|
|
|
|
call MaxVolume
|
|
|
|
call DisableLCD
|
|
|
|
ld hl, VTiles0
|
2015-10-14 06:29:15 -07:00
|
|
|
ld de, VTiles2 tile $31
|
2013-12-17 22:11:06 -08:00
|
|
|
ld bc, $0110
|
|
|
|
call CopyBytes
|
2015-10-14 06:29:15 -07:00
|
|
|
ld hl, VTiles0 tile $11
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, VTiles2
|
|
|
|
ld bc, $0310
|
|
|
|
call CopyBytes
|
|
|
|
call EnableLCD
|
|
|
|
ret
|
|
|
|
; 3e358
|
|
|
|
|
|
|
|
|
|
|
|
Function3e358: ; 3e358
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld d, a
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
cp d
|
|
|
|
jr nz, .asm_3e36b
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_PkmnIsAlreadyOut
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
jp Function3e299
|
|
|
|
|
|
|
|
.asm_3e36b
|
2015-11-08 10:27:26 -08:00
|
|
|
ld a, [wPlayerWrapCount]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr nz, .asm_3e378
|
|
|
|
ld a, [EnemySubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_CANT_RUN, a
|
2013-12-17 22:11:06 -08:00
|
|
|
jr z, .asm_3e381
|
|
|
|
|
|
|
|
.asm_3e378
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_PkmnCantBeRecalled
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
jp Function3e299
|
|
|
|
|
|
|
|
.asm_3e381
|
2015-09-06 14:38:01 -07:00
|
|
|
call CheckIfPartyHasPkmnToBattleWith
|
2013-12-17 22:11:06 -08:00
|
|
|
jp z, Function3e299
|
|
|
|
ld a, [CurBattleMon]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [LastPlayerMon], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $2
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0ec], 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-07-15 12:48:44 -07:00
|
|
|
call WriteBackup
|
2013-12-17 22:11:06 -08:00
|
|
|
call ClearSGB
|
2015-09-09 16:27:07 -07:00
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurBattleMon], a
|
|
|
|
; fallthrough
|
|
|
|
; 3e3ad
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
PlayerSwitch: ; 3e3ad
|
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
|
2015-11-11 13:11:08 -08:00
|
|
|
call LoadStandardMenuDataHeader
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3e8e4
|
2015-07-15 12:48:44 -07:00
|
|
|
call WriteBackup
|
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]
|
2015-11-06 06:04:27 -08:00
|
|
|
cp BATTLEACTION_E
|
|
|
|
jp z, .switch
|
|
|
|
cp BATTLEACTION_D
|
|
|
|
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
|
|
|
|
ld a, [hLinkPlayerNumber]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
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
|
|
|
|
; 3e3ff
|
|
|
|
|
2015-11-06 06:04:27 -08:00
|
|
|
EnemyMonEntrance: ; 3e3ff
|
2014-08-13 19:44:56 -07:00
|
|
|
callab 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
|
|
|
; 3e40b
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
BattleMonEntrance: ; 3e40b
|
2015-09-09 16:27:07 -07:00
|
|
|
call BattleMonNickComma_TextBox
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus4
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3dce6
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld [CurPartyMon], 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
|
2015-09-06 14:38:01 -07:00
|
|
|
call SendOutPkmnText
|
2014-01-01 05:09:15 -08:00
|
|
|
call NewBattleMonStatus
|
|
|
|
call BreakAttraction
|
2015-11-07 06:48:32 -08:00
|
|
|
call SendOutPlayerMon
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07: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-11-04 11:02:11 -08:00
|
|
|
ld [MenuSelection2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3e459
|
|
|
|
|
2014-01-01 05:09:15 -08:00
|
|
|
PassedBattleMonEntrance: ; 3e459
|
|
|
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurBattleMon], a
|
2015-11-07 18:04:54 -08:00
|
|
|
call AddBattleParticipant
|
2015-11-06 13:42:38 -08:00
|
|
|
call InitBattleMon
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2015-09-09 16:27:07 -07:00
|
|
|
call ApplyStatLevelMultiplierOnAllStats
|
2015-11-07 06:48:32 -08:00
|
|
|
call SendOutPlayerMon
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07: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
|
|
|
; 3e489
|
|
|
|
|
|
|
|
|
2014-06-17 11:58:11 -07:00
|
|
|
BattleMenu_Run: ; 3e489
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $3
|
2015-11-04 11:02:11 -08:00
|
|
|
ld [MenuSelection2], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonSpeed
|
|
|
|
ld de, EnemyMonSpeed
|
2015-09-09 16:27:07 -07:00
|
|
|
call TryToRunAwayFromBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $0
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd266], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret c
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0ec]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
2014-06-17 11:58:11 -07:00
|
|
|
jp BattleMenu
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3e4a8
|
|
|
|
|
|
|
|
|
2014-06-13 21:18:14 -07:00
|
|
|
CheckAmuletCoin: ; 3e4a8
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleMonItem]
|
|
|
|
ld b, a
|
2015-11-10 08:05:26 -08:00
|
|
|
callab 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-02-08 00:03:32 -08:00
|
|
|
ld [wc73d], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3e4bc
|
|
|
|
|
2015-10-10 04:45:39 -07:00
|
|
|
MoveSelectionScreen: ; 3e4bc
|
2014-06-17 11:58:11 -07:00
|
|
|
call IsMobileBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nz, .asm_3e4c8
|
|
|
|
callba Function100b9f
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3e4c8
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonMoves
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd235]
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
|
|
|
jr z, .asm_3e4e2
|
|
|
|
dec a
|
|
|
|
jr z, .asm_3e4dd
|
|
|
|
call Function3e786
|
|
|
|
ret z
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, BattleMonMoves
|
2013-12-17 22:11:06 -08:00
|
|
|
jr .asm_3e4e2
|
|
|
|
|
|
|
|
.asm_3e4dd
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetPartyParamLocation
|
|
|
|
|
|
|
|
.asm_3e4e2
|
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
|
|
|
|
ld [hBGMapMode], a
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
hlcoord 4, 17 - NUM_MOVES - 1
|
|
|
|
ld b, 4
|
|
|
|
ld c, 14
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd235]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
|
|
|
jr nz, .asm_3e503
|
2014-06-10 23:08:07 -07:00
|
|
|
hlcoord 4, 17 - NUM_MOVES - 1 - 4
|
|
|
|
ld b, 4
|
|
|
|
ld c, 14
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3e503
|
|
|
|
call TextBox
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
hlcoord 6, 17 - NUM_MOVES
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd235]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
|
|
|
jr nz, .asm_3e513
|
2014-06-10 23:08:07 -07:00
|
|
|
hlcoord 6, 17 - NUM_MOVES - 4
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3e513
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, SCREEN_WIDTH
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [Buffer1], a
|
2014-06-16 11:20:01 -07:00
|
|
|
predef ListMoves
|
2014-06-10 23:08:07 -07:00
|
|
|
|
|
|
|
ld b, 5
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd235]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $2
|
2014-06-10 23:08:07 -07:00
|
|
|
ld a, 17 - NUM_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nz, .asm_3e52c
|
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
|
|
|
|
|
|
|
.asm_3e52c
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfa1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, b
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfa2], a
|
|
|
|
ld a, [wd235]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
|
|
|
jr z, .asm_3e53e
|
|
|
|
ld a, [CurMoveNum]
|
|
|
|
inc a
|
|
|
|
|
|
|
|
.asm_3e53e
|
2015-11-04 11:02:11 -08:00
|
|
|
ld [MenuSelection2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfaa], a
|
|
|
|
ld a, [wd0eb]
|
2013-12-17 22:11:06 -08:00
|
|
|
inc a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfa3], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfa4], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, $2c
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd235]
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
|
|
|
ld b, $c1
|
|
|
|
jr z, .asm_3e569
|
|
|
|
dec a
|
|
|
|
ld b, $c3
|
|
|
|
jr z, .asm_3e569
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr nz, .asm_3e569
|
|
|
|
ld b, $c7
|
|
|
|
|
|
|
|
.asm_3e569
|
|
|
|
ld a, b
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfa8], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, c
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfa5], a
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfa6], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $10
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wcfa7], a
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3e57a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd235]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr z, .asm_3e58e
|
|
|
|
dec a
|
|
|
|
jr nz, .asm_3e5a3
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 11, 14
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, .string_3e61c
|
|
|
|
call PlaceString
|
|
|
|
jr .asm_3e5a3
|
|
|
|
|
|
|
|
.asm_3e58e
|
|
|
|
call MoveInfoBox
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0e3]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr z, .asm_3e5a3
|
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
|
|
|
|
|
|
|
.asm_3e5a3
|
|
|
|
ld a, $1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
call Function1bd3
|
2014-06-17 12:52:32 -07:00
|
|
|
bit 6, a ; D_UP
|
2013-12-17 22:11:06 -08:00
|
|
|
jp nz, .asm_3e61d
|
2014-06-17 12:52:32 -07:00
|
|
|
bit 7, a ; D_DOWN
|
2013-12-17 22:11:06 -08:00
|
|
|
jp nz, .asm_3e62e
|
2014-06-17 12:52:32 -07:00
|
|
|
bit 2, a ; B_BUTTON
|
|
|
|
jp nz, .asm_3e643
|
|
|
|
bit 1, a ; 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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0e3], a
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
2015-11-04 11:02:11 -08:00
|
|
|
ld [MenuSelection2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd235]
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
|
|
|
jr nz, .asm_3e5d0
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3e5d0
|
|
|
|
dec a
|
|
|
|
ld a, b
|
|
|
|
ld [CurMoveNum], a
|
|
|
|
jr nz, .asm_3e5d9
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3e5d9
|
|
|
|
pop af
|
|
|
|
ret nz
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, BattleMonPP
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
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]
|
|
|
|
and $3f
|
|
|
|
jr z, .asm_3e610
|
|
|
|
ld a, [PlayerDisableCount]
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
dec a
|
|
|
|
cp c
|
|
|
|
jr z, .asm_3e60b
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc6e1]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr nz, .asm_3e606
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, BattleMonMoves
|
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]
|
|
|
|
|
|
|
|
.asm_3e606
|
|
|
|
ld [CurPlayerMove], a
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3e60b
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_TheMoveIsDisabled
|
2013-12-17 22:11:06 -08:00
|
|
|
jr .asm_3e613
|
|
|
|
|
|
|
|
.asm_3e610
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_TheresNoPPLeftForThisMove
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3e613
|
|
|
|
call StdBattleTextBox
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2015-10-10 04:45:39 -07:00
|
|
|
jp MoveSelectionScreen
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3e61c
|
|
|
|
|
|
|
|
.string_3e61c ; 3e61c
|
|
|
|
db "@"
|
|
|
|
; 3e61d
|
|
|
|
|
|
|
|
.asm_3e61d
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jp nz, .asm_3e57a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0eb]
|
2013-12-17 22:11:06 -08:00
|
|
|
inc a
|
2015-11-04 11:02:11 -08:00
|
|
|
ld [MenuSelection2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
jp .asm_3e57a
|
|
|
|
; 3e62e
|
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
.asm_3e62e ; 3e62e
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0eb]
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
inc a
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
cp b
|
|
|
|
jp nz, .asm_3e57a
|
|
|
|
ld a, $1
|
2015-11-04 11:02:11 -08:00
|
|
|
ld [MenuSelection2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
jp .asm_3e57a
|
|
|
|
; 3e643
|
|
|
|
|
2014-06-17 12:52:32 -07:00
|
|
|
.asm_3e643 ; 3e643
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0e3]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr z, .asm_3e6bf
|
|
|
|
ld hl, BattleMonMoves
|
|
|
|
call .asm_3e6a5
|
|
|
|
ld hl, BattleMonPP
|
|
|
|
call .asm_3e6a5
|
|
|
|
ld hl, PlayerDisableCount
|
|
|
|
ld a, [hl]
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
ld b, a
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp b
|
|
|
|
jr nz, .asm_3e671
|
|
|
|
ld a, [hl]
|
|
|
|
and $f
|
|
|
|
ld b, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0e3]
|
2013-12-17 22:11:06 -08:00
|
|
|
swap a
|
|
|
|
add b
|
|
|
|
ld [hl], a
|
|
|
|
jr .asm_3e682
|
|
|
|
|
|
|
|
.asm_3e671
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0e3]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp b
|
|
|
|
jr nz, .asm_3e682
|
|
|
|
ld a, [hl]
|
|
|
|
and $f
|
|
|
|
ld b, a
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
swap a
|
|
|
|
add b
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
.asm_3e682
|
|
|
|
ld a, [PlayerSubStatus5]
|
2014-06-13 21:18:14 -07:00
|
|
|
bit SUBSTATUS_TRANSFORMED, a
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nz, .asm_3e69e
|
|
|
|
ld hl, PartyMon1Moves
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
push hl
|
|
|
|
call .asm_3e6a5
|
|
|
|
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
|
|
|
|
call .asm_3e6a5
|
|
|
|
|
|
|
|
.asm_3e69e
|
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0e3], a
|
2015-10-10 04:45:39 -07:00
|
|
|
jp MoveSelectionScreen
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.asm_3e6a5
|
|
|
|
push hl
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0e3]
|
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-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
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
|
|
|
|
|
|
|
|
.asm_3e6bf
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0e3], a
|
2015-10-10 04:45:39 -07:00
|
|
|
jp MoveSelectionScreen
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3e6c8
|
|
|
|
|
|
|
|
MoveInfoBox: ; 3e6c8
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
|
|
|
|
hlcoord 0, 8
|
|
|
|
ld b, 3
|
|
|
|
ld c, 9
|
|
|
|
call TextBox
|
|
|
|
call MobileTextBorder
|
|
|
|
|
|
|
|
ld a, [PlayerDisableCount]
|
|
|
|
and a
|
|
|
|
jr z, .asm_3e6f4
|
|
|
|
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
ld b, a
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp b
|
|
|
|
jr nz, .asm_3e6f4
|
|
|
|
|
|
|
|
hlcoord 1, 10
|
|
|
|
ld de, .Disabled
|
|
|
|
call PlaceString
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.asm_3e6f4
|
2015-11-04 11:02:11 -08:00
|
|
|
ld hl, MenuSelection2
|
2013-12-17 22:11:06 -08:00
|
|
|
dec [hl]
|
|
|
|
call SetPlayerTurn
|
|
|
|
ld hl, BattleMonMoves
|
2015-11-04 11:02:11 -08:00
|
|
|
ld a, [MenuSelection2]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld [CurPlayerMove], a
|
|
|
|
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld [CurPartyMon], a
|
|
|
|
ld a, WILDMON
|
|
|
|
ld [MonType], a
|
2015-11-08 07:59:28 -08:00
|
|
|
callab GetMaxPPOfMove
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-04 11:02:11 -08:00
|
|
|
ld hl, MenuSelection2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, [hl]
|
|
|
|
inc [hl]
|
|
|
|
ld b, 0
|
|
|
|
ld hl, BattleMonPP
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
and $3f
|
|
|
|
ld [StringBuffer1], a
|
|
|
|
call Function3e75f
|
|
|
|
|
|
|
|
hlcoord 1, 9
|
|
|
|
ld de, .Type
|
|
|
|
call PlaceString
|
|
|
|
|
|
|
|
hlcoord 7, 11
|
|
|
|
ld [hl], "/"
|
|
|
|
|
|
|
|
callab 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
|
2014-06-16 11:20:01 -07:00
|
|
|
predef PrintMoveType
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.done
|
|
|
|
ret
|
|
|
|
; 3e74f
|
|
|
|
|
|
|
|
.Disabled
|
|
|
|
db "Disabled!@"
|
|
|
|
.Type
|
|
|
|
db "TYPE/@"
|
|
|
|
; 3e75f
|
|
|
|
|
|
|
|
|
|
|
|
Function3e75f: ; 3e75f
|
|
|
|
hlcoord 5, 11
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode] ; What's the point of this check?
|
|
|
|
cp LINK_MOBILE
|
2014-06-17 12:52:32 -07:00
|
|
|
jr c, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
hlcoord 5, 11
|
2014-06-17 12:52:32 -07:00
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
push hl
|
|
|
|
ld de, StringBuffer1
|
2015-10-10 14:03:04 -07:00
|
|
|
lb bc, 1, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
call PrintNum
|
|
|
|
pop hl
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hl], "/"
|
|
|
|
inc hl
|
2015-10-10 14:03:04 -07:00
|
|
|
ld de, wNamedObjectIndexBuffer
|
|
|
|
lb bc, 1, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
call PrintNum
|
|
|
|
ret
|
|
|
|
; 3e786
|
|
|
|
|
|
|
|
Function3e786: ; 3e786
|
|
|
|
ld a, STRUGGLE
|
|
|
|
ld [CurPlayerMove], a
|
|
|
|
ld a, [PlayerDisableCount]
|
|
|
|
and a
|
|
|
|
ld hl, BattleMonPP
|
|
|
|
jr nz, .asm_3e79f
|
|
|
|
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
inc hl
|
|
|
|
or [hl]
|
|
|
|
inc hl
|
|
|
|
or [hl]
|
|
|
|
and $3f
|
|
|
|
ret nz
|
|
|
|
jr .asm_3e7b4
|
|
|
|
|
|
|
|
.asm_3e79f
|
|
|
|
swap a
|
|
|
|
and $f
|
|
|
|
ld b, a
|
|
|
|
ld d, $5
|
|
|
|
xor a
|
|
|
|
.asm_3e7a7
|
|
|
|
dec d
|
|
|
|
jr z, .asm_3e7b2
|
|
|
|
ld c, [hl]
|
|
|
|
inc hl
|
|
|
|
dec b
|
|
|
|
jr z, .asm_3e7a7
|
|
|
|
or c
|
|
|
|
jr .asm_3e7a7
|
|
|
|
|
|
|
|
.asm_3e7b2
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
.asm_3e7b4
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_PkmnHasNoMovesLeft
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
ld c, 60
|
|
|
|
call DelayFrames
|
|
|
|
xor a
|
|
|
|
ret
|
|
|
|
; 3e7c1
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-08 16:09:36 -08:00
|
|
|
ParseEnemyAction: ; 3e7c1
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd0ec]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
call z, Function3e8e4
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, [wBattleAction]
|
2015-11-06 06:04:27 -08:00
|
|
|
cp BATTLEACTION_E
|
2015-11-07 18:04:54 -08:00
|
|
|
jp z, .struggle
|
2015-11-06 06:04:27 -08:00
|
|
|
cp BATTLEACTION_D
|
2015-11-07 18:04:54 -08:00
|
|
|
jp z, .battle_action_d
|
2015-11-06 06:04:27 -08:00
|
|
|
cp BATTLEACTION_SWITCH1
|
2015-09-09 16:27:07 -07:00
|
|
|
jp nc, ResetVarsForSubstatusRage
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurEnemyMoveNum], a
|
|
|
|
ld c, a
|
|
|
|
ld a, [EnemySubStatus1]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ROLLOUT, a
|
2015-11-07 18:04:54 -08:00
|
|
|
jp nz, .skip_load
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemySubStatus3]
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [LastEnemyMove]
|
2015-11-07 18:04:54 -08:00
|
|
|
jp nz, .finish
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus5
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ENCORED, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .skip_encore
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [LastEnemyMove]
|
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
|
2015-09-09 16:27:07 -07:00
|
|
|
call CheckSubstatus_RechargeChargedRampageBideRollout
|
|
|
|
jp nz, ResetVarsForSubstatusRage
|
2015-11-07 18:04:54 -08:00
|
|
|
jr .continue
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.battle_action_d
|
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
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld de, EnemyMonPP
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemyDisabledMove]
|
|
|
|
cp [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .disabled
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [de]
|
|
|
|
and $3f
|
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
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonMoves
|
2013-12-17 22:11:06 -08:00
|
|
|
call BattleRandom
|
2014-06-10 23:08:07 -07:00
|
|
|
and 3 ; TODO factor in 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
|
|
|
|
ld a, [EnemyDisableCount]
|
|
|
|
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
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonPP
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
|
|
|
ld b, a
|
|
|
|
ld a, [hl]
|
|
|
|
and $3f
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, c
|
|
|
|
ld [CurEnemyMoveNum], a
|
|
|
|
ld a, b
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.finish
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurEnemyMove], a
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip_load
|
2013-12-17 22:11:06 -08:00
|
|
|
call SetEnemyTurn
|
|
|
|
callab UpdateMoveData
|
2015-09-09 16:27:07 -07:00
|
|
|
call CheckSubstatus_RechargeChargedRampageBideRollout
|
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
|
|
|
|
ld [EnemyFuryCutterCount], a
|
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus4
|
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
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [EnemyProtectCount], 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
|
|
|
; 3e8c1
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
ResetVarsForSubstatusRage: ; 3e8c1
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [EnemyFuryCutterCount], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [EnemyProtectCount], a
|
2015-11-05 16:13:09 -08:00
|
|
|
ld [wEnemyRageCounter], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus4
|
2014-06-10 23:08:07 -07:00
|
|
|
res SUBSTATUS_RAGE, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3e8d1
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
CheckSubstatus_RechargeChargedRampageBideRollout: ; 3e8d1
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemySubStatus4]
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus3
|
|
|
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemySubStatus1
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_ROLLOUT, [hl]
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3e8e4
|
|
|
|
|
|
|
|
Function3e8e4: ; 3e8e4
|
|
|
|
callba Function100a09
|
|
|
|
ret
|
|
|
|
; 3e8eb
|
|
|
|
|
|
|
|
|
|
|
|
LoadEnemyMon: ; 3e8eb
|
|
|
|
; Initialize enemy monster parameters
|
|
|
|
; To do this we pull the species from TempEnemyMonSpecies
|
|
|
|
|
|
|
|
; Notes:
|
|
|
|
; BattleRandom is used to ensure sync between Game Boys
|
|
|
|
|
|
|
|
; Clear the whole EnemyMon struct
|
|
|
|
xor a
|
|
|
|
ld hl, EnemyMonSpecies
|
|
|
|
ld bc, EnemyMonEnd - EnemyMon
|
|
|
|
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
|
|
|
|
jp nz, Function3dabd
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
; and also not in a BattleTower-Battle
|
|
|
|
ld a, [InBattleTowerBattle] ; ????
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 0, a
|
|
|
|
jp nz, Function3dabd
|
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
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
ld [EnemyMonSpecies], a
|
|
|
|
ld [CurSpecies], a
|
|
|
|
ld [CurPartySpecies], 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
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld hl, OTPartyMon1Item
|
|
|
|
call GetPartyLocation ; bc = PartyMon[CurPartyMon] - PartyMons
|
|
|
|
ld a, [hl]
|
|
|
|
jr .UpdateItem
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.WildItem
|
|
|
|
; In a wild battle, we pull from the item slots in BaseData
|
|
|
|
|
|
|
|
; Force Item1
|
|
|
|
; Used for Ho-Oh, Lugia and Snorlax encounters
|
|
|
|
ld a, [BattleType]
|
|
|
|
cp BATTLETYPE_FORCEITEM
|
|
|
|
ld a, [BaseItems]
|
|
|
|
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
|
2015-07-20 00:51:52 -07:00
|
|
|
cp a, 1 + (75 percent)
|
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
|
2015-07-20 00:51:52 -07:00
|
|
|
cp a, 8 percent ; 8% of 25% = 2% Item2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BaseItems]
|
|
|
|
jr nc, .UpdateItem
|
|
|
|
ld a, [BaseItems+1]
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.UpdateItem
|
|
|
|
ld [EnemyMonItem], 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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemySubStatus5]
|
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
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wc6f2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, EnemyMonDVs
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
jp .Happiness
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.InitDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
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
|
|
|
|
callba GetTrainerDVs
|
|
|
|
; 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
|
|
|
|
ld a, [BattleType]
|
|
|
|
cp a, BATTLETYPE_ROAMING
|
|
|
|
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
|
|
|
|
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.NotRoaming
|
|
|
|
; Register a contains BattleType
|
|
|
|
|
|
|
|
; Forced shiny battle type
|
|
|
|
; Used by Red Gyarados at Lake of Rage
|
|
|
|
cp a, BATTLETYPE_SHINY
|
|
|
|
jr nz, .GenerateDVs
|
|
|
|
|
|
|
|
ld b, ATKDEFDV_SHINY ; $ea
|
|
|
|
ld c, SPDSPCDV_SHINY ; $aa
|
|
|
|
jr .UpdateDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.GenerateDVs
|
|
|
|
; Generate new random DVs
|
|
|
|
call BattleRandom
|
|
|
|
ld b, a
|
|
|
|
call BattleRandom
|
|
|
|
ld c, a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.UpdateDVs
|
|
|
|
; Input DVs in register bc
|
|
|
|
ld hl, EnemyMonDVs
|
|
|
|
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
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
cp a, UNOWN
|
|
|
|
jr nz, .Magikarp
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; Get letter based on DVs
|
|
|
|
ld hl, EnemyMonDVs
|
2014-06-16 11:20:01 -07: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
|
|
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.Magikarp
|
|
|
|
; Skimming this part recommended
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
cp a, MAGIKARP
|
|
|
|
jr nz, .Happiness
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; Get Magikarp's length
|
|
|
|
ld de, EnemyMonDVs
|
|
|
|
ld bc, PlayerID
|
|
|
|
callab CalcMagikarpLength
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; We're clear if the length is < 1536
|
|
|
|
ld a, [MagikarpLength]
|
|
|
|
cp a, $06 ; $600 = 1536
|
|
|
|
jr nz, .CheckMagikarpArea
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; 5% chance of skipping size checks
|
|
|
|
call Random
|
|
|
|
cp a, $0c ; / $100
|
|
|
|
jr c, .CheckMagikarpArea
|
|
|
|
; Try again if > 1614
|
|
|
|
ld a, [MagikarpLength + 1]
|
|
|
|
cp a, $50
|
|
|
|
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
|
|
|
|
cp a, $32 ; / $100
|
|
|
|
jr c, .CheckMagikarpArea
|
|
|
|
; Try again if > 1598
|
|
|
|
ld a, [MagikarpLength + 1]
|
|
|
|
cp a, $40
|
|
|
|
jr nc, .GenerateDVs
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.CheckMagikarpArea
|
|
|
|
; The z checks are supposed to be nz
|
|
|
|
; Instead, all maps in GROUP_LAKE_OF_RAGE (mahogany area)
|
|
|
|
; and routes 20 and 44 are treated as Lake of Rage
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; This also means Lake of Rage Magikarp can be smaller than ones
|
|
|
|
; caught elsewhere rather than the other way around
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; Intended behavior enforces a minimum size at Lake of Rage
|
|
|
|
; The real behavior prevents size flooring in the Lake of Rage area
|
|
|
|
ld a, [MapGroup]
|
|
|
|
cp a, GROUP_LAKE_OF_RAGE
|
|
|
|
jr z, .Happiness
|
|
|
|
ld a, [MapNumber]
|
|
|
|
cp a, MAP_LAKE_OF_RAGE
|
|
|
|
jr z, .Happiness
|
|
|
|
; 40% chance of not flooring
|
|
|
|
call Random
|
|
|
|
cp a, $64 ; / $100
|
|
|
|
jr c, .Happiness
|
|
|
|
; Floor at length 1024
|
|
|
|
ld a, [MagikarpLength]
|
|
|
|
cp a, 1024 >> 8
|
|
|
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.Happiness
|
|
|
|
; Set happiness
|
|
|
|
ld a, BASE_HAPPINESS
|
|
|
|
ld [EnemyMonHappiness], a
|
|
|
|
; Set level
|
|
|
|
ld a, [CurPartyLevel]
|
|
|
|
ld [EnemyMonLevel], a
|
|
|
|
; Fill stats
|
|
|
|
ld de, EnemyMonMaxHP
|
|
|
|
ld b, $00
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, LinkBattleRNs + 7 ; ?
|
2015-10-08 11:53:39 -07:00
|
|
|
predef CalcPkmnStats
|
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]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp a, TRAINER_BATTLE
|
|
|
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemySubStatus5]
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.TreeMon
|
|
|
|
; If we're headbutting trees, some monsters enter battle asleep
|
|
|
|
call CheckSleepingTreeMon
|
2014-06-13 21:18:14 -07:00
|
|
|
ld a, SLP ; Asleep for 7 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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.UpdateStatus
|
|
|
|
ld hl, EnemyMonStatus
|
|
|
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; Full HP...
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [EnemyMonMaxHP]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hli], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [EnemyMonMaxHP + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hl], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; ...unless it's a RoamMon
|
|
|
|
ld a, [BattleType]
|
|
|
|
cp a, BATTLETYPE_ROAMING
|
|
|
|
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]
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [EnemyMonHP + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
jr .Moves
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.InitRoamHP
|
|
|
|
; HP only uses the lo byte in the RoamMon struct since
|
|
|
|
; Raikou/Entei/Suicune will have < 256 hp at level 40
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [EnemyMonHP + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hl], a
|
|
|
|
jr .Moves
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.OpponentParty
|
|
|
|
; Get HP from the party struct
|
2014-02-22 22:10:58 -08:00
|
|
|
ld hl, (OTPartyMon1HP + 1)
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [hld]
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [EnemyMonHP + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hld]
|
2014-06-12 18:32:42 -07:00
|
|
|
ld [EnemyMonHP], 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
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld [CurOTMon], 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
|
|
|
|
ld [EnemyMonStatus], a
|
2015-07-20 08:28:05 -07:00
|
|
|
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.Moves
|
|
|
|
ld hl, BaseType1
|
|
|
|
ld de, EnemyMonType1
|
|
|
|
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
|
|
|
|
ld de, EnemyMonMoves
|
|
|
|
; Are we in a trainer battle?
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp a, TRAINER_BATTLE
|
|
|
|
jr nz, .WildMoves
|
|
|
|
; Then copy moves from the party struct
|
|
|
|
ld hl, OTPartyMon1Moves
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
ld bc, NUM_MOVES
|
|
|
|
call CopyBytes
|
|
|
|
jr .PP
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.WildMoves
|
|
|
|
; Clear EnemyMonMoves
|
|
|
|
xor a
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 3
|
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
|
|
|
|
; Make sure the predef knows this isn't a partymon
|
|
|
|
ld [MagikarpLength], a
|
|
|
|
; Fill moves based on level
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FillMoves
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.PP
|
|
|
|
; Trainer battle?
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wBattleMode]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp a, TRAINER_BATTLE
|
|
|
|
jr z, .TrainerPP
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; Fill wild PP
|
|
|
|
ld hl, EnemyMonMoves
|
|
|
|
ld de, EnemyMonPP
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FillPP
|
2013-12-17 22:11:06 -08:00
|
|
|
jr .Finish
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.TrainerPP
|
|
|
|
; Copy PP from the party struct
|
|
|
|
ld hl, OTPartyMon1PP
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
call GetPartyLocation
|
|
|
|
ld de, EnemyMonPP
|
|
|
|
ld bc, NUM_MOVES
|
|
|
|
call CopyBytes
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.Finish
|
|
|
|
; Only the first five base stats are copied...
|
|
|
|
ld hl, BaseStats
|
|
|
|
ld de, EnemyMonBaseStats
|
|
|
|
ld b, BaseSpecialDefense - BaseStats
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
ld a, [BaseCatchRate]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
|
|
|
|
ld a, [BaseExp]
|
|
|
|
ld [de], a
|
|
|
|
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], 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
|
|
|
|
|
|
|
|
; Update enemy nick
|
|
|
|
ld hl, StringBuffer1
|
|
|
|
ld de, EnemyMonNick
|
|
|
|
ld bc, PKMN_NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
; Caught this mon
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 1 ; set
|
|
|
|
ld hl, PokedexSeen
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FlagPredef
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
ld hl, EnemyMonStats
|
|
|
|
ld de, EnemyStats
|
|
|
|
ld bc, EnemyMonStatsEnd - EnemyMonStats
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
ret
|
|
|
|
; 3eb38
|
|
|
|
|
|
|
|
|
|
|
|
CheckSleepingTreeMon: ; 3eb38
|
|
|
|
; 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
|
|
|
|
ld a, [BattleType]
|
|
|
|
cp a, BATTLETYPE_TREE
|
|
|
|
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
|
|
|
|
ld hl, .Morn
|
|
|
|
ld a, [TimeOfDay]
|
|
|
|
cp a, DAY
|
|
|
|
jr c, .Check
|
|
|
|
ld hl, .Day
|
|
|
|
jr z, .Check
|
|
|
|
ld hl, .Nite
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.Check
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.NotSleeping
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.Nite
|
|
|
|
db CATERPIE
|
|
|
|
db METAPOD
|
|
|
|
db BUTTERFREE
|
|
|
|
db WEEDLE
|
|
|
|
db KAKUNA
|
|
|
|
db BEEDRILL
|
|
|
|
db SPEAROW
|
|
|
|
db EKANS
|
|
|
|
db EXEGGCUTE
|
|
|
|
db LEDYBA
|
|
|
|
db AIPOM
|
2015-10-19 07:23:58 -07:00
|
|
|
db -1 ; end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.Day
|
|
|
|
db VENONAT
|
|
|
|
db HOOTHOOT
|
|
|
|
db NOCTOWL
|
|
|
|
db SPINARAK
|
|
|
|
db HERACROSS
|
2015-10-19 07:23:58 -07:00
|
|
|
db -1 ; end
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
.Morn
|
|
|
|
db VENONAT
|
|
|
|
db HOOTHOOT
|
|
|
|
db NOCTOWL
|
|
|
|
db SPINARAK
|
|
|
|
db HERACROSS
|
2015-10-19 07:23:58 -07:00
|
|
|
db -1 ; end
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3eb75
|
|
|
|
|
|
|
|
|
|
|
|
CheckUnownLetter: ; 3eb75
|
|
|
|
; Return carry if the Unown letter hasn't been unlocked yet
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [UnlockedUnowns]
|
|
|
|
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?
|
|
|
|
ld hl, .LetterSets
|
|
|
|
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
|
|
|
|
ld a, [UnownLetter]
|
|
|
|
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
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
inc e
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, e
|
|
|
|
cp a, .Set1 - .LetterSets
|
|
|
|
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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.LetterSets
|
|
|
|
dw .Set1
|
|
|
|
dw .Set2
|
|
|
|
dw .Set3
|
|
|
|
dw .Set4
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
.Set1
|
|
|
|
; A B C D E F G H I J K
|
|
|
|
db 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, $ff
|
|
|
|
.Set2
|
|
|
|
; L M N O P Q R
|
|
|
|
db 12, 13, 14, 15, 16, 17, 18, $ff
|
|
|
|
.Set3
|
|
|
|
; S T U V W
|
|
|
|
db 19, 20, 21, 22, 23, $ff
|
|
|
|
.Set4
|
|
|
|
; X Y Z
|
|
|
|
db 24, 25, 26, $ff
|
2015-07-20 08:28:05 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3ebc7
|
|
|
|
|
|
|
|
|
|
|
|
Function3ebc7: ; 3ebc7
|
|
|
|
push bc
|
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
ld b, a
|
|
|
|
ld a, [EnemyMonLevel]
|
|
|
|
ld [BattleMonLevel], a
|
|
|
|
ld a, b
|
|
|
|
ld [EnemyMonLevel], a
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3ebd8
|
|
|
|
|
|
|
|
Function3ebd8: ; 3ebd8
|
|
|
|
xor a
|
|
|
|
ld [TempEnemyMonSpecies], a
|
2015-11-09 13:41:09 -08:00
|
|
|
call FinishBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [OtherTrainerClass]
|
|
|
|
ld [TrainerClass], a
|
|
|
|
ld de, VTiles2
|
2014-06-18 00:55:44 -07:00
|
|
|
callab GetTrainerPic
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 19, 0
|
2013-12-17 22:11:06 -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
|
|
|
|
cp $7
|
|
|
|
ret z
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld [hBGMapThird], a
|
|
|
|
ld d, $0
|
|
|
|
push bc
|
|
|
|
push hl
|
2015-10-19 13:49:29 -07:00
|
|
|
|
|
|
|
.inner_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3ec1a
|
|
|
|
inc hl
|
|
|
|
ld a, $7
|
|
|
|
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
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld c, $4
|
|
|
|
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
|
|
|
; 3ec1a
|
|
|
|
|
|
|
|
Function3ec1a: ; 3ec1a
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
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
|
|
|
|
; 3ec2c
|
|
|
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
ApplyStatusEffectOnPlayerStats: ; 3ec2c
|
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
|
|
|
; 3ec30
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
ApplyStatusEffectOnEnemyStats: ; 3ec30
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
; 3ec31
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
ApplyStatusEffectOnStats: ; 3ec31
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hBattleTurn], a
|
2015-11-06 17:55:16 -08:00
|
|
|
call ApplyPrzEffectOnSpeed
|
|
|
|
jp ApplyBrnEffectOnAttack
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3ec39
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ApplyPrzEffectOnSpeed: ; 3ec39
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .enemy
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
and 1 << PAR
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, BattleMonSpeed + 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $1
|
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemyMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
and 1 << PAR
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, EnemyMonSpeed + 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $1
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.enemy_ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hl], b
|
|
|
|
ret
|
|
|
|
; 3ec76
|
|
|
|
|
2015-11-06 17:55:16 -08:00
|
|
|
ApplyBrnEffectOnAttack: ; 3ec76
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
and a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .enemy
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
and 1 << BRN
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, BattleMonAttack + 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $1
|
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemyMonStatus]
|
2014-06-17 12:52:32 -07:00
|
|
|
and 1 << BRN
|
2013-12-17 22:11:06 -08:00
|
|
|
ret z
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, EnemyMonAttack + 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $1
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.enemy_ok
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hl], b
|
|
|
|
ret
|
|
|
|
; 3ecab
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
ApplyStatLevelMultiplierOnAllStats: ; 3ecab
|
|
|
|
; 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
|
|
|
|
cp 5
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nz, .stat_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3ecb7
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
ApplyStatLevelMultiplier: ; 3ecb7
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
|
|
|
push bc
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd265]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ld a, c
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonAttack
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, PlayerStats
|
|
|
|
ld bc, PlayerAtkLevel
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .got_pointers
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonAttack
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, EnemyStats
|
|
|
|
ld bc, EnemyAtkLevel
|
|
|
|
|
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
|
|
|
|
ld hl, .StatLevelMultipliers
|
|
|
|
dec b
|
|
|
|
sla b
|
|
|
|
ld c, b
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [de]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
inc de
|
|
|
|
ld a, [de]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld [hMultiplier], a
|
|
|
|
call Multiply
|
|
|
|
ld a, [hl]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $4
|
|
|
|
call Divide
|
|
|
|
pop hl
|
|
|
|
|
|
|
|
; Cap at 999.
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
sub 999 % $100
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
sbc 999 / $100
|
2015-11-07 18:04:54 -08:00
|
|
|
jp c, .okay3
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
ld a, 999 / $100
|
2015-11-07 18:04:54 -08:00
|
|
|
ld [hQuotient + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, 999 % $100
|
2015-11-07 18:04:54 -08:00
|
|
|
ld [hQuotient + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.okay3
|
|
|
|
ld a, [hQuotient + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hli], a
|
|
|
|
ld b, a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [hQuotient + 2]
|
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
|
|
|
|
; 3ed2b
|
|
|
|
|
|
|
|
.StatLevelMultipliers
|
|
|
|
; /
|
|
|
|
db 25, 100 ; 25%
|
|
|
|
db 28, 100 ; 28%
|
|
|
|
db 33, 100 ; 33%
|
|
|
|
db 40, 100 ; 40%
|
|
|
|
db 50, 100 ; 50%
|
|
|
|
db 66, 100 ; 66%
|
|
|
|
|
|
|
|
db 1, 1 ; 100%
|
|
|
|
|
|
|
|
db 15, 10 ; 150%
|
|
|
|
db 2, 1 ; 200%
|
|
|
|
db 25, 10 ; 250%
|
|
|
|
db 3, 1 ; 300%
|
|
|
|
db 35, 10 ; 350%
|
|
|
|
db 4, 1 ; 400%
|
|
|
|
; 3ed45
|
|
|
|
|
|
|
|
|
|
|
|
BadgeStatBoosts: ; 3ed45
|
|
|
|
; Raise BattleMon stats depending on which badges have been obtained.
|
|
|
|
|
|
|
|
; Every other badge boosts a stat, starting from the first.
|
|
|
|
|
|
|
|
; ZephyrBadge: Attack
|
|
|
|
; PlainBadge: Speed
|
|
|
|
; MineralBadge: Defense
|
|
|
|
; GlacierBadge: Special Attack
|
|
|
|
; RisingBadge: Special Defense
|
|
|
|
|
|
|
|
; 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
|
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
ld a, [JohtoBadges]
|
|
|
|
|
|
|
|
; Swap badges 3 (PlainBadge) and 5 (MineralBadge).
|
|
|
|
ld d, a
|
2015-11-07 18:04:54 -08:00
|
|
|
and (1 << PLAINBADGE)
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add a
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
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
|
|
|
|
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonAttack
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, 4
|
|
|
|
.CheckBadge
|
|
|
|
ld a, b
|
|
|
|
srl b
|
|
|
|
call c, BoostStat
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
; Check every other badge.
|
|
|
|
srl b
|
|
|
|
dec c
|
|
|
|
jr nz, .CheckBadge
|
|
|
|
; And the last one (RisingBadge) too.
|
|
|
|
srl a
|
|
|
|
call c, BoostStat
|
|
|
|
ret
|
|
|
|
; 3ed7c
|
|
|
|
|
|
|
|
|
|
|
|
BoostStat: ; 3ed7c
|
|
|
|
; 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]
|
|
|
|
sub 999 % $100
|
|
|
|
ld a, [hl]
|
|
|
|
sbc 999 / $100
|
|
|
|
ret c
|
|
|
|
ld a, 999 / $100
|
|
|
|
ld [hli], a
|
|
|
|
ld a, 999 % $100
|
|
|
|
ld [hld], a
|
|
|
|
ret
|
|
|
|
; 3ed9f
|
|
|
|
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
_LoadBattleFontsHPBar: ; 3ed9f
|
2015-11-10 08:05:26 -08:00
|
|
|
callab LoadBattleFontsHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3eda6
|
|
|
|
|
2015-11-10 16:51:13 -08:00
|
|
|
_LoadHPBar: ; 3eda6
|
2015-11-10 08:05:26 -08:00
|
|
|
callab LoadHPBar
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3edad
|
|
|
|
|
|
|
|
|
2015-11-04 12:35:29 -08:00
|
|
|
LoadHPExpBarGFX: ; unreferenced
|
|
|
|
ld de, EnemyHPBarBorderGFX
|
2015-10-14 06:29:15 -07: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
|
2015-10-14 06:29:15 -07: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
|
2015-10-14 06:29:15 -07: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
|
|
|
|
; 3edd1
|
|
|
|
|
|
|
|
|
|
|
|
EmptyBattleTextBox: ; 3edd1
|
|
|
|
ld hl, .empty
|
|
|
|
jp BattleTextBox
|
|
|
|
.empty
|
|
|
|
db "@"
|
|
|
|
; 3edd8
|
|
|
|
|
|
|
|
|
2014-02-01 17:26:39 -08:00
|
|
|
_BattleRandom:: ; 3edd8
|
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
|
|
|
|
ld a, [LinkBattleRNCount]
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
ld hl, LinkBattleRNs
|
|
|
|
add hl, bc
|
|
|
|
inc a
|
|
|
|
ld [LinkBattleRNCount], a
|
|
|
|
|
|
|
|
; 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
|
|
|
|
ld [LinkBattleRNCount], a
|
|
|
|
ld hl, LinkBattleRNs
|
|
|
|
ld b, 10 ; number of seeds
|
|
|
|
|
|
|
|
; Generate next number in the sequence for each seed
|
|
|
|
; The algorithm takes the form *5 + 1 % 256
|
|
|
|
.loop
|
|
|
|
; get last #
|
|
|
|
ld a, [hl]
|
|
|
|
|
|
|
|
; a * 5 + 1
|
|
|
|
ld c, a
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add a
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
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
|
|
|
|
; 3ee0f
|
|
|
|
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
Call_PlayBattleAnim_OnlyIfVisible: ; 3ee0f
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, BATTLE_VARS_SUBSTATUS3
|
|
|
|
call GetBattleVar
|
|
|
|
and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
|
|
|
|
ret nz
|
|
|
|
; 3ee17
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
Call_PlayBattleAnim: ; 3ee17
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, e
|
|
|
|
ld [FXAnimIDLo], a
|
|
|
|
ld a, d
|
|
|
|
ld [FXAnimIDHi], a
|
|
|
|
call WaitBGMap
|
2014-06-16 11:20:01 -07:00
|
|
|
predef_jump PlayBattleAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3ee27
|
|
|
|
|
2015-11-09 13:41:09 -08:00
|
|
|
FinishBattleAnim: ; 3ee27
|
2013-12-17 22:11:06 -08:00
|
|
|
push af
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push hl
|
2015-11-16 13:01:45 -08:00
|
|
|
ld b, SCGB_01
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetSGBLayout
|
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
|
|
|
|
; 3ee3b
|
|
|
|
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
GiveExperiencePoints: ; 3ee3b
|
2014-06-03 14:07:10 -07:00
|
|
|
; Give experience.
|
2015-11-11 11:12:46 -08:00
|
|
|
; Don't give experience if linked or in the Battle Tower.
|
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
|
|
|
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 0, a
|
|
|
|
ret nz
|
2015-08-24 16:56:30 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3f0d4
|
|
|
|
xor a
|
|
|
|
ld [CurPartyMon], a
|
|
|
|
ld bc, PartyMon1Species
|
|
|
|
|
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]
|
2015-11-07 18:04:54 -08:00
|
|
|
jp z, .skip_stats ; fainted
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
2015-11-07 18:04:54 -08:00
|
|
|
ld hl, wBattleParticipantsNotFainted
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld c, a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld b, CHECK_FLAG
|
2013-12-17 22:11:06 -08:00
|
|
|
ld d, $0
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FlagPredef
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
pop bc
|
2015-11-07 18:04:54 -08:00
|
|
|
jp z, .skip_stats
|
|
|
|
ld hl, MON_STAT_EXP + 1
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2014-06-03 14:07:10 -07:00
|
|
|
ld hl, EnemyMonBaseStats - 1
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
|
|
|
ld c, $5
|
2015-11-07 18:04:54 -08:00
|
|
|
.loop1
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [de]
|
|
|
|
add [hl]
|
|
|
|
ld [de], a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nc, .okay1
|
2013-12-17 22:11:06 -08:00
|
|
|
dec de
|
|
|
|
ld a, [de]
|
|
|
|
inc a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .next
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.okay1
|
2013-12-17 22:11:06 -08:00
|
|
|
push hl
|
|
|
|
push bc
|
2015-11-04 08:19:58 -08:00
|
|
|
ld a, MON_PKRUS
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetPartyParamLocation
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
pop bc
|
|
|
|
pop hl
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .skip
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [de]
|
|
|
|
add [hl]
|
|
|
|
ld [de], a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nc, .skip
|
2013-12-17 22:11:06 -08:00
|
|
|
dec de
|
|
|
|
ld a, [de]
|
|
|
|
inc a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .next
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [de], a
|
|
|
|
inc de
|
2015-11-07 18:04:54 -08:00
|
|
|
jr .skip
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.next
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $ff
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld [de], a
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
inc de
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
dec c
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nz, .loop1
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
|
|
|
ld [hMultiplicand + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemyMonBaseExp]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemyMonLevel]
|
|
|
|
ld [hMultiplier], a
|
|
|
|
call Multiply
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, 7
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld b, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
call Divide
|
|
|
|
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
|
|
|
|
ld a, [PlayerID]
|
|
|
|
cp [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nz, .boosted
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [PlayerID + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp [hl]
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.no_boost
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [StringBuffer2 + 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
|
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
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [hQuotient + 2]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [StringBuffer2 + 1], a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [hQuotient + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [StringBuffer2], a
|
|
|
|
ld a, [CurPartyMon]
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, PartyMonNicknames
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetNick
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, Text_PkmnGainedExpPoint
|
2013-12-17 22:11:06 -08:00
|
|
|
call BattleTextBox
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [StringBuffer2 + 1]
|
2015-11-07 18:04:54 -08:00
|
|
|
ld [hQuotient + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [StringBuffer2]
|
2015-11-07 18:04:54 -08:00
|
|
|
ld [hQuotient + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
|
|
|
call Function3f136
|
|
|
|
push bc
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
2015-11-07 18:04:54 -08:00
|
|
|
ld hl, MON_EXP + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
add d
|
|
|
|
ld [hld], a
|
|
|
|
ld d, [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [hQuotient + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
adc d
|
|
|
|
ld [hl], a
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nc, .skip2
|
2013-12-17 22:11:06 -08:00
|
|
|
dec hl
|
|
|
|
inc [hl]
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nz, .skip2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $ff
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
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
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld e, a
|
|
|
|
ld d, $0
|
|
|
|
ld hl, PartySpecies
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
ld [CurSpecies], a
|
|
|
|
call GetBaseData
|
|
|
|
push bc
|
2014-06-03 14:07:10 -07:00
|
|
|
ld d, MAX_LEVEL
|
2015-11-03 09:36:33 -08:00
|
|
|
callab CalcExpAtLevel
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
2015-11-07 18:04:54 -08:00
|
|
|
ld hl, MON_EXP + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
|
|
|
push bc
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [hQuotient]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [hQuotient + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, a
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [hQuotient + 2]
|
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-11-07 18:04:54 -08:00
|
|
|
jr c, .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-11-07 18:04:54 -08:00
|
|
|
.max_exp
|
2015-10-07 18:27:32 -07:00
|
|
|
xor a ; PARTYMON
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
2015-10-08 11:53:39 -07:00
|
|
|
predef CopyPkmnToTempMon
|
2015-11-03 09:36:33 -08:00
|
|
|
callab 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
|
2015-11-07 18:04:54 -08:00
|
|
|
jp nc, .skip_stats
|
2013-12-17 22:11:06 -08:00
|
|
|
cp d
|
2015-11-07 18:04:54 -08:00
|
|
|
jp z, .skip_stats
|
|
|
|
; <NICKNAME> grew to level ##!
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc719], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyLevel]
|
|
|
|
push af
|
|
|
|
ld a, d
|
|
|
|
ld [CurPartyLevel], a
|
|
|
|
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]
|
|
|
|
ld [CurSpecies], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
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-11-07 18:04:54 -08:00
|
|
|
ld hl, MON_EXP + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
|
|
|
push bc
|
|
|
|
ld b, $1
|
2015-10-08 11:53:39 -07:00
|
|
|
predef CalcPkmnStats
|
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
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld d, a
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
cp d
|
2015-11-07 18:04:54 -08:00
|
|
|
jr nz, .skip_animation
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, BattleMonHP
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
ld de, BattleMonMaxHP
|
|
|
|
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]
|
|
|
|
ld [BattleMonLevel], a
|
|
|
|
ld a, [PlayerSubStatus5]
|
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
|
|
|
|
ld de, PlayerStats
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2015-09-09 16:27:07 -07:00
|
|
|
call ApplyStatLevelMultiplierOnAllStats
|
2015-11-07 18:04:54 -08:00
|
|
|
callab ApplyStatusEffectOnPlayerStats
|
2013-12-17 22:11:06 -08:00
|
|
|
callab BadgeStatBoosts
|
2014-06-16 22:52:59 -07:00
|
|
|
callab UpdatePlayerHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
call EmptyBattleTextBox
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip_animation
|
2015-07-19 01:58:31 -07:00
|
|
|
callba LevelUpHappinessMod
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurBattleMon]
|
|
|
|
ld b, a
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
cp b
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .skip_animation2
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
2015-09-09 16:27:07 -07:00
|
|
|
call LoadTileMapToTempTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip_animation2
|
2015-10-07 18:27:32 -07:00
|
|
|
xor a ; PARTYMON
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
2015-10-08 11:53:39 -07:00
|
|
|
predef CopyPkmnToTempMon
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 9, 0
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $a
|
|
|
|
ld c, $9
|
|
|
|
call TextBox
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 11, 1
|
2013-12-17 22:11:06 -08:00
|
|
|
ld bc, $0004
|
2015-02-11 13:15:38 -08:00
|
|
|
predef PrintTempMonStats
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, $1e
|
|
|
|
call DelayFrames
|
2015-11-10 20:23:28 -08:00
|
|
|
call WaitPressAorB_BlinkCursor
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2015-10-07 18:27:32 -07:00
|
|
|
xor a ; PARTYMON
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
|
|
|
ld a, [CurSpecies]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartyLevel]
|
|
|
|
push af
|
|
|
|
ld c, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc719]
|
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
|
|
|
|
ld [CurPartyLevel], a
|
|
|
|
push bc
|
2014-06-16 11:20:01 -07: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
|
|
|
|
ld [CurPartyLevel], a
|
|
|
|
ld hl, EvolvableFlags
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
ld c, a
|
|
|
|
ld b, $1
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FlagPredef
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
|
|
|
ld [CurPartyLevel], a
|
|
|
|
|
2015-11-07 18:04:54 -08:00
|
|
|
.skip_stats
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PartyCount]
|
|
|
|
ld b, a
|
|
|
|
ld a, [CurPartyMon]
|
|
|
|
inc a
|
|
|
|
cp b
|
2015-11-07 18:04:54 -08:00
|
|
|
jr z, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurPartyMon], 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
|
|
|
; 3f0d4
|
|
|
|
|
|
|
|
Function3f0d4: ; 3f0d4
|
2015-11-07 18:04:54 -08:00
|
|
|
ld a, [wBattleParticipantsNotFainted]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
|
|
|
ld c, $6
|
|
|
|
ld d, $0
|
|
|
|
.asm_3f0dc
|
|
|
|
xor a
|
|
|
|
srl b
|
|
|
|
adc d
|
|
|
|
ld d, a
|
|
|
|
dec c
|
|
|
|
jr nz, .asm_3f0dc
|
|
|
|
cp $2
|
|
|
|
ret c
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd265], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, EnemyMonBaseStats
|
|
|
|
ld c, $7
|
|
|
|
.asm_3f0ef
|
|
|
|
xor a
|
2015-09-09 16:27:07 -07:00
|
|
|
ld [hDividend + 0], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
2015-09-09 16:27:07 -07:00
|
|
|
ld [hDividend + 1], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd265]
|
2015-09-09 16:27:07 -07:00
|
|
|
ld [hDivisor], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $2
|
|
|
|
call Divide
|
2015-09-09 16:27:07 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hli], a
|
|
|
|
dec c
|
|
|
|
jr nz, .asm_3f0ef
|
|
|
|
ret
|
|
|
|
; 3f106
|
|
|
|
|
2015-11-11 11:12:46 -08:00
|
|
|
BoostExp: ; 3f106
|
|
|
|
; 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
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld 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
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 3], a
|
|
|
|
ld a, [hProduct + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
adc b
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3f11b
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
Text_PkmnGainedExpPoint: ; 3f11b
|
|
|
|
text_jump Text_Gained
|
2013-12-17 22:11:06 -08:00
|
|
|
start_asm
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, TextJump_StringBuffer2ExpPoints
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [StringBuffer2 + 2] ; IsTradedMon
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
|
|
ld hl, TextJump_ABoostedStringBuffer2ExpPoints
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f12c
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
TextJump_ABoostedStringBuffer2ExpPoints: ; 3f12c
|
|
|
|
text_jump Text_ABoostedStringBuffer2ExpPoints
|
2013-12-17 22:11:06 -08:00
|
|
|
db "@"
|
|
|
|
; 3f131
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
TextJump_StringBuffer2ExpPoints: ; 3f131
|
|
|
|
text_jump Text_StringBuffer2ExpPoints
|
2013-12-17 22:11:06 -08:00
|
|
|
db "@"
|
|
|
|
; 3f136
|
|
|
|
|
|
|
|
|
|
|
|
Function3f136: ; 3f136
|
|
|
|
push bc
|
|
|
|
|
|
|
|
ld hl, CurPartyMon
|
|
|
|
ld a, [CurBattleMon]
|
|
|
|
cp [hl]
|
2015-11-10 16:51:13 -08:00
|
|
|
jp nz, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
ld a, [BattleMonLevel]
|
|
|
|
cp MAX_LEVEL
|
2015-11-10 16:51:13 -08:00
|
|
|
jp nc, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 3]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd004], a
|
2013-12-17 22:11:06 -08:00
|
|
|
push af
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 2]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd003], a
|
2013-12-17 22:11:06 -08:00
|
|
|
push af
|
|
|
|
xor a
|
2015-11-10 16:51:13 -08:00
|
|
|
ld [wd002], a
|
2015-10-07 18:27:32 -07:00
|
|
|
xor a ; PARTYMON
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [MonType], a
|
2015-10-08 11:53:39 -07:00
|
|
|
predef CopyPkmnToTempMon
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [TempMonLevel]
|
|
|
|
ld b, a
|
|
|
|
ld e, a
|
|
|
|
push de
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, TempMonExp + 2
|
2015-11-10 13:53:37 -08:00
|
|
|
call CalcExpBar
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, TempMonExp + 2
|
|
|
|
ld a, [wd004]
|
2013-12-17 22:11:06 -08:00
|
|
|
add [hl]
|
|
|
|
ld [hld], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wd003]
|
2013-12-17 22:11:06 -08:00
|
|
|
adc [hl]
|
|
|
|
ld [hld], a
|
|
|
|
jr nc, .asm_3f186
|
|
|
|
inc [hl]
|
|
|
|
jr nz, .asm_3f186
|
|
|
|
ld a, $ff
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
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
|
|
|
|
|
|
|
|
.asm_3f186
|
2014-06-03 14:07:10 -07:00
|
|
|
ld d, MAX_LEVEL
|
2015-11-03 09:36:33 -08:00
|
|
|
callab CalcExpAtLevel
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, a
|
2015-11-09 20:01:45 -08:00
|
|
|
ld a, [hProduct + 3]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld d, a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, TempMonExp + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hld]
|
|
|
|
sub d
|
|
|
|
ld a, [hld]
|
|
|
|
sbc c
|
|
|
|
ld a, [hl]
|
|
|
|
sbc b
|
|
|
|
jr c, .asm_3f1a8
|
|
|
|
ld a, b
|
|
|
|
ld [hli], a
|
|
|
|
ld a, c
|
|
|
|
ld [hli], a
|
|
|
|
ld a, d
|
|
|
|
ld [hld], a
|
|
|
|
|
|
|
|
.asm_3f1a8
|
2015-11-03 09:36:33 -08:00
|
|
|
callab CalcLevel
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, d
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
ld d, a
|
|
|
|
cp e
|
|
|
|
jr nc, .asm_3f1b7
|
|
|
|
ld a, e
|
|
|
|
ld d, a
|
|
|
|
|
|
|
|
.asm_3f1b7
|
|
|
|
ld a, e
|
2014-03-05 02:42:09 -08:00
|
|
|
cp MAX_LEVEL
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nc, .asm_3f1ff
|
|
|
|
cp d
|
|
|
|
jr z, .asm_3f1ff
|
|
|
|
inc a
|
|
|
|
ld [TempMonLevel], a
|
|
|
|
ld [CurPartyLevel], a
|
|
|
|
ld [BattleMonLevel], a
|
|
|
|
push de
|
|
|
|
call Function3f21b
|
|
|
|
ld c, $40
|
|
|
|
call Function3f22c
|
|
|
|
call PrintPlayerHUD
|
|
|
|
ld hl, BattleMonNick
|
|
|
|
ld de, StringBuffer1
|
|
|
|
ld bc, $000b
|
|
|
|
call CopyBytes
|
|
|
|
call Function3dfe
|
|
|
|
ld de, SFX_HIT_END_OF_EXP_BAR
|
|
|
|
call PlaySFX
|
|
|
|
callba Function8e79d
|
|
|
|
call WaitSFX
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_StringBuffer1GrewToLevel
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
|
|
|
pop de
|
|
|
|
inc e
|
|
|
|
ld b, $0
|
|
|
|
jr .asm_3f1b7
|
|
|
|
|
|
|
|
.asm_3f1ff
|
|
|
|
push bc
|
|
|
|
ld b, d
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, TempMonExp + 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
|
|
|
|
call Function3f21b
|
|
|
|
call Function3f22c
|
|
|
|
call Function3dfe
|
|
|
|
pop af
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [hProduct + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
2015-11-09 20:01:45 -08:00
|
|
|
ld [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
|
|
|
|
; 3f21b
|
|
|
|
|
|
|
|
Function3f21b: ; 3f21b
|
|
|
|
push bc
|
|
|
|
call WaitSFX
|
|
|
|
ld de, SFX_EXP_BAR
|
|
|
|
call PlaySFX
|
|
|
|
ld c, 10
|
|
|
|
call DelayFrames
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
; 3f22c
|
|
|
|
|
|
|
|
Function3f22c: ; 3f22c
|
|
|
|
ld d, $3
|
|
|
|
dec b
|
|
|
|
.asm_3f22f
|
|
|
|
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
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld c, d
|
|
|
|
call DelayFrames
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
pop bc
|
|
|
|
ld a, c
|
|
|
|
cp b
|
|
|
|
jr z, .asm_3f268
|
|
|
|
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
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld c, d
|
|
|
|
call DelayFrames
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
dec d
|
|
|
|
jr nz, .asm_3f263
|
|
|
|
ld d, $1
|
|
|
|
|
|
|
|
.asm_3f263
|
|
|
|
pop bc
|
|
|
|
ld a, c
|
|
|
|
cp b
|
|
|
|
jr nz, .asm_3f22f
|
|
|
|
|
|
|
|
.asm_3f268
|
|
|
|
ld a, $1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
SendOutPkmnText: ; 3f26d
|
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
|
|
|
|
|
|
|
ld hl, JumpText_GoPkmn ; If we're in a LinkBattle print just "Go <PlayerMon>"
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, [wd264] ; unless this (unidentified) variable is set
|
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
|
2015-09-06 14:38:01 -07:00
|
|
|
; Depending on the HP of the enemy Pkmn, the game prints a different text
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, JumpText_GoPkmn
|
2015-11-10 13:53:37 -08:00
|
|
|
jr z, .skip_to_textbox
|
2015-09-06 14:38:01 -07:00
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
; compute enemy helth remaining as a percentage
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 0], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [wEnemyHPAtTimeOfPlayerSwitch], a
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, 25
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hMultiplier], a
|
|
|
|
call Multiply
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonMaxHP
|
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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call Divide
|
2015-11-10 13:53:37 -08:00
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
|
|
|
ld hl, JumpText_GoPkmn
|
2015-11-10 13:53:37 -08:00
|
|
|
cp 70
|
|
|
|
jr nc, .skip_to_textbox
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, JumpText_DoItPkmn
|
2015-11-10 13:53:37 -08:00
|
|
|
cp 40
|
|
|
|
jr nc, .skip_to_textbox
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
ld hl, JumpText_GoForItPkmn
|
2015-11-10 13:53:37 -08:00
|
|
|
cp 10
|
|
|
|
jr nc, .skip_to_textbox
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, JumpText_YourFoesWeakGetmPkmn
|
|
|
|
.skip_to_textbox
|
2013-12-17 22:11:06 -08:00
|
|
|
jp BattleTextBox
|
|
|
|
; 3f2d1
|
|
|
|
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
JumpText_GoPkmn: ; 3f2d1
|
|
|
|
text_jump Text_GoPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
start_asm
|
2015-09-06 14:38:01 -07:00
|
|
|
jr Function_TextJump_BattleMonNick01
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3f2d6
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
JumpText_DoItPkmn: ; 3f2d8
|
|
|
|
text_jump Text_DoItPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
start_asm
|
2015-09-06 14:38:01 -07:00
|
|
|
jr Function_TextJump_BattleMonNick01
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3f2dd
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
JumpText_GoForItPkmn: ; 3f2df
|
|
|
|
text_jump Text_GoForItPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
start_asm
|
2015-09-06 14:38:01 -07:00
|
|
|
jr Function_TextJump_BattleMonNick01
|
2013-12-17 22:11:06 -08:00
|
|
|
; 3f2e4
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
JumpText_YourFoesWeakGetmPkmn: ; 3f2e6
|
|
|
|
text_jump Text_YourFoesWeakGetmPkmn
|
2013-12-17 22:11:06 -08:00
|
|
|
start_asm
|
|
|
|
; 3f2eb
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
Function_TextJump_BattleMonNick01: ; 3f2eb
|
|
|
|
ld hl, TextJump_BattleMonNick01
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f2ef
|
|
|
|
|
2015-09-06 14:38:01 -07:00
|
|
|
TextJump_BattleMonNick01: ; 3f2ef
|
|
|
|
text_jump Text_BattleMonNick01
|
2013-12-17 22:11:06 -08:00
|
|
|
db "@"
|
|
|
|
; 3f2f4
|
|
|
|
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
BattleMonNickComma_TextBox: ; 3f2f4
|
|
|
|
ld hl, TextJump_BattleMonNickComma
|
2013-12-17 22:11:06 -08:00
|
|
|
jp BattleTextBox
|
|
|
|
; 3f2fa
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
TextJump_BattleMonNickComma: ; 3f2fa
|
|
|
|
text_jump Text_BattleMonNickComma
|
2013-12-17 22:11:06 -08:00
|
|
|
start_asm
|
|
|
|
; 3f2ff
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
WithdrawPkmnText: ; 3f2ff
|
2015-09-09 16:27:07 -07:00
|
|
|
; Print text to withdraw Pkmn
|
|
|
|
; depending on HP the message is different
|
2013-12-17 22:11:06 -08:00
|
|
|
push de
|
|
|
|
push bc
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonHP + 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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
dec de
|
|
|
|
ld b, [hl]
|
|
|
|
ld a, [de]
|
|
|
|
sbc b
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hMultiplicand + 1], a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, 25
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hMultiplier], a
|
|
|
|
call Multiply
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonMaxHP
|
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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2013-12-17 22:11:06 -08:00
|
|
|
call Divide
|
|
|
|
pop bc
|
|
|
|
pop de
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, TextJump_ThatsEnoughComeBack
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
ret z
|
2015-09-09 16:27:07 -07:00
|
|
|
|
|
|
|
ld hl, TextJump_ComeBack
|
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
|
|
|
|
|
|
|
ld hl, TextJump_OKComeBack
|
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
|
|
|
|
|
|
|
ld hl, TextJump_GoodComeBack
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f348
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
TextJump_ThatsEnoughComeBack: ; 3f348
|
|
|
|
text_jump Text_ThatsEnoughComeBack
|
2013-12-17 22:11:06 -08:00
|
|
|
db "@"
|
|
|
|
; 3f34d
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
TextJump_OKComeBack: ; 3f34d
|
|
|
|
text_jump Text_OKComeBack
|
2013-12-17 22:11:06 -08:00
|
|
|
db "@"
|
|
|
|
; 3f352
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
TextJump_GoodComeBack: ; 3f352
|
|
|
|
text_jump Text_GoodComeBack
|
2013-12-17 22:11:06 -08:00
|
|
|
db "@"
|
|
|
|
; 3f357
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
Function_TextJump_ComeBack: ; 3f357
|
|
|
|
; this function doesn't seem to be used
|
|
|
|
ld hl, TextJump_ComeBack
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f35b
|
|
|
|
|
2015-09-09 16:27:07 -07:00
|
|
|
TextJump_ComeBack: ; 3f35b
|
|
|
|
text_jump Text_ComeBack
|
2013-12-17 22:11:06 -08:00
|
|
|
db "@"
|
|
|
|
; 3f360
|
|
|
|
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
HandleSafariAngerEatingStatus: ; unreferenced
|
|
|
|
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]
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_WildPkmnIsEating
|
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
|
|
|
|
dec hl ; wSafariMonAngerCount
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
dec [hl]
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_WildPkmnIsAngry
|
2015-11-10 13:53:37 -08:00
|
|
|
jr nz, .finish
|
2013-12-17 22:11:06 -08:00
|
|
|
push hl
|
|
|
|
ld a, [EnemyMonSpecies]
|
|
|
|
ld [CurSpecies], a
|
|
|
|
call GetBaseData
|
|
|
|
ld a, [BaseCatchRate]
|
|
|
|
ld [EnemyMonCatchRate], a
|
|
|
|
pop hl
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
.finish
|
2013-12-17 22:11:06 -08:00
|
|
|
push hl
|
2015-09-09 16:27:07 -07:00
|
|
|
call Call_LoadTempTileMapToTileMap
|
2013-12-17 22:11:06 -08:00
|
|
|
pop hl
|
|
|
|
jp StdBattleTextBox
|
|
|
|
; 3f390
|
|
|
|
|
|
|
|
|
|
|
|
FillInExpBar: ; 3f390
|
|
|
|
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
|
|
|
; 3f39c
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
CalcExpBar: ; 3f39c
|
|
|
|
; 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
|
2015-11-03 09:36:33 -08:00
|
|
|
callab 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
|
2015-11-03 09:36:33 -08:00
|
|
|
callab 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]
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hMathBuffer + 2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
|
|
|
sub b
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [hl]
|
2015-11-10 13:53:37 -08:00
|
|
|
ld [hMathBuffer + 1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
pop bc
|
|
|
|
sbc b
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [hl]
|
|
|
|
ld [hMathBuffer], a
|
|
|
|
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
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, [hMathBuffer + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
sub c
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [de]
|
|
|
|
dec de
|
|
|
|
ld b, a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld a, [hMathBuffer + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
sbc b
|
|
|
|
ld [hld], a
|
|
|
|
ld a, [de]
|
|
|
|
ld c, a
|
|
|
|
ld a, [hMathBuffer]
|
|
|
|
sbc c
|
|
|
|
ld [hld], a
|
|
|
|
xor a
|
|
|
|
ld [hl], a
|
2015-11-10 13:53:37 -08:00
|
|
|
; multiply by 64
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $40
|
|
|
|
ld [hMultiplier], a
|
|
|
|
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
|
2015-09-06 14:38:01 -07:00
|
|
|
ld [hDivisor], a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld b, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
call Divide
|
2015-09-06 14:38:01 -07:00
|
|
|
ld a, [hQuotient + 2]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, a
|
|
|
|
ld a, $40
|
|
|
|
sub b
|
|
|
|
ld b, a
|
|
|
|
ret
|
|
|
|
; 3f41c
|
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
PlaceExpBar: ; 3f41c
|
|
|
|
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
|
|
|
|
; 3f43d
|
|
|
|
|
2015-11-06 11:45:10 -08:00
|
|
|
GetMonBackpic: ; 3f43d
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PlayerSubStatus4]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, BattleAnimCmd_RaiseSub
|
|
|
|
jr nz, GetBackpic_DoAnim ; substitute
|
2014-06-17 12:52:32 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
Function3f447: ; 3f447
|
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
|
|
|
|
jr nz, GetBackpic_DoAnim
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartySpecies]
|
|
|
|
push af
|
|
|
|
ld a, [BattleMonSpecies]
|
|
|
|
ld [CurPartySpecies], a
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, BattleMonDVs
|
2014-06-16 11:20:01 -07:00
|
|
|
predef GetUnownLetter
|
2015-10-14 06:29:15 -07:00
|
|
|
ld de, VTiles2 tile $31
|
2014-06-18 00:55:44 -07:00
|
|
|
predef GetBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
ret
|
2013-12-31 01:09:00 -08:00
|
|
|
; 3f46f
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
GetBackpic_DoAnim: ; 3f46f
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
push af
|
|
|
|
xor a
|
|
|
|
ld [hBattleTurn], a
|
|
|
|
ld a, BANK(BattleAnimCommands)
|
|
|
|
rst FarCall
|
|
|
|
pop af
|
|
|
|
ld [hBattleTurn], a
|
|
|
|
ret
|
|
|
|
; 3f47c
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
GetMonFrontpic: ; 3f47c
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [EnemySubStatus4]
|
2014-06-17 12:52:32 -07:00
|
|
|
bit SUBSTATUS_SUBSTITUTE, a
|
2015-11-10 13:53:37 -08:00
|
|
|
ld hl, BattleAnimCmd_RaiseSub
|
|
|
|
jr nz, GetFrontpic_DoAnim
|
2014-06-18 00:55:44 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
Function3f486: ; 3f486
|
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
|
|
|
|
jr nz, GetFrontpic_DoAnim
|
2014-06-18 00:55:44 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartySpecies]
|
|
|
|
push af
|
|
|
|
ld a, [EnemyMonSpecies]
|
|
|
|
ld [CurSpecies], a
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
call GetBaseData
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonDVs
|
2014-06-16 11:20:01 -07:00
|
|
|
predef GetUnownLetter
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, VTiles2
|
2014-06-16 11:20:01 -07:00
|
|
|
predef Function5108b
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
|
|
|
ld [CurPartySpecies], a
|
|
|
|
ret
|
2013-12-31 01:09:00 -08:00
|
|
|
; 3f4b4
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-10 13:53:37 -08:00
|
|
|
GetFrontpic_DoAnim: ; 3f4b4
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hBattleTurn]
|
|
|
|
push af
|
|
|
|
call SetEnemyTurn
|
|
|
|
ld a, BANK(BattleAnimCommands)
|
|
|
|
rst FarCall
|
|
|
|
pop af
|
|
|
|
ld [hBattleTurn], a
|
|
|
|
ret
|
|
|
|
; 3f4c1
|
|
|
|
|
|
|
|
|
|
|
|
StartBattle: ; 3f4c1
|
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.
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [PartyCount]
|
|
|
|
and a
|
|
|
|
ret z
|
2015-10-24 07:34:19 -07:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [TimeOfDayPal]
|
|
|
|
push af
|
2015-11-10 17:18:49 -08:00
|
|
|
call BattleIntro
|
2015-11-10 20:23:28 -08:00
|
|
|
call SendOutFirstMons
|
|
|
|
call ExitBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
pop af
|
|
|
|
ld [TimeOfDayPal], a
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
; 3f4d9
|
|
|
|
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
_SendOutFirstMons: ; 3f4d9
|
|
|
|
; unreferenced
|
|
|
|
call SendOutFirstMons
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f4dd
|
|
|
|
|
|
|
|
|
2015-11-10 17:18:49 -08:00
|
|
|
BattleIntro: ; 3f4dd
|
2015-10-24 07:34:19 -07:00
|
|
|
callba MobileFn_106050 ; mobile
|
|
|
|
call LoadTrainerOrWildMonPic
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [TempBattleMonSpecies], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0d2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-11-05 11:06:03 -08:00
|
|
|
ld [hMapAnims], a
|
2013-12-17 22:11:06 -08:00
|
|
|
callba PlayBattleMusic
|
2015-10-24 07:34:19 -07:00
|
|
|
callba ShowLinkBattleParticipants
|
|
|
|
callba FindFirstAliveMon
|
|
|
|
call DisableSpriteUpdates
|
2013-12-17 22:11:06 -08:00
|
|
|
callba ClearBattleRAM
|
2015-11-06 13:42:38 -08:00
|
|
|
call InitEnemy
|
|
|
|
call BackUpVBGMap2
|
2015-11-16 13:01:45 -08:00
|
|
|
ld b, SCGB_00
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetSGBLayout
|
|
|
|
ld hl, rLCDC
|
|
|
|
res 6, [hl]
|
2015-11-10 17:18:49 -08:00
|
|
|
call InitBattleDisplay
|
2013-12-17 22:11:06 -08:00
|
|
|
call BattleStartMessage
|
|
|
|
ld hl, rLCDC
|
|
|
|
set 6, [hl]
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
call EmptyBattleTextBox
|
|
|
|
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]
|
2013-12-17 22:11:06 -08:00
|
|
|
cp $1
|
2014-06-16 22:52:59 -07:00
|
|
|
call z, UpdateEnemyHUD
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ret
|
|
|
|
; 3f54e
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
LoadTrainerOrWildMonPic: ; 3f54e
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [OtherTrainerClass]
|
|
|
|
and a
|
2015-10-24 07:34:19 -07:00
|
|
|
jr nz, .Trainer
|
2015-07-23 00:41:52 -07:00
|
|
|
ld a, [TempWildMonSpecies]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurPartySpecies], a
|
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
.Trainer
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [TempEnemyMonSpecies], a
|
|
|
|
ret
|
|
|
|
; 3f55e
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
InitEnemy: ; 3f55e
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [OtherTrainerClass]
|
|
|
|
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
|
|
|
; 3f568
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
BackUpVBGMap2: ; 3f568
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2015-11-06 13:42:38 -08:00
|
|
|
ld a, $6 ; BANK(w6_d000)
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [rSVBK], a
|
2015-02-10 18:21:38 -08:00
|
|
|
ld hl, w6_d000
|
2015-11-06 13:42:38 -08:00
|
|
|
ld bc, $40 tiles ; VBGMap3 - VBGMap2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $2
|
|
|
|
call ByteFill
|
|
|
|
ld a, [rVBK]
|
|
|
|
push af
|
|
|
|
ld a, $1
|
|
|
|
ld [rVBK], a
|
2015-02-10 18:21:38 -08:00
|
|
|
ld de, w6_d000
|
2015-11-06 13:42:38 -08:00
|
|
|
ld hl, VBGMap0 ; VBGMap2
|
|
|
|
lb bc, BANK(BackUpVBGMap2), $40
|
2013-12-17 22:11:06 -08:00
|
|
|
call Request2bpp
|
|
|
|
pop af
|
|
|
|
ld [rVBK], a
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 3f594
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
InitEnemyTrainer: ; 3f594
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [TrainerClass], a
|
2015-10-24 07:34:19 -07:00
|
|
|
callba MobileFn_10606a
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [TempEnemyMonSpecies], a
|
|
|
|
callab Function3957b
|
2014-06-14 22:33:23 -07:00
|
|
|
callab ReadTrainerParty
|
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [TrainerClass]
|
2014-06-14 22:33:23 -07:00
|
|
|
cp RIVAL1
|
|
|
|
jr nz, .ok
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [OTPartyMon1Item], a
|
2014-06-14 22:33:23 -07:00
|
|
|
.ok
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
ld de, VTiles2
|
2014-06-18 00:55:44 -07:00
|
|
|
callab GetTrainerPic
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hFillBox], a
|
2013-12-17 22:11:06 -08:00
|
|
|
dec a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wc6e6], a
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 12, 0
|
2014-06-14 22:33:23 -07:00
|
|
|
lb bc, 7, 7
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FillBox
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, -1
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurOTMon], 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
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
call IsJohtoGymLeader
|
2015-10-12 09:33:24 -07:00
|
|
|
jr nc, .done
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [CurPartyMon], a
|
|
|
|
ld a, [PartyCount]
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
callab 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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, CurPartyMon
|
|
|
|
inc [hl]
|
2015-10-12 09:33:24 -07:00
|
|
|
jr .partyloop
|
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f607
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
InitEnemyWildmon: ; 3f607
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
2015-10-19 07:23:58 -07:00
|
|
|
ld [wBattleMode], a
|
2015-10-24 07:34:19 -07:00
|
|
|
callba MobileFn_10605d
|
2013-12-17 22:11:06 -08:00
|
|
|
call LoadEnemyMon
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonMoves
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, wc735
|
2014-06-10 23:08:07 -07:00
|
|
|
ld bc, NUM_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonPP
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, wc739
|
2014-06-10 23:08:07 -07:00
|
|
|
ld bc, NUM_MOVES
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2014-06-12 18:32:42 -07:00
|
|
|
ld hl, EnemyMonDVs
|
2014-06-16 11:20:01 -07:00
|
|
|
predef GetUnownLetter
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurPartySpecies]
|
2014-06-10 23:08:07 -07:00
|
|
|
cp UNOWN
|
2015-11-09 20:55:39 -08:00
|
|
|
jr nz, .skip_unown
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wdef4]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
2015-11-09 20:55:39 -08:00
|
|
|
jr nz, .skip_unown
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [UnownLetter]
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wdef4], a
|
2015-11-09 20:55:39 -08:00
|
|
|
.skip_unown
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, VTiles2
|
2014-06-16 11:20:01 -07:00
|
|
|
predef Function5108b
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [TrainerClass], a
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hFillBox], a
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 12, 0
|
2014-06-14 22:33:23 -07:00
|
|
|
lb bc, 7, 7
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FillBox
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f662
|
|
|
|
|
|
|
|
Function3f662: ; 3f662
|
2014-06-10 23:08:07 -07:00
|
|
|
ld hl, EnemyMonMoves
|
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
|
|
|
|
|
|
|
ld bc, EnemyMonPP - (EnemyMonMoves + 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
|
2014-01-05 04:28:55 -08:00
|
|
|
ld bc, EnemyMonPP - (EnemyMonMoves + 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
|
|
|
|
; 3f69e
|
|
|
|
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
ExitBattle: ; 3f69e
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3f6a5
|
2015-11-10 20:23:28 -08:00
|
|
|
call CleanUpBattleRAM
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f6a5
|
|
|
|
|
|
|
|
Function3f6a5: ; 3f6a5
|
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
|
|
|
|
call Function3f77c
|
|
|
|
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-02-08 00:03:32 -08:00
|
|
|
ld [wd1e9], a
|
2015-11-18 15:35:44 -08:00
|
|
|
predef EvolveAfterBattle
|
2013-12-17 22:11:06 -08:00
|
|
|
callba Function2ed44
|
|
|
|
ret
|
|
|
|
; 3f6d0
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
CleanUpBattleRAM: ; 3f6d0
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3f998
|
|
|
|
xor a
|
|
|
|
ld [Danger], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld [wBattleMode], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [BattleType], a
|
|
|
|
ld [AttackMissed], a
|
2015-07-23 00:41:52 -07:00
|
|
|
ld [TempWildMonSpecies], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [OtherTrainerClass], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd266], a
|
|
|
|
ld [wd267], a
|
2015-11-08 16:09:36 -08:00
|
|
|
ld [wForcedSwitch], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0d8], a
|
2015-10-24 16:49:19 -07:00
|
|
|
ld [wKeyItemsPocketCursor], a
|
|
|
|
ld [wItemsPocketCursor], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0d2], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [CurMoveNum], a
|
2015-10-24 16:49:19 -07:00
|
|
|
ld [wBallsPocketCursor], a
|
2015-02-08 00:03:32 -08:00
|
|
|
ld [wd0d6], a
|
|
|
|
ld [wd0e4], a
|
|
|
|
ld [wd0e0], a
|
|
|
|
ld [wd0df], a
|
|
|
|
ld [wd0e1], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, PlayerSubStatus1
|
|
|
|
ld b, $18
|
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
|
|
|
|
; 3f71d
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
CheckPayDay: ; 3f71d
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, wPayDayMoney
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
inc hl
|
|
|
|
or [hl]
|
|
|
|
ret z
|
2015-02-08 00:03:32 -08:00
|
|
|
ld a, [wc73d]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
2015-11-10 20:23:28 -08:00
|
|
|
jr z, .okay
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, wPayDayMoney + 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
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
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
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
.okay
|
2014-06-13 21:18:14 -07:00
|
|
|
ld hl, wPayDayMoney + 2
|
2014-06-10 23:08:07 -07:00
|
|
|
ld de, Money + 2
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3d0be
|
2015-09-09 16:27:07 -07:00
|
|
|
ld hl, BattleText_PlayerPickuedUpPayDayMoney
|
2013-12-17 22:11:06 -08:00
|
|
|
call StdBattleTextBox
|
2015-09-04 13:30:40 -07:00
|
|
|
ld a, [InBattleTowerBattle]
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 0, a
|
|
|
|
ret z
|
|
|
|
call ClearTileMap
|
2015-11-11 20:38:57 -08:00
|
|
|
call ClearBGPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f759
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
ShowLinkBattleParticipantsAfterEnd: ; 3f759
|
2015-10-24 07:34:19 -07:00
|
|
|
callba MobileFn_1060df
|
2015-11-05 11:06:03 -08:00
|
|
|
callba BackupMobileEventIndex
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [CurOTMon]
|
|
|
|
ld hl, OTPartyMon1Status
|
|
|
|
call GetPartyLocation
|
|
|
|
ld a, [EnemyMonStatus]
|
|
|
|
ld [hl], a
|
|
|
|
call ClearTileMap
|
2015-10-24 07:34:19 -07:00
|
|
|
callba _ShowLinkBattleParticipants
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f77c
|
|
|
|
|
|
|
|
Function3f77c: ; 3f77c
|
2015-11-08 16:09:36 -08:00
|
|
|
callba CheckMobileBattleError
|
2015-11-10 20:23:28 -08:00
|
|
|
jp c, .Mobile_InvalidBattle
|
|
|
|
call IsMobileBattle2
|
2015-11-10 15:17:04 -08:00
|
|
|
jr nz, .proceed
|
2015-11-10 20:23:28 -08:00
|
|
|
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wcd2a
|
2013-12-17 22:11:06 -08:00
|
|
|
bit 4, [hl]
|
2015-11-10 15:17:04 -08:00
|
|
|
jr z, .proceed
|
2015-11-10 20:23:28 -08:00
|
|
|
|
|
|
|
callba DetermineLinkBattleResult
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
.proceed
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $f
|
|
|
|
cp $1
|
2015-11-10 15:17:04 -08:00
|
|
|
jr c, .victory
|
|
|
|
jr z, .loss
|
2015-11-10 20:23:28 -08:00
|
|
|
callba MobileFn_SaveBattleResult_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
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
.victory
|
2015-11-10 20:23:28 -08:00
|
|
|
callba MobileFn_SaveBattleResult_Win
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, .Win
|
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
|
|
|
.loss
|
2015-11-10 20:23:28 -08:00
|
|
|
callba MobileFn_SaveBattleResult_Lose
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, .Lose
|
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-05 11:06:03 -08:00
|
|
|
callba BackupMobileEventIndex
|
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)
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetSRAMBank
|
2015-11-10 15:17:04 -08:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3fa42
|
|
|
|
call Function3f85f
|
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 IsMobileBattle2
|
|
|
|
jr z, .mobile
|
|
|
|
call WaitPressAorB_BlinkCursor
|
2013-12-17 22:11:06 -08:00
|
|
|
call ClearTileMap
|
|
|
|
ret
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
.mobile
|
2015-11-10 15:17:04 -08:00
|
|
|
ld c, 200
|
2013-12-17 22:11:06 -08:00
|
|
|
call DelayFrames
|
|
|
|
call ClearTileMap
|
|
|
|
ret
|
|
|
|
; 3f7f7
|
|
|
|
|
|
|
|
.Win
|
|
|
|
db "YOU WIN@"
|
|
|
|
.Lose
|
|
|
|
db "YOU LOSE@"
|
|
|
|
.Draw
|
|
|
|
db " DRAW@"
|
|
|
|
; 3f80f
|
|
|
|
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
.Mobile_InvalidBattle: ; 3f80f
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 6, 8
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, .Invalid
|
|
|
|
call PlaceString
|
2015-11-10 20:23:28 -08:00
|
|
|
ld c, 200
|
2013-12-17 22:11:06 -08:00
|
|
|
call DelayFrames
|
|
|
|
call ClearTileMap
|
|
|
|
ret
|
|
|
|
; 3f821
|
|
|
|
|
|
|
|
.Invalid
|
|
|
|
db "INVALID BATTLE@"
|
|
|
|
; 3f830
|
|
|
|
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
IsMobileBattle2: ; 3f830
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
|
|
|
cp LINK_MOBILE
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f836
|
|
|
|
|
|
|
|
|
2015-11-16 19:29:54 -08:00
|
|
|
DisplayLinkRecord: ; 3f836
|
2015-08-19 21:21:38 -07:00
|
|
|
ld a, BANK(sLinkBattleStats)
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetSRAMBank
|
2015-11-10 20:23:28 -08:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3f85f
|
2015-11-10 20:23:28 -08:00
|
|
|
|
2013-12-17 22:11:06 -08:00
|
|
|
call CloseSRAM
|
2015-07-22 12:57:02 -07:00
|
|
|
hlcoord 0, 0, AttrMap
|
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
|
|
|
|
call Function3200
|
2015-11-16 13:01:45 -08:00
|
|
|
ld b, SCGB_08
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetSGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, $8
|
|
|
|
call DelayFrames
|
2015-11-10 20:23:28 -08:00
|
|
|
call WaitPressAorB_BlinkCursor
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f85f
|
|
|
|
|
|
|
|
|
|
|
|
Function3f85f: ; 3f85f
|
|
|
|
call ClearTileMap
|
|
|
|
call ClearSprites
|
|
|
|
call .asm_3f8e0
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 0, 8
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $5
|
2015-10-04 11:14:51 -07:00
|
|
|
ld de, sLinkBattleStats + $8
|
2013-12-17 22:11:06 -08:00
|
|
|
.asm_3f870
|
|
|
|
push bc
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
ld a, [de]
|
|
|
|
and a
|
|
|
|
jr z, .asm_3f8c9
|
2015-10-16 10:35:43 -07:00
|
|
|
ld a, [wSavedAtLeastOnce]
|
2013-12-17 22:11:06 -08:00
|
|
|
and a
|
|
|
|
jr z, .asm_3f8c9
|
|
|
|
push hl
|
|
|
|
push hl
|
|
|
|
ld h, d
|
|
|
|
ld l, e
|
2015-11-10 16:51:13 -08:00
|
|
|
ld de, wd002
|
2013-12-17 22:11:06 -08:00
|
|
|
ld bc, $000a
|
|
|
|
call CopyBytes
|
|
|
|
ld a, $50
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
ld bc, $0006
|
|
|
|
call CopyBytes
|
2015-11-10 16:51:13 -08:00
|
|
|
ld de, wd002
|
2013-12-17 22:11:06 -08:00
|
|
|
pop hl
|
|
|
|
call PlaceString
|
|
|
|
pop hl
|
|
|
|
ld de, $001a
|
|
|
|
add hl, de
|
|
|
|
push hl
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, wd00d
|
2015-10-10 14:03:04 -07:00
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
call PrintNum
|
|
|
|
pop hl
|
|
|
|
ld de, $0005
|
|
|
|
add hl, de
|
|
|
|
push hl
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, wd00f
|
2015-10-10 14:03:04 -07:00
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
call PrintNum
|
|
|
|
pop hl
|
|
|
|
ld de, $0005
|
|
|
|
add hl, de
|
2015-02-08 00:03:32 -08:00
|
|
|
ld de, wd011
|
2015-10-10 14:03:04 -07:00
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
call PrintNum
|
|
|
|
jr .asm_3f8cf
|
|
|
|
|
|
|
|
.asm_3f8c9
|
|
|
|
ld de, .Format
|
|
|
|
call PlaceString
|
|
|
|
|
|
|
|
.asm_3f8cf
|
|
|
|
pop hl
|
|
|
|
ld bc, $0012
|
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
ld bc, $0028
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
|
|
|
jr nz, .asm_3f870
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3f8e0
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call .asm_3f92b
|
|
|
|
jr c, .asm_3f92a
|
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call .asm_3f92b
|
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call .asm_3f92b
|
|
|
|
|
2015-10-10 14:03:04 -07:00
|
|
|
lb bc, 2, 4
|
2013-12-17 22:11:06 -08:00
|
|
|
call PrintNum
|
|
|
|
|
|
|
|
.asm_3f92a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3f92b
|
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
|
|
|
|
; 3f938
|
|
|
|
|
|
|
|
.Scores
|
|
|
|
db " 0 0 0@"
|
|
|
|
; 3f947
|
|
|
|
|
|
|
|
.Format ; 3f947
|
2015-10-16 10:35:43 -07:00
|
|
|
db " --- <LNBRK> - - -@"
|
2013-12-17 22:11:06 -08:00
|
|
|
.Record ; 3f964
|
2015-10-16 10:35:43 -07:00
|
|
|
db "<PLAYER>'s RECORD@"
|
2013-12-17 22:11:06 -08:00
|
|
|
.Result ; 3f96e
|
|
|
|
db "RESULT WIN LOSE DRAW@"
|
|
|
|
.Total ; 3f983
|
|
|
|
db "TOTAL WIN LOSE DRAW@"
|
|
|
|
; 3f998
|
|
|
|
|
|
|
|
|
|
|
|
Function3f998: ; 3f998
|
|
|
|
ld a, [BattleType]
|
|
|
|
cp BATTLETYPE_ROAMING
|
|
|
|
jr nz, .asm_3f9c4
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $f
|
|
|
|
jr z, .asm_3f9af
|
|
|
|
call GetRoamMonHP
|
2014-06-12 18:32:42 -07:00
|
|
|
ld a, [EnemyMonHP + 1]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hl], a
|
|
|
|
jr .asm_3f9ca
|
|
|
|
|
|
|
|
.asm_3f9af
|
|
|
|
call GetRoamMonHP
|
|
|
|
ld [hl], $0
|
|
|
|
call GetRoamMonMapGroup
|
|
|
|
ld [hl], $ff
|
|
|
|
call GetRoamMonMapNumber
|
|
|
|
ld [hl], $ff
|
|
|
|
call GetRoamMonSpecies
|
|
|
|
ld [hl], $0
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_3f9c4
|
|
|
|
call BattleRandom
|
|
|
|
and $f
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
.asm_3f9ca
|
2015-07-20 00:51:52 -07:00
|
|
|
callab UpdateRoamMons
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3f9d1
|
|
|
|
|
|
|
|
GetRoamMonMapGroup: ; 3f9d1
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
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
|
|
|
|
; 3f9e9
|
|
|
|
|
|
|
|
GetRoamMonMapNumber: ; 3f9e9
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
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
|
|
|
|
; 3fa01
|
|
|
|
|
|
|
|
GetRoamMonHP: ; 3fa01
|
2014-06-12 18:32:42 -07:00
|
|
|
; output: hl = wRoamMonHP
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
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
|
|
|
|
; 3fa19
|
|
|
|
|
|
|
|
GetRoamMonDVs: ; 3fa19
|
2014-06-12 18:32:42 -07:00
|
|
|
; output: hl = wRoamMonDVs
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [TempEnemyMonSpecies]
|
|
|
|
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
|
|
|
|
; 3fa31
|
|
|
|
|
|
|
|
GetRoamMonSpecies: ; 3fa31
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
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
|
|
|
|
; 3fa42
|
|
|
|
|
|
|
|
|
|
|
|
Function3fa42: ; 3fa42
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wd276
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, StringBuffer1
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 2
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2015-02-08 00:03:32 -08:00
|
|
|
ld hl, wd26b
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 10
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2015-11-10 15:17:04 -08:00
|
|
|
ld hl, s1_b254
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3faa0
|
2015-11-10 15:17:04 -08:00
|
|
|
ld hl, s1_b266
|
|
|
|
ld d, 5
|
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
push hl
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
inc hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hl]
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
dec hl
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
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
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 12
|
2013-12-17 22:11:06 -08:00
|
|
|
ld de, StringBuffer1
|
|
|
|
call CompareLong
|
|
|
|
pop de
|
|
|
|
pop hl
|
2015-11-10 15:17:04 -08:00
|
|
|
jr c, .done
|
|
|
|
ld bc, 18
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
|
|
|
dec d
|
2015-11-10 15:17:04 -08:00
|
|
|
jr nz, .loop
|
2015-11-09 20:01:45 -08:00
|
|
|
ld bc, -18
|
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
|
|
|
|
ld hl, StringBuffer1
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 12
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call Function3faa0
|
|
|
|
call Function3fac8
|
|
|
|
ret
|
|
|
|
; 3faa0
|
|
|
|
|
|
|
|
Function3faa0: ; 3faa0
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wBattleResult]
|
2013-12-17 22:11:06 -08:00
|
|
|
and $f
|
|
|
|
cp $1
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 13
|
|
|
|
jr c, .okay
|
|
|
|
ld bc, 15
|
|
|
|
jr z, .okay
|
|
|
|
ld bc, 17
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
.okay
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
|
|
|
call Function3fabe
|
|
|
|
ret nc
|
|
|
|
inc [hl]
|
|
|
|
ret nz
|
|
|
|
dec hl
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 3fabe
|
|
|
|
|
|
|
|
Function3fabe: ; 3fabe
|
|
|
|
dec hl
|
|
|
|
ld a, [hl]
|
|
|
|
inc hl
|
|
|
|
cp $27
|
|
|
|
ret c
|
|
|
|
ld a, [hl]
|
|
|
|
cp $f
|
|
|
|
ret
|
|
|
|
; 3fac8
|
|
|
|
|
|
|
|
Function3fac8: ; 3fac8
|
|
|
|
ld b, $5
|
2015-11-10 15:17:04 -08:00
|
|
|
ld hl, s1_b277
|
2015-11-10 16:51:13 -08:00
|
|
|
ld de, wd002
|
2015-11-10 15:17:04 -08:00
|
|
|
.loop
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
call Function3fb54
|
|
|
|
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
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 18
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec b
|
2015-11-10 15:17:04 -08:00
|
|
|
jr nz, .loop
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $0
|
|
|
|
ld c, $1
|
2015-11-10 15:17:04 -08:00
|
|
|
.loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, b
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add b
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld e, a
|
|
|
|
ld d, $0
|
2015-11-10 16:51:13 -08:00
|
|
|
ld hl, wd002
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, de
|
|
|
|
push hl
|
|
|
|
ld a, c
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 2
|
2013-12-17 22:11:06 -08:00
|
|
|
add c
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-12-17 22:11:06 -08:00
|
|
|
ld e, a
|
|
|
|
ld d, $0
|
2015-11-10 16:51:13 -08:00
|
|
|
ld hl, wd002
|
2013-12-17 22:11:06 -08:00
|
|
|
add hl, de
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
push bc
|
|
|
|
ld c, $3
|
|
|
|
call StringCmp
|
|
|
|
pop bc
|
2015-11-10 15:17:04 -08:00
|
|
|
jr z, .equal
|
|
|
|
jr nc, .done
|
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
|
2015-11-10 15:17:04 -08:00
|
|
|
jr nz, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
inc b
|
|
|
|
ld c, b
|
|
|
|
inc c
|
|
|
|
ld a, b
|
|
|
|
cp $4
|
2015-11-10 15:17:04 -08:00
|
|
|
jr nz, .loop2
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
.done
|
2013-12-17 22:11:06 -08:00
|
|
|
push bc
|
|
|
|
ld a, b
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 18
|
|
|
|
ld hl, s1_b266
|
2013-12-17 22:11:06 -08:00
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2015-11-10 16:51:13 -08:00
|
|
|
ld de, wd002
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 18
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
push hl
|
|
|
|
ld a, c
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 18
|
|
|
|
ld hl, s1_b266
|
2013-12-17 22:11:06 -08:00
|
|
|
call AddNTimes
|
|
|
|
pop de
|
|
|
|
push hl
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 18
|
2013-12-17 22:11:06 -08:00
|
|
|
call CopyBytes
|
2015-11-10 16:51:13 -08:00
|
|
|
ld hl, wd002
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, 18
|
2013-12-17 22:11:06 -08:00
|
|
|
pop de
|
|
|
|
call CopyBytes
|
|
|
|
ret
|
|
|
|
; 3fb54
|
|
|
|
|
|
|
|
Function3fb54: ; 3fb54
|
|
|
|
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
|
2015-11-10 15:17:04 -08:00
|
|
|
jr nc, .okay
|
2013-12-17 22:11:06 -08:00
|
|
|
inc e
|
|
|
|
|
2015-11-10 15:17:04 -08:00
|
|
|
.okay
|
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
|
|
|
|
; 3fb6c
|
|
|
|
|
2015-11-10 17:18:49 -08:00
|
|
|
InitBattleDisplay: ; 3fb6c
|
|
|
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
call TextBox
|
|
|
|
callba MobileTextBorder
|
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
|
2015-11-05 11:06:03 -08:00
|
|
|
ld [hMapAnims], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hSCY], a
|
|
|
|
ld a, $90
|
|
|
|
ld [hWY], a
|
|
|
|
ld [rWY], a
|
|
|
|
call WaitBGMap
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
2015-11-10 17:18:49 -08:00
|
|
|
callba SlideBattlePics
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld a, $31
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hFillBox], a
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 2, 6
|
2015-11-06 13:42:38 -08:00
|
|
|
lb bc, 6, 6
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FillBox
|
2013-12-17 22:11:06 -08:00
|
|
|
xor a
|
|
|
|
ld [hWY], a
|
|
|
|
ld [rWY], a
|
|
|
|
call WaitBGMap
|
|
|
|
call HideSprites
|
2015-11-16 13:01:45 -08:00
|
|
|
ld b, SCGB_01
|
2013-12-17 22:11:06 -08:00
|
|
|
call GetSGBLayout
|
2015-09-09 16:27:07 -07:00
|
|
|
call SetPalettes
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $90
|
|
|
|
ld [hWY], a
|
|
|
|
xor a
|
|
|
|
ld [hSCX], a
|
|
|
|
ret
|
|
|
|
; 3fbd6
|
|
|
|
|
2015-11-10 17:18:49 -08:00
|
|
|
.BlankBGMap: ; 3fbd6
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, $6
|
|
|
|
ld [rSVBK], a
|
2015-11-10 15:17:04 -08:00
|
|
|
|
2015-02-10 18:21:38 -08:00
|
|
|
ld hl, w6_d000
|
2015-11-10 15:17:04 -08:00
|
|
|
ld bc, w6_d400 - w6_d000
|
|
|
|
ld a, " "
|
2013-12-17 22:11:06 -08:00
|
|
|
call ByteFill
|
2015-11-10 15:17:04 -08:00
|
|
|
|
2015-02-10 18:21:38 -08:00
|
|
|
ld de, w6_d000
|
2013-12-17 22:11:06 -08:00
|
|
|
ld hl, VBGMap0
|
2015-11-10 17:18:49 -08:00
|
|
|
lb bc, BANK(.BlankBGMap), $40
|
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
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 3fbf8
|
|
|
|
|
2015-11-10 17:18:49 -08:00
|
|
|
.InitBackPic: ; 3fbf8
|
2015-11-06 13:42:38 -08:00
|
|
|
call GetTrainerBackpic
|
|
|
|
call CopyBackpic
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3fbff
|
|
|
|
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
GetTrainerBackpic: ; 3fbff
|
2013-12-17 22:11:06 -08:00
|
|
|
; Load the player character's backpic (6x6) into VRAM starting from $9310.
|
|
|
|
|
|
|
|
; Special exception for Dude.
|
|
|
|
ld b, BANK(DudeBackpic)
|
|
|
|
ld hl, DudeBackpic
|
|
|
|
ld a, [BattleType]
|
|
|
|
cp BATTLETYPE_TUTORIAL
|
|
|
|
jr z, .Decompress
|
|
|
|
|
|
|
|
; What gender are we?
|
2015-10-24 07:34:19 -07:00
|
|
|
ld a, [wPlayerSpriteSetupFlags]
|
2015-11-16 13:01:45 -08:00
|
|
|
bit 2, a ; transformed to male
|
2013-12-17 22:11:06 -08:00
|
|
|
jr nz, .Chris
|
|
|
|
ld a, [PlayerGender]
|
|
|
|
bit 0, a
|
|
|
|
jr z, .Chris
|
|
|
|
|
|
|
|
; It's a girl.
|
|
|
|
callba GetKrisBackpic
|
|
|
|
ret
|
|
|
|
|
|
|
|
.Chris
|
|
|
|
; It's a boy.
|
|
|
|
ld b, BANK(ChrisBackpic)
|
|
|
|
ld hl, ChrisBackpic
|
|
|
|
|
|
|
|
.Decompress
|
2015-10-14 06:29:15 -07:00
|
|
|
ld de, VTiles2 tile $31
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, $31
|
2014-06-16 11:20:01 -07:00
|
|
|
predef DecompressPredef
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3fc30
|
|
|
|
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
CopyBackpic: ; 3fc30
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
|
|
|
ld a, $6
|
|
|
|
ld [rSVBK], a
|
|
|
|
ld hl, VTiles0
|
2015-10-14 06:29:15 -07:00
|
|
|
ld de, VTiles2 tile $31
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [hROMBank]
|
|
|
|
ld b, a
|
|
|
|
ld c, $31
|
|
|
|
call Get2bpp
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
call Function3fc5b
|
|
|
|
ld a, $31
|
2015-11-09 13:41:09 -08:00
|
|
|
ld [hFillBox], a
|
2014-06-04 01:10:56 -07:00
|
|
|
hlcoord 2, 6
|
2015-11-06 13:42:38 -08:00
|
|
|
lb bc, 6, 6
|
2014-06-16 11:20:01 -07:00
|
|
|
predef FillBox
|
2013-12-17 22:11:06 -08:00
|
|
|
ret
|
|
|
|
; 3fc5b
|
|
|
|
|
|
|
|
Function3fc5b: ; 3fc5b
|
|
|
|
ld hl, Sprites
|
|
|
|
xor a
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [hMapObjectIndexBuffer], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld b, $6
|
|
|
|
ld e, $a8
|
2015-11-06 13:42:38 -08:00
|
|
|
.outer_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
ld c, $3
|
|
|
|
ld d, $40
|
2015-11-06 13:42:38 -08:00
|
|
|
.inner_loop
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hl], d
|
|
|
|
inc hl
|
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [hMapObjectIndexBuffer]
|
2013-12-17 22:11:06 -08:00
|
|
|
ld [hli], a
|
|
|
|
inc a
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [hMapObjectIndexBuffer], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, $1
|
|
|
|
ld [hli], a
|
|
|
|
ld a, d
|
|
|
|
add $8
|
|
|
|
ld d, a
|
|
|
|
dec c
|
2015-11-06 13:42:38 -08:00
|
|
|
jr nz, .inner_loop
|
2015-11-02 08:15:32 -08:00
|
|
|
ld a, [hMapObjectIndexBuffer]
|
2013-12-17 22:11:06 -08:00
|
|
|
add $3
|
2015-11-02 08:15:32 -08:00
|
|
|
ld [hMapObjectIndexBuffer], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, e
|
|
|
|
add $8
|
|
|
|
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
|
|
|
|
; 3fc8b
|
|
|
|
|
|
|
|
|
|
|
|
BattleStartMessage: ; 3fc8b
|
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
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
callba 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-02-08 00:03:32 -08:00
|
|
|
ld [wcfca], a
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, 1
|
|
|
|
ld [hBattleTurn], a
|
|
|
|
ld a, 1
|
2015-11-06 17:55:16 -08:00
|
|
|
ld [wKickCounter], 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
|
2013-12-17 22:11:06 -08:00
|
|
|
callba CheckSleepingTreeMon
|
2015-11-06 13:42:38 -08:00
|
|
|
jr c, .skip_cry
|
2013-12-17 22:11:06 -08:00
|
|
|
|
|
|
|
callba 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
|
|
|
|
predef AnimateFrontpic
|
2015-11-06 13:42:38 -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, $0f
|
|
|
|
ld [CryTracks], a
|
|
|
|
ld a, [TempEnemyMonSpecies]
|
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
|
2013-12-17 22:11:06 -08:00
|
|
|
ld a, [BattleType]
|
|
|
|
cp BATTLETYPE_FISH
|
2015-11-06 13:42:38 -08:00
|
|
|
jr nz, .NotFishing
|
2013-12-17 22:11:06 -08:00
|
|
|
|
2015-10-24 07:34:19 -07:00
|
|
|
callba MobileFn_106086
|
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
|
|
|
|
2015-11-06 13:42:38 -08: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
|
|
|
|
|
2015-11-06 13:42:38 -08:00
|
|
|
.PlaceBattleStartText
|
2013-12-17 22:11:06 -08:00
|
|
|
push hl
|
|
|
|
callba Function2c000
|
|
|
|
pop hl
|
|
|
|
call StdBattleTextBox
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
call IsMobileBattle2
|
2013-12-17 22:11:06 -08:00
|
|
|
ret nz
|
|
|
|
|
|
|
|
ld c, $2
|
|
|
|
callba Function4ea0a
|
|
|
|
|
|
|
|
ret
|
|
|
|
; 3fd26
|