WaitRender();

function gameinput(sender,obj_id,attachedID)	
--обработка плашки
 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)
			gameinput(26,imageid)	
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;	
	
	if obj_id ==44 then
	 StartAnimation(444); 
 speciale_action(4,444);
StartTravel(444,1,nil,nil, { "InstantiationOfLine",2, -200,460,1100,460,15,false});
	return;end;
	
	
		if obj_id ==444 then

 speciale_action(4,44);
StartTravel(44,1,nil,nil, { "InstantiationOfLine",2, 1100,460,-200,460,15,false});
	return;end;
	
	if obj_id ==46 then
	set_visible_object(46,false); 
	return;end;
	return;end;

if sender==777 then
--старт уровня
			if  flags.comics then		
				StartTimer(43342,0.5,"conv16")
			function conv16()
				CreatePlashechka(79,"101","goodgirl")	
			end		
				
				ShowMenu(true)
				SwitchToSheet("re")
				flags.comics=false;
			return;end	
--старт мини
	if not flags.mini1_complete and flags.start_mini then	 			
		leafobj={2234}
		GetRenderTarget(2234,"rendertar");	
		mininame="mini";
		mininum1=16;
		mininum2=11;
		mininame2="trum";		
	return;end;
	
	if top_plush_id then		
		ShowMenu(true)
	end	
		
	end

if sender == 100 then	
	
	-----обработка сохранения-------------
if not flags.sunduk then
	
	else
	
	set_visible_object(obj.krishka1.id,true);
	set_visible_object(obj.krishka2.id,false);
	set_visible_object(obj.krishka3.id,false);

	end;
	AddParticleToObject(obj.dver2.id,"dver");
	MoveEmiter("dver",150,360);
	StartEmiter("dver");
	
	if	flags.mini1_complete  then		
		StopEmiter("shah");
		set_visible_object(obj.dver1.id,true); 
	else
	AddParticleToObject(obj.shah.id,"shah");
	MoveEmiter("shah",85,355);
end;

---------------------------------------

	

	
	
	
	---------Наличие предметов после загрузки
	if obj.fonar.is_collapsed then
	
	set_visible_object(obj.tenfonar.id,false);  
	
	end;
	if obj.shlem.is_collapsed then
	
	set_visible_object(obj.tenshlem.id,false);  
	
	end;
	
	
	
	
	---------------------------
	
	

		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;
---------------------------------------------------------
	
		end;  -- 100 сендер
	
if sender == 1 then
---Предметы поиска--------------

if obj_id == obj.shlem.id then
	if scaner_on then
		CreatePlashechka(9999,"70","goodgirl")
	return;end;
	set_visible_object(obj.tenshlem.id,false); 
	flags.items1 = flags.items1 +1;
	CollapseObj(obj_id);
return;end;

if obj_id == obj.fonar.id then
	if scaner_on then
		CreatePlashechka(9999,"70","goodgirl")
	return;end;
	flags.items1 = flags.items1 +1;
	CollapseObj(obj_id);
	set_visible_object(obj.tenfonar.id,false);    
return;end;

if obj_id >obj.konek1.id -1 and obj_id < obj.korall1.id +1 then

if scaner_on then
		CreatePlashechka(9999,"70","goodgirl")
return;end;




flags.items1 = flags.items1 +1;
CollapseObj(obj_id);

if obj_id == obj.shlem.id	then
set_visible_object(obj.tenshlem.id,false);     	
end;

if obj_id == obj.fonar.id	then
set_visible_object(obj.tenfonar.id,false);     	
end;

if obj_id == obj.vaza.id	then
set_visible_object(obj.tenvaza.id,false);     	
end;
if obj_id == obj.zvezda.id	then
set_visible_object(obj.tenzvezda.id,false);     	
end;

if flags.items1 ==15  then 
flags.items_collected=true;
AlternateTimer("SwitchSheet1",1000)	

 if  flags.mini1_complete then

   StartTimer(5000,2.5);
 
 end;
end;

return;end;
-------------------------------------------------------


-------- сканнер----------------


if obj_id == obj.enter.id  and not  flags.enter and flags.start_scaner then
	set_visible_object(44,false); 
	set_visible_object(46,false); 

	set_visible_object(444,false); 
	SetAlfa(obj.enter.id,0.01,1,0)
	speciale_action(4,obj.polosa.id);
	speciale_action(2,obj.polosa.id,true);
	speciale_action(4,obj.kluchik.id);
	
	flags.scanner = true; 
	flags.enter=true
return;end;

---------------------------------------------------

----Миниигра--------------
if obj_id == 999 and not flags.mini1_complete then
if scaner_on then
		CreatePlashechka(9999,"70","goodgirl")
	return;end;
			StopEmiter("shah");
			StopEmiter("dver");	
			speciale_action( 4, top_plush_id );
			speciale_action( 4, bottom_plush_id_plush_id );			  
			ClosePlushes();
			flags.start_mini=true;
			flags.ministart=true;
			ShowMenu(false);		

return;end;
------------------------



-----Дверь-----------------
if obj_id ==obj.dver2.id  then
CreatePolygon(999,4,"shah")
Set_Cursor(999,2)
if scaner_on then
		CreatePlashechka(9999,"70","goodgirl")
return;end;
			
speciale_action(2,obj.dver2.id);
set_visible_object(obj.shah.id,true); 
set_visible_object(obj.tenshah.id,true); 
speciale_action(2,obj.dver1.id,true);
StartAnimation(46); 
speciale_action(2,46);
speciale_action(4,46);

-- Set_Cursor(obj.shah.id,2);
StartEmiter("shah");
flags.rybka=true;
StartTimer(102,24);
StartTravel(46,1,nil,nil, { "InstantiationOfLine",2, 75,250,1100,250,24,false});
playeffect("101");
return;end;
--------------------------

--------Осьминог--------
if obj_id ==888 and not flags.sunduk then
	if scaner_on then
			CreatePlashechka(9999,"70","goodgirl")
	return;end;
	StartAnimation(477); 
	set_visible_object(47,false);
	flags.sunduk=true;
	StartTimer(100,1.2);
return;end;
-----------------------

end; --сендер 1
  
-----Объект стал видимым
if sender ==16 then

if obj_id ==obj.polosa.id then
	MoveObjectX(obj.polosa.id,112,839,5);
	StartTimer(555,5);
	playeffect("024")
return;end;
if obj_id ==obj.krishka1.id  then
	StartAnimation(48); 
	StartTravel(48,1,nil,nil, { "InstantiationOfLine",2, 785,320,785,0,1.8,false});

	StartTimer(101,1.8);
	speciale_action(2,48);
	speciale_action(4,48);
	flags.bulki=true;
return;end;







end;
--------------------------
	if sender==26 then
		if obj_id ==50 then
			if flags.items_collected then			
				CreatePlashechka(51,"106","goodgirl")	
				flags.finish=true; 	
				canmenu=true
			else		
			CreatePlashechka(52,"104","goodgirl")	
			SwitchToSheet("re")
			end		
		
		end
--конец локации		
		if obj_id ==51  then
			del_object_from_game(obj.dragonfly.id)
			leafobj={2234}
			GetRenderTarget(2234,"rendertar");	
			minigg=true;
			levelnext=17;
		end


	end
---------Таймер-------------------------	
if sender == 36 then		
			if obj_id ==5000 then		
		  	CreatePlashechka(51,"105","goodgirl")	
			ShowMenu(true);
			flags.finish=true;
		 	return;end;
			
			if obj_id ==555 then				  
				set_visible_object(obj.enter.id,false);  
				set_visible_object(obj.scanner.id,false);  
				set_visible_object(obj.kluchik.id,false);  		 
				set_visible_object(obj.polosa.id,false);  		
				flags.start_scaner=false
				CreatePlashechka(50,"103","goodgirl")	
				flags.comics1=true;
				 if flags.items_collected then		 
					canmenu=true
				end
				
				
				ShowMenu(true)				
		
			return;end;			

			if obj_id ==100 then	 	
			PauseAnimation(477,true);
			speciale_action(2,obj.krishka1.id,true,1);
			speciale_action(2,obj.krishka2.id,true,1);
			speciale_action(2,obj.krishka2.id);
			speciale_action(2,obj.krishka3.id);
			speciale_action(10,477);
			playeffect("099");
			flags.sunduk=true;

			flags.sunduk1=true;
			return;end;

			if obj_id ==101 then	
				PauseAnimation(48,true);
				set_visible_object(48,false);
			return;end;		
		
			if obj_id ==102 then	
				PauseAnimation(46,true);
			return;end;
	 
	   
return; end;
--------------------------------------------


 ------------правая кнопка мыши----------------- 
if sender == 8 then
	HideGlove();	
	HideScaner();	
	HideRentgen()
	HideNvg();
return end;

--------------меню------------------------	
if sender == 2 then
	RemoveFromMouse(object);
	MessageProc(sender,obj_id);
return;end;	

--наведение на кнопку сканировать
	if sender==35 and flags.start_scaner then
		SetAlfa(obj.enter.id,0.01,1,0) 
	end
--уведение	
	if sender==39 and flags.start_scaner then	
		SetAlfa(obj.enter.id,1,0.01,0)
	end

	if sender == 33 then		 
		 
	if	flags.mini1_complete and  flags.scan and not flags.comics1 then	 	
		


		set_visible_object(obj.scanner.id,true);  
		set_visible_object(obj.kluchik.id,true,3);  		 
		speciale_action(4,obj.scanner.id);		
		speciale_action(4,obj.enter.id);
		speciale_action(4,obj.kluchik.id);
		ShowMenu(false);
		OnMouseOver(obj.enter.id)
		flags.scan=false;
		flags.start_scaner=true
		speciale_action(2,444);
		speciale_action(2,44);
		set_visible_object(obj.dver2.id,false);  
		
		speciale_action(2,999)
		StopEmiter("shah");
	return;end;
		
	if not flags.finish then
		-- flags.finish = false;
			-- ShowMenu(true);
			-- SwitchToSheet("re");
		return end		
	return;end;
---------------------------------------------	
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.items1 >= 15 then
	if not flags.mini1_complete then
	computation(obj.shah.id);
		
		return; end;
		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;
-------------------------------------