Advertisement
pigdevil2010

Untitled

Dec 21st, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; In link battle, the player chooses moves, not the AI.
  2.     ld a, [InLinkBattle]
  3.     and a
  4.     ret nz
  5.  
  6. ;Let's start
  7. MilitaryInit:
  8.     ld a, [wdffa] ;Checks if in military mode
  9.     and $1
  10.     ret nz
  11.     callab Function4000
  12.     ld a, MILITARY_IDLE + (MILITARY_IDLE * $10)
  13.     ld [wdff8], a
  14. MilitaryPlayerLoop:
  15.     ld hl, wdffa
  16.     res 1, [hl]
  17. MilitaryLoop:
  18.     call GetCommand
  19.     cp MILITARY_IDLE
  20.     jr z, MilitaryPlayerLoop
  21.     cp MILITARY_ATTACK + NUM_MOVES
  22.     jp c, GetMove
  23.     ret
  24.  
  25. MilitaryEnemyLoop:
  26.     ld hl, wdffa
  27.     set 1, [hl]
  28.     jp MilitaryLoop
  29.    
  30. GetArrayPosition: MACRO
  31.     ld b, 0
  32.     ld c, a
  33.     add hl, bc
  34.     ld a, [hl]
  35. ENDM
  36.  
  37. AddressEnd:
  38.     pop af
  39.     ret
  40.    
  41. MoveAddress:
  42.     push af
  43.     ld hl, BattleMonMoves
  44.     call GetMode
  45.     jp z, AddressEnd
  46.     ld hl, EnemyMonMoves
  47.     jp AddressEnd
  48.    
  49. PPAddress:
  50.     push af
  51.     call GetMode
  52.     ld hl, BattleMonPP
  53.     jp z, AddressEnd
  54.     ld hl, EnemyMonPP
  55.     jp AddressEnd
  56.    
  57. DisableAddress:
  58.     push af
  59.     call GetMode
  60.     ld hl, DisabledMove
  61.     jp z, AddressEnd
  62.     ld hl, EnemyDisabledMove
  63.     jp AddressEnd
  64.  
  65. ;Set the move that's going to be used  
  66. SetMove:
  67.     push af
  68.     call GetMode
  69.     jr z, .setPlayerMove
  70.     pop af
  71.     ld [CurEnemyMove], a
  72.     ret
  73. .setPlayerMove
  74.     pop af
  75.     ld [CurPlayerMove], a
  76.     ret
  77.    
  78. ;Checks if you have enough PP for this move and that it isn't disabled. If all checks out then use it.
  79. GetMove:
  80.     call PPAddress
  81.     GetArrayPosition
  82.     and a
  83.     jp z, MilitaryPlayerLoop
  84.     call GetCommand
  85.    
  86.     call MoveAddress
  87.     GetArrayPosition
  88.    
  89.     ld b, a
  90.     call DisableAddress
  91.     ld a, [hl]
  92.     cp b
  93.     jp z, MilitaryPlayerLoop
  94.     ld a, b
  95.     call SetMove
  96.     jp ChangeMode
  97.  
  98. ;Switches checking from player or enemy.
  99. ChangeMode:
  100.     call GetMode
  101.     jr nz, .endSegment
  102.     jp MilitaryEnemyLoop
  103. .endSegment;Let's execute these commands
  104.     ld hl, wdffa
  105.     res 1, [hl]
  106.     xor a
  107.     ld [wd267], a
  108.     jp Function30b4
  109.    
  110. GetCommand:
  111.     call GetMode
  112.     jr nz, .enemyCommand
  113.     ld a, [wdff8]
  114.     and $f
  115.     ret
  116. .enemyCommand
  117.     push bc
  118.     ld a, [wdff8]
  119.     ld c, $10
  120.     call SimpleDivide
  121.     ld a, b
  122.     pop bc
  123.     ret
  124.    
  125. GetMode:
  126.     ld a, [wdffa]
  127.     and $2
  128.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement