function RedStuff_process( inst, key )
	local value = inst
	if value.batch.left == 1 then
		value.score = 500
	end
	inst.speed = 1 + math.sin( (time-inst.creation_time)/1000 )
	if math.abs( inst.targets[inst.target][1] - value.x ) + math.abs( value.targets[value.target][2] - value.y ) < 10 then
		if value.target == #value.targets then
			delete( enemies, key )
		else
			value.target = value.target + 1
			local angle = math.atan2( value.targets[value.target][2] - value.x, value.targets[value.target][1]-value.x )
			value.vel = { math.cos( angle ), math.sin( angle ) }
		end
	end
	if time - value.last_shot > (500 * options.enemy_reload) and math.random( 1, 10 ) > 7 then
		value.last_shot = time
		PlaySnd( "shot4.ogg", true, value.x, value.y )
		local plr = math.random( 1, players_num )
		local ang = math.atan2( players[plr].y - value.y, players[plr].x - value.x )
		local vx = math.cos(ang)
		if math.abs( vx ) < 0.3 then
			CreateSimpleBullet( value.x, value.y, { vx, 3 }, { 1, .3, .3, 1 } )
		else
			CreateSimpleBullet( value.x, value.y, { 0, 3 }, { 1, .3, .3, 1 } )
		end
	end
end

function CreateRedStuff( x, y, targets, number )
	local from_x = x
	local to_x = targets[1][1]
	--if math.random(1, 10) > 5 then
	--	to_x, from_x = from_x, to_x
	--end
	local angle = math.atan2( targets[1][2] - y, targets[1][1]-from_x )
	local batch = { left = number }
	Resume( NewThread( function( from_x, to_x, targets, angle, y )
			for i = 1, number do
				local spr = CreateSprite( "sprite", x, y )
				SetObjAnim( spr, 1, false )
				local vel = { math.cos( angle ), math.sin( angle ) }
				table.insert( enemies,
						{
							sprite = spr,
							x = x,
							y = y,
							size = 16,
							speed = 2,
							targets = deep_copy( targets ),
							target = 1,
							creation_time = time,
							last_shot = 0,
							score = 100,
							vel = vel,
							batch = batch,
							destroy = function( x, y, v ) v.batch.left = v.batch.left - 1 end,
							process = RedStuff_process
						})
					Wait( 500 )
				 end
			end ), from_x, to_x, targets, angle, y)
end