SHARE
TWEET

Pokemon Red substitute/swift/drain bugs

a guest Jul 1st, 2016 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; PokeRed version
  2. ; based on https://github.com/pret/pokered/blob/master/engine/battle/core.asm
  3.  
  4. ; 3E582 (6582 in bank F)
  5. .dreamEaterCheck
  6. 1A      ld a,[de]
  7. FE 08   cp a,DREAM_EATER_EFFECT
  8. 20 06   jr nz,.swiftCheck
  9. 0A      ld a,[bc]
  10. E6 07   and a,SLP ; is the target pokemon sleeping?
  11. CA 0966 jp z,.moveMissed
  12.  
  13. .swiftCheck
  14. 1A      ld a,[de]
  15. FE 11   cp a,SWIFT_EFFECT
  16. C8      ret z ; Swift never misses
  17.  
  18. ; This was moved from above swiftCheck, fixing one bug and creating another.
  19. CD 797B call CheckTargetSubstitute ; note that this overwrites a
  20. 28 0A   jr z,.checkForDigOrFlyStatus
  21.  
  22. ; This code is buggy.
  23. ; It's supposed to prevent HP draining moves from working on substitutes.
  24. ; Since $7b79 overwrites a with either $00 or $01, it never works.
  25. FE 03   cp a,DRAIN_HP_EFFECT
  26. CA 0966 jp z,.moveMissed
  27. FE 08   cp a,DREAM_EATER_EFFECT
  28. CA 0966 jp z,.moveMissed
  29.  
  30. .checkForDigOrFlyStatus
  31. CB 76   bit Invulnerable,[hl]
  32. C2 0966 jp nz,.moveMissed
  33.  
  34. ; ...
  35.  
  36. ; 3FB79 (7B79 in bank F)
  37. CheckTargetSubstitute:
  38. E5      push hl
  39. 21 68D0 ld hl, wEnemyBattleStatus2
  40. F0 F3   ld a, [H_WHOSETURN]
  41. A7      and a
  42. 28 03   jr z, .next1
  43. 21 63D0 ld hl, wPlayerBattleStatus2
  44. .next1
  45. CB 66   bit HasSubstituteUp, [hl]
  46. E1      pop hl
  47. C9      ret
  48.  
  49.  
  50.  
  51. ; Pocket Monsters Aka (Japan) (Rev A)
  52.  
  53. ; 3E86B (686B in bank F)
  54. .dreamEaterCheck
  55. 1A      ld a,[de]
  56. FE 08   cp a,DREAM_EATER_EFFECT
  57. 20 06   jr nz,.substCheck
  58. 0A      ld a,[bc]
  59. E6 07   and a,SLP ; is the target pokemon sleeping?
  60. CA F268 jp z,.moveMissed
  61.  
  62. .substCheck
  63. CD B17F call CheckTargetSubstituteProbably
  64. 28 0E   jr z,.checkForDigOrFlyStatus
  65.  
  66. ; Supposed to prevent HP draining moves from working on substitutes?
  67. ; But also prevents Swift Effect from working when there isn't a substitute?
  68.  
  69. 1A      ld a,[de]
  70. FE 11   cp a,SWIFT_EFFECT
  71. C8      ret z
  72.  
  73. FE 03   cp a,DRAIN_HP_EFFECT
  74. CA F268 jp z,.moveMissed
  75. FE 08   cp a,DREAM_EATER_EFFECT
  76. CA F268 jp z,.moveMissed
  77.  
  78. .checkForDigOrFlyStatus
  79. CB 76
  80. C2 F268 jp nz,.moveMissed
  81.  
  82. ; ...
  83.  
  84. ; 3FFB1 (7FB1 in bank F)
  85. ; Same opcodes as PokeRed's CheckTargetSubstitute.
  86. ; Assume the variables mean the same thing for now.
  87. CheckTargetSubstituteProbably:
  88. E5      push hl
  89. 21 45D0 ld hl,?
  90. F0 F3   ld a, [?]
  91. A7      and a
  92. 28 03   jr z, .next1
  93. 21 40D0 ld hl,?
  94. .next1
  95. CB 66   bit HasSubstituteUp?, [hl]
  96. E1      pop hl
  97. C9      ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top