1{
2id: "kitty_ninja_playable",
3prototype: ["playable", "kitty"],
4
5#solid_area=6,10,26,33
6solid_area: [21,10,41,31],
7hitpoints: 8,
8
9properties: {
10	attack_damage: "if(level.player.difficulty <= level.player.difficulty_casual,1,3)",
11	player_in_attack_area: "if(abs(level.player.midpoint_y - midpoint_y) < 50 and abs(level.player.midpoint_x - midpoint_x) > 150 and abs(level.player.midpoint_x - midpoint_x) < 350, 1, 0)",
12	player_facing_us: "if(level.player.facing - player_side = 0, 0,1 ) where player_side = if(level.player.midpoint_x > midpoint_x, 1, -1)",
13	is_shuriken_usable: "if(abs(level.player.midpoint_x - midpoint_x) < 500 and abs(level.player.midpoint_y - midpoint_y) < 500, 1, 0)",
14	consider_shuriken: "def() [if((cycle-vars.last_toss) > 100, animation('shurikenPrep'))]",
15	fire_shuriken: "def() [animation('shurikenFire'),sound('weapon-swing-lighter'+1d2+'.wav'),[set(vars.last_toss,cycle),spawn('kitty_ninja.shuriken', midpoint_x+50*facing, midpoint_y, facing, [set(velocity_x, 800*(facing)), set(velocity_y, if(ctrl_up, -800, if(ctrl_down, 800, 0)) )])]
16
17			where x_mag = decimal(level.player.midpoint_x - midpoint_x)/length
18			where y_mag = decimal(level.player.midpoint_y - midpoint_y)/length]
19				where length = abs(sqrt( (level.player.midpoint_x - midpoint_x)^2 + (level.player.midpoint_y - midpoint_y)^2))",
20	player_too_close: "if(abs(level.player.midpoint_y - midpoint_y) < 150 and abs(level.player.midpoint_x - midpoint_x) < 150, 1, 0)",
21	begin_attack: "def() animation('dash')",
22	jump_back: "def() [add(velocity_y, -1000-200), add(velocity_x, -(1000+200)*facing), animation('jumpback')]",
23	jump_forward: "def() [add(velocity_y, -1000-200), add(velocity_x, (1000+200)*facing), animation('jumpback')]",
24	strafe: "def() [animation('stand'),if(1d2=2,add(velocity_x,-1000-1d500),add(velocity_x,1000+1d500))]",
25	consider_strafe: "def() [if(1d5=5, strafe())]",
26	escape_to_start: "def() [set(vars.escape_counter, 0),set(vars.last_escape,cycle),animation('hide'), set(xy, [vars.init_x, vars.init_y])]",
27	consider_escape: "def() [animation('smokebomb'),schedule(10,sound('smoke-bomb-throw'+1d4+'.wav',0.6))]",
28	xchoose_action: "def() if(facing !=desired_facing, [animation('turn'), set(facing, desired_facing)],
29								if(player_too_close, jump_back(),
30									if(player_in_attack_area, begin_attack(),
31										if(is_shuriken_usable, switch(1d3, 1,consider_shuriken(), 2, consider_strafe(), 3, consider_escape() )
32													,consider_escape() ))))",
33	choose_action: "def() animation('stand')",
34
35	stand: "def(foo) null",
36			team: "'player'",
37},
38vars: {
39	points_value: 271,
40	turns_at_cliffs: 1,
41	turns_towards_player: 0,
42	posthurt_counter: 0,
43	last_escape: -300,
44	escape_counter: 0,
45	last_toss: -100,
46},
47consts: {
48	basic_type: "kitty_spear",
49	frogourmet_tag: "kitty_ninja",
50},
51on_create: "[animation('hide'),set(vars.init_x, x), set(vars.init_y, y),if(level.player.difficulty <= level.player.difficulty_casual, set(max_hitpoints, 8))]",
52on_end_dash_anim: "if(abs(level.player.midpoint_x - self.midpoint_x) < 120 or facing != desired_facing, [animation('slash'),sound('weapon-swing-lightest'+1d7+'.wav')], animation('dash'))",
53on_end_slash_anim: "animation('recovery')",
54on_end_turn_anim: "animation('stand')",
55on_end_stand_anim: "choose_action()",
56on_end_recovery_anim: "choose_action()",
57on_end_spring_anim: "strafe()",
58on_end_shurikenPrep_anim: "fire_shuriken()",
59on_end_shurikenFire_anim: "choose_action()",
60on_end_jumpback_anim: "if(is_standing, animation('stand'), animation('jumpback'))",
61on_collide_feet: "if(is_standing and animation in ['jumpback'], animation('stand'))",
62on_change_solid_dimensions_fail: "schedule(3, set(solid_dimensions_in, ['enemy', 'common']))",
63on_end_smokebomb_anim: "[sound('smoke-seeping'+1d3+'.wav',0.8),spawn('kitty_ninja.smoke_spawner',midpoint_x, midpoint_y, facing),escape_to_start()]",
64
65#on_become_active="escape_to_start()"
66on_process_hide: "[set(facing, desired_facing),if(player_in_attack_area and (not player_facing_us) and (abs(vars.last_escape - cycle) > 300), begin_attack())]",
67on_end_hide_anim: "animation('hide')",
68
69on_footfall: "[sound('kitty-footstep'+1d10+'.wav', volume)] where volume = constrain(0, 300.0/distance(self, level.player),1.0)",
70
71on_ctrl_attack: "if(animation != 'hide', consider_escape(), animation('stand'))",
72
73on_ctrl_tongue: "if(animation = 'stand', animation('shurikenPrep'))",
74
75on_ctrl_left: "fire_event(self, 'go', {dir:-1})",
76on_ctrl_right: "fire_event(self, 'go', {dir:1})",
77on_ctrl_jump: "swallow_event()",
78on_go: "if(ctrl_up or ctrl_jump, [
79		if(dir = facing, [
80			jump_forward(),
81		], [
82			jump_back(),
83		])
84	], [
85		if(dir = facing, [
86			animation('dash'),
87			],[
88			animation('turn'),
89			set(facing, dir),
90		])
91	])",
92
93#make it so you can pass through the ninja when it's hiding.
94on_enter_hide_anim: "[set(solid_dimensions_in, [])]",
95on_leave_hide_anim: "[set(solid_dimensions_in, ['enemy', 'common'])]",
96editor_info: {
97	category: "enemies, milgramen",
98},
99animation: [
100	{
101		"@base": true,
102		no_remove_alpha_borders: true,
103		image: "enemies/kitty-ninja.png",
104		accel_x: 0,
105		accel_y: 80,
106		pad: 3,
107		rotate_on_slope: true,
108		body_area: "all",
109	},
110	{
111		id: "stand",
112		rect: [1,1,64,39],
113		frames: 3,
114		frames_per_row: 1,
115		duration: 5,
116		reverse: true,
117	},
118	{
119		accel_y: 0,
120		body_area: [21,10,41,31,"solid"],
121		id: "hide",
122		rect: [1,432,64,470],
123		frames: 4,
124		duration: 5,
125		reverse: true,
126		velocity_y: 0,
127		solid_area: null,
128	},
129	{
130		accel_y: 0,
131		body_area: [21,10,41,31,"solid"],
132		id: "hide",
133		rect: [68,390,131,428],
134		frames: 1,
135		duplicates: 6,
136		duration: 20,
137		velocity_y: 0,
138		solid_area: null,
139	},
140	{
141		image: "enemies/kitty-ninja.png",
142		accel_x: 2000,
143		accel_y: 80,
144		pad: 3,
145		rotate_on_slope: true,
146		body_area: "all",
147		id: "dash",
148		rect: [336,178,437,216],
149		frames: 4,
150		frames_per_row: 1,
151		duration: 4,
152		events: "0:8:footfall",
153		solid_area: [40,10,60,31],
154	},
155	{
156		id: "slash",
157		rect: [135,43,236,81],
158		frames: 5,
159		frames_per_row: 1,
160		duration: 3,
161		solid_area: [40,10,60,31],
162		attack_area: [59,14,99,37],
163	},
164	{
165		id: "jumpback",
166		rect: [68,1,131,39],
167		frames: 6,
168		frames_per_row: 1,
169		duration: 2,
170	},
171	{
172		id: "smokebomb",
173		rect: [240,1,303,48],
174		solid_area: [21,21,41,42],
175		frames: 7,
176		frames_per_row: 1,
177		duration: 5,
178	},
179	{
180		id: "recovery",
181		rect: [68,306,131,344],
182		frames: 1,
183		duration: 15,
184	},
185	{
186		id: "turn",
187		rect: [1,306,64,344],
188		frames: 3,
189		frames_per_row: 1,
190		duration: 2,
191	},
192	{
193		id: "shurikenPrep",
194		rect: [353,8,416,46],
195		frames: 4,
196		frames_per_row: 1,
197		duration: 4,
198	},
199	{
200		id: "shurikenFire",
201		rect: [420,8,483,46],
202		frames: 1,
203		frames_per_row: 1,
204		duration: 15,
205	},
206	{
207		id: "hurt",
208		rect: [1,264,64,302],
209		frames: 1,
210		duration: 12,
211	},
212	{
213		id: "spring",
214		rect: [135,390,198,428],
215		frames: 5,
216		duration: 4,
217	},
218],
219object_type: [
220	{
221		dies_on_inactive: true,
222		id: "shuriken",
223		prototype: ["shot"],
224		properties: {
225			attack_damage: 20,
226			team: "'player'",
227		},
228		on_collide_level: "[sound('shuriken-hits-stone'+1d5+'.wav',0.6),proto_event('shot','collide_level')]",
229		on_process: "add(rotate,30)",
230		animation: {
231			id: "normal",
232			image: "enemies/kitty-ninja.png",
233			rect: [327,3,346,22],
234			duration: 10000,
235			//attack_area: "all",
236		},
237	},
238	{
239		id: "smoke_spawner",
240		properties: {
241			smoke_spawn: "def() spawn('kitty_ninja.smoke_cloud', midpoint_x + 1d50-25,  midpoint_y + 1d50-25, facing)",
242		},
243		on_create: "[	map([0]*3, smoke_spawn() ),
244						schedule(2, smoke_spawn() ),
245						schedule(4, smoke_spawn() ),
246						schedule(6, die())
247					]",
248		animation: {
249			id: "die",
250			image: "effects/die-cloud.png",
251			rect: [4,57,1,1],
252			duration: 3,
253		},
254	},
255	{
256		id: "smoke_cloud",
257		hitpoints: 1,
258		on_end_anim: "die()",
259
260		#		on_create="sound('splat.ogg')"
261		on_process: "if(cycle%6=0,spawn('die_cloud_2',midpoint_x+1d10-5,midpoint_y+1d30-15,facing))",
262		zorder: 40,
263		animation: {
264			id: "die",
265			image: "effects/die-cloud.png",
266			rect: [4,57,48,101],
267			frames: 15,
268			frames_per_row: 5,
269			pad: 3,
270			duration: 3,
271		},
272	},
273],
274}
275