Advertisement
KDLPro

Sleep Code v1.0

Mar 22nd, 2021
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. BattleCommand_SleepTarget:
  2. ; sleeptarget
  3.  
  4. call GetOpponentItem
  5. ld a, b
  6. cp HELD_PREVENT_SLEEP
  7. jr nz, .not_protected_by_item
  8.  
  9. ld a, [hl]
  10. ld [wNamedObjectIndex], a
  11. call GetItemName
  12. ld hl, ProtectedByText
  13. jr .fail
  14.  
  15. .not_protected_by_item
  16. ld a, BATTLE_VARS_STATUS_OPP
  17. call GetBattleVarAddr
  18. ld d, h
  19. ld e, l
  20. ld a, [de]
  21. and SLP
  22. ld hl, AlreadyAsleepText
  23. jr nz, .fail
  24.  
  25. ld a, [wAttackMissed]
  26. and a
  27. jp nz, PrintDidntAffect2
  28.  
  29. ld hl, DidntAffect1Text
  30.  
  31. ld a, [de]
  32. and a
  33. jr nz, .fail
  34.  
  35. call CheckSubstituteOpp
  36. jr nz, .fail
  37.  
  38. call AnimateCurrentMove
  39. ld b, SLP
  40. ld a, [wInBattleTowerBattle]
  41. and a
  42. jr z, .random_sleep
  43. ld b, %011
  44.  
  45. .random_sleep
  46. call BattleRandom
  47. cp 51 percent
  48. jr c, .two_turns
  49. cp 86 percent
  50. jr c, .three_turns
  51. jr .four_turns
  52.  
  53. .two_turns
  54. ld a, 2
  55. jr .continue
  56.  
  57. .three_turns
  58. ld a, 3
  59. jr .continue
  60.  
  61. .four_turns
  62. ld a, 4
  63.  
  64. .continue
  65. inc a
  66. ld [de], a
  67. call UpdateOpponentInParty
  68. call RefreshBattleHuds
  69.  
  70. ld hl, FellAsleepText
  71. call StdBattleTextbox
  72.  
  73. farcall UseHeldStatusHealingItem
  74.  
  75. jp z, OpponentCantMove
  76. ret
  77.  
  78. .fail
  79. push hl
  80. call AnimateFailedMove
  81. pop hl
  82. jp StdBattleTextbox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement