1{ 2id: "bat_black_pf", 3activation_border: 1000, 4prototype: ["ant_flying"], 5solid_dimensions: [], 6properties: { 7 fly_height_adjust: "(wave(cycle*5+1000)/50)", 8 9 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])]", 10 should_dive: "if(animation = 'cling' and 11 cycle - vars.last_clung > 100 and 12 level.player.y > y + 50 and level.player.y < vars.dive_height and 13 level.player.midpoint_x > vars.x_bound and 14 level.player.midpoint_x < vars.x2_bound, 1, 0)", 15 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)", 16 should_cling: "if(abs(midpoint_x - vars.init_x) < 10 and abs(midpoint_y - vars.init_y) < 10, 1, 0)", 17 begin_dive: "def() [ animation('wake'), 18 if(level.player.midpoint_x > midpoint_x, facing(1), facing(-1)), 19 set(vars.behavior, 'dive'), 20 set(vars.target_x, level.player.midpoint_x), 21 set(vars.target_y, level.player.y), 22 add(velocity_y,200)]", 23 begin_climb: "def() [ set(vars.behavior, 'climb')]", 24 begin_cling: "def() [ animation('cling'), 25 set(vars.last_clung, cycle), 26 set(vars.behavior, ''), 27 set(velocity_x,0), 28 set(velocity_y,0)]", 29 process_dive: "def() [ if(level.player.midpoint_y > midpoint_y, add(velocity_y, 8),add(velocity_y,-8) ), 30 if(level.player.midpoint_x > midpoint_x, [try_facing(1),add(velocity_x, 12)],[try_facing(-1),add(velocity_x,-12)] ), 31 if(should_climb, begin_climb() )]", 32 goal_x: "if(vars.path_node < vars.path_x.size, path_x[vars.path_node],init_x)", 33 goal_y: "if(vars.path_node < vars.path_y.size, path_y[vars.path_node],init_y)", 34 should_move_to_next_path_node: "if(abs(midpoint_x - goal_x) < 20 and abs(midpoint_y - goal_y) < 20, 1, 0)", 35 next_path_node: "def() if(path_node < (vars.path_x.size + 1), add(path_node,1))", 36 process_climb: "def() [ if(cycle-vars.path_age > 300, [set(vars.path_age,cycle),new_path]), 37 debug(vars.path_x.size), 38 debug('path_node = '+ vars.path_node), 39 #debug('goal_x = '+ goal_x), 40 debug('goal_y = '+ goal_y),# 41 debug([path_x,path_y]), 42 43 if(midpoint_x < goal_x, [try_facing(1),add(velocity_x, 5)],[try_facing(-1),add(velocity_x,-5)] ), 44 if(midpoint_y < goal_y, add(velocity_y, 8),add(velocity_y,-8) ), 45 [if(should_move_to_next_path_node, next_path_node()), 46 if(should_cling, begin_cling())] 47 ]", 48 try_facing: "def(direction) if(direction != facing,fire_event('turn'))", 49}, 50vars: { 51 points_value: 14, 52 path_x: [0], 53 path_y: [0], 54 path_age: -200, 55 path_node: 0, 56}, 57consts: { 58 basic_type: "bat_black", 59 thrown_type: "bat_black.thrown", 60 basic_animation: "fly", 61}, 62 63#on_child_spawned="schedule(2,execute(child,debug(child.vars.Xpoints.size)) 64#set(vars.path_x, child.vars.Xpoints) 65#)" 66on_child_spawned: "[ schedule(2,fire_event(child, 'communicate_path')), 67 schedule(40,fire_event(child, 'seppuku'))]", 68on_create: "[ set(vars.behavior,''), 69 animation('cling'), 70 set(vars.init_y, midpoint_y), 71 set(vars.init_x, midpoint_x) 72 ]", 73on_end_anim: "if(animation in ['cling'], animation('cling'),animation('fly'))", 74 75#on_process="debug(animation + vars.behavior)," 76# 77#Note: the proto will set our y velocity for regular soaring. We only override this if we're busy diving or climbing. 78on_process_cling: "if(should_dive, begin_dive())", 79on_process_fly: "switch(vars.behavior, 80 'dive', process_dive(), 81 'climb', process_climb(), 82 'regular', [proto_event('ant_flying', 'process_fly'), if(should_dive, begin_dive())])", 83on_process_turn: "fire_event('process_fly')", 84on_lose_wings: "#don't lose wings#", 85animation: [ 86 { 87 image: "enemies/bat-black.png", 88 pad: 3, 89 body_area: "all", 90 accel_y: 0, 91 id: "cling", 92 rect: [1,1,18,28], 93 frames: 2, 94 duration: 16, 95 accel_x: 0, 96 }, 97 { 98 image: "enemies/bat-black.png", 99 pad: 3, 100 body_area: "all", 101 accel_y: 0, 102 id: "wake", 103 rect: [43,1,60,28], 104 frames: 1, 105 duration: 6, 106 accel_x: 0, 107 }, 108 { 109 image: "enemies/bat-black.png", 110 pad: 3, 111 body_area: "all", 112 accel_y: 0, 113 id: "fly", 114 rect: [1,32,26,70], 115 frames: 4, 116 duration: 4, 117 accel_x: 0, 118 }, 119 { 120 image: "enemies/bat-black.png", 121 pad: 3, 122 body_area: "all", 123 accel_y: 0, 124 id: "spring", 125 rect: [1,32,26,70], 126 frames: 1, 127 duration: 3, 128 }, 129 { 130 image: "enemies/bat-black.png", 131 pad: 3, 132 body_area: "all", 133 accel_y: 0, 134 id: "turn", 135 rect: [1,74,26,112], 136 frames: 2, 137 duration: 3, 138 }, 139 { 140 image: "enemies/bat-black.png", 141 pad: 3, 142 body_area: "all", 143 accel_y: 0, 144 id: "hurt", 145 rect: [120,32,145,70], 146 }, 147], 148object_type: { 149 id: "thrown", 150 prototype: ["throwable_small_enemy"], 151 solid_dimensions: ["enemy","common"], 152 consts: { 153 basic_type: "bat_black", 154 thrown_type: "bat_black.thrown", 155 basic_animation: "fly", 156 }, 157 on_spat: "[proto_event('throwable_small_enemy', 'spat'), set(vars.bomb, null), set(attached_objects, [])]", 158 animation: [ 159 { 160 image: "enemies/bat-black.png", 161 id: "thrown", 162 thrown_area: "all", 163 duration: 60, 164 rect: [149,32,174,70], 165 frames: 1, 166 body_area: null, 167 }, 168 { 169 image: "enemies/bat-black.png", 170 id: "on_back", 171 rect: [149,32,174,70], 172 frames: 2, 173 duration: 5, 174 body_area: "all", 175 }, 176 ], 177}, 178} 179