Skip to content

Commit

Permalink
link battle action constants
Browse files Browse the repository at this point in the history
  • Loading branch information
YamaArashi committed Oct 29, 2016
1 parent d1162fe commit bb1bf5e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions constants/misc_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,7 @@ LINK_STATE_START_BATTLE EQU $03 ; pre-battle initialisation
LINK_STATE_BATTLING EQU $04 ; in a link battle
LINK_STATE_RESET EQU $05 ; reset game (unused)
LINK_STATE_TRADING EQU $32 ; in a link trade

LINKBATTLE_RUN EQU $F
LINKBATTLE_STRUGGLE EQU $E
LINKBATTLE_NO_ACTION EQU $D ; never sent
30 changes: 15 additions & 15 deletions engine/battle/core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,13 @@ MainInBattleLoop:
jr nz, .noLinkBattle
; link battle
ld a, [wSerialExchangeNybbleReceiveData]
cp $f
cp LINKBATTLE_RUN
jp z, EnemyRan
cp $e
cp LINKBATTLE_STRUGGLE
jr z, .noLinkBattle
cp $d
cp LINKBATTLE_NO_ACTION
jr z, .noLinkBattle
sub $4
sub 4
jr c, .noLinkBattle
; the link battle enemy has switched mons
ld a, [wPlayerBattleStatus1]
Expand Down Expand Up @@ -990,7 +990,7 @@ ReplaceFaintedEnemyMon:
; link battle
call LinkBattleExchangeData
ld a, [wSerialExchangeNybbleReceiveData]
cp $f
cp LINKBATTLE_RUN
ret z
call LoadScreenTilesFromBuffer1
.notLinkBattle
Expand Down Expand Up @@ -1679,12 +1679,12 @@ TryRunningFromBattle:
call SaveScreenTilesToBuffer1
xor a
ld [wActionResultOrTookBattleTurn], a
ld a, $f
ld a, LINKBATTLE_RUN
ld [wPlayerMoveListIndex], a
call LinkBattleExchangeData
call LoadScreenTilesFromBuffer1
ld a, [wSerialExchangeNybbleReceiveData]
cp $f
cp LINKBATTLE_RUN
ld a, $2
jr z, .playSound
dec a
Expand Down Expand Up @@ -2999,16 +2999,16 @@ SelectEnemyMove:
call LinkBattleExchangeData
call LoadScreenTilesFromBuffer1
ld a, [wSerialExchangeNybbleReceiveData]
cp $e
cp LINKBATTLE_STRUGGLE
jp z, .linkedOpponentUsedStruggle
cp $d
cp LINKBATTLE_NO_ACTION
jr z, .unableToSelectMove
cp $4
cp 4
ret nc
ld [wEnemyMoveListIndex], a
ld c, a
ld hl, wEnemyMonMoves
ld b, $0
ld b, 0
add hl, bc
ld a, [hl]
jr .done
Expand Down Expand Up @@ -3087,15 +3087,15 @@ LinkBattleExchangeData:
ld a, $ff
ld [wSerialExchangeNybbleReceiveData], a
ld a, [wPlayerMoveListIndex]
cp $f ; is the player running from battle?
cp LINKBATTLE_RUN ; is the player running from battle?
jr z, .doExchange
ld a, [wActionResultOrTookBattleTurn]
and a ; is the player switching in another mon?
jr nz, .switching
; the player used a move
ld a, [wPlayerSelectedMove]
cp STRUGGLE
ld b, $e
ld b, LINKBATTLE_STRUGGLE
jr z, .next
dec b
inc a
Expand Down Expand Up @@ -5676,9 +5676,9 @@ ExecuteEnemyMove:
jr nz, .executeEnemyMove
ld b, $1
ld a, [wSerialExchangeNybbleReceiveData]
cp $e
cp LINKBATTLE_STRUGGLE
jr z, .executeEnemyMove
cp $4
cp 4
ret nc
.executeEnemyMove
ld hl, wAILayer2Encouragement
Expand Down

0 comments on commit bb1bf5e

Please sign in to comment.