Advertisement
Guest User

Untitled

a guest
Jun 17th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. local Max = 10 -- Max number of frames to wait
  2. local MaxHold = 1  -- Max number of frames to hold on the last button press
  3. local hold -- How much current attempt will hold
  4. local waitSpots = 4  -- At how many presses manipulation waits will occur
  5. local finalFrame = 740 -- The frame where results are evident
  6. local press = {}  -- Frames where current attempt will press
  7. local frame = {321,382,529,639}  -- Earliest frames presses can occur
  8. local wait = {0,0,0,0} -- How much will be added to each frame in an attempt, the last number will be the total loss
  9. local out = "solutions.txt"
  10. local AttackID = 81 -- Enter here the ID of the attack you want the opponent to use
  11. local num = 0
  12.  
  13. function pressButton (pos)
  14.     a=num
  15.     for i=1,pos do a = (a - a%2)/2 end
  16.     if a%2==0 then joypad.set(1,{["A"]=true}) end
  17.     if a%2==1 then joypad.set(1,{["start"]=true}) end
  18. end
  19.  
  20. function printToScreen ()
  21.     a=num
  22.     if a%2==0 then str = "A" end
  23.     if a%2==1 then str = "S" end
  24.     for i=1,3 do
  25.         a = (a - a%2) / 2
  26.         if a%2==0 then str = str.."A" end
  27.         if a%2==1 then str = str.."S" end
  28.     end
  29.     gui.text(1,1,str)
  30.     gui.text(1,10,wait[1]..wait[2]..wait[3]..wait[4])
  31.     gui.text(60,1,memory.readbyte(0xD358).." "..memory.readbyte(0xD359))
  32. end
  33.  
  34. function updateWait()
  35.     hold=1
  36.     if wait[1]==Max then wait[1]=1000 end
  37.     for i=waitSpots,1,-1 do
  38.         if wait[i]<Max then
  39.             wait[i]=wait[i]+1
  40.             for j=i+1,waitSpots do wait[j]=wait[i] end
  41.             break
  42.         end
  43.     end
  44.     wait[waitSpots]=Max -- Enter this if you want to test the ones that wait exactly "n" frames
  45. end
  46.  
  47. function printToFile()
  48.     HP=memory.readbyte(0xCFE7)
  49.     --move=memory.readbyte(0xCCDD)
  50.     a=num
  51.     if a%2==0 then str = "A" end
  52.     if a%2==1 then str = "S" end
  53.     for i=1,3 do
  54.         a = (a - a%2) / 2
  55.         if a%2==0 then str = str.."A" end
  56.         if a%2==1 then str = str.."S" end
  57.     end
  58.     io.write(str.." ")
  59.     for i=1,waitSpots do io.write(wait[i]+frame[i].." ") end
  60.     io.write(memory.readbyte(0xD358).." "..memory.readbyte(0xD359).."\n")
  61. end
  62.  
  63. function updateHold()
  64.     if hold==MaxHold then updateWait()
  65.     else hold=hold+1 end
  66. end
  67.  
  68. function build ()
  69.     for i=1,waitSpots do press[i]=frame[i]+wait[i] end -- The frames that will be pressed by current attempt
  70. end
  71.  
  72. function frames()
  73.     f=movie.framecount()
  74.     printToScreen()
  75.     joypad.set(1,{}) -- Necessary to erase the presses
  76.     for i=1,waitSpots do
  77.         if f==press[i]-1 then pressButton(i-1) end
  78.     end
  79.     if f==finalFrame then
  80.         printToFile()
  81.         if wait[1]==1000 and num < 16 then
  82.             num=num+1
  83.             wait[1]=0
  84.             wait[2]=0
  85.             wait[3]=0
  86.             wait[4]=0
  87.         end -- Stop condition
  88.         if wait[1]==1000 and num == 16 then vba.pause() end
  89.         --if memory.readbyte(0xCCDD)==AttackID then updateHold() -- Only try holds if the move is "Tail whip"
  90.         --else updateWait() end
  91.         updateHold()
  92.         build()
  93.     end
  94. end
  95.  
  96. hold=1
  97. build()
  98. gui.register(frames)
  99. io.output(out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement