------Emitters-------------------
AddParticleToObject(201,"fakel1");
MoveEmiter("fakel1",70,455);
StartEmiter("fakel1");

AddParticleToObject(202,"fakel2");
MoveEmiter("fakel2",980,300);  
StartEmiter("fakel2");

AddParticleToObject(1,"mech");
MoveEmiter("mech",600,394);
------End Emitters------------


local speed = 1;
last_id = nil;

WaitRender();

function gameinput( sender,obj_id,attachedID )
	if SLevel==1.0 then 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 == 6 then
		if flags.first_time_load then
			flags.first_time_load = false;			
		return;end;
		if not flags.key_placed_25 then
			CreatePlashechka(9999,"202","goodgirl")
		end;
	end;	
	
	
	if sender==36 then
	
	if obj_id == 444 then
	StartAnimation( 5555555555,1,5 );
	return;end;	
	return;end;
	if sender == 33 then	
	
		if flags.finish then
			ShowMenu(false);
		else
			ShowMenu(true);
			SwitchToSheet("re")
		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==777 then
		if  flags.comics1 then						
				StartTimer(43342,0.5,"conv25")
			function conv25()
				CreatePlashechka(79,"112","goodgirl")
			end						
				ShowMenu(true);			
				SwitchToSheet("re")
				flags.comics1=false;
			return;end
	
	
	if not flags.mini1 and flags.start_mini then	
		
		leafobj={2234}
		GetRenderTarget(2234,"rendertar");	
		mininame="mini";
		mininum1=25;
		mininum2=10;
		mininame2="forge";				
	return;end;
	if top_plush_id then		
		ShowMenu(true)
	end	
	end
	
	
	if sender == 100 then
	
		if flags.n >= 15 then		
			ClosePlushes()			
			flags.start_mini=true;
		return; end;
		
		if flags.comics3 then
			StartEmiter("mech");
		end;		
	
		if flags.comics2 and not flags.mini then	
			LevelComplete()
		return; 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);			
		return; end;	
				
	return; end;	

	
	

	
	if sender == 1 then

		if obj_id == 1 then
			if scaner_on then
							CreatePlashechka(9999,"70","goodgirl")
			return;end;
			if attachedID == 111 then
				
				playeffect("141")
				RemoveFromMouse(attachedID);
				SwitchToSheet("re")	
				DeleteElement(sheet,111);
				Set_Cursor(1,3);
				flags.key_placed_25 = true;
				StopEmiter("mech");
				-- Comics --
				if flags.comics3 then
					flags.comics3 = false;
					Set_Cursor(1,3);
					CreatePlashechka(79,"114","goodgirl")			
				return; end;
			
			else
				if not flags.key_placed_25 then
					CreatePlashechka(9999,"201","goodgirl")
				end;
			end;
		end;
		if attachedID == -1 then
		if scaner_on then
							CreatePlashechka(9999,"70","goodgirl")
			return;end;
			if flags.key_placed_25 then
				
				if obj_id >= obj.topor_25.id and obj_id <= obj.utug_25.id then
					CollapseObj(obj_id);
					flags.n = flags.n + 1;
				end;
				if obj_id == obj.gayka_25.id then
					speciale_action(2,2);
					CollapseObj(obj_id);
					flags.n = flags.n + 1;
				end;
				if obj_id == obj.ruletka_25.id then
					speciale_action(2,4);
					CollapseObj(obj_id);
					flags.n = flags.n + 1;
				end;
				if obj_id == obj.serp_25.id then
					speciale_action(2,5);
					CollapseObj(obj_id);
					flags.n = flags.n + 1;
				end;
			end;
		
			last_id = obj_id;
		end;
	return; end;

	 if sender == 12 then		
		if flags.n >= 15 then
			WaitRender();
			AlternateTimer("SwitchSheet1",1000)	
		 return;end;
	 end;
	
	if sender == 14 then		
	 if scaner_on then return;end
			addObjectToMouse(obj_id);		
	return;end;
	
	
end;


function SelectRandom()
local dist=-1;local a=-1;local b=-1;local v=100; t=-1;local diag=-1;
local width = -1;local height = -1;local radius=1.2;
				
	if not flags.key_placed_25 or flags.n >= 15 then		
		computation( 1);			
		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;

