KDLPro

Defrosting Code v1.0

Mar 21st, 2021 (edited)
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 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. jr .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. ret
  39.  
  40. .two_turns
  41. ld a, 2
  42. ld [wPlayerFrozenTurns], a
  43. ret
  44.  
  45. .three_turns
  46. ld a, 3
  47. ld [wPlayerFrozenTurns], a
  48. ret
  49.  
  50. .defrosting
  51. ld a, [wPlayerFrozenTurns]
  52. dec a
  53. ld [wPlayerFrozenTurns], a
  54. ret nz
  55.  
  56. xor a
  57. ld [wBattleMonStatus], a
  58. ld a, [wCurBattleMon]
  59. ld hl, wPartyMon1Status
  60. call GetPartyLocation
  61. ld [hl], 0
  62. call UpdateBattleHuds
  63. call SetEnemyTurn
  64. ld hl, DefrostedOpponentText
  65. jp StdBattleTextbox
  66.  
  67. .do_enemy_turn
  68. ld a, [wEnemyMonStatus]
  69. bit FRZ, a
  70. ret z
  71.  
  72. ld a, [wEnemyIsSwitching]
  73. and a
  74. jr nz, .switch_roll_e
  75.  
  76. ld a, [wEnemyJustGotFrozen]
  77. and a
  78. jr z, .defrosting_e
  79. call BattleRandom
  80. cp 21 percent
  81. jr c, .one_turn_e
  82. cp 61 percent
  83. jr c, .two_turns_e
  84. jr .three_turns_e
  85.  
  86. .switch_roll_e
  87. call BattleRandom
  88. cp 51 percent
  89. jr c, .one_turn_e
  90. jr .two_turns_e
  91.  
  92. .one_turn_e
  93. ld a, 1
  94. ld [wEnemyFrozenTurns], a
  95. ret
  96.  
  97. .two_turns_e
  98. ld a, 2
  99. ld [wEnemyFrozenTurns], a
  100. ret
  101.  
  102. .three_turns_e
  103. ld a, 3
  104. ld [wEnemyFrozenTurns], a
  105. ret
  106.  
  107. .defrosting_e
  108. ld a, [wEnemyFrozenTurns]
  109. dec a
  110. ld [wEnemyFrozenTurns], a
  111. ret nz
  112.  
  113. xor a
  114. ld [wEnemyMonStatus], a
  115.  
  116. ld a, [wBattleMode]
  117. dec a
  118. jr z, .wild
  119. ld a, [wCurOTMon]
  120. ld hl, wOTPartyMon1Status
  121. call GetPartyLocation
  122. ld [hl], 0
  123. .wild
  124.  
  125. call UpdateBattleHuds
  126. call SetPlayerTurn
  127. ld hl, DefrostedOpponentText
  128. jp StdBattleTextbox
Add Comment
Please, Sign In to add comment