Advertisement
IdainTV

DetermineMoveOrder

Jul 10th, 2021
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DetermineMoveOrder:
  2.     ld a, [wLinkMode]
  3.     and a
  4.     jr z, .use_move
  5.     ld a, [wBattleAction]
  6.     cp BATTLEACTION_STRUGGLE
  7.     jr z, .use_move
  8.     cp BATTLEACTION_SKIPTURN
  9.     jr z, .use_move
  10.     sub BATTLEACTION_SWITCH1
  11.     jr c, .use_move
  12.     ld a, [wBattlePlayerAction]
  13.     cp BATTLEPLAYERACTION_SWITCH
  14.     jr nz, .switch
  15.     ldh a, [hSerialConnectionStatus]
  16.     cp USING_INTERNAL_CLOCK
  17.     jr z, .player_2
  18.  
  19.     call BattleRandom
  20.     cp 50 percent + 1
  21.     jp c, .player_first
  22.     jp .enemy_first
  23.  
  24. .player_2
  25.     call BattleRandom
  26.     cp 50 percent + 1
  27.     jp c, .enemy_first
  28.     jp .player_first
  29.  
  30. .switch
  31.     callfar AI_Switch
  32.     call SetEnemyTurn
  33.     call SpikesDamage
  34.     jp .enemy_first
  35.  
  36. .use_move
  37.     ld a, [wBattlePlayerAction]
  38.     and a ; BATTLEPLAYERACTION_USEMOVE?
  39.     jp nz, .player_first
  40.     call CompareMovePriority
  41.     jr z, .equal_priority
  42.     jr c, .player_first ; player goes first
  43.     jr .enemy_first
  44.  
  45. .equal_priority
  46.     call SetPlayerTurn
  47.     callfar GetUserItem
  48.     push bc
  49.     callfar GetOpponentItem
  50.     pop de
  51.     ld a, d
  52.     cp HELD_QUICK_CLAW
  53.     jr nz, .player_no_quick_claw
  54.     ld a, b
  55.     cp HELD_QUICK_CLAW
  56.     jr z, .both_have_quick_claw
  57.     call BattleRandom
  58.     cp e
  59.     jr nc, .speed_check
  60.     jr .player_first
  61.  
  62. .player_no_quick_claw
  63.     ld a, b
  64.     cp HELD_QUICK_CLAW
  65.     jr nz, .speed_check
  66.     call BattleRandom
  67.     cp c
  68.     jr nc, .speed_check
  69.     jr .enemy_first
  70.  
  71. .both_have_quick_claw
  72.     ldh a, [hSerialConnectionStatus]
  73.     cp USING_INTERNAL_CLOCK
  74.     jr z, .player_2b
  75.     call BattleRandom
  76.     cp c
  77.     jp c, .enemy_first
  78.     call BattleRandom
  79.     cp e
  80.     jr c, .player_first
  81.     jr .speed_check
  82.  
  83. .player_2b
  84.     call BattleRandom
  85.     cp e
  86.     jr c, .player_first
  87.     call BattleRandom
  88.     cp c
  89.     jr c, .enemy_first
  90.  
  91. .speed_check
  92.     ld de, wBattleMonSpeed
  93.     ld hl, wEnemyMonSpeed
  94.     ld c, 2
  95.     call CompareBytes
  96.     jr z, .speed_tie
  97.     jr nc, .player_first
  98.     jr .enemy_first
  99.  
  100. .speed_tie
  101.     ldh a, [hSerialConnectionStatus]
  102.     cp USING_INTERNAL_CLOCK
  103.     jr z, .player_2c
  104.     call BattleRandom
  105.     cp 50 percent + 1
  106.     jr c, .player_first
  107.     jr .enemy_first
  108.  
  109. .player_2c
  110.     call BattleRandom
  111.     cp 50 percent + 1
  112.     jr c, .enemy_first
  113. .player_first
  114.     scf
  115.     ret
  116.  
  117. .enemy_first
  118.     and a
  119.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement