1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
{
id: "fish",
prototype: ["hittable"],
hitpoints: 50,
traction_in_water: 1000,
traction_in_air: 0,
friction: 1000,
has_feet: false,
solid_dimensions: ["enemy","common"],
solid_area: [3,3,27,19],
properties: {
team: "'evil'",
hurt_velocity_y: 0,
hurt_velocity_x: 0,
attack_damage: 1,
player_within: "def(distance) if((level.player.midpoint_x > midpoint_x - distance) and (level.player.midpoint_x < midpoint_x + distance) and (level.player.midpoint_y > midpoint_y - distance) and (level.player.midpoint_y < midpoint_y + distance), 1, 0)",
ideal_x: "def() ((vars.x2_bound + vars.x_bound) / 2)",
inside_aggro_range: "def(distance) if(abs(ideal_x() - midpoint_x) < distance, 1, 0)",
target_y: "def() (vars.desired_height + (wave(cycle*10+1000)/15))",
},
vars: {
points_value: 20,
},
on_die: "[score(level,points_value), spawn_item(self), death_burst_tracked(self)]",
#
#
# collision handling:
on_collide_side: "[set(velocity_x, 0), facing(-facing)]",
on_surface_damage: "die()",
on_exit_water: "die()",
#
#
# animation switching:
on_end_hurt_anim: "set(animation, 'swim')",
on_end_swim_anim: "if(facing < 0 and x < vars.x_bound or
facing > 0 and x2 > vars.x2_bound,
[facing(-facing), animation('swim')],
animation('swim'))",
on_process_swim: "if(abs(y - target_y()) > 10, set(accel_y, (20*if(target_y() < y, -1, 1))), [set(accel_y,0)])",
timer_frequency: 10,
on_timer: "if(solid(level, front + facing*90, y, 1, y2 - y),
[facing(-facing)])",
#
#
# error condition handling:
on_change_solid_dimensions_fail: "if(tmp.in_change_dimensions_fail or (not collide_with), die(),
[set(tmp.in_change_dimensions_fail, 1),
fire_event(collide_with, 'blocking_thrown_object'),
set(solid_dimensions_in, consts.solid_dimensions),
set(tmp.in_change_dimensions_fail, 0)
])",
on_change_animation_failure: "[die()]",
on_add_object_fail: "[if(collide_with.vars.team != vars.team and collide_with.get_hit_by, collide_with.get_hit_by(me)), die()]",
editor_info: {
category: "enemies, water",
var: [
{
name: "x_bound",
type: "x",
value: "x - 200",
},
{
name: "x2_bound",
type: "x",
value: "x2 + 200",
},
{
name: "desired_height",
type: "y",
value: "y",
},
],
},
animation: [
{
image: "enemies/fish-purple.png",
pad: 3,
body_area: "all",
attack_area: "all",
id: "swim",
duplicates: 6,
rect: [2,1,42,29],
frames: 4,
duration: 6,
accel_x: 20,
},
{
image: "enemies/fish-purple.png",
pad: 3,
body_area: "all",
attack_area: "all",
id: "swim",
#blink variant
rect: [2,33,42,61],
frames: 4,
duration: 6,
accel_x: 20,
},
{
image: "enemies/fish-purple.png",
pad: 3,
body_area: "all",
attack_area: "all",
id: "startle",
rect: [2,65,42,93],
frames: 1,
duration: 10,
},
{
image: "enemies/fish-purple.png",
pad: 3,
body_area: "all",
attack_area: "all",
id: "hurt",
rect: [90,65,130,93],
frames: 1,
duration: 10,
},
{
image: "enemies/fish-purple.png",
pad: 3,
body_area: "all",
attack_area: "all",
id: "swimMad",
rect: [2,97,42,125],
frames: 4,
duration: 6,
accel_x: 30,
},
],
}
|