Advertisement
cleartonic

mm5_wily_press.lua

Nov 17th, 2021 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. --- CONFIG ---
  2. -- options are (case sensitive):
  3. -- A, B, start, select, left, up, down, right
  4.  
  5.  
  6. pattern1_first_button = "select"
  7. pattern1_second_button = "left"
  8. pattern2_first_button = "select"
  9. pattern2_second_button = "up"
  10. pattern3_first_button = "select"
  11. pattern3_second_button = "right"
  12. pattern4_first_button = "select"
  13. pattern4_second_button = "down"
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. --- CODE ---
  21. pattern1 = 3
  22. pattern2 = 5
  23. pattern3 = 7
  24. pattern4 = 7
  25. MAX = 4
  26. current_pattern = pattern1
  27. current_pattern_num = 1
  28. change_flag = false
  29. byte_write_val = 0
  30. selection_cooldown = 0
  31. waiting_flag = true
  32.  
  33. while true do
  34. inputs = joypad.get(1)
  35. -- emu.print(inputs)
  36. selection_cooldown = selection_cooldown + 1
  37.  
  38. if inputs[pattern1_first_button] and inputs[pattern1_second_button] and selection_cooldown > 15 then
  39. if pattern1 == 3 then
  40. pattern1 = 5
  41. elseif pattern1 == 5 then
  42. pattern1 = 7
  43. else
  44. pattern1 = 3
  45. end
  46. selection_cooldown = 0
  47.  
  48. elseif inputs[pattern2_first_button] and inputs[pattern2_second_button] and selection_cooldown > 15 then
  49. if pattern2 == 3 then
  50. pattern2 = 5
  51. elseif pattern2 == 5 then
  52. pattern2 = 7
  53. else
  54. pattern2 = 3
  55. end
  56. selection_cooldown = 0
  57.  
  58.  
  59. elseif inputs[pattern3_first_button] and inputs[pattern3_second_button] and selection_cooldown > 15 then
  60. if pattern3 == 3 then
  61. pattern3 = 5
  62. elseif pattern3 == 5 then
  63. pattern3 = 7
  64. else
  65. pattern3 = 3
  66. end
  67. selection_cooldown = 0
  68.  
  69. elseif inputs[pattern4_first_button] and inputs[pattern4_second_button] and selection_cooldown > 15 then
  70. if pattern4 == 3 then
  71. pattern4 = 5
  72. elseif pattern4 == 5 then
  73. pattern4 = 7
  74. else
  75. pattern4 = 3
  76. end
  77. selection_cooldown = 0
  78.  
  79. end
  80.  
  81.  
  82.  
  83. gui.text(120,9,"Pattern: "..pattern1..", "..pattern2..", "..pattern3..", "..pattern4)
  84. gui.text(120,19,"Current pattern: #"..current_pattern_num.." ("..current_pattern..")")
  85.  
  86. waiting_flag = memory.readbyte(0x0458) == 0
  87.  
  88. if waiting_flag then
  89. gui.text(120,29,"Waiting to start fight...")
  90. fight_start = false
  91.  
  92.  
  93. else
  94.  
  95. if fight_start == false then
  96.  
  97. current_pattern = pattern1
  98. current_pattern_num = 1
  99. change_flag = false
  100.  
  101. if current_pattern == 3 then
  102. byte_write_val = 255
  103. elseif current_pattern == 5 then
  104. byte_write_val = 202
  105. elseif current_pattern == 7 then
  106. byte_write_val = 0
  107. end
  108.  
  109. memory.writebyte(0x00E4, 0)
  110. memory.writebyte(0x00E5, 255)
  111. memory.writebyte(0x00E6, byte_write_val)
  112. memory.writebyte(0x00E7, 0)
  113.  
  114. fight_start = true
  115.  
  116. end
  117.  
  118. wily_pattern_num = memory.readbyte(0x009b)
  119.  
  120. wily_pattern_change = false
  121. if wily_pattern_num ~= 191 then
  122. -- emu.print("Set wily_pattern_change")
  123. wily_pattern_change = true
  124. end
  125.  
  126. if wily_pattern_num == 191 then
  127. change_flag = true
  128. -- emu.print("Set change_flag")
  129. end
  130.  
  131. if wily_pattern_change and change_flag then
  132. emu.print("Change value")
  133. if current_pattern_num == MAX then
  134. current_pattern_num = 1
  135. else
  136. current_pattern_num = current_pattern_num + 1
  137. end
  138.  
  139. if current_pattern_num == 1 then
  140. current_pattern = pattern1
  141.  
  142. elseif current_pattern_num == 2 then
  143. current_pattern = pattern2
  144. elseif current_pattern_num == 3 then
  145. current_pattern = pattern3
  146. elseif current_pattern_num == 4 then
  147. current_pattern = pattern4
  148. end
  149.  
  150.  
  151. if current_pattern == 3 then
  152. byte_write_val = 255
  153. elseif current_pattern == 5 then
  154. byte_write_val = 202
  155. elseif current_pattern == 7 then
  156. byte_write_val = 0
  157. end
  158.  
  159. -- set rng
  160.  
  161.  
  162. -- emu.print("Unset change_flag")
  163. change_flag = false
  164.  
  165. end
  166.  
  167.  
  168. memory.writebyte(0x00E4, 0)
  169. memory.writebyte(0x00E5, 255)
  170. memory.writebyte(0x00E6, byte_write_val)
  171. memory.writebyte(0x00E7, 0)
  172. end
  173.  
  174. emu.frameadvance()
  175.  
  176.  
  177.  
  178. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement