function add_fibrillation_effector_candle(obj, delay)
	local duration = 5.5

	eff= CreateAnimationEffector()
	eff:AttachTo(obj)
	eff:SetMode(_ANIM_LOOP)

    local dopacity = -0.55

	eff:SetKey(_TRACK_O, 0.0 + delay, 1.0 + dopacity)
	eff:SetKey(_TRACK_O, duration * 1.0 / 4.0 + delay, 0.75 + dopacity)
	eff:SetKey(_TRACK_O, duration * 2.0 / 4.0 + delay, 1.0 + dopacity)
	eff:SetKey(_TRACK_O, duration * 3.0 / 4.0 + delay, 0.59 + dopacity)
	eff:SetKey(_TRACK_O, duration * 4.0 / 4.0 + delay, 1.0 + dopacity)
	eff:Play()
end

function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad('data/Scenes/07_Cemetry_HO.lua',
                       'hidden_object',
                       'data/Scenes/07_Cemetry_Main.lua')

    local level = play_field:GetLevelScreen()
    --level:AddTask(CreateTask('KNIFE', '', 'Knife'))
    --level:AddTask(CreateTask('LIZZARD', '', 'Lizzard'))
    --level:AddTask(CreateTask('BINOCULAR', '', 'Binocular'))
    --level:AddTask(CreateTask('CHAIN', '', 'Chain'))
    level:AddTask(CreateTask('BUTTERFLY', 'BUTTERFLIES', 'Butterfly_1', 'Butterfly_2'))
    level:AddTask(CreateTask('CROW_BAR', '', 'crow_bar'))
    level:AddTask(CreateTask('KETTLE', '', 'kettle'))
    level:AddTask(CreateTask('MAGNIFYING_GLASS', '', 'Magnifying_Glass'))
    level:AddTask(CreateTask('PAPER', '', 'paper'))
    level:AddTask(CreateTask('PITCHFORK', '', 'Pitchfork'))
    level:AddTask(CreateTask('SAW', 'SAWS', 'Saw', 'Saw1', 'Saw2', 'Saw3'))
    level:AddTask(CreateTask('SPRING', 'SPRINGS', 'Spring', 'Spring1', 'Spring2', 'Spring3'))
    level:AddTask(CreateTask('MASK', 'MASKS', 'Mask', 'Mask2'))
    level:AddTask(CreateTask('VIOLIN', '', 'Violin'))
    level:AddTask(CreateTask('HAT', '', 'Hat'))
    level:AddTask(CreateTask('MANACLES', '', 'Manacles'))

    play_field:IgnoreOnTestPoint('Layer_paper_over')
    play_field:IgnoreOnTestPoint('dymok1')
    play_field:IgnoreOnTestPoint('dymok2')
    play_field:IgnoreOnTestPoint('dymok3')
    play_field:IgnoreOnTestPoint('Layer_Binocular_Over')
    play_field:IgnoreOnTestPoint('Layer_Light')
    play_field:IgnoreOnTestPoint('Layer_Lizard_Over')
    play_field:IgnoreOnTestPoint('svet')

    RegisterToolFindInfo('07_mask', nil, nil, nil)

    add_fibrillation_effector_candle(play_field:GetObject('svet'), 0.)
    LoadSound("WaterDrop", "data/Sound/07_Cemetery/Water_drop.ogg");
    
    TimerDoString("PlayWaterDropSound();", 0.889, play_field:GetTimer());
end

function PlayWaterDropSound()

    PlaySound('WaterDrop');
    TimerDoString("PlayWaterDropSound();", 1.889, play_field:GetTimer());

end

function OnSceneFree(screen)
    DefaultOnSceneFree()
    FreeData(screen)
end

function OnUpdate(dt)
    DefaultOnUpdate(dt)
end

function OnAllItemsFound()
    DefaultOnAllItemsFound()
end

function OnLose()
    DefaultOnLose()
end

function OnExit()
    DefaultOnExit()
end

function OnClose()
    DefaultOnClose()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
end

function OnObjectMouseDown(object)
    local is_wrong_click = not DefaultOnObjectMouseDown(object)
    local obj_name = object:GetName()
    local pf = play_field

    DefaultOnObjectMouseDownProcessed(is_wrong_click);
end

function OnObjectMouseUp(object)
    DefaultOnObjectMouseUp(object)
end

function OnObjectFound(object)
    DefaultOnObjectFound(object)
end

function OnToolFound(tool)
    DefaultOnToolFound(tool)
end

function OnToolApply(tool, object)
    DefaultOnToolApply(tool, object)
end

function OnObjectReachPanel(object)
    DefaultOnObjectReachPanel(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
end

function OnMouseMove(previous_pos, current_pos)
    DefaultOnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
    DefaultOnSetTool(tool)
end

function LevelLoaded(level)

    local effector = CreateAnimationEffector();
	effector:SetMode(_ANIM_LOOP); -- loop
	--effector:SetKey(_TRACK_O, 0.0, 0.);
	effector:SetKey(_TRACK_O, 0.0, 0.);
	effector:SetKey(_TRACK_O, 1.4, 0.50);
	effector:SetKey(_TRACK_O, 2.8, 0.);
	effector:AttachTo(play_field:GetObject('Layer_Light'));
	effector:Play();
	
end

function OnSceneDestroy(playfield)
    DefaultOnSceneDestroy(playfield)
end

--------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Butterfly_1.PNG',0,0,65,57,1,0)
	anim:SetHotSpot(32,28)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Butterfly_1',anim,272,191,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Butterfly_2.PNG',0,0,45,42,1,0)
	anim:SetHotSpot(22,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Butterfly_2',anim,637,626,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/kettle.PNG',0,0,92,80,1,0)
	anim:SetHotSpot(46,40)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('kettle',anim,26,578,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Magnifying_Glass.PNG',0,0,56,45,1,0)
	anim:SetHotSpot(28,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Magnifying_Glass',anim,435,601,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Pitchfork.PNG',0,0,51,221,1,0)
	anim:SetHotSpot(25,110)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Pitchfork',anim,695,359,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Saw.PNG',0,0,143,89,1,0)
	anim:SetHotSpot(71,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Saw',anim,832,253,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Spring.PNG',0,0,53,86,1,0)
	anim:SetHotSpot(26,43)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Spring',anim,1003,551,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/BG_cemetry.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('BG_cemetry',anim,512,384,40,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_Lizard_Over.PNG',0,0,68,134,1,0)
	anim:SetHotSpot(34,67)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Lizard_Over',anim,684,640,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Animations/kaplia/sleza.png',0,0,132,438,17,9)
	anim:SetHotSpot(54,0)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('sleza',anim,451,155,111,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/svet.png',0,0,255,245,1,0)
	anim:SetHotSpot(127,122)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('svet',anim,455,443,109,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_Light.png',0,0,731,641,1,0)
	anim:SetHotSpot(365,320)
	anim:SetBlendMode(0)
	anim:SetColor('0xAAFFFFFF')
	screen:CreateObject('Layer_Light',anim,365,320,120,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/dymok1.png',0,0,861,415,1,0)
	anim:SetHotSpot(430,207)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('dymok1',anim,580,405,115,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/dymok2.png',0,0,720,295,1,0)
	anim:SetHotSpot(360,147)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('dymok2',anim,512,384,116,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/dymok3.png',0,0,955,586,1,0)
	anim:SetHotSpot(477,293)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('dymok3',anim,512,384,117,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/05_Metrodotel_Hall/Zone_Main/Interactives/svechka2_20x40.png',0,0,20,40,25,12)
	anim:SetHotSpot(10,20)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('candle_fire',anim,461,447,150,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_Binocular_Over.PNG',0,0,45,34,1,0)
	anim:SetHotSpot(22,17)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Binocular_Over',anim,385,595,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_Grabli_Over.PNG',0,0,28,31,1,0)
	anim:SetHotSpot(14,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Grabli_Over',anim,690,450,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Hat.PNG',0,0,70,50,1,0)
	anim:SetHotSpot(35,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Hat',anim,672,517,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Manacles.PNG',0,0,78,65,1,0)
	anim:SetHotSpot(39,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Manacles',anim,744,183,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Violin.PNG',0,0,49,101,1,0)
	anim:SetHotSpot(24,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Violin',anim,266,522,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Mask.PNG',0,0,96,63,1,0)
	anim:SetHotSpot(48,31)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Mask',anim,285,594,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/Mask2.PNG',0,0,70,68,1,0)
	anim:SetHotSpot(35,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Mask2',anim,982,371,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_Mask2_Over.PNG',0,0,54,36,1,0)
	anim:SetHotSpot(27,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Mask2_Over',anim,979,392,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_Mask_Over.PNG',0,0,41,62,1,0)
	anim:SetHotSpot(20,31)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Mask_Over',anim,240,611,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_Violin_Over.PNG',0,0,63,43,1,0)
	anim:SetHotSpot(31,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Violin_Over',anim,278,563,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_Hat_Over.PNG',0,0,43,39,1,0)
	anim:SetHotSpot(22,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Hat_Over',anim,677,526,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items_add/Saw1.png',0,0,31,117,1,0)
	anim:SetHotSpot(15,58)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Saw1',anim,351,523,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items_add/Saw2.png',0,0,105,104,1,0)
	anim:SetHotSpot(52,52)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Saw2',anim,111,606,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items_add/Saw3.png',0,0,85,138,1,0)
	anim:SetHotSpot(42,69)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Saw3',anim,920,495,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items_add/Spring1.png',0,0,41,44,1,0)
	anim:SetHotSpot(20,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Spring1',anim,732,581,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items_add/Spring2.png',0,0,39,40,1,0)
	anim:SetHotSpot(19,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Spring2',anim,108,539,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items_add/Spring3.png',0,0,45,54,1,0)
	anim:SetHotSpot(22,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Spring3',anim,966,277,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers_add/Layer_Saw3_Over.png',0,0,78,102,1,0)
	anim:SetHotSpot(39,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_Saw3_Over',anim,926,519,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/crow_bar.png',0,0,89,111,1,0)
	anim:SetHotSpot(44,55)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('crow_bar',anim,494,599,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Items/paper.png',0,0,69,38,1,0)
	anim:SetHotSpot(34,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('paper',anim,403,313,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_HO/Layers/Layer_paper_over.png',0,0,74,20,1,0)
	anim:SetHotSpot(37,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_paper_over',anim,414,326,102,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
