function SelectRandom()
  if not flags.pjatnashki then
    selectrandomobject1(1.5,36,false); --пятнашки
  return; end;
  if obj.metla~=nil and (not obj.metla.is_collapsed) then
     selectrandomobject1(1.5,obj.metal.id);
  return;end;
  if (not flags.hidden6) or (flags.is_spirit and not flags.hidden_kucha_two) then
     selectrandomobject1(1.5,35);
  return;end;
  if obj.metla~=nil and obj.metla.is_collapsed and not flags.secret_book then
      selectrandomobject1(1.5,9);
  return;end; 
  if obj.svech~=nil and obj.svech.is_collapsed and not flags.fakel then
      selectrandomobject1(1.5,14);
  return;end; 
  if obj.svgor~=nil and obj.svgor.is_collapsed and not flags.nisha  then
      selectrandomobject1(1.5,39);
  return;end; 
  if not flags.portret_mini then
      selectrandomobject1(1.5,33);
  return;end; 
 not_hint=true  
  CreatePlashechka(900000,"10005")
return;end;


function SetParticles()
if flags.is_spirit then
  if not flags.hidden_kucha_two then
    AddParticleToObject(35,"kucha",874,613);
    MoveEmiter("kucha",874,613);
    StartEmiter("kucha");
    ActivateObject(35,true);
  end;
end;
if not flags.pjatnashki then
  AddParticleToObject(36,"book",470,297);
  MoveEmiter("book",470,297);
  StartEmiter("book");
end;
if flags.pjatnashki then
  if not obj.metal.is_collapsed then
      AddParticleToObject(obj.metal.id,"pism",547,403);
      MoveEmiter("pism",547,403);
      StartEmiter("pism");  
  end;
      AddParticleToObject(38,"fakel1",74,280);
      MoveEmiter("fakel1",74,280);
      StartEmiter("fakel1");
      AddParticleToObject(1010,"fakel2",404,274);
      MoveEmiter("fakel2",404,274);
      StartEmiter("fakel2");
      AddParticleToObject(11,"fakel3",923,271);
      MoveEmiter("fakel3",923,271);
      StartEmiter("fakel3");
      AddParticleToObject(1011,"fakel4",970,280);
      MoveEmiter("fakel4",970,280);
      StartEmiter("fakel4");
    if flags.cvecha_main or flags.nisha then
        AddParticleToObject(29,"svecha_loc",852,421);
        MoveEmiter("svecha_loc",852,421);
        StartEmiter("svecha_loc");     
    end;     
  if not flags.secret_book then
    AddParticleToObject(9,"secret_book",647,427);
    MoveEmiter("secret_book",647,427);
    StartEmiter("secret_book");
  end;    
    if not flags.portret_mini  then
      AddParticleToObject(33,"portret",172,384);
      MoveEmiter("portret",172,384);
      StartEmiter("portret");
    end;

    if not flags.hidden6 then
      AddParticleToObject(35,"kucha",874,613);
      MoveEmiter("kucha",874,613);
      StartEmiter("kucha");
    end;

    if not flags.fakel then
      AddParticleToObject(14,"na_fakel",397,321);
      MoveEmiter("na_fakel",397,321);
      StartEmiter("na_fakel");
    end;

    if not flags.help_metla then
      AddParticleToObject(obj.metal.id,"pism",547,403);
      MoveEmiter("pism",547,403);
      StartEmiter("pism");
    end;

    if not flags.nisha then
      AddParticleToObject(39,"nisha",880,384);
      MoveEmiter("nisha",880,384);
      StartEmiter("nisha");
    end;  
end;

end;

function SetCursors()
    ItemsCur={}
    PointingItems={}
    if not flags.pjatnashki then
        Set_Anim_Cur(36,2);
    end;
    if flags.pjatnashki then
      if not obj.metla.is_collapsed then
        Set_Anim_Cur(obj.metal.id,4);
      end;
      if not flags.nisha then
        Set_Anim_Cur(39,2);
      end;
      if not flags.fakel then
        Set_Anim_Cur(14,2);
      end;
      if (not flags.hidden6) or (flags.is_spirit and not flags.hidden_kucha_two) then
        Set_Anim_Cur(35,2);
      end;
      if not flags.secret_book then
            Set_Anim_Cur(9,2);
      end;
      if not flags.portret_mini then
        Set_Anim_Cur(33,2);
      end;      
      if flags.portret_mini then
        Set_Anim_Cur(34,16);
      end;      
    end;
end;

function ActionsJump ()
    
end;

function gameinput (sender,obj_id,attachedID)  
    CursorTreatment(obj_id,sender,attachedID); 
    
    if sender==28 then
        mesdark=true
        if obj_id>=50 and obj_id<=54 then
            speciale_action(2,obj_id)
        return;end;
    return;end;
    
    if sender==36 then
        if obj_id==10642 then
        Block_Show_Cur(false);
         playeffect("ceiling");
            StopEmiter("pil2",true);
            CreatePlashechka(900000,"322")
        return;end;
    return;end;
    
    if sender == 100 then
    SetParticles()
    SetCursors()
    BlockCursor(false)
        if flags.pjatnashki then
            playeffect("fire",true);
        end;
        if fromPyatnashki then
          fromPyatnashki=false
          speciale_action(2,36);
          speciale_action(2,1);
          speciale_action(2,16);
          speciale_action(2,19);
          speciale_action(2,22);
          speciale_action(2,25);
          StopEmiter("book");
          
          AddParticleToObject(38,"fakel1",74,280);
          MoveEmiter("fakel1",74,280);
          StartEmiter("fakel1");
          
          AddParticleToObject(1010,"fakel2",404,274);
          MoveEmiter("fakel2",404,274);
          StartEmiter("fakel2");
          
          AddParticleToObject(11,"fakel3",923,271);
          MoveEmiter("fakel3",923,271);
          StartEmiter("fakel3");
          
          AddParticleToObject(34,"fakel4",970,280);
          MoveEmiter("fakel4",970,280);
          StartEmiter("fakel4");
          
          
          AddParticleToObject(9,"secret_book",647,427);
          MoveEmiter("secret_book",647,427);
          StartEmiter("secret_book");
          
          AddParticleToObject(33,"portret",172,384);
          MoveEmiter("portret",172,384);
          StartEmiter("portret");
          
          AddParticleToObject(35,"kucha",874,613);
          MoveEmiter("kucha",874,613);
          StartEmiter("kucha");
          Set_Anim_Cur(35,2);
          
          AddParticleToObject(14,"na_fakel",397,321);
          MoveEmiter("na_fakel",397,321);
          StartEmiter("na_fakel");
          
          AddParticleToObject(obj.metal.id,"metla",547,403);
          MoveEmiter("metla",547,403);
          StartEmiter("metla");
          
          AddParticleToObject(39,"nisha",880,384);
          MoveEmiter("nisha",880,384);
          StartEmiter("nisha");
          

          Set_Anim_Cur(obj.metal.id,4);
          Set_Anim_Cur(39,2);
          Set_Anim_Cur(14,2);
          Set_Anim_Cur(33,2);
          Set_Anim_Cur(6,2);
          AddParticleToObject(36,"book",470,297);
          MoveEmiter("book",470,297);
          StartEmiter("book");
          Block_Show_Cur(false);    
          CreatePlashechka(900000,"144")
        end;
        if flags.is_hidden_finish then
            flags.is_hidden_finish=false
            ActivateObject(35,false);
            Set_Anim_Cur(35,3);        
        end;
        if proval then
        proval=false
        ShowMenu(true);
        mesdark=true
        if not flags.pjatnashki then
            Block_Show_Cur(true);
            MoveObjectY(50,-100,400,0.2)
            MoveObjectY(51,-100,400,0.1)
            MoveObjectY(52,-100,400,0.3)
            MoveObjectY(53,-100,400,0.1)
            MoveObjectY(54,-100,400,0.2)
            StartTimer(10642,0.5)
            AddParticleToObject(1012,"pil2",848,514);  
            MoveEmiter("pil2",848,514);            
            StartEmiter("pil2");
        end;          
        DarkScreen1(false);
        end;
        if from_comicsk then
            from_comicsk=false
            ShowMenu(true)
            CreatePlashechka(900000,"2018")
        end;
    return; end;
    
    
    if sender==12 and clicking_now then
        Block_Show_Cur(false)
    return;end;

  if sender == 1 then
    
    g_attachedID = attachedID;    
    
    if obj_id == 39 and flags.pjatnashki then
        s_obj=attachedID
        RemObjFromMouse()
        Set_Sat("nisha",7,3,"secret_room")

    return; end;
    
    if obj_id == 14 and flags.pjatnashki then
        s_obj=attachedID    
        RemObjFromMouse()
        Set_Sat("fakel",7,4,"secret_room")
    return; end;
    
    if obj_id == 36 then
        RemObjFromMouse()
        IsMiniGame=true        
        Set_Sat("pjatnashki",7,12,"secret_room")
    return; end;
    
    if obj_id == 35 and flags.pjatnashki then
        if (not flags.hidden6) or (flags.is_spirit and not flags.hidden_kucha_two) then
          flags.is_hidden_loc = true;
          RemObjFromMouse()      
          jump("secret_room","kucha",7,1);        
        return; end;
    return; end;
    
    if obj_id == obj.metal.id and flags.pjatnashki then
        clicking_now=true
        RemObjFromMouse()
        StopEmiter("pism");        
        StoreObj(obj.metla.id,obj_id,"146",335,350,"metla",247,300)
    return;end;
    
    if obj_id == 9 and flags.pjatnashki then
        s_obj=attachedID         
        RemObjFromMouse()
        Set_Sat("secret_book",7,2,"secret_room")
    return; end;
    
    if obj_id == 33 and flags.pjatnashki then
        RemObjFromMouse()
        IsMiniGame=true        
        Set_Sat("portret",7,11,"secret_room")
    return; end;
    
    
    if obj_id == 34 and flags.pjatnashki then
        playeffect("step_room")
        RemObjFromMouse()
        jump("secret_room","jmp_mayor_house",50,2);
      if not flags.hidden_garderob_two and flags.mini_dnk and flags.mini_opyt_blood and flags.mini_notebook then
        Set_Anim_Cur(5,2);
        AddParticleToObject(5,"garderob",55,561);
        MoveEmiter("garderob",55,561);
        StartEmiter("garderob");
      end;
    return; end;
  return; end;
  
  
end
function SheetSwitched(nCount)
end;