Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Max = 10 -- Max number of frames to wait
- local MaxHold = 1 -- Max number of frames to hold on the last button press
- local hold -- How much current attempt will hold
- local waitSpots = 4 -- At how many presses manipulation waits will occur
- local finalFrame = 740 -- The frame where results are evident
- local press = {} -- Frames where current attempt will press
- local frame = {321,382,529,639} -- Earliest frames presses can occur
- 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
- local out = "solutions.txt"
- local AttackID = 81 -- Enter here the ID of the attack you want the opponent to use
- local num = 0
- function pressButton (pos)
- a=num
- for i=1,pos do a = (a - a%2)/2 end
- if a%2==0 then joypad.set(1,{["A"]=true}) end
- if a%2==1 then joypad.set(1,{["start"]=true}) end
- end
- function printToScreen ()
- a=num
- if a%2==0 then str = "A" end
- if a%2==1 then str = "S" end
- for i=1,3 do
- a = (a - a%2) / 2
- if a%2==0 then str = str.."A" end
- if a%2==1 then str = str.."S" end
- end
- gui.text(1,1,str)
- gui.text(1,10,wait[1]..wait[2]..wait[3]..wait[4])
- gui.text(60,1,memory.readbyte(0xD358).." "..memory.readbyte(0xD359))
- end
- function updateWait()
- hold=1
- if wait[1]==Max then wait[1]=1000 end
- for i=waitSpots,1,-1 do
- if wait[i]<Max then
- wait[i]=wait[i]+1
- for j=i+1,waitSpots do wait[j]=wait[i] end
- break
- end
- end
- wait[waitSpots]=Max -- Enter this if you want to test the ones that wait exactly "n" frames
- end
- function printToFile()
- HP=memory.readbyte(0xCFE7)
- --move=memory.readbyte(0xCCDD)
- a=num
- if a%2==0 then str = "A" end
- if a%2==1 then str = "S" end
- for i=1,3 do
- a = (a - a%2) / 2
- if a%2==0 then str = str.."A" end
- if a%2==1 then str = str.."S" end
- end
- io.write(str.." ")
- for i=1,waitSpots do io.write(wait[i]+frame[i].." ") end
- io.write(memory.readbyte(0xD358).." "..memory.readbyte(0xD359).."\n")
- end
- function updateHold()
- if hold==MaxHold then updateWait()
- else hold=hold+1 end
- end
- function build ()
- for i=1,waitSpots do press[i]=frame[i]+wait[i] end -- The frames that will be pressed by current attempt
- end
- function frames()
- f=movie.framecount()
- printToScreen()
- joypad.set(1,{}) -- Necessary to erase the presses
- for i=1,waitSpots do
- if f==press[i]-1 then pressButton(i-1) end
- end
- if f==finalFrame then
- printToFile()
- if wait[1]==1000 and num < 16 then
- num=num+1
- wait[1]=0
- wait[2]=0
- wait[3]=0
- wait[4]=0
- end -- Stop condition
- if wait[1]==1000 and num == 16 then vba.pause() end
- --if memory.readbyte(0xCCDD)==AttackID then updateHold() -- Only try holds if the move is "Tail whip"
- --else updateWait() end
- updateHold()
- build()
- end
- end
- hold=1
- build()
- gui.register(frames)
- io.output(out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement