Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This script is designed to work with Bizhawk
- --This script assumes a pre-made state on Quicksave Slot 0, 1 enemy, with % hit selected (next X press would attack)
- --Set the correct memory domain
- --memory.usememorydomain("System Bus")
- --define variables
- wins = 0
- miss = 0
- total = 0
- save_state_slot = 0 -- which quickload slot to load from
- counter = 0
- pervious = 0
- HPaddr = 0x0DBDD8
- --HPaddr = 0x0DD2F0
- file = io.open('attack_' ..tostring(emu.framecount()) ..'.txt', "a")
- io.output(file)
- io.write("---Streak---\n")
- --Wait function for advancing 1 frame and displaying results on the screen
- function Wait(number)
- for i=0,number-1 do
- emu.frameadvance()
- --display the HP
- gui.text(330,150,'HP: '..(memory.read_u16_le(HPaddr)) )
- gui.text(330,170,'Total: '..total)
- if(total ~= 0) then
- gui.text(330,210,'Hit: '..wins..' ('..(math.floor(1000 * wins / (total)) / 10)..'%)')
- gui.text(330,230,'Miss: '..miss..' ('..(math.floor(1000 * miss / (total)) / 10)..'%)')
- end
- end
- end
- --the main loop, this runs forever
- while true do
- --load the savestate
- savestate.loadslot(save_state_slot);
- --wait, then save state for the next round
- Wait(1);
- savestate.saveslot(save_state_slot);
- HPStart = memory.read_u16_le(HPaddr)
- wait = 30
- --run the attack loop
- while true do
- joypad.set({R2=true}, 1)
- joypad.set({Cross=true}, 1)
- wait = wait - 1
- Wait(1);
- --wait for the attack to resolve
- if ((wait == 0) or (memory.read_u16_le(HPaddr) ~= HPStart)) then break end
- end
- --read the variables we need to record data
- HPEnd = memory.read_u16_le(HPaddr);
- if (HPStart ~= HPEnd) then
- --hit
- wins = wins + 1
- if(previous == 0) then
- --increment the counter
- counter = counter + 1;
- else
- --write to file
- io.write('Miss: ', counter, '\n')
- counter = 1
- previous = 0
- end
- else
- --miss
- miss = miss + 1
- if(previous == 1) then
- --increment the counter
- counter = counter + 1;
- else
- --write to file
- io.write('Hit : ', counter, '\n')
- counter = 1
- previous = 1
- end
- end
- total = total + 1;
- --we are finished, record the data, set total number of trials here
- if(total == 10000) then
- if(previous == 1) then
- io.write('Miss: ', counter, '\n')
- else
- io.write('Hit : ', counter, '\n')
- end
- io.write('\n')
- io.write('Total : ', total, '\n')
- io.write('Total Hit : ', wins, ' (', (math.floor(1000 * wins / (total)) / 10), '%)\n')
- io.write('Total Miss: ', miss, ' (', (math.floor(1000 * miss / (total)) / 10), '%)\n')
- io.close(file)
- break
- end
- Wait(1);
- end
Add Comment
Please, Sign In to add comment