KDLPro

Defrosting Code v2.0

Mar 29th, 2021 (edited)
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. HandleDefrost:
  2. ldh a, [hSerialConnectionStatus]
  3. cp USING_EXTERNAL_CLOCK
  4. jr z, .enemy_first
  5. call .do_player_turn
  6. jp .do_enemy_turn
  7.  
  8. .enemy_first
  9. call .do_enemy_turn
  10. .do_player_turn
  11. ld a, [wBattleMonStatus]
  12. bit FRZ, a
  13. ret z
  14.  
  15. ld a, [wPlayerIsSwitching]
  16. and a
  17. jr nz, .switch_roll
  18.  
  19. ld a, [wPlayerJustGotFrozen]
  20. and a
  21. jr z, .defrosting
  22. xor a
  23. ld [wPlayerJustGotFrozen], a
  24. call BattleRandom
  25. cp 21 percent
  26. jr c, .one_turn
  27. cp 61 percent
  28. jr c, .two_turns
  29. jr .three_turns
  30.  
  31. .switch_roll
  32. call BattleRandom
  33. cp 51 percent
  34. jr c, .one_turn
  35. jr .two_turns
  36.  
  37. .one_turn
  38. ld a, 1
  39. ld [wPlayerFrozenTurns], a
  40. jr .go_last_p
  41.  
  42. .two_turns
  43. ld a, 2
  44. ld [wPlayerFrozenTurns], a
  45. jr .go_last_p
  46.  
  47. .three_turns
  48. ld a, 3
  49. ld [wPlayerFrozenTurns], a
  50. jr .go_last_p
  51.  
  52. .go_last_p
  53. ld a, [wPlayerIsSwitching]
  54. and a
  55. ret nz
  56. ld a, [wEnemyGoesFirst]
  57. and a
  58. ret z
  59. .defrosting
  60. ld a, [wPlayerFrozenTurns]
  61. and a
  62. jr nz, .decr_frozen
  63. call .switch_roll
  64. ld a, [wPlayerFrozenTurns]
  65. .decr_frozen
  66. dec a
  67. ld [wPlayerFrozenTurns], a
  68. ret nz
  69.  
  70. xor a
  71. ld [wBattleMonStatus], a
  72. ld a, [wCurBattleMon]
  73. ld hl, wPartyMon1Status
  74. call GetPartyLocation
  75. ld [hl], 0
  76. call UpdateBattleHuds
  77. call SetEnemyTurn
  78. ld hl, DefrostedOpponentText
  79. jp StdBattleTextbox
  80.  
  81. .do_enemy_turn
  82. ld a, [wEnemyMonStatus]
  83. bit FRZ, a
  84. ret z
  85.  
  86. ld a, [wEnemyIsSwitching]
  87. and a
  88. jr nz, .switch_roll_e
  89.  
  90. ld a, [wEnemyJustGotFrozen]
  91. and a
  92. jr z, .defrosting_e
  93. xor a
  94. ld [wEnemyJustGotFrozen], a
  95. call BattleRandom
  96. cp 21 percent
  97. jr c, .one_turn_e
  98. cp 61 percent
  99. jr c, .two_turns_e
  100. jr .three_turns_e
  101.  
  102. .switch_roll_e
  103. call BattleRandom
  104. cp 51 percent
  105. jr c, .one_turn_e
  106. jr .two_turns_e
  107.  
  108. .one_turn_e
  109. ld a, 1
  110. ld [wEnemyFrozenTurns], a
  111. jr .go_last_e
  112.  
  113. .two_turns_e
  114. ld a, 2
  115. ld [wEnemyFrozenTurns], a
  116. jr .go_last_e
  117.  
  118. .three_turns_e
  119. ld a, 3
  120. ld [wEnemyFrozenTurns], a
  121. jr .go_last_e
  122.  
  123. .go_last_e
  124. ld a, [wEnemyIsSwitching]
  125. and a
  126. ret nz
  127. ld a, [wEnemyGoesFirst]
  128. and a
  129. ret nz
  130. .defrosting_e
  131. ld a, [wEnemyFrozenTurns]
  132. and a
  133. jr nz, .decr_frozen_e
  134. call .switch_roll_e
  135. ld a, [wEnemyFrozenTurns]
  136. .decr_frozen_e
  137. dec a
  138. ld [wEnemyFrozenTurns], a
  139. ret nz
  140.  
  141. xor a
  142. ld [wEnemyMonStatus], a
  143.  
  144. ld a, [wBattleMode]
  145. dec a
  146. jr z, .wild
  147. ld a, [wCurOTMon]
  148. ld hl, wOTPartyMon1Status
  149. call GetPartyLocation
  150. ld [hl], 0
  151. .wild
  152.  
  153. call UpdateBattleHuds
  154. call SetPlayerTurn
  155. ld hl, DefrostedOpponentText
  156. jp StdBattleTextbox
Add Comment
Please, Sign In to add comment