2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_BeatUp:
|
2018-01-26 08:36:00 -08:00
|
|
|
; beatup
|
|
|
|
|
|
|
|
call ResetDamage
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jp nz, .enemy_beats_up
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerSubStatus3]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_IN_LOOP, a
|
|
|
|
jr nz, .next_mon
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, 20
|
|
|
|
call DelayFrames
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wPlayerRolloutCount], a
|
2020-10-29 11:45:40 -07:00
|
|
|
ld [wCurBeatUpPartyMon], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wBeatUpHitAtLeastOnce], a
|
|
|
|
jr .got_mon
|
|
|
|
|
|
|
|
.next_mon
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPlayerRolloutCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
sub b
|
2020-10-29 11:45:40 -07:00
|
|
|
ld [wCurBeatUpPartyMon], a
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.got_mon
|
2020-10-29 11:45:40 -07:00
|
|
|
ld a, [wCurBeatUpPartyMon]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPartyMonNicknames
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetNick
|
|
|
|
ld a, MON_HP
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
jp z, .beatup_fail ; fainted
|
2020-10-29 11:45:40 -07:00
|
|
|
ld a, [wCurBeatUpPartyMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurBattleMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
; BUG: this can desynchronize link battles
|
|
|
|
; Change "cp [hl]" to "cp c" to fix
|
|
|
|
cp [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wBattleMonStatus
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .active_mon
|
|
|
|
ld a, MON_STATUS
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
.active_mon
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jp nz, .beatup_fail
|
|
|
|
|
|
|
|
ld a, $1
|
|
|
|
ld [wBeatUpHitAtLeastOnce], a
|
|
|
|
ld hl, BeatUpAttackText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemyMonSpecies]
|
|
|
|
ld [wCurSpecies], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetBaseData
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBaseDefense]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push bc
|
|
|
|
ld a, MON_SPECIES
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCurSpecies], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetBaseData
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBaseAttack]
|
2018-01-26 08:36:00 -08:00
|
|
|
pop bc
|
|
|
|
ld b, a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push bc
|
|
|
|
ld a, MON_LEVEL
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
ld a, [hl]
|
|
|
|
ld e, a
|
|
|
|
pop bc
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wPlayerMoveStructPower]
|
|
|
|
ld d, a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.enemy_beats_up
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemySubStatus3]
|
2018-01-26 08:36:00 -08:00
|
|
|
bit SUBSTATUS_IN_LOOP, a
|
2018-04-04 13:35:47 -07:00
|
|
|
jr nz, .enemy_next_mon
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
xor a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wEnemyRolloutCount], a
|
2020-10-29 11:45:40 -07:00
|
|
|
ld [wCurBeatUpPartyMon], a
|
2018-01-26 08:36:00 -08:00
|
|
|
ld [wBeatUpHitAtLeastOnce], a
|
2018-04-04 13:35:47 -07:00
|
|
|
jr .enemy_got_mon
|
2018-01-26 08:36:00 -08:00
|
|
|
|
2018-04-04 13:35:47 -07:00
|
|
|
.enemy_next_mon
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemyRolloutCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wOTPartyCount]
|
2018-01-26 08:36:00 -08:00
|
|
|
sub b
|
2020-10-29 11:45:40 -07:00
|
|
|
ld [wCurBeatUpPartyMon], a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
|
|
|
.enemy_got_mon
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wBattleMode]
|
|
|
|
dec a
|
|
|
|
jr z, .wild
|
|
|
|
|
|
|
|
ld a, [wLinkMode]
|
|
|
|
and a
|
|
|
|
jr nz, .link_or_tower
|
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wInBattleTowerBattle]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
|
|
|
jr nz, .link_or_tower
|
|
|
|
|
2020-10-29 11:45:40 -07:00
|
|
|
ld a, [wCurBeatUpPartyMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wOTPartySpecies
|
2018-01-26 08:36:00 -08:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetPokemonName
|
|
|
|
jr .got_enemy_nick
|
|
|
|
|
|
|
|
.link_or_tower
|
2020-10-29 11:45:40 -07:00
|
|
|
ld a, [wCurBeatUpPartyMon]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wOTPartyMonNicknames
|
2018-01-26 08:36:00 -08:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call AddNTimes
|
2018-02-03 15:21:53 -08:00
|
|
|
ld de, wStringBuffer1
|
2018-01-26 08:36:00 -08:00
|
|
|
call CopyBytes
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
.got_enemy_nick
|
|
|
|
ld a, MON_HP
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
ld a, [hli]
|
|
|
|
or [hl]
|
|
|
|
jp z, .beatup_fail
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2020-10-29 11:45:40 -07:00
|
|
|
ld a, [wCurBeatUpPartyMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wCurOTMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
cp b
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wEnemyMonStatus
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .active_enemy
|
|
|
|
ld a, MON_STATUS
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
.active_enemy
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr nz, .beatup_fail
|
|
|
|
|
|
|
|
ld a, $1
|
|
|
|
ld [wBeatUpHitAtLeastOnce], a
|
|
|
|
jr .finish_beatup
|
|
|
|
|
|
|
|
.wild
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wEnemyMonSpecies]
|
2020-12-23 13:29:30 -08:00
|
|
|
ld [wNamedObjectIndex], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetPokemonName
|
|
|
|
ld hl, BeatUpAttackText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-01-26 08:36:00 -08:00
|
|
|
jp EnemyAttackDamage
|
|
|
|
|
|
|
|
.finish_beatup
|
|
|
|
ld hl, BeatUpAttackText
|
2019-04-08 05:15:10 -07:00
|
|
|
call StdBattleTextbox
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBattleMonSpecies]
|
|
|
|
ld [wCurSpecies], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetBaseData
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBaseDefense]
|
2018-01-26 08:36:00 -08:00
|
|
|
ld c, a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push bc
|
|
|
|
ld a, MON_SPECIES
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
ld a, [hl]
|
2018-02-03 15:21:53 -08:00
|
|
|
ld [wCurSpecies], a
|
2018-01-26 08:36:00 -08:00
|
|
|
call GetBaseData
|
2018-02-03 15:21:53 -08:00
|
|
|
ld a, [wBaseAttack]
|
2018-01-26 08:36:00 -08:00
|
|
|
pop bc
|
|
|
|
ld b, a
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
push bc
|
|
|
|
ld a, MON_LEVEL
|
|
|
|
call GetBeatupMonLocation
|
|
|
|
ld a, [hl]
|
|
|
|
ld e, a
|
|
|
|
pop bc
|
2018-04-04 13:35:47 -07:00
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wEnemyMoveStructPower]
|
|
|
|
ld d, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.beatup_fail
|
2018-01-26 08:36:00 -08:00
|
|
|
ld b, buildopponentrage_command
|
|
|
|
jp SkipToBattleCommand
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BattleCommand_BeatUpFailText:
|
2018-04-03 03:00:24 -07:00
|
|
|
; beatupfailtext
|
|
|
|
|
2018-01-26 08:36:00 -08:00
|
|
|
ld a, [wBeatUpHitAtLeastOnce]
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
|
|
|
|
jp PrintButItFailed
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetBeatupMonLocation:
|
2018-01-26 08:36:00 -08:00
|
|
|
push bc
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hBattleTurn]
|
2018-01-26 08:36:00 -08:00
|
|
|
and a
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wPartyMon1Species
|
2018-01-26 08:36:00 -08:00
|
|
|
jr z, .got_species
|
2018-02-03 15:21:53 -08:00
|
|
|
ld hl, wOTPartyMon1Species
|
2018-01-26 08:36:00 -08:00
|
|
|
|
|
|
|
.got_species
|
2020-10-29 11:45:40 -07:00
|
|
|
ld a, [wCurBeatUpPartyMon]
|
2018-01-26 08:36:00 -08:00
|
|
|
add hl, bc
|
|
|
|
call GetPartyLocation
|
|
|
|
pop bc
|
|
|
|
ret
|