Advertisement
MKnightDH

GBW3 damage coding

Apr 3rd, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. Note: this is for Red Star's side of things. White Moon's uses similar enough values.
  2.  
  3. 0C:4A26 FAD7DB ld a,[$DBD7]
  4. 0C:4A29 47 ld b,a - B carries Level byte
  5. 0C:4A2A FAD8DB ld a,[$DBD8]
  6. 0C:4A2D 4F ld c,a - C carries Flank byte
  7. 0C:4A2E FAD9DB ld a,[$DBD9] - A carries Support byte
  8. 0C:4A31 CDA249 call $49A2 - H is the truncation of the multiplier, L is the float point (percent being value multiplied by 64/25)
  9. 0C:4A34 54 ld d,h
  10. 0C:4A35 5D ld e,l - D is the truncation of the multiplier, E is the float point (percent being value multiplied by 64/25)
  11. 0C:4A36 FAD4DB ld a,[$DBD4]
  12. 0C:4A39 47 ld b,a - B carries ATK byte
  13. 0C:4A3A FAD3DB ld a,[$DBD3] - A carries HP byte
  14. 0C:4A3D CDFC49 call $49FC - Total ATK = ATK * HP * (100 + ATK boosts) / 100; Float error causes slightly lower values on any number not a multiple of 25
  15. 0C:4A40 7D ld a,l
  16. 0C:4A41 EADADB ld [$DBDA],a
  17. 0C:4A44 7C ld a,h
  18. 0C:4A45 EADBDB ld [$DBDB],a - $DBDA (2 bytes) carries Total ATK
  19. 0C:4A48 E5 push hl
  20. 0C:4A49 216400 ld hl,$0064
  21. 0C:4A4C FAECDB ld a,[$DBEC]
  22. 0C:4A4F 47 ld b,a - B carries opponent's Level byte
  23. 0C:4A50 FAEDDB ld a,[$DBED]
  24. 0C:4A53 4F ld c,a - C carries opponent's Flank byte
  25. 0C:4A54 FAEBDB ld a,[$DBEB] - A carries opponent's Cover byte
  26. 0C:4A57 CDCC49 call $49CC - H is the truncation of the multiplier, L is the float point (percent being value multiplied by 64/25). All 3 multiplier change bytes have half effect, if you're wondering.
  27. 0C:4A5A 54 ld d,h
  28. 0C:4A5B 5D ld e,l - D is the truncation of the multiplier, E is the float point (percent being value multiplied by 64/25)
  29. 0C:4A5C FAEADB ld a,[$DBEA]
  30. 0C:4A5F 47 ld b,a - B carries opponent's DEF byte
  31. 0C:4A60 FAE8DB ld a,[$DBE8] - A carries opponent's HP byte
  32. 0C:4A63 CD214A call $4A21 - for opponent, Total DEF = DEF * 2 * HP * (100 + DEF boosts / 2) / 100; Float error causes slightly lower values on any number not a multiple of 25
  33. 0C:4A66 7D ld a,l
  34. 0C:4A67 EAF1DB ld [$DBF1],a
  35. 0C:4A6A 7C ld a,h
  36. 0C:4A6B EAF2DB ld [$DBF2],a - $DBF2 (2 bytes) carries opponent's Total DEF
  37. 0C:4A6E D1 pop de - if you're confused, at this point, the Total ATK would be at the very top of the stack from the Push HL instruction, so DE would be holding the Total ATK value now
  38. 0C:4A6F CDC329 call $29C3 - HL = Total DEF - Total ATK
  39. 0C:4A72 3822 jr c,$30A96 - if HL is now negative, this basically sets A to 0 and ends the whole thing. The opponent's unit will be destroyed as a result.
  40. 0C:4A74 54 ld d,h
  41. 0C:4A75 5D ld e,l
  42. 0C:4A76 FAEADB ld a,[$DBEA]
  43. 0C:4A79 07 rlca
  44. 0C:4A7A 4F ld c,a - C is double the opponent's DEF byte
  45. 0C:4A7B 0600 ld b,$00
  46. 0C:4A7D CD212A call $2A21 - DE = (Total DEF - Total ATK) / (DEF*2); BC holds remainder
  47. 0C:4A80 78 ld a,b
  48. 0C:4A81 B1 or c
  49. 0C:4A82 2801 jr z,$30A85
  50. 0C:4A84 13 inc de - if remainder != 0, increase DE by 1
  51. 0C:4A85 7A ld a,d
  52. 0C:4A86 A7 and a
  53. 0C:4A87 2008 jr nz,$30A91 - yeah, why should DE even approach 255?
  54. 0C:4A89 FAE8DB ld a,[$DBE8]
  55. 0C:4A8C 57 ld d,a - D carries opponent's HP value
  56. 0C:4A8D 7B ld a,e - A carries expected new HP value
  57. 0C:4A8E BA cp d
  58. 0C:4A8F 3806 jr c,$30A97 - if the expected new HP value is lower, this procedure will be ended
  59. 0C:4A91 FAE8DB ld a,[$DBE8] - forces HP to remain unchanged if the new value were to exceed the old one
  60. 0C:4A94 1801 jr $30A97 - ends
  61. 0C:4A96 AF xor a
  62. 0C:4A97 C9 ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement