Advertisement
KDLPro

Defrosting Code

Mar 21st, 2021
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 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, [wPlayerJustGotFrozen]
  16. and a
  17. jr z, .defrosting
  18. call BattleRandom
  19. cp 21 percent
  20. jr c, .one_turn
  21. cp 61 percent
  22. jr c, .two_turns
  23. jr .three_turns
  24.  
  25. .one_turn
  26. ld a, 1
  27. ld [wPlayerFrozenTurns], a
  28. ret
  29.  
  30. .two_turns
  31. ld a, 2
  32. ld [wPlayerFrozenTurns], a
  33. ret
  34.  
  35. .three_turns
  36. ld a, 3
  37. ld [wPlayerFrozenTurns], a
  38. ret
  39.  
  40. .defrosting
  41. ld a, [wPlayerFrozenTurns]
  42. dec a
  43. ld [wPlayerFrozenTurns], a
  44. ret nz
  45.  
  46. xor a
  47. ld [wBattleMonStatus], a
  48. ld a, [wCurBattleMon]
  49. ld hl, wPartyMon1Status
  50. call GetPartyLocation
  51. ld [hl], 0
  52. call UpdateBattleHuds
  53. call SetEnemyTurn
  54. ld hl, DefrostedOpponentText
  55. jp StdBattleTextbox
  56.  
  57. .do_enemy_turn
  58. ld a, [wEnemyMonStatus]
  59. bit FRZ, a
  60. ret z
  61. ld a, [wEnemyJustGotFrozen]
  62. and a
  63. jr z, .defrosting_e
  64. call BattleRandom
  65. cp 21 percent
  66. jr c, .one_turn_e
  67. cp 61 percent
  68. jr c, .two_turns_e
  69. jr .three_turns_e
  70.  
  71. .one_turn_e
  72. ld a, 1
  73. ld [wEnemyFrozenTurns], a
  74. ret
  75.  
  76. .two_turns_e
  77. ld a, 2
  78. ld [wEnemyFrozenTurns], a
  79. ret
  80.  
  81. .three_turns_e
  82. ld a, 3
  83. ld [wEnemyFrozenTurns], a
  84. ret
  85.  
  86. .defrosting_e
  87. ld a, [wEnemyFrozenTurns]
  88. dec a
  89. ld [wEnemyFrozenTurns], a
  90. ret nz
  91.  
  92. xor a
  93. ld [wEnemyMonStatus], a
  94.  
  95. ld a, [wBattleMode]
  96. dec a
  97. jr z, .wild
  98. ld a, [wCurOTMon]
  99. ld hl, wOTPartyMon1Status
  100. call GetPartyLocation
  101. ld [hl], 0
  102. .wild
  103.  
  104. call UpdateBattleHuds
  105. call SetPlayerTurn
  106. ld hl, DefrostedOpponentText
  107. jp StdBattleTextbox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement