Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- itools = dofile('lib_input_tools.lua')
- core = dofile('lib_core.lua')
- function i_advance(amount)
- for i = 1, amount, 1 do
- itools.iframe_advance()
- end
- end
- function v_advance(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance()
- end
- end
- function v_advance_hold_up_and_A(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['A']=true,['X Axis']=0,['Y Axis']=127})
- end
- end
- function v_advance_hold_up(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=0,['Y Axis']=127})
- end
- end
- function v_advance_press_A(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['A']=true})
- end
- end
- function v_advance_press_Z(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['Z']=true})
- end
- end
- function v_advance_press_C_Right(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['C Right']=true})
- end
- end
- function v_advance_press_C_Right_and_hold_up(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['C Right']=true,['X Axis']=0,['Y Axis']=127})
- end
- end
- function v_advance_press_R(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['R']=true})
- end
- end
- function v_advance_hold_up(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=0,['Y Axis']=127})
- end
- end
- function v_advance_hold_left(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=-128,['Y Axis']=0})
- end
- end
- function v_advance_hold_left_and_target(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=-128,['Y Axis']=0,['Z']=true})
- end
- end
- function v_advance_hold_up_and_target(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=0,['Y Axis']=127,['Z']=true})
- end
- end
- function v_advance_hold_down(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=0,['Y Axis']=-128})
- end
- end
- function v_advance_hold_down_and_target(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=0,['Y Axis']=-128,['Z']=true})
- end
- end
- function v_advance_hold_right(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=127,['Y Axis']=0})
- end
- end
- function v_advance_hold_right_and_target(amount)
- for i = 1, amount, 1 do
- itools.vframe_advance({['X Axis']=127,['Y Axis']=0,['Z']=true})
- end
- end
- function Turn_Right()
- -- Press Z to target for 1 visual frame, then do nothing for 5 visual frames, then hold Right for 1 visual frame
- -- clear inputs at the start of each function for safety
- -- advance visual frame at the start for safety
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['Z']=true})
- v_advance(5)
- itools.vframe_advance({['X Axis']=127,['Y Axis']=0})
- itools.clear_inputs()
- itools.vframe_advance()
- end
- function Turn_Left()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['Z']=true})
- v_advance(5)
- itools.vframe_advance({['X Axis']=-128,['Y Axis']=0})
- itools.clear_inputs()
- itools.vframe_advance()
- end
- function Turn_Down()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['Z']=true})
- v_advance(5)
- itools.vframe_advance({['X Axis']=0,['Y Axis']=-128})
- itools.clear_inputs()
- itools.vframe_advance()
- end
- function Turn_Up()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['Z']=true})
- itools.clear_inputs()
- v_advance(5)
- itools.vframe_advance({['X Axis']=0,['Y Axis']=127})
- itools.clear_inputs()
- itools.vframe_advance()
- end
- ------------------------------------------------------------------------
- ------------------------------------------------------------------------
- -- Assume the savestate is oriented for a backwalk, so you need to turn down before
- -- doing the spin. Assume initial position is in savestate (3). After drowning, save
- -- to savestate (4).
- ------------------------------------------------------------------------
- ------------------------------------------------------------------------
- Movement_Options = {'Backwalk', 'Spin'}
- Movement_Directions = {'Neutral', 'Up', 'Down', 'Left', 'Right', 'Neutral + Target', 'Up + Target', 'Down + Target', 'Left + Target', 'Right + Target'}
- Fly_Directions = {'Neutral', 'Up', 'Down', 'Left', 'Right'}
- M = 20
- file_write = io.open('reverse pf climb ladder mask and target same frame backwalk and spin.txt', 'w+')
- Left_Clip_Exists = false
- Right_Clip_Exists = false
- for i = 1, table.getn(Movement_Options), 1 do
- itools.clear_inputs()
- option = Movement_Options[i]
- if option == 'Backwalk' then
- itools.clear_inputs()
- -- load state (3)
- itools.load_state(3)
- --- Determine when the fourth bounce is
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- previous_y_position = false
- bounce_count = 0
- frame_count = 0
- while bounce_count < 4 do
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- v_advance_hold_down_and_target(1)
- frame_count = frame_count + 1
- if Y_Position == -400 and previous_y_position == false then
- bounce_count = bounce_count + 1
- previous_y_position = true
- elseif Y_Position ~= -400 then
- previous_y_position = false
- end
- end
- itools.clear_inputs()
- -- load state (3)
- itools.load_state(3)
- v_advance_hold_down_and_target(frame_count - 3)
- -- save state (4) to test every movement direction more efficiently
- itools.save_state(4)
- for j = 1, table.getn(Movement_Directions), 1 do
- movement_direction = Movement_Directions[j]
- In_Updraft = false
- Left_Clip_Down = false
- Right_Clip_Down = false
- Left_Clip_Up = false
- Right_Clip_Up = false
- Left_Clip_Left = false
- Right_Clip_Left = false
- Left_Clip_Right = false
- Right_Clip_Right = false
- Left_Clip_Neutral = false
- Right_Clip_Neutral = false
- -- because this is redunant (just test individually or add elseif to test it once)
- if movement_direction ~= 'Down + Target' then
- for k = 0, M, 1 do
- print('i: ' .. i .. ' j: ' .. j .. ' k: ' .. k .. ' Left: ' .. tostring(Left_Clip_Exists) .. ' Right ' .. tostring(Right_Clip_Exists))
- itools.clear_inputs()
- itools.load_state(4)
- v_advance_hold_down_and_target(k)
- itools.clear_inputs()
- if movement_direction == 'Up' then
- v_advance_hold_up(M - k + 12)
- elseif movement_direction == 'Down' then
- v_advance_hold_down(M - k + 12)
- elseif movement_direction == 'Right' then
- v_advance_hold_right(M - k + 12)
- elseif movement_direction == 'Left' then
- v_advance_hold_left(M - k + 12)
- elseif movement_direction == 'Neutral' then
- v_advance(M - k + 12)
- elseif movement_direction == 'Up + Target' then
- v_advance_hold_up_and_target(M - k + 12)
- elseif movement_direction == 'Down + Target' then
- v_advance_hold_down_and_target(M - k + 12)
- elseif movement_direction == 'Right + Target' then
- v_advance_hold_right_and_target(M - k + 12)
- elseif movement_direction == 'Left + Target' then
- v_advance_hold_left_and_target(M - k + 12)
- elseif movement_direction == 'Neutral + Target' then
- v_advance_press_Z(M - k + 12)
- end
- ---- Check if in updraft after waiting 12 frames
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- if Z_Position >= -218 and Z_Position <= -107 and X_Position <= 2446.1 and X_Position >= 2375 then
- In_Updraft = true
- itools.save_state(5)
- else
- In_Updraft = false
- end
- if In_Updraft == true then
- itools.load_state(5)
- itools.clear_inputs()
- for m = 1, table.getn(Fly_Directions), 1 do
- direction = Fly_Directions[m]
- itools.load_state(5)
- itools.clear_inputs()
- if direction == 'Up' then
- --v_advance_hold_up(60)
- t = 0
- while t < 60 and Left_Clip_Up == false and Right_Clip_Up == false do
- v_advance_hold_up(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Up = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Up = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- elseif direction == 'Down' then
- --v_advance_hold_down(60)
- t = 0
- while t < 60 and Left_Clip_Down == false and Right_Clip_Down == false do
- v_advance_hold_down(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Down = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Down = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- elseif direction == 'Left' then
- --v_advance_hold_left(60)
- t = 0
- while t < 60 and Left_Clip_Left == false and Right_Clip_Left == false do
- v_advance_hold_left(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Left = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Left = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- elseif direction == 'Right' then
- --v_advance_hold_right(60)
- t = 0
- while t < 60 and Left_Clip_Right == false and Right_Clip_Right == false do
- v_advance_hold_right(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Right = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Right = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- elseif direction == 'Neutral' then
- --v_advance(60)
- t = 0
- while t < 60 and Left_Clip_Neutral == false and Right_Clip_Neutral == false do
- v_advance(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Neutral = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Neutral = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- end
- end
- end
- ----- after testing all 5 fly directions...
- file_write:write(option .. ' ' .. movement_direction .. ' ' .. k .. '\n')
- if In_Updraft == true then
- file_write:write('In Updraft? Yes\n')
- elseif In_Updraft == false then
- file_write:write('In Updraft? No\n')
- end
- if Left_Clip_Up == true then
- file_write:write('Left Clip Up? Yes\n')
- elseif Left_Clip_Up == false then
- file_write:write('Left Clip Up? No\n')
- end
- if Right_Clip_Up == true then
- file_write:write('Right Clip Up? Yes\n')
- elseif Right_Clip_Up == false then
- file_write:write('Right Clip Up? No\n')
- end
- if Left_Clip_Down == true then
- file_write:write('Left Clip Down? Yes\n')
- elseif Left_Clip_Down == false then
- file_write:write('Left Clip Down? No\n')
- end
- if Right_Clip_Down == true then
- file_write:write('Right Clip Down? Yes\n')
- elseif Right_Clip_Down == false then
- file_write:write('Right Clip Down? No\n')
- end
- if Left_Clip_Right == true then
- file_write:write('Left Clip Right? Yes\n')
- elseif Left_Clip_Right == false then
- file_write:write('Left Clip Right? No\n')
- end
- if Right_Clip_Right == true then
- file_write:write('Right Clip Right? Yes\n')
- elseif Right_Clip_Right == false then
- file_write:write('Right Clip Right? No\n')
- end
- if Left_Clip_Left == true then
- file_write:write('Left Clip Left? Yes\n')
- elseif Left_Clip_Left == false then
- file_write:write('Left Clip Left? No\n')
- end
- if Right_Clip_Left == true then
- file_write:write('Right Clip Left? Yes\n')
- elseif Right_Clip_Left == false then
- file_write:write('Right Clip Left? No\n')
- end
- file_write:write('---\n')
- end
- end
- end
- elseif option == 'Spin' then
- itools.clear_inputs()
- -- load state (3)
- itools.load_state(3)
- Turn_Down()
- v_advance_press_Z(6)
- --- Determine when the fourth bounce is
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- previous_y_position = false
- bounce_count = 0
- frame_count = 0
- while bounce_count < 4 do
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- -- the first A press + Up starts the spin, the rest continue holding Up
- v_advance_hold_up_and_A(1)
- frame_count = frame_count + 1
- if Y_Position == -400 and previous_y_position == false then
- bounce_count = bounce_count + 1
- previous_y_position = true
- elseif Y_Position ~= -400 then
- previous_y_position = false
- end
- end
- itools.clear_inputs()
- -- load state (3)
- itools.load_state(3)
- v_advance_hold_up(frame_count - 3)
- -- save state (4) to test every movement direction more efficiently
- itools.save_state(4)
- for j = 1, table.getn(Movement_Directions), 1 do
- movement_direction = Movement_Directions[j]
- In_Updraft = false
- Left_Clip_Down = false
- Right_Clip_Down = false
- Left_Clip_Up = false
- Right_Clip_Up = false
- Left_Clip_Left = false
- Right_Clip_Left = false
- Left_Clip_Right = false
- Right_Clip_Right = false
- Left_Clip_Neutral = false
- Right_Clip_Neutral = false
- -- because this is redunant (just test individually or add elseif to test it once)
- if movement_direction ~= 'Up' then
- for k = 0, M, 1 do
- print('i: ' .. i .. ' j: ' .. j .. ' k: ' .. k .. ' Left: ' .. tostring(Left_Clip_Exists) .. ' Right ' .. tostring(Right_Clip_Exists))
- itools.clear_inputs()
- itools.load_state(4)
- v_advance_hold_up(k)
- itools.clear_inputs()
- if movement_direction == 'Up' then
- v_advance_hold_up(M - k + 12)
- elseif movement_direction == 'Down' then
- v_advance_hold_down(M - k + 12)
- elseif movement_direction == 'Right' then
- v_advance_hold_right(M - k + 12)
- elseif movement_direction == 'Left' then
- v_advance_hold_left(M - k + 12)
- elseif movement_direction == 'Neutral' then
- v_advance(M - k + 12)
- elseif movement_direction == 'Up + Target' then
- v_advance_hold_up_and_target(M - k + 12)
- elseif movement_direction == 'Down + Target' then
- v_advance_hold_down_and_target(M - k + 12)
- elseif movement_direction == 'Right + Target' then
- v_advance_hold_right_and_target(M - k + 12)
- elseif movement_direction == 'Left + Target' then
- v_advance_hold_left_and_target(M - k + 12)
- elseif movement_direction == 'Neutral + Target' then
- v_advance_press_Z(M - k + 12)
- end
- ---- Check if in updraft after waiting 12 frames
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- if Z_Position >= -218 and Z_Position <= -107 and X_Position <= 2446.1 and X_Position >= 2375 then
- In_Updraft = true
- itools.save_state(5)
- else
- In_Updraft = false
- end
- if In_Updraft == true then
- itools.load_state(5)
- itools.clear_inputs()
- for m = 1, table.getn(Fly_Directions), 1 do
- direction = Fly_Directions[m]
- itools.load_state(5)
- itools.clear_inputs()
- if direction == 'Up' then
- --v_advance_hold_up(60)
- t = 0
- while t < 60 and Left_Clip_Up == false and Right_Clip_Up == false do
- v_advance_hold_up(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Up = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Up = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- elseif direction == 'Down' then
- --v_advance_hold_down(60)
- t = 0
- while t < 60 and Left_Clip_Down == false and Right_Clip_Down == false do
- v_advance_hold_down(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Down = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Down = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- elseif direction == 'Left' then
- --v_advance_hold_left(60)
- t = 0
- while t < 60 and Left_Clip_Left == false and Right_Clip_Left == false do
- v_advance_hold_left(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Left = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Left = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- elseif direction == 'Right' then
- --v_advance_hold_right(60)
- t = 0
- while t < 60 and Left_Clip_Right == false and Right_Clip_Right == false do
- v_advance_hold_right(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Right = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Right = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- elseif direction == 'Neutral' then
- --v_advance(60)
- t = 0
- while t < 60 and Left_Clip_Neutral == false and Right_Clip_Neutral == false do
- v_advance(1)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- t = t + 1
- if Z_Position > -593 and X_Position < 2234 and Y_Position > -290 then
- Left_Clip_Neutral = true
- Left_Clip_Exists = true
- print('Left Clip!!!!!!')
- elseif Z_Position < -868 and Y_Position > -290 then
- Right_Clip_Neutral = true
- Right_Clip_Exists = true
- print('Right Clip!!!!!!')
- end
- end
- end
- end
- end
- ----- after testing all 5 fly directions...
- file_write:write(option .. ' ' .. movement_direction .. ' ' .. k .. '\n')
- if In_Updraft == true then
- file_write:write('In Updraft? Yes\n')
- elseif In_Updraft == false then
- file_write:write('In Updraft? No\n')
- end
- if Left_Clip_Up == true then
- file_write:write('Left Clip Up? Yes\n')
- elseif Left_Clip_Up == false then
- file_write:write('Left Clip Up? No\n')
- end
- if Right_Clip_Up == true then
- file_write:write('Right Clip Up? Yes\n')
- elseif Right_Clip_Up == false then
- file_write:write('Right Clip Up? No\n')
- end
- if Left_Clip_Down == true then
- file_write:write('Left Clip Down? Yes\n')
- elseif Left_Clip_Down == false then
- file_write:write('Left Clip Down? No\n')
- end
- if Right_Clip_Down == true then
- file_write:write('Right Clip Down? Yes\n')
- elseif Right_Clip_Down == false then
- file_write:write('Right Clip Down? No\n')
- end
- if Left_Clip_Right == true then
- file_write:write('Left Clip Right? Yes\n')
- elseif Left_Clip_Right == false then
- file_write:write('Left Clip Right? No\n')
- end
- if Right_Clip_Right == true then
- file_write:write('Right Clip Right? Yes\n')
- elseif Right_Clip_Right == false then
- file_write:write('Right Clip Right? No\n')
- end
- if Left_Clip_Left == true then
- file_write:write('Left Clip Left? Yes\n')
- elseif Left_Clip_Left == false then
- file_write:write('Left Clip Left? No\n')
- end
- if Right_Clip_Left == true then
- file_write:write('Right Clip Left? Yes\n')
- elseif Right_Clip_Left == false then
- file_write:write('Right Clip Left? No\n')
- end
- file_write:write('---\n')
- end
- end
- end
- end
- end
- file_write:close()
- print('done')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement