Advertisement
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, with 1 Metal slime
- --Set the correct memory domain
- memory.usememorydomain("System Bus")
- --define variables
- wins = 0
- runs = 0
- para = 0
- total = 0
- save_state_slot = 0 -- which quickload slot to load from
- rng1 = 0
- rng2 = 0
- rng3 = 0
- --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 metal slime's HP
- gui.text(120,150,'HP: '..(memory.readbyte(0x727E) + memory.readbyte(0x727F) * 256))
- gui.text(30,170,'Total: '..total)
- if(total ~= 0) then
- gui.text(30,210,'Wins: '..wins..' ('..(math.floor(1000 * wins / (total)) / 10)..'%)')
- gui.text(30,230,'Run: '..runs..' ('..(math.floor(1000 * runs / (total)) / 10)..'%)')
- gui.text(30,250,'Para: '..para..' ('..(math.floor(1000 * para / (total)) / 10)..'%)')
- end
- end
- end
- --the main loop, this runs forever
- while true do
- --load the savestate (a single Metal Slime)
- savestate.loadslot(save_state_slot);
- --load the previous rng values back into the state
- memory.writebyte(0x0012,rng1);
- memory.writebyte(0x0013,rng2);
- memory.writebyte(0x050D,rng3);
- --while the metal slime's HP is still greater than 0, run the attack loop
- while (memory.readbyte(0x727E) > 0x00) do
- Wait(math.random(5)+1); --wait a random number of frames
- joypad.set({A=true}, 1)
- Wait(1);
- joypad.set({A=false}, 1)
- --this reads the status byte and detects if the metal slime ran away, and breaks the loop
- if (memory.readbyte(0x727A) == 0x01) then break end
- end
- --read the variables we need to record data
- status = memory.readbyte(0x727A);
- if status == 0x01 then
- --this means the slime ran
- runs = runs + 1;
- elseif status == 0xE0 then
- --this means the slime was paralyzed and killed (only relevant if Brey is equipped with the Venomous Dagger)
- wins = wins + 1;
- para = para + 1;
- else
- --Metal Slime was killed
- wins = wins + 1;
- end
- total = total + 1;
- --save the RNG values for the next loop
- rng1 = memory.readbyte(0x0012)
- rng2 = memory.readbyte(0x0013)
- rng3 = memory.readbyte(0x050D)
- Wait(1);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement