Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; In link battle, the player chooses moves, not the AI.
- ld a, [InLinkBattle]
- and a
- ret nz
- ;Let's start
- MilitaryInit:
- ld a, [wdffa] ;Checks if in military mode
- and $1
- ret nz
- callab Function4000
- ld a, MILITARY_IDLE + (MILITARY_IDLE * $10)
- ld [wdff8], a
- MilitaryPlayerLoop:
- ld hl, wdffa
- res 1, [hl]
- MilitaryLoop:
- call GetCommand
- cp MILITARY_IDLE
- jr z, MilitaryPlayerLoop
- cp MILITARY_ATTACK + NUM_MOVES
- jp c, GetMove
- ret
- MilitaryEnemyLoop:
- ld hl, wdffa
- set 1, [hl]
- jp MilitaryLoop
- GetArrayPosition: MACRO
- ld b, 0
- ld c, a
- add hl, bc
- ld a, [hl]
- ENDM
- AddressEnd:
- pop af
- ret
- MoveAddress:
- push af
- ld hl, BattleMonMoves
- call GetMode
- jp z, AddressEnd
- ld hl, EnemyMonMoves
- jp AddressEnd
- PPAddress:
- push af
- call GetMode
- ld hl, BattleMonPP
- jp z, AddressEnd
- ld hl, EnemyMonPP
- jp AddressEnd
- DisableAddress:
- push af
- call GetMode
- ld hl, DisabledMove
- jp z, AddressEnd
- ld hl, EnemyDisabledMove
- jp AddressEnd
- ;Set the move that's going to be used
- SetMove:
- push af
- call GetMode
- jr z, .setPlayerMove
- pop af
- ld [CurEnemyMove], a
- ret
- .setPlayerMove
- pop af
- ld [CurPlayerMove], a
- ret
- ;Checks if you have enough PP for this move and that it isn't disabled. If all checks out then use it.
- GetMove:
- call PPAddress
- GetArrayPosition
- and a
- jp z, MilitaryPlayerLoop
- call GetCommand
- call MoveAddress
- GetArrayPosition
- ld b, a
- call DisableAddress
- ld a, [hl]
- cp b
- jp z, MilitaryPlayerLoop
- ld a, b
- call SetMove
- jp ChangeMode
- ;Switches checking from player or enemy.
- ChangeMode:
- call GetMode
- jr nz, .endSegment
- jp MilitaryEnemyLoop
- .endSegment;Let's execute these commands
- ld hl, wdffa
- res 1, [hl]
- xor a
- ld [wd267], a
- jp Function30b4
- GetCommand:
- call GetMode
- jr nz, .enemyCommand
- ld a, [wdff8]
- and $f
- ret
- .enemyCommand
- push bc
- ld a, [wdff8]
- ld c, $10
- call SimpleDivide
- ld a, b
- pop bc
- ret
- GetMode:
- ld a, [wdffa]
- and $2
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement