<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Quest SName="lenspuzzle" RName="lenspuzzle" LName="lenspuzzle">

  <Tasks>
    <Task Type="REQUEST_TASKS" NameOfRequest="MiniQuestEnter" />
    <Task Type="ADD_MARK" Key="Global" Name="LastMiniQuest" Value="lenspuzzle" Mode="String"/>
  </Tasks>

  <ScaleEffect X="660" Y="490" Effect="1" StartScale="0" />

  <Decorations>
    <Decoration>
      <Id Name="background" Order="-1" SubId="10" />
      <Visible Value="1" />
      <Type Value="ANIM_MACHINE" />
      <MoveX>
        <Type Value="STATIC" />
        <PosBegin Value="43" />
      </MoveX>
      <MoveY>
        <Type Value="STATIC" />
        <PosBegin Value="8" />
      </MoveY>
      <AnimMachine BeginStep="background" EndStep="background">
        <Steps>
          <Step Key="default" Name="background" Delay="100" NameStep="background" />
        </Steps>
      </AnimMachine>
    </Decoration>
    <Decoration>
      <Id Name="break" Order="-1" SubId="10" />
      <Visible Value="1" />
      <Type Value="ANIM_MACHINE" />
      <MoveX>
        <Type Value="STATIC" />
        <PosBegin Value="285" />
      </MoveX>
      <MoveY>
        <Type Value="STATIC" />
        <PosBegin Value="81" />
      </MoveY>
      <AnimMachine BeginStep="break" EndStep="break">
        <Steps>
          <Step Key="default" Name="break" Delay="100" NameStep="break" />
        </Steps>
      </AnimMachine>
    </Decoration>
    <Decoration>
      <Id Name="lens_full" Order="-1" SubId="30000" />
      <Visible Value="0" />
      <Type Value="ANIM_MACHINE" />
      <MoveX>
        <Type Value="STATIC" />
        <PosBegin Value="285" />
      </MoveX>
      <MoveY>
        <Type Value="STATIC" />
        <PosBegin Value="81" />
      </MoveY>
      <AnimMachine BeginStep="lens_full" EndStep="lens_full">
        <Steps>
          <Step Key="default" Name="lens_full" Delay="100" NameStep="lens_full" />
        </Steps>
      </AnimMachine>
    </Decoration>
    <Decoration>
      <Id Name="border" Order="-1" SubId="3000" />
      <Visible Value="1" />
      <Type Value="ANIM_MACHINE" />
      <MoveX>
        <Type Value="STATIC" />
        <PosBegin Value="35" />
      </MoveX>
      <MoveY>
        <Type Value="STATIC" />
        <PosBegin Value="5" />
      </MoveY>
      <AnimMachine BeginStep="border" EndStep="border">
        <Steps>
          <Step Key="default" Name="border" Delay="100" NameStep="border" />
        </Steps>
      </AnimMachine>
    </Decoration>
  </Decorations>
  

  <Functionals>

    <Functional>
      <Type Value="ITEM" />
      <Id Name="lens_base" Order="-1" SubId="100" />
      <Mask Key="mask" Name="500_m" />
      <Enable Value="0" />
      <Visible Value="1" />
      <IsOnceAction Value="0" />
      <MoveX>
        <Type Value="STATIC" />
        <PosBegin Value="260" />
      </MoveX>
      <MoveY>
        <Type Value="STATIC" />
        <PosBegin Value="60" />
      </MoveY>
      <TasksOnDeny>
          <Task Type="SET_SOUND" Mode="DelayPlay" Name="search_denied2.ogg" Delay="100"/>
          <Task Type="SET_SCENE" Mode="Set" Name="darktomb"/>
          <Task Type="TOPDESCRIPTION" SKey="hint" SName="4" />
          <Task Type="SET_SCENE" Mode="Reset"/>
      </TasksOnDeny>
      <Puzzles>
        <Puzzle Name="lens_install" X="0" Y="0" W="1" H="1" >
          <Tasks>
          <Task Type="SET_SCENE" Mode="Set" Name="darktomb"/>
            <Task Type="ENABLE" Param1="lens_base4blick" Param2="0" Param3="0" />
            <Task Type="VISIBLE" Param1="lens_base4blick" Param2="0" />
          <Task Type="SET_SCENE" Mode="Reset"/>
            <Task Type="ADD_MARK" Param1="lenspuzzle" Param2="State" Param3="2" />
            
            
<!--            <Task Type="ENABLE" Param1="lens_base" Param2="0" Param3="0" />
            <Task Type="VISIBLE" Param1="lens_full" Param2="1" Param3="0" Param4="500"/>

            <Task Type="ADD_MARK" Key="darktomb" Name="lens_base_ready" Value="1" />
            <Task Type="ENABLE" Param1="lens_base_2" Param2="1" Param3="0" />-->
          </Tasks>
        </Puzzle>
      </Puzzles>
      <Cursor Key="default" Name="mechanic" />
      <Tasks>
      </Tasks>
    </Functional>
  </Functionals>
  
  <RequestTasks>

    <!--Эта задача выполянется если запущен квест запущен первый раз-->

    <RequestTask Name="QuestOnBegin">
      <Condition>
        <Var Key="lenspuzzle" Name="State" Value="0" />
      </Condition>
      <Tasks>
        <Task Type="ADD_MARK" Param1="lenspuzzle" Param2="State" Param3="1" />
        <Task Type="ENABLE" Param1="lens_base" Param2="1" Param3="0" />
      </Tasks>
    </RequestTask>

    <!--Эта задача выполняется непосредственно перед началом игры-->
    <RequestTask Name="GameOnBegin">
      <Condition>
        <Var Key="lenspuzzle" Name="State" Value="2" />
      </Condition>
      <Tasks>
        <Task Type="ENABLE" Param1="lens_base" Param2="0" Param3="0" />
      </Tasks>
    </RequestTask>

    <!--Эта задача выполняется непосредственно если происходит выйгрышь или пропуск-->
    <RequestTask Name="GameOnWinOrPass">
      <Condition>
        <Var Key="lenspuzzle" Name="State" Value="3" />
      </Condition>
      <Tasks>
        <Task Type="REQUEST_TASKS" NameOfRequest="manual_hide" />
        <!--<Task Type="VISIBLE" Param1="lens_full" Param2="1" Param3="0" Param4="1000" />-->
      
        <Task Type="ADD_MARK" Key="darktomb" Name="lenspuzzle_end" Value="1" />
        <Task Type="QUEUE" Mode="begin" Name="lenspuzzle_ready" />
<!--        <Task Type="DELAY" Delay="10" />
        <Task Type="SET_SCENE" Mode="Set" Name="darktomb"/>
        <Task Type="REQUEST_TASKS" Param1="lenspuzzle_finished" />
        <Task Type="SET_SCENE" Mode="Reset"/>-->
        <Task Type="DELAY" Delay="2000" />
        <Task Type="ADD_MARK" Param1="lenspuzzle" Param2="State" Param3="4" />
        <Task Type="QUEUE" Mode="end" />
        <Task Type="EMULATE_HINT" Action="UsrEvt" Name="lens_collected_win"/>
      </Tasks>
    </RequestTask>

    <RequestTask Name="GameOnCancel">
      <Condition>
        <Var Key="no" Name="no" Value="0" />
      </Condition>
      <Tasks>
        <Task Type="REQUEST_TASKS" NameOfRequest="close" />
      </Tasks>
    </RequestTask>

    <!--Эта задача выполняется непосредственно когда происходит завершение уровня-->
    <RequestTask Name="QuestOnEnd">
      <Condition>
        <Var Key="lenspuzzle" Name="State" Value="4" />
      </Condition>
      <Tasks>
        <Task Type="REQUEST_TASKS" NameOfRequest="close" />
      </Tasks>
    </RequestTask>

    <RequestTask Name="manual_show">
      <Condition>
        <Var Key="no" Name="no" Value="0" />
      </Condition>
      <Tasks>
        <Task Type="SET_ANIMATIONTOOL" ResName="lenspuzzle" AKey="default" AName="manual" CtrlName="manual" RX="512" RY="315" SX="207" SY="10" SW="610" SH="610" RequestName="manual_hide" Angle="0" IsFlickr="0"/>
      </Tasks>
    </RequestTask>    
  </RequestTasks>

</Quest>