Advertisement
KDLPro

Defrosting Code v1.1

Mar 22nd, 2021
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 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. call BattleRandom
  23. cp 21 percent
  24. jr c, .one_turn
  25. cp 61 percent
  26. jr c, .two_turns
  27. jr .three_turns
  28.  
  29. .switch_roll
  30. call BattleRandom
  31. cp 51 percent
  32. jr c, .one_turn
  33. jr .two_turns
  34.  
  35. .one_turn
  36. ld a, 1
  37. ld [wPlayerFrozenTurns], a
  38. ld a, [wPlayerIsSwitching]
  39. and a
  40. ret z
  41. ldh a, [hSerialConnectionStatus]
  42. cp USING_EXTERNAL_CLOCK
  43. jr nz, .defrosting
  44. ret
  45.  
  46. .two_turns
  47. ld a, 2
  48. ld [wPlayerFrozenTurns], a
  49. ld a, [wPlayerIsSwitching]
  50. and a
  51. ret z
  52. ldh a, [hSerialConnectionStatus]
  53. cp USING_EXTERNAL_CLOCK
  54. jr nz, .defrosting
  55. ret
  56.  
  57. .three_turns
  58. ld a, 3
  59. ld [wPlayerFrozenTurns], a
  60. ld a, [wPlayerIsSwitching]
  61. and a
  62. ret z
  63. ldh a, [hSerialConnectionStatus]
  64. cp USING_EXTERNAL_CLOCK
  65. jr nz, .defrosting
  66. ret
  67.  
  68. .defrosting
  69. ld a, [wPlayerFrozenTurns]
  70. and a
  71. jr nz, .decr_frozen
  72. call .switch_roll
  73. ld a, [wPlayerFrozenTurns]
  74. .decr_frozen
  75. dec a
  76. ld [wPlayerFrozenTurns], a
  77. ret nz
  78.  
  79. xor a
  80. ld [wBattleMonStatus], a
  81. ld a, [wCurBattleMon]
  82. ld hl, wPartyMon1Status
  83. call GetPartyLocation
  84. ld [hl], 0
  85. call UpdateBattleHuds
  86. call SetEnemyTurn
  87. ld hl, DefrostedOpponentText
  88. jp StdBattleTextbox
  89.  
  90. .do_enemy_turn
  91. ld a, [wEnemyMonStatus]
  92. bit FRZ, a
  93. ret z
  94.  
  95. ld a, [wEnemyIsSwitching]
  96. and a
  97. jr nz, .switch_roll_e
  98.  
  99. ld a, [wEnemyJustGotFrozen]
  100. and a
  101. jr z, .defrosting_e
  102. call BattleRandom
  103. cp 21 percent
  104. jr c, .one_turn_e
  105. cp 61 percent
  106. jr c, .two_turns_e
  107. jr .three_turns_e
  108.  
  109. .switch_roll_e
  110. call BattleRandom
  111. cp 51 percent
  112. jr c, .one_turn_e
  113. jr .two_turns_e
  114.  
  115. .one_turn_e
  116. ld a, 1
  117. ld [wEnemyFrozenTurns], a
  118. ld a, [wEnemyIsSwitching]
  119. and a
  120. ret z
  121. ldh a, [hSerialConnectionStatus]
  122. cp USING_EXTERNAL_CLOCK
  123. jr z, .defrosting_e
  124. ret
  125.  
  126. .two_turns_e
  127. ld a, 2
  128. ld [wEnemyFrozenTurns], a
  129. ld a, [wEnemyIsSwitching]
  130. and a
  131. ret z
  132. ldh a, [hSerialConnectionStatus]
  133. cp USING_EXTERNAL_CLOCK
  134. jr z, .defrosting_e
  135. ret
  136.  
  137. .three_turns_e
  138. ld a, 3
  139. ld [wEnemyFrozenTurns], a
  140. ld a, [wEnemyIsSwitching]
  141. and a
  142. ret z
  143. ldh a, [hSerialConnectionStatus]
  144. cp USING_EXTERNAL_CLOCK
  145. jr z, .defrosting_e
  146. ret
  147.  
  148. .defrosting_e
  149. ld a, [wEnemyFrozenTurns]
  150. and a
  151. jr nz, .decr_frozen_e
  152. call .switch_roll_e
  153. ld a, [wEnemyFrozenTurns]
  154. .decr_frozen_e
  155. dec a
  156. ld [wEnemyFrozenTurns], a
  157. ret nz
  158.  
  159. xor a
  160. ld [wEnemyMonStatus], a
  161.  
  162. ld a, [wBattleMode]
  163. dec a
  164. jr z, .wild
  165. ld a, [wCurOTMon]
  166. ld hl, wOTPartyMon1Status
  167. call GetPartyLocation
  168. ld [hl], 0
  169. .wild
  170.  
  171. call UpdateBattleHuds
  172. call SetPlayerTurn
  173. ld hl, DefrostedOpponentText
  174. jp StdBattleTextbox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement