User File #39902972814196237

Upload All User Files

#39902972814196237 -

ZX4_wallclip.lua
Game: Zook Man ZX4 ( GBA, see all files )
789 downloads
Uploaded 6/24/2017 12:34 AM by lapogne36 (see all 25)
Lua script to brute force the wall clips in ZX4
How to use/requirements :
-The savestate slot 9 must be the initial state from where you want to find the fastest wall clip (i.e. before the wall clip)
-The savestate slot 0 must be a state after after ZX4 did a wall clip (all that really matters is that ZX4's height is higher than the height aim)
-You must edit the height aim in the lua (i.e. if ZX4's height is higher than the height aim, it means that the wall clip was a success)
-Eventually, edit in the lua the direction ZX4 must face to wall jump (either Left or Right)
Once all is done, you can run the lua and stop it after enough time has passed (use turbo to speed up the process), the best attempt will be saved on slot 0
-- while true do
	-- joypad.set({Left=true}) 
	-- --joypad.setfrommnemonicstr("|    0,    0,    0,  100,..L........|")
	-- emu.frameadvance();
-- end



rrcount=movie.getrerecordcount() --don't increase rerecords

console.clear()
savestate.loadslot(0)
fbest = emu.framecount()
yposbest = memory.read_u16_le( 0x1564 )
fbest2=fbest+10
yposbest2=yposbest
print("all-time best : " .. fbest)
print("all-time best : " .. yposbest)

while true do
	savestate.loadslot(9)
	A_ind=0
	movie.setrerecordcount(rrcount)
	while (emu.framecount()<=fbest) do
	joypad.set({B=true})
	x=math.random(100)
	if (x>50 and A_ind==0) then 
		joypad.set({A=true}) 
		A_ind=1
		else A_ind=0
	end
	y=math.random(100)
	if (y>20) then 
		joypad.set({Right=true}) --Set to Left or Right
	end
	emu.frameadvance()
	if memory.read_u16_le( 0x1564 ) < 80 then  --height aim
		break 
	end
	end
	if ((emu.framecount() < fbest) or 
	(emu.framecount() == fbest and memory.read_s16_le( 0x1564 ) < yposbest)) then
		fbest = emu.framecount()
		yposbest = memory.read_u16_le( 0x1564 )
		savestate.saveslot(0)
		--print("all-time best : " .. fbest)
		--print("all-time best : " .. yposbest)
	end
	if ((emu.framecount() < fbest2) or 
	(emu.framecount() == fbest2 and memory.read_s16_le( 0x1564 ) < yposbest2)) then
		fbest2 = emu.framecount()
		yposbest2 = memory.read_u16_le( 0x1564 )
		print("session best : " .. fbest2)
		print("session best : " .. yposbest2)
	end
end