
	[object_type]
	id=milgram_block_launcher
	prototype=stationary_vulnerable
	hitpoints=10
	zorder=0
	
	[editor_info]
	category=machines
		[var]
		name=max_objects
		value="3"
		[/var]
		[var]
		name=loading_time
		value="1"
		[/var]
		[var]
		name=zone_x1
		type=x
		value="x - 300"
		[/var]
		[var]
		name=zone_x2
		type=x
		value="x + 400"
		[/var]
		[var]
		name=zone_y1
		type=y
		value="y - 400"
		[/var]
		[var]
		name=zone_y2
		type=y
		value="y + 500"
		[/var]
	[/editor_info]

	[vars]
		load=0
		team="'evil'"
		points_value="50"
		damage=1
		spawned_objects="[]"
		max_objects=3
	[/vars]
	
	[consts]
		armor=4
	[/consts]
	
	[properties]
		shouldfire="if(size(vars.spawned_objects) < vars.max_objects,1,0)"
	[/properties]
	
	on_create="add_particles('steam')"
	
	on_end_anim="[if(animation = 'normal',
	                   if(vars.load >= vars.loading_time,
					     [if(size(vars.spawned_objects) < vars.max_objects,animation('prepfire'),animation('normal')), set_var('load', 0)],
						 [animation('normal'), set_var('load', vars.load + 1)]),),
						 
					set(vars.spawned_objects, filter(vars.spawned_objects, 'ant', ant.hitpoints > 0 and ant.x > context.vars.zone_x1 and ant.x2 < context.vars.zone_x2 and ant.y >  context.vars.zone_y1 and ant.y2 < context.vars.zone_y2))]"
					
	on_child_spawned="if(child.type in ['milgram_pod'],set(vars.spawned_objects, vars.spawned_objects + [child]))"
					
	on_end_prepfire_anim="animation('fire')"
	on_end_fire_anim="animation('normal')"
					      
	on_shoot="[spawn('milgram_pod', midpoint_x+ facing*50, midpoint_y -50, facing, [set(velocity_x,1000*facing),set(velocity_y,-1000),set(animation,'thrown'), set_var('damage', 0)]),sound('FlowerShot.ogg')]"

	
	on_die="spawn('explosion_big_recurring',  midpoint_x, midpoint_y, facing)"
	
	#on_puff="if(1d2=2,spawn('steam_particle',midpoint_x - 12*facing,y+14,1))"

	solid_area=10,20,38,50

		[base:animation]
		image=enemies/milgram-block-launcher.png
		pad=3
		accel_y=80
		body_area=all
		[/animation]
		
		[animation]
		id=normal
		rect=1,1,49,53
		frames=3
		reverse=yes
		duration=4
		events="12:puff"
		[/animation]
		
		#the spring animation is a duplicate of the normal animation,
		#unless/until we have a proper one.
		[animation]
		id=spring
		rect=1,1,49,53
		frames=3
		reverse=yes
		duration=4
		[/animation]


		[animation]
		id=prepfire
		rect=1,58,49,110
		frames=4
		duration=5
		[/animation]


		[animation]
		id=fire
		rect=1,115,49,167
		frames=4
		duration=5
		events="1:shoot"
		[/animation]

		[animation]
		id=hurt
		rect=1,58,49,110
		[/animation]
		
		
		[particle_system]
		id=steam
		type=simple
		spawn_rate=200
		time_to_live=75
		min_x=25
		max_x=30
		min_y=5
		max_y=15
		velocity_y=-200
		velocity_x=-200
		velocity_x_random=400
		velocity_y_random=400
		accel_y=-40
		#color=255,255,255,255
		delta_a=1
		[animation]
			id=normal
			image=effects/particles.png
			x=3
			y=67
			w=9
			h=9
			pad=3
			frames=5
			duration=15
			accel_y=-2
			[/animation]
		[/particle_system]

	[/object_type]
