transform_effect.asm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. TransformEffect_:
  2. ld hl, wBattleMonSpecies
  3. ld de, wEnemyMonSpecies
  4. ld bc, wEnemyBattleStatus3
  5. ld a, [wEnemyBattleStatus1]
  6. ld a, [H_WHOSETURN]
  7. and a
  8. jr nz, .hitTest
  9. ld hl, wEnemyMonSpecies
  10. ld de, wBattleMonSpecies
  11. ld bc, wPlayerBattleStatus3
  12. ld [wPlayerMoveListIndex], a
  13. ld a, [wPlayerBattleStatus1]
  14. .hitTest
  15. bit INVULNERABLE, a ; is mon invulnerable to typical attacks? (fly/dig)
  16. jp nz, .failed
  17. push hl
  18. push de
  19. push bc
  20. ld hl, wPlayerBattleStatus2
  21. ld a, [H_WHOSETURN]
  22. and a
  23. jr z, .transformEffect
  24. ld hl, wEnemyBattleStatus2
  25. .transformEffect
  26. ; animation(s) played are different if target has Substitute up
  27. bit HAS_SUBSTITUTE_UP, [hl]
  28. push af
  29. ld hl, HideSubstituteShowMonAnim
  30. ld b, BANK(HideSubstituteShowMonAnim)
  31. call nz, Bankswitch
  32. ld a, [wOptions]
  33. add a
  34. ld hl, PlayCurrentMoveAnimation
  35. ld b, BANK(PlayCurrentMoveAnimation)
  36. jr nc, .gotAnimToPlay
  37. ld hl, AnimationTransformMon
  38. ld b, BANK(AnimationTransformMon)
  39. .gotAnimToPlay
  40. call Bankswitch
  41. ld hl, ReshowSubstituteAnim
  42. ld b, BANK(ReshowSubstituteAnim)
  43. pop af
  44. call nz, Bankswitch
  45. pop bc
  46. ld a, [bc]
  47. set TRANSFORMED, a ; mon is now transformed
  48. ld [bc], a
  49. pop de
  50. pop hl
  51. push hl
  52. ; transform user into opposing Pokemon
  53. ; species
  54. ld a, [hl]
  55. ld [de], a
  56. ; type 1, type 2, catch rate, and moves
  57. ld bc, $5
  58. add hl, bc
  59. inc de
  60. inc de
  61. inc de
  62. inc de
  63. inc de
  64. inc bc
  65. inc bc
  66. call CopyData
  67. ld a, [H_WHOSETURN]
  68. and a
  69. jr z, .next
  70. ; save enemy mon DVs at wTransformedEnemyMonOriginalDVs
  71. ld a, [de]
  72. ld [wTransformedEnemyMonOriginalDVs], a
  73. inc de
  74. ld a, [de]
  75. ld [wTransformedEnemyMonOriginalDVs + 1], a
  76. dec de
  77. .next
  78. ; DVs
  79. ld a, [hli]
  80. ld [de], a
  81. inc de
  82. ld a, [hli]
  83. ld [de], a
  84. inc de
  85. ; Attack, Defense, Speed, and Special stats
  86. inc hl
  87. inc hl
  88. inc hl
  89. inc de
  90. inc de
  91. inc de
  92. ld bc, $8
  93. call CopyData
  94. ld bc, wBattleMonMoves - wBattleMonPP
  95. add hl, bc ; ld hl, wBattleMonMoves
  96. ld b, NUM_MOVES
  97. .copyPPLoop
  98. ; 5 PP for all moves
  99. ld a, [hli]
  100. and a
  101. jr z, .lessThanFourMoves
  102. ld a, $5
  103. ld [de], a
  104. inc de
  105. dec b
  106. jr nz, .copyPPLoop
  107. jr .copyStats
  108. .lessThanFourMoves
  109. ; 0 PP for blank moves
  110. xor a
  111. ld [de], a
  112. inc de
  113. dec b
  114. jr nz, .lessThanFourMoves
  115. .copyStats
  116. ; original (unmodified) stats and stat mods
  117. pop hl
  118. ld a, [hl]
  119. ld [wd11e], a
  120. call GetMonName
  121. ld hl, wEnemyMonUnmodifiedAttack
  122. ld de, wPlayerMonUnmodifiedAttack
  123. call .copyBasedOnTurn ; original (unmodified) stats
  124. ld hl, wEnemyMonStatMods
  125. ld de, wPlayerMonStatMods
  126. call .copyBasedOnTurn ; stat mods
  127. ld hl, TransformedText
  128. jp PrintText
  129. .copyBasedOnTurn
  130. ld a, [H_WHOSETURN]
  131. and a
  132. jr z, .gotStatsOrModsToCopy
  133. push hl
  134. ld h, d
  135. ld l, e
  136. pop de
  137. .gotStatsOrModsToCopy
  138. ld bc, $8
  139. jp CopyData
  140. .failed
  141. ld hl, PrintButItFailedText_
  142. jp BankswitchEtoF
  143. TransformedText:
  144. TX_FAR _TransformedText
  145. db "@"