Advertisement
DrBaldhead

LUA__NES_TMNT_TOUR_FIRST_TRY

Jan 7th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. -- Some LUA tryouts by DrBaldhead. Tested on FCEUX. TMNT Tournament Fighters US version.
  2. -- Displays:
  3. -- Players positions
  4. -- The ball position
  5. -- Calculated distance between the characters
  6. -- P2 fatigue timer
  7. local P1XAddr = 0x0440
  8. local P1YAddr = 0x0410
  9. local P2XAddr = 0x0441
  10. local P2YAddr = 0x0411
  11. -- These ball coordinates are not final. When the ball isn't present in the arena, these coords are equal to P2 position.
  12. -- Also they are used by the ball dispenser while it flies across the screen. So it's not certain that these are the main addrs for the data.
  13. local BallXAddr = 0x0002
  14. local BallYAddr = 0x0001
  15. -- The game tries to calculate this value as a kind of a distance between the players.
  16. -- Generally it equals the diff between players X positions minus 24 pixels and never drops below zero.
  17. -- Right now I don't actually use it.
  18. local EnemyDistAddr = 0x0638
  19. -- Each player has a kind of a fatigue counter. When this counter changes by a certain amount,
  20. -- the character falls down and stands stunned for a while.
  21. -- Some attacks seem to drop the counter. All successful hits change the counter. Some attacks never trigger the fatigue stun.
  22. -- Those that do must be successfully landed not less often than each 79 frames
  23. -- Some attacks affect the counter more than the others. For example Don's roundhouse kick can sometimes cause an instant stun.
  24. -- (but usually counts as a dash kick which stuns on the second successful hit)
  25. -- Raph's far punch and far kick can stun in two hits (he's actually the top in terms of melee power).
  26. -- Character power can affect this mechanics. Using game genie to raise it beyond the maximum can make all melee hits trigger fatigue stun instantly.
  27. -- This Addr is not final. Also I'm not sure whether it's 8-bit or 16-bit value. It looks much more reasonable when watched
  28. -- as a byte at 0x00B1, but the byte at 0x00B0 is also changing. Or maybe it's actually two different timers?
  29. local P2FatiqueAddr = 0x00B0
  30. local P1X = 0
  31. local P1Y = 0
  32. local P2X = 0
  33. local P2Y = 0
  34. local P2Fatique = 0
  35. local P2FatiqueStored = 0xFFFF
  36. local P2FatiqueTimer = 0
  37. local BX = 0
  38. local BY = 0
  39. local EnemyGapLeft = 0
  40. local EnemyGapRight = 0
  41. P2Fatique = memory.readword(P2FatiqueAddr)
  42. P2FatiqueStored = P2Fatique
  43. while true do
  44. -- Memory scanning
  45. P1X = memory.readbyte(P1XAddr)
  46. P1Y = memory.readbyte(P1YAddr)
  47. P2X = memory.readbyte(P2XAddr)
  48. P2Y = memory.readbyte(P2YAddr)
  49. BX = memory.readbyte(BallXAddr)
  50. BY = memory.readbyte(BallYAddr)
  51. EDIST = memory.readbyte(EnemyDistAddr)
  52. P2Fatique = memory.readword(P2FatiqueAddr)
  53. -- Draw horizontal
  54. gui.line(P1X, 1, P1X, 239)
  55. gui.line(P2X, 1, P2X, 239, "cyan")
  56. -- Draw vertical
  57. gui.line(1, P1Y, 255, P1Y)
  58. gui.line(1, P2Y, 255, P2Y, "cyan")
  59. -- Draw the distance
  60. if P2X > P1X then
  61. EnemyGapLeft = P1X + 12
  62. EnemyGapRight = P2X - 12
  63. else
  64. EnemyGapLeft = P2X + 12
  65. EnemyGapRight = P1X - 12
  66. end
  67. if EnemyGapRight > EnemyGapLeft then
  68. gui.line(EnemyGapLeft, 130, EnemyGapLeft, 150)
  69. gui.line(EnemyGapRight, 130, EnemyGapRight, 150)
  70. gui.line(EnemyGapLeft,140, EnemyGapRight,140)
  71. end
  72. -- Draw the ball
  73. if (BY ~= P2Y) and (BX ~= P2X) and (BX > 3) and (BX < 250) and (BY > 3) and (BY < 237) then
  74. gui.line(BX, BY-3, BX, BY+3, "green")
  75. gui.line(BX-3, BY, BX+3, BY, "green")
  76. end
  77. -- Fatique analysis P2
  78. if P2Fatique == P2FatiqueStored then
  79. if P2FatiqueTimer > 0 then
  80. P2FatiqueTimer = P2FatiqueTimer-1
  81. end
  82. else
  83. P2FatiqueTimer = 79
  84. P2FatiqueStored = P2Fatique
  85. end
  86. -- Draw P2 fatique
  87. if P2FatiqueTimer > 0 then
  88. gui.drawbox(136, 41, (P2FatiqueTimer + 136), 43, "white", "white")
  89. gui.text(136, 45, "Fatique!", "white", "black")
  90. end
  91. -- Go on then
  92. emu.frameadvance()
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement