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')
- N = 15 -- number of visual frames to advance before assuming link does not clip out of bounds
- M = 30 -- number of visual frames to advance before assuming link does not land out of bounds
- 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_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_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_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_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 set_down_isg_targeted()
- -- set down a bomb (on C-Down) and get isg
- -- This takes a total of 42 visual frames
- itools.vframe_advance({['C Down']=true})
- itools.clear_inputs()
- v_advance(1)
- itools.vframe_advance({['A']=true})
- itools.clear_inputs()
- v_advance_press_R(12)
- itools.vframe_advance({['R']=true,['B']=true})
- itools.clear_inputs()
- v_advance_press_R(6)
- itools.vframe_advance({['R']=true,['A']=true})
- itools.clear_inputs()
- v_advance_press_Z(19)
- itools.clear_inputs()
- -- can perform the first input to walk somewhere (for example) on the next frame
- end
- function shield_drop_isg()
- -- frame perfectly shield drop a bomb (on C-Down) and get isg off of it
- -- This takes a total of 34 visual frames
- itools.vframe_advance({['C Down']=true})
- itools.clear_inputs()
- v_advance(2)
- v_advance_press_R(4)
- itools.vframe_advance({['R']=true,['B']=true})
- itools.clear_inputs()
- v_advance_press_R(6)
- itools.vframe_advance({['R']=true,['A']=true})
- itools.clear_inputs()
- v_advance(19)
- -- can perform the first input to walk somewhere (for example) on the next frame
- end
- -- Define functions to perform each movement option (except for 'Nothing')
- -- Movement_Options = ['Untargeted Horizontal Slash',
- -- 'Untargeted Horizontal Slash, Shield', 'Targeted Vertical Slash', 'Targeted Vertical Slash, Untarget ASAP',
- -- 'Untargeted Right Slash', 'Untargeted Right Slash, Shield', 'Targeted Forward Thrust',
- -- 'Targeted Forward Thrust, Untarget ASAP', 'Nothing', 'Dry Roll']
- function Untargeted_Horizontal_Slash()
- itools.clear_inputs()
- v_advance(2)
- itools.vframe_advance({['B']=true})
- itools.clear_inputs()
- v_advance(15)
- end
- function Untargeted_Horizontal_Slash_Shield()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['B']=true})
- itools.clear_inputs()
- v_advance_press_R(10)
- itools.clear_inputs()
- v_advance(8)
- end
- function Targeted_Vertical_Slash()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['B']=true, ['Z']=true})
- v_advance_press_Z(8)
- itools.clear_inputs()
- v_advance(7)
- itools.clear_inputs()
- itools.vframe_advance()
- end
- function Targeted_Vertical_Slash_Untarget_ASAP()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['B']=true, ['Z']=true})
- itools.clear_inputs()
- v_advance(14)
- end
- function Untargeted_Right_Slash()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['Z']=true})
- itools.clear_inputs()
- v_advance(5)
- itools.vframe_advance({['X Axis']=127,['Y Axis']=0,['B']=true})
- itools.clear_inputs()
- v_advance(17)
- end
- function Untargeted_Right_Slash_Shield()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance({['Z']=true})
- itools.clear_inputs()
- v_advance(5)
- itools.vframe_advance({['X Axis']=127,['Y Axis']=0,['B']=true})
- itools.clear_inputs()
- v_advance_press_R(9)
- itools.clear_inputs()
- v_advance(8)
- end
- function Targeted_Forward_Thrust()
- itools.clear_inputs()
- itools.vframe_advance()
- itools.vframe_advance()
- itools.vframe_advance({['Z']=true})
- itools.clear_inputs()
- v_advance(5)
- itools.vframe_advance({['X Axis']=0,['Y Axis']=127,['B']=true,['Z']=true})
- itools.clear_inputs()
- v_advance_press_Z(8)
- itools.clear_inputs()
- v_advance(5)
- end
- function Targeted_Forward_Thrust_Untarget_ASAP()
- 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,['B']=true,['Z']=true})
- itools.clear_inputs()
- --v_advance(12)
- v_advance(4)
- end
- function Dry_Roll()
- ------ This puts away sword before dry rolling
- itools.clear_inputs()
- v_advance_press_A(1)
- --- v_advance_press_Z(1) and get rid of the A press above if sword isn't drawn already
- v_advance_press_Z(6)
- itools.vframe_advance({['Z']=true, ['A']=true})
- itools.clear_inputs()
- v_advance(12)
- end
- -- START OF CODE
- file_write = io.open('peahat_ae.txt', 'w+')
- initial_state_slot = 0
- state_slot_1 = 1
- state_slot_2 = 2
- state_slot_3 = 3
- state_slot_0 = 4
- --walk_options = {14, 15}
- walk_options = {15, 14}
- target_options = {'target', 'no_target'}
- options = {'drop_bomb', 'backwalk'}
- itools.load_state(initial_state_slot)
- itools.clear_inputs()
- frame_count = 0 -- I orignally named this "current_frame" but accidentally wrote "frame_count" in most of the code instead, so I changed its name
- -- COLLECT DATA OF INITIAL State (JP 1.0)
- X_Position = core.read_float_be(0x3FFFC4,'RDRAM')
- Z_Position = core.read_float_be(0x3FFFCC,'RDRAM')
- Y_Position = core.read_float_be(0x3FFFC8,'RDRAM')
- Angle1 = bizstring.hex(mainmemory.readbyte(0x40005E))
- Angle2 = bizstring.hex(mainmemory.readbyte(0x40005F))
- X_Position1 = bizstring.hex(mainmemory.readbyte(0x3FFFC4))
- X_Position2 = bizstring.hex(mainmemory.readbyte(0x3FFFC5))
- X_Position3 = bizstring.hex(mainmemory.readbyte(0x3FFFC6))
- X_Position4 = bizstring.hex(mainmemory.readbyte(0x3FFFC7))
- Y_Position1 = bizstring.hex(mainmemory.readbyte(0x3FFFC8))
- Y_Position2 = bizstring.hex(mainmemory.readbyte(0x3FFFC9))
- Y_Position3 = bizstring.hex(mainmemory.readbyte(0x3FFFCA))
- Y_Position4 = bizstring.hex(mainmemory.readbyte(0x3FFFCB))
- Z_Position1 = bizstring.hex(mainmemory.readbyte(0x3FFFCC))
- Z_Position2 = bizstring.hex(mainmemory.readbyte(0x3FFFCD))
- Z_Position3 = bizstring.hex(mainmemory.readbyte(0x3FFFCE))
- Z_Position4 = bizstring.hex(mainmemory.readbyte(0x3FFFCF))
- file_write:write('Type 1 Backflip = Hold Backflip, Type 2 Backflip = Tap Backflip\n')
- file_write:write('== Initial State Data ==\n')
- file_write:write('Angle: ' .. Angle1 .. Angle2 .. '\n')
- file_write:write('X Position: ' .. X_Position1 .. X_Position2 .. X_Position3 .. X_Position4 .. ' Float: ' .. X_Position .. '\n')
- file_write:write('Y Position: ' .. Y_Position1 .. Y_Position2 .. Y_Position3 .. Y_Position4 .. ' Float: ' .. Y_Position .. '\n')
- file_write:write('Z Position: ' .. Z_Position1 .. Z_Position2 .. Z_Position3 .. Z_Position4 .. ' Float: ' .. Z_Position .. '\n\n================================================================\n\n')
- -- in case the state wasn't already targeted, stand in place targeting for 6 frames
- v_advance_press_Z(6)
- -- assume bomb is on C-Down, need to hold shield for at least 3 frames!!
- itools.vframe_advance({['R']=true,['Z']=true,['C Down']=true,['X Axis']=0,['Y Axis']=127})
- itools.clear_inputs()
- frame_count = frame_count + 1
- itools.vframe_advance({['R']=true,['Z']=true,['X Axis']=0,['Y Axis']=127})
- itools.clear_inputs()
- frame_count = frame_count + 1
- itools.vframe_advance({['R']=true,['Z']=true,['X Axis']=0,['Y Axis']=127})
- itools.clear_inputs()
- frame_count = frame_count + 1
- store_frame_count_1 = frame_count
- --- Create a Save State
- itools.save_state(state_slot_0)
- for i = 1, table.getn(walk_options), 1 do
- frame_count = store_frame_count_1
- -- load state
- itools.load_state(state_slot_0)
- itools.clear_inputs()
- -- keep in mind that we are on frame 3 instead of frame 0, so we already walked for 1 frame, so 14 becomes 11 and 15 becomes 12
- v_advance_hold_up_and_target(walk_options[i] - 3)
- itools.clear_inputs()
- frame_count = frame_count + walk_options[i] - 3
- --- Create a Save State
- itools.save_state(state_slot_1)
- store_frame_count_2 = frame_count
- for j = 1, table.getn(target_options), 1 do
- itools.load_state(state_slot_1)
- itools.clear_inputs()
- frame_count = store_frame_count_2
- if target_options[j] == 'target' then
- -- pull bomb
- itools.vframe_advance({['C Down']=true,['Z']=true})
- itools.clear_inputs()
- v_advance_press_Z(4)
- itools.clear_inputs()
- frame_count = frame_count + 5
- v_advance(1)
- frame_count = frame_count + 1
- elseif target_options[j] == 'no_target' then
- itools.vframe_advance({['C Down']=true})
- itools.clear_inputs()
- v_advance(5)
- frame_count = frame_count + 6
- end
- -- now turn left
- itools.vframe_advance({['X Axis']=-128,['Y Axis']=0})
- itools.clear_inputs()
- frame_count = frame_count + 1
- -- now target for at least 6 frames
- v_advance_press_Z(6)
- itools.clear_inputs()
- frame_count = frame_count + 6
- itools.save_state(state_slot_2)
- store_frame_count_3 = frame_count
- for k = frame_count, 46, 1 do
- itools.load_state(state_slot_2)
- itools.clear_inputs()
- frame_count = store_frame_count_3
- v_advance_press_Z(k - frame_count)
- itools.clear_inputs()
- frame_count = frame_count + k - frame_count
- -- set down the bomb and start backwalking
- itools.vframe_advance({['C Down']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true})
- itools.clear_inputs()
- frame_count = frame_count + 1
- v_advance_hold_down_and_target(66 - frame_count)
- itools.clear_inputs()
- frame_count = frame_count + 66 - frame_count
- itools.save_state(state_slot_3)
- store_frame_count_4 = frame_count
- for L = 1, 2, 1 do
- print('i=' .. i .. ' j=' .. j .. ' k=' .. k .. ' L=' .. L .. ' --')
- itools.load_state(state_slot_3)
- itools.clear_inputs()
- frame_count = store_frame_count_4
- successful_clip = false
- -- hold backflip
- if L == 1 then
- itools.vframe_advance({['A']=true,['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 1
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 2
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 3
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 4
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 5
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 6
- itools.clear_inputs()
- frame_count = frame_count + 6
- -- tap backflip
- elseif L == 2 then
- itools.vframe_advance({['A']=true,['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 1
- itools.vframe_advance({['R']=true,['Z']=true}) -- 2
- itools.vframe_advance({['R']=true,['Z']=true}) -- 3
- itools.vframe_advance({['R']=true,['Z']=true}) -- 4
- itools.vframe_advance({['R']=true,['Z']=true}) -- 5
- itools.vframe_advance({['R']=true,['Z']=true}) -- 6
- itools.clear_inputs()
- frame_count = frame_count + 6
- end
- shuffle = false
- drose = 0
- while drose < 40 do
- y_pos = core.read_float_be(0x3FFFC8,'RDRAM')
- y_vel = core.read_float_be(0x400008,'RDRAM')
- if ((walk_options[i] == 14 and y_vel < -9.1 and y_vel > -9.3) or (walk_options[i] == 15 and y_vel < -10.1 and y_vel > -10.3)) and shuffle == false then
- --print('yes A ' .. y_vel)
- itools.clear_inputs()
- v_advance_press_Z(2)
- itools.clear_inputs()
- itools.vframe_advance({['X Axis']=0,['Y Axis']=-128,['Z']=true})
- itools.clear_inputs()
- frame_count = frame_count + 3
- shuffle = true
- elseif shuffle == false then
- --print('Yes B ' .. y_vel)
- itools.vframe_advance({['X Axis']=-30,['Y Axis']=127,['Z']=true})
- itools.clear_inputs()
- frame_count = frame_count + 1
- elseif shuffle == true then
- v_advance_press_Z(1)
- itools.clear_inputs()
- frame_count = frame_count + 1
- end
- if y_pos < -21 and successful_clip == false then
- print('Success!!!!!!!!!!!!!!!!!!!!!')
- successful_clip = true
- end
- drose = drose + 1
- end
- itools.clear_inputs()
- if successful_clip == true then
- successful_clip_string = 'True'
- else
- successful_clip_string = 'False'
- end
- file_write:write('Walk_Option: ' .. walk_options[i] .. ' Target_Option: ' .. target_options[j] .. ' Bomb_Drop_Option: Set_Down_Bomb Backwalk_Frame: ' .. k .. ' Backflip_Type: ' .. L .. ' Successful_Clip: ' .. successful_clip_string .. '\n\n')
- end -- end L for loop
- end
- frame_count = store_frame_count_3
- for k = frame_count, 66, 1 do
- itools.load_state(state_slot_2)
- itools.clear_inputs()
- frame_count = store_frame_count_3
- v_advance_press_Z(k - frame_count)
- itools.clear_inputs()
- frame_count = frame_count + k - frame_count
- -- shield drop the bomb and start backwalking
- if frame_count < 66 then
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true})
- itools.clear_inputs()
- frame_count = frame_count + 1
- end
- v_advance_hold_down_and_target(66 - frame_count)
- itools.clear_inputs()
- frame_count = frame_count + 66 - frame_count
- itools.save_state(state_slot_3)
- store_frame_count_4 = frame_count
- for L = 1, 2, 1 do
- print('i=' .. i .. ' j=' .. j .. ' k=' .. k .. ' L=' .. L .. ' --')
- itools.load_state(state_slot_3)
- itools.clear_inputs()
- frame_count = store_frame_count_4
- successful_clip = false
- -- hold backflip
- if L == 1 then
- itools.vframe_advance({['A']=true,['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 1
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 2
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 3
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 4
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 5
- itools.vframe_advance({['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 6
- itools.clear_inputs()
- frame_count = frame_count + 6
- -- tap backflip
- elseif L == 2 then
- itools.vframe_advance({['A']=true,['R']=true,['X Axis']=0,['Y Axis']=-128,['Z']=true}) -- 1
- itools.vframe_advance({['R']=true,['Z']=true}) -- 2
- itools.vframe_advance({['R']=true,['Z']=true}) -- 3
- itools.vframe_advance({['R']=true,['Z']=true}) -- 4
- itools.vframe_advance({['R']=true,['Z']=true}) -- 5
- itools.vframe_advance({['R']=true,['Z']=true}) -- 6
- itools.clear_inputs()
- frame_count = frame_count + 6
- end
- shuffle = false
- drose = 0
- while drose < 40 do
- y_pos = core.read_float_be(0x3FFFC8,'RDRAM')
- y_vel = core.read_float_be(0x400008,'RDRAM')
- if ((walk_options[i] == 14 and y_vel < -9.1 and y_vel > -9.3) or (walk_options[i] == 15 and y_vel < -10.1 and y_vel > -10.3)) and shuffle == false then
- itools.clear_inputs()
- v_advance_press_Z(2)
- itools.clear_inputs()
- itools.vframe_advance({['X Axis']=0,['Y Axis']=-128,['Z']=true})
- itools.clear_inputs()
- frame_count = frame_count + 3
- shuffle = true
- elseif shuffle == false then
- itools.vframe_advance({['X Axis']=-30,['Y Axis']=127,['Z']=true})
- itools.clear_inputs()
- frame_count = frame_count + 1
- elseif shuffle == true then
- v_advance_press_Z(1)
- itools.clear_inputs()
- frame_count = frame_count + 1
- end
- if y_pos < -21 and successful_clip == false then
- print('Success!!!!!!!!!!!!!!!!!!!!!')
- successful_clip = true
- end
- drose = drose + 1
- end
- itools.clear_inputs()
- if successful_clip == true then
- successful_clip_string = 'True'
- else
- successful_clip_string = 'False'
- end
- file_write:write('Walk_Option: ' .. walk_options[i] .. ' Target_Option: ' .. target_options[j] .. ' Bomb_Drop_Option: Shield_Drop_Bomb Backwalk_Frame: ' .. k .. ' Backflip_Type: ' .. L .. ' Successful_Clip: ' .. successful_clip_string .. '\n\n')
- end -- end L for loop (2)
- end
- end
- end
- file_write:close()
- print('done')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement