
AddParticleToObject(1,"Highlight");
MoveEmiter("Highlight",460,465);
AddParticleToObject(105,"voda1");
MoveEmiter("voda1",404,235);
AddParticleToObject(104,"voda2");
MoveEmiter("voda2",663,235);
StartEmiter("voda2")
StartEmiter("voda1")
skippp=false
startcom=false;
WaitRender();

function gameinput(sender,obj_id,attachedID)
	if SLevel==1.0 then return; end;
	if sender == 2 then
		RemoveFromMouse(object);
		MessageProc(sender,obj_id);
	return;end;	
--обработка плашки
 if (sender == 1  or sender==5) and not isTimes  and imagetex~=-1 then
			set_visible_object(obj.plashechka.id,false)
			set_visible_object(obj[imagetex].id,false)
			del_object_from_game(5654547)		
			gameinput(26,imageid)
del_object_from_game(5654547)
				del_object_from_game(5654547)
				del_object_from_game(5654547)
				del_object_from_game(5654547)
				del_object_from_game(5654547)
				del_object_from_game(5654547)				
	end

if sender ==41 then	
	RotateHandler(obj_id);
if obj_id ==obj.dragonfly.id then	
	StartAnimation( 5555555555,1,5 );
	return;end;	
	
	return;end;
--коллапс мусора
	if sender == 12 then
		if not flags.items_collected then
		if obj.vel88.is_collapsed and obj.otkr88.is_collapsed and obj.ognet88.is_collapsed and obj.siga88.is_collapsed and obj.grozd88.is_collapsed and obj.lasti88.is_collapsed and obj.rog88.is_collapsed and
			obj.noj88.is_collapsed and obj.term88.is_collapsed and obj.drot88.is_collapsed and obj.kruk88.is_collapsed and obj.maska88.is_collapsed and
			obj.jiga88.is_collapsed and obj.perec88.is_collapsed and obj.ballon88.is_collapsed then	
				flags.items_collected = true;
				flags.comics2 = true;		
				WaitRender();	
AlternateTimer("SwitchSheet1",1000)		
				end
		end;
	return; end;
		
	
	if sender == 33 then	
		if not flags.finish then
		flags.finish = false;
			ShowMenu(true);
			SwitchToSheet("re");
		return end
	return;end;
	
	if sender==777 then
	--старт локации
			if top_plush_id and flags.comics1 then
			flags.comics1=false;
			StartTimer(43342,0.5,"conv14")
			function conv14()
				CreatePlashechka(79,"51","goodgirl")	
			end		
				
			ShowMenu(true)
			SwitchToSheet("re")
			end
	if top_plush_id then		
		ShowMenu(true)
		end	
	
	end

	if sender == 100 then
	
		
		if flags.first_time_load then
		
				flags.first_time_load=false
			set_visible_object(obj.intro.id,true);
			speciale_action(4,obj.intro.id);
			flags.start_draw = false;
		return; end;
		
		if flags.comics2 then			
			CreatePlashechka(20,"53","goodgirl")	
			canmenu=true
			flags.comics2=false;
		return; end;
		if flags.start_draw then
			flags.start_draw = false;
		
		return; end;	
				-- First Comics --
	return; end;
		if sender == 8 then
		HideGlove();
		
		HideScaner();
		HideRentgen()
		HideNvg();
	return end;
	
if sender == 1 then
--кликнули на скип
		if obj_id == skip_id then			
			MoveObjectY(top_plush_id, -256, -384, 1.5/2);
			MoveObjectY(bottom_plush_id, 640, 769, 1.5/2);
			HideSkipButton()			
			StartTimer(533335,1.5,"lvl144end")		
			function lvl144end()			
				LevelEnd(15)
			end
			skippp=true;			
		end;
		
--собираем мусор		
		if obj_id == obj.vel88.id or obj_id == obj.otkr88.id or obj_id == obj.ognet88.id or obj_id == obj.siga88.id or obj_id == obj.grozd88.id or obj_id == obj.lasti88.id or obj_id == obj.rog88.id or
			obj_id == obj.noj88.id or obj_id == obj.term88.id or obj_id == obj.drot88.id or obj_id == obj.kruk88.id or obj_id == obj.maska88.id or
			obj_id == obj.jiga88.id or obj_id == obj.perec88.id or obj_id == obj.ballon88.id then
			if scaner_on then
				CreatePlashechka(9999,"70","goodgirl")
			return;end;
				flags.items = flags.items + 1;		
				
				CollapseObj(obj_id);
		return; end;
return; end;

	if sender==26 then
--комикс с катером
	if obj_id ==20 and not startcom then
	
			set_visible_object(obj.plashechka.id,false)
			set_visible_object(obj.goodgirl.id,false)
			del_object_from_game(5654547)	
	
			leafobj={2235}
			GetRenderTarget(2235,"rendertar1");	
		function rendertar1(tex_name,tex_id)
			FlipVertical(2235);
			SetAlfa(2235,0,1,0,"vasea3353523")
			SetObjectPosition(2235,0,-256);
			LeaveObjectsOnReder("leafobj");
			ShowMenu(false)
			addstaticobjecttogame(top_plush_id, "plush", 0, 0, "");
			addstaticobjecttogame(bottom_plush_id, "plush", 0, 384, "");	
			takeobjecttohand=true
			addstaticobjecttogame(1025,"sea",0,0,"");
			speciale_action(2,1025)	
			add_animation(706);
			add_animation_frame(706,"lodka_anim",-420,298,0,0,546,124,0.3);-------------------кейс
			add_animation_frame(706,"lodka_anim",-420,298,0,124,546,124,0.3);
			add_animation_frame(706,"lodka_anim",-420,298,0,248,546,124,0.3);
			add_animation_frame(706,"lodka_anim",-420,298,0,372,546,124,0.3);
			speciale_action(2,706);			
			set_visible_object(top_plush_id,true)
			set_visible_object(bottom_plush_id,true)
			MoveObjectY(top_plush_id, -384, -256, 1.5/2);
			MoveObjectY(bottom_plush_id, 769, 640, 1.5/2);		
			speciale_action(2,1025,true)	
			speciale_action(2,706)				
			speciale_action(4,1025)
			speciale_action(4,706)
			speciale_action(4,bottom_plush_id)	
			speciale_action(4,top_plush_id)
			DrawSkipButton()
			StartAnimation(706);	
			StartTravel(706,1,nil,nil,{"InstantiationOfLine",2,-400,350,1024,350,7,false})
			StartTimer(55555,3,"theend");	
			ShowMenu(false);
			startlodka=true
			startcom=true
			playeffect("092")
		end		
	
	ShowMenu(false)
	end
	function theend ()	
	if  not skippp then	
	HideSkipButton()
	MoveObjectY(top_plush_id, -256, -384, 1.5/2);
	MoveObjectY(bottom_plush_id, 640, 769, 1.5/2);	
	StartTimer(5335,1.5,"lvl14end")
		
			function lvl14end()		
				LevelEnd(15)
			end
			flags.finish=true;
		end
	end
	
	
	end
		
return; end; 


function SelectRandom()
local dist=-1;local a=-1;local b=-1;local v=100;local t=-1;local diag=-1;
local width = -1;local height = -1;local radius=1.2;
				
	if flags.items >= 15 then
		
	return end
	
	ok = false
	while not ok do
		help_id = GetRandomObject();
		for i,v in pairs(obj) do
			if v.id == help_id and not v.is_collapsed then
				ok = true
				x,y=GetObjectPosition(v.id);
				x1,y1=GetObjectPosition(obj.dragonfly.id);
				width,height = GetObjectSize(v.id)
				a= (x-x1); b= (y-y1);  dist= math.sqrt (a^2+b^2);				
		        t=dist/400;		
                r = (math.sqrt(width^2+height^2)*0.5);		
				
				if r<50 then	r=75;	radius=4;	end  -- при радиусе меньше 50 определяем время кружения и радиус стрекозы
				
				if r>50 and r <100 then	r=87 radius=2.5;  end  --при радиусе больше 50 и меньше 100
				
				if r>100 then 	r=100 	radius=0.75;  end  -- при радиусе больше 100
				
				StartBigTravel(obj.dragonfly.id, v.id, 0, t, r/90, t, 2 ,radius);
			return end
		end
	end
end;
