{ id: "bat_black_pf", activation_border: 1000, prototype: ["ant_flying"], solid_dimensions: [], properties: { fly_height_adjust: "(wave(cycle*5+1000)/50)", new_path: "[spawn('pathfinding_experiment',midpoint_x,midpoint_y,0, [set(x_1,midpoint_x),set(y_1,midpoint_y),set(x_2,vars.init_x),set(y_2,vars.init_y),set(parent,me)]), set(vars.path_node,0), set(vars.path_x,[0]),set(vars.path_y,[0])]", should_dive: "if(animation = 'cling' and cycle - vars.last_clung > 100 and level.player.y > y + 50 and level.player.y < vars.dive_height and level.player.midpoint_x > vars.x_bound and level.player.midpoint_x < vars.x2_bound, 1, 0)", should_climb: "if(midpoint_y > vars.dive_height or midpoint_y < vars.desired_height-20 or midpoint_x > vars.x2_bound or midpoint_x < vars.x_bound, 1, 0)", should_cling: "if(abs(midpoint_x - vars.init_x) < 10 and abs(midpoint_y - vars.init_y) < 10, 1, 0)", begin_dive: "def() [ animation('wake'), if(level.player.midpoint_x > midpoint_x, facing(1), facing(-1)), set(vars.behavior, 'dive'), set(vars.target_x, level.player.midpoint_x), set(vars.target_y, level.player.y), add(velocity_y,200)]", begin_climb: "def() [ set(vars.behavior, 'climb')]", begin_cling: "def() [ animation('cling'), set(vars.last_clung, cycle), set(vars.behavior, ''), set(velocity_x,0), set(velocity_y,0)]", process_dive: "def() [ if(level.player.midpoint_y > midpoint_y, add(velocity_y, 8),add(velocity_y,-8) ), if(level.player.midpoint_x > midpoint_x, [try_facing(1),add(velocity_x, 12)],[try_facing(-1),add(velocity_x,-12)] ), if(should_climb, begin_climb() )]", goal_x: "if(vars.path_node < vars.path_x.size, path_x[vars.path_node],init_x)", goal_y: "if(vars.path_node < vars.path_y.size, path_y[vars.path_node],init_y)", should_move_to_next_path_node: "if(abs(midpoint_x - goal_x) < 20 and abs(midpoint_y - goal_y) < 20, 1, 0)", next_path_node: "def() if(path_node < (vars.path_x.size + 1), add(path_node,1))", process_climb: "def() [ if(cycle-vars.path_age > 300, [set(vars.path_age,cycle),new_path]), debug(vars.path_x.size), debug('path_node = '+ vars.path_node), #debug('goal_x = '+ goal_x), debug('goal_y = '+ goal_y),# debug([path_x,path_y]), if(midpoint_x < goal_x, [try_facing(1),add(velocity_x, 5)],[try_facing(-1),add(velocity_x,-5)] ), if(midpoint_y < goal_y, add(velocity_y, 8),add(velocity_y,-8) ), [if(should_move_to_next_path_node, next_path_node()), if(should_cling, begin_cling())] ]", try_facing: "def(direction) if(direction != facing,fire_event('turn'))", }, vars: { points_value: 14, path_x: [0], path_y: [0], path_age: -200, path_node: 0, }, consts: { basic_type: "bat_black", thrown_type: "bat_black.thrown", basic_animation: "fly", }, #on_child_spawned="schedule(2,execute(child,debug(child.vars.Xpoints.size)) #set(vars.path_x, child.vars.Xpoints) #)" on_child_spawned: "[ schedule(2,fire_event(child, 'communicate_path')), schedule(40,fire_event(child, 'seppuku'))]", on_create: "[ set(vars.behavior,''), animation('cling'), set(vars.init_y, midpoint_y), set(vars.init_x, midpoint_x) ]", on_end_anim: "if(animation in ['cling'], animation('cling'),animation('fly'))", #on_process="debug(animation + vars.behavior)," # #Note: the proto will set our y velocity for regular soaring. We only override this if we're busy diving or climbing. on_process_cling: "if(should_dive, begin_dive())", on_process_fly: "switch(vars.behavior, 'dive', process_dive(), 'climb', process_climb(), 'regular', [proto_event('ant_flying', 'process_fly'), if(should_dive, begin_dive())])", on_process_turn: "fire_event('process_fly')", on_lose_wings: "#don't lose wings#", animation: [ { image: "enemies/bat-black.png", pad: 3, body_area: "all", accel_y: 0, id: "cling", rect: [1,1,18,28], frames: 2, duration: 16, accel_x: 0, }, { image: "enemies/bat-black.png", pad: 3, body_area: "all", accel_y: 0, id: "wake", rect: [43,1,60,28], frames: 1, duration: 6, accel_x: 0, }, { image: "enemies/bat-black.png", pad: 3, body_area: "all", accel_y: 0, id: "fly", rect: [1,32,26,70], frames: 4, duration: 4, accel_x: 0, }, { image: "enemies/bat-black.png", pad: 3, body_area: "all", accel_y: 0, id: "spring", rect: [1,32,26,70], frames: 1, duration: 3, }, { image: "enemies/bat-black.png", pad: 3, body_area: "all", accel_y: 0, id: "turn", rect: [1,74,26,112], frames: 2, duration: 3, }, { image: "enemies/bat-black.png", pad: 3, body_area: "all", accel_y: 0, id: "hurt", rect: [120,32,145,70], }, ], object_type: { id: "thrown", prototype: ["throwable_small_enemy"], solid_dimensions: ["enemy","common"], consts: { basic_type: "bat_black", thrown_type: "bat_black.thrown", basic_animation: "fly", }, on_spat: "[proto_event('throwable_small_enemy', 'spat'), set(vars.bomb, null), set(attached_objects, [])]", animation: [ { image: "enemies/bat-black.png", id: "thrown", thrown_area: "all", duration: 60, rect: [149,32,174,70], frames: 1, body_area: null, }, { image: "enemies/bat-black.png", id: "on_back", rect: [149,32,174,70], frames: 2, duration: 5, body_area: "all", }, ], }, }