zone_monument = nil;
violinMonumentCompilation = nil;
cemetryDoorOpeningCompilation = nil;


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

	RegisterQuestObjects('area_monument', 'area_ho')
	if HasGameState('ToolFound', '07_mask') then
		game_state.quest_objects['area_street'] = true
	else
		game_state.ignore_on_highlight['area_street'] = true
	end

    --LinkScene('area_ho', 'CursorActive', 'data/Scenes/07_Cemetry_HO.lua', true)
    RegisterMonologObject('area_ho', 'C_07_GATE_CLOSED', true)
    RegisterMonologObject('rust_1', 'C_07_RUSTY_PUPPET')
    RegisterMonologObject('rust_2', 'C_07_RUSTY_PUPPET')
    RegisterMonologObject('rust_3', 'C_07_RUSTY_PUPPET')

    LinkScene('area_street', 'CursorDoorDown', 'data/Scenes/06_Hotel_Street_Evening_Main.lua', false)

    if HasGameState('AllSceneTaskObjectsFound', 'data/Scenes/07_Cemetry_HO.lua') then
        game_state.custom_cursors['area_grave'] = 'CursorGlass'
        play_field:GetObject('area_ho'):SetOpacity(0.)
    else
        play_field:GetObject('area_grave'):SetOpacity(0.)
    end

    BuildViolinMonumentAnimation();
    BuildCemeteryDoorOpeningAnimation();

    zone_monument = CreateZoomZone('area_monument',
                                   'CloseZoneViolin',
                                   'BG_Zoom_Violin', true,
                                   'rust_1', true,
                                   'rust_2', true,
                                   'rust_3', true)

    local on_oiler_apply = function(tool_name, object_name)
        if object_name == 'rust_1' then
            zone_monument.SetObjectVisible('rust_1', false)
            play_field:GetObject('rust_1'):ChangeOpacity(1.0, 0.0, 0.5);
			MakeSoundEntity('07_Oiling_statue'):Play(false);
        end
        if object_name == 'rust_2' then
            zone_monument.SetObjectVisible('rust_2', false)
            play_field:GetObject('rust_2'):ChangeOpacity(1.0, 0.0, 0.5);
			MakeSoundEntity('07_Oiling_statue'):Play(false);
        end
        if object_name == 'rust_3' then
            zone_monument.SetObjectVisible('rust_3', false)
            play_field:GetObject('rust_3'):ChangeOpacity(1.0, 0.0, 0.5);
			MakeSoundEntity('07_Oiling_statue'):Play(false);
        end
        if not object_name then
            UnregisterActiveObject('area_ho');

            PauseAmbientMusic(true);

            TimerDoString("zone_monument.SetVisible(false);"..
                          "zone_monument.Disable();"..
                          "violinMonumentCompilation:Play();"..
                          "MakeSoundEntity('Violin_cemetery_door'):Play(false);",
                          1.5, play_field:GetTimer());

            TimerDoString("cemetryDoorOpeningCompilation:Play();",
                          2.5, play_field:GetTimer());

            TimerDoString("ShowMonolog('C_07_GATE_OPEN', 'C_07_GATE_OPEN');" ..
                          "LinkScene('area_ho', 'CursorGlass', 'data/Scenes/07_Cemetry_HO.lua', true);",
                          12.5, play_field:GetTimer());

            TimerDoString("ContinueAmbientMusic(true);",
                          21.5, play_field:GetTimer());

            TimerDoString("RegisterRustyOpenerRavagedComment()", 28, play_field:GetTimer());

			game_state.ignore_on_highlight['area_monument'] = true
        end

    end
    local on_load_when_oiler_applied = function(tool_name, object_name)
        if object_name == 'rust_1' then
            zone_monument.SetObjectVisible('rust_1', false)
            play_field:GetObject('rust_1'):SetOpacity(0.0);
        end
        if object_name == 'rust_2' then
            zone_monument.SetObjectVisible('rust_2', false)
            play_field:GetObject('rust_2'):SetOpacity(0.0);
        end
        if object_name == 'rust_3' then
            zone_monument.SetObjectVisible('rust_3', false)
            play_field:GetObject('rust_3'):SetOpacity(0.0);
        end
        if not object_name then
            UnregisterActiveObject('area_ho');
            LinkScene('area_ho', 'CursorGlass', 'data/Scenes/07_Cemetry_HO.lua', true)
            zone_monument.Disable();
            violinMonumentCompilation:Stop();
            violinMonumentCompilation:Rewind(true);
            cemetryDoorOpeningCompilation:Stop();
            cemetryDoorOpeningCompilation:Rewind(true);

            RegisterRustyOpenerRavagedComment();

			game_state.ignore_on_highlight['area_monument'] = true
        end
        
    end
    RegisterToolApplyInfo('05_oiler', {'rust_1', 'rust_2', 'rust_3'}, nil, nil, on_oiler_apply, on_load_when_oiler_applied)
	
	LoadSound('07_Oiling_statue', 'data/Sound/07_Cemetery/Oiling_statue.ogg');

end

function RegisterRustyOpenerRavagedComment()

    play_field:DoNotIgnoreOnTestPoint('area_monument');
    game_state.locked_objects['area_monument'] = nil;
    RegisterActiveObject('area_monument',
        function() ShowMonolog('C_07_RUSTED_OPENER_RAVAGED', 'C_07_RUSTED_OPENER_RAVAGED') end,
        nil, true, 'CursorGlass')

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

    if obj_name == 'area_grave' then
        ShowMonolog('07_Grave', 'C_07_GRAVE')
		game_state.ignore_on_highlight['area_grave'] = true
		AddGameState('IgnoreOnHighlight', 'area_grave')
        is_wrong_click = false
    end

    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)

end

function OnSceneDestroy(playfield)
    DefaultOnSceneDestroy(playfield)
    
    StopSound('Violin_cemetery_door');
end

function BuildViolinMonumentAnimation()

    local screen = play_field;
    
    violinMonumentCompilation = CreateCompositionSequence();
    local composition = violinMonumentCompilation
    local compositionDuration = 26.32;
    composition:SetDuration(compositionDuration);
    composition:AttachTo(screen);
    composition:SetZ(110);
    composition:SetXY(412, 200);
    composition:SetDestroysOnEnd(false);
    
    -- Layer Dust_1
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_1");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(306, 104);
    
    element:SetAngle(0.16961682914546);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.12, 1.75999990224838);
    
    effector:SetKey(_TRACK_SX, 0.12, 0.21);
    effector:SetKey(_TRACK_SY, 0.12, 0.21);
    effector:SetKey(_TRACK_SX, 0.33999998688698, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 0.33999998688698, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 1.73999989032745, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 1.73999989032745, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.12, 0);
    effector:SetKey(_TRACK_O, 0.33999998688698, 1);
    effector:SetKey(_TRACK_O, 1.11999994039536, 1);
    effector:SetKey(_TRACK_O, 1.71999990463257, 0);
    
    effector:Play();
    
    
    -- Layer Dust_2
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_2");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(420, 141);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.12, 1.75999990224838);
    
    effector:SetKey(_TRACK_SX, 0.12, 0.21);
    effector:SetKey(_TRACK_SY, 0.12, 0.21);
    effector:SetKey(_TRACK_SX, 0.33999998688698, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 0.33999998688698, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 1.73999989032745, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 1.73999989032745, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.12, 0);
    effector:SetKey(_TRACK_O, 0.33999998688698, 1);
    effector:SetKey(_TRACK_O, 1.11999994039536, 1);
    effector:SetKey(_TRACK_O, 1.71999990463257, 0);
    
    effector:Play();
    
    
    -- Layer Dust_3
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_3");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(461, 78);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.12, 1.75999990224838);
    
    effector:SetKey(_TRACK_SX, 0.12, 0.21);
    effector:SetKey(_TRACK_SY, 0.12, 0.21);
    effector:SetKey(_TRACK_SX, 0.33999998688698, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 0.33999998688698, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 1.73999989032745, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 1.73999989032745, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.12, 0);
    effector:SetKey(_TRACK_O, 0.33999998688698, 1);
    effector:SetKey(_TRACK_O, 1.11999994039536, 1);
    effector:SetKey(_TRACK_O, 1.71999990463257, 0);
    
    effector:Play();
    
    
    -- Layer Dust_4
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_4");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(377, 88);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.12, 1.75999990224838);
    
    effector:SetKey(_TRACK_SX, 0.12, 0.21);
    effector:SetKey(_TRACK_SY, 0.12, 0.21);
    effector:SetKey(_TRACK_SX, 0.33999998688698, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 0.33999998688698, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 1.73999989032745, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 1.73999989032745, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.12, 0);
    effector:SetKey(_TRACK_O, 0.33999998688698, 1);
    effector:SetKey(_TRACK_O, 1.11999994039536, 1);
    effector:SetKey(_TRACK_O, 1.71999990463257, 0);
    
    effector:Play();
    
    
    -- Layer Dust_5
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_5");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(354, 156);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(22.64, 25.92);
    
    effector:SetKey(_TRACK_SX, 22.64, 0.21);
    effector:SetKey(_TRACK_SY, 22.64, 0.21);
    effector:SetKey(_TRACK_SX, 23.08, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 23.08, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 25.88, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 25.88, 1.86961331472992);
    effector:SetKey(_TRACK_O, 22.64, 0);
    effector:SetKey(_TRACK_O, 23.08, 1);
    effector:SetKey(_TRACK_O, 24.64, 1);
    effector:SetKey(_TRACK_O, 25.84, 0);
    
    effector:Play();
    
    
    -- Layer Dust_6
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_6");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(354, 156);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(18.28, 21.56);
    
    effector:SetKey(_TRACK_SX, 18.28, 0.21);
    effector:SetKey(_TRACK_SY, 18.28, 0.21);
    effector:SetKey(_TRACK_SX, 18.72, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 18.72, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 21.52, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 21.52, 1.86961331472992);
    effector:SetKey(_TRACK_O, 18.28, 0);
    effector:SetKey(_TRACK_O, 18.72, 1);
    effector:SetKey(_TRACK_O, 20.28, 1);
    effector:SetKey(_TRACK_O, 21.48, 0);
    
    effector:Play();
    
    
    -- Layer Dust_7
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_7");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(354, 156);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(15.8, 19.08);
    
    effector:SetKey(_TRACK_SX, 15.8, 0.21);
    effector:SetKey(_TRACK_SY, 15.8, 0.21);
    effector:SetKey(_TRACK_SX, 16.24, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 16.24, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 19.04, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 19.04, 1.86961331472992);
    effector:SetKey(_TRACK_O, 15.8, 0);
    effector:SetKey(_TRACK_O, 16.24, 1);
    effector:SetKey(_TRACK_O, 17.8, 1);
    effector:SetKey(_TRACK_O, 19, 0);
    
    effector:Play();
    
    
    -- Layer Dust_8
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_8");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(421, 146);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(13, 16.28);
    
    effector:SetKey(_TRACK_SX, 13, 0.21);
    effector:SetKey(_TRACK_SY, 13, 0.21);
    effector:SetKey(_TRACK_SX, 13.44, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 13.44, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 16.24, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 16.24, 1.86961331472992);
    effector:SetKey(_TRACK_O, 13, 0);
    effector:SetKey(_TRACK_O, 13.44, 1);
    effector:SetKey(_TRACK_O, 15, 1);
    effector:SetKey(_TRACK_O, 16.2, 0);
    
    effector:Play();
    
    
    -- Layer Dust_9
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_9");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(403, 191);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(8.52, 11.8);
    
    effector:SetKey(_TRACK_SX, 8.52, 0.21);
    effector:SetKey(_TRACK_SY, 8.52, 0.21);
    effector:SetKey(_TRACK_SX, 8.96, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 8.96, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 11.76, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 11.76, 1.86961331472992);
    effector:SetKey(_TRACK_O, 8.52, 0);
    effector:SetKey(_TRACK_O, 8.96, 1);
    effector:SetKey(_TRACK_O, 10.52, 1);
    effector:SetKey(_TRACK_O, 11.72, 0);
    
    effector:Play();
    
    
    -- Layer Dust_10
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_10");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(362, 159);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(5.04, 8.32);
    
    effector:SetKey(_TRACK_SX, 5.04, 0.21);
    effector:SetKey(_TRACK_SY, 5.04, 0.21);
    effector:SetKey(_TRACK_SX, 5.48, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 5.48, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 8.28, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 8.28, 1.86961331472992);
    effector:SetKey(_TRACK_O, 5.04, 0);
    effector:SetKey(_TRACK_O, 5.48, 1);
    effector:SetKey(_TRACK_O, 7.04, 1);
    effector:SetKey(_TRACK_O, 8.24, 0);
    
    effector:Play();
    
    
    -- Layer Dust_11
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_11");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(403, 142);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(3.24, 6.52);
    
    effector:SetKey(_TRACK_SX, 3.24, 0.21);
    effector:SetKey(_TRACK_SY, 3.24, 0.21);
    effector:SetKey(_TRACK_SX, 3.68, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 3.68, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 6.48, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 6.48, 1.86961331472992);
    effector:SetKey(_TRACK_O, 3.24, 0);
    effector:SetKey(_TRACK_O, 3.68, 1);
    effector:SetKey(_TRACK_O, 5.24, 1);
    effector:SetKey(_TRACK_O, 6.44, 0);
    
    effector:Play();
    
    
    -- Layer Dust_12
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_12");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(403, 142);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0.32, 2.32080004692078);
    
    effector:SetKey(_TRACK_SX, 0.32, 0.21);
    effector:SetKey(_TRACK_SY, 0.32, 0.21);
    effector:SetKey(_TRACK_SX, 0.58840000629425, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 0.58840000629425, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 2.29640004634857, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 2.29640004634857, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0.32, 0);
    effector:SetKey(_TRACK_O, 0.58840000629425, 1);
    effector:SetKey(_TRACK_O, 1.54000002861023, 1);
    effector:SetKey(_TRACK_O, 2.27200004577637, 0);
    
    effector:Play();
    
    
    -- Layer Dust_13
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/dust.png");
    element:SetName("Dust_13");
    composition:AddElement(element);
    element:SetHotSpot(86.5, -55.5);
    element:SetParentElement(composition);
    element:SetXY(363, 192);
    
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 2.00080004692078);
    
    effector:SetKey(_TRACK_SX, 0, 0.21);
    effector:SetKey(_TRACK_SY, 0, 0.21);
    effector:SetKey(_TRACK_SX, 0.26840000629425, 0.48537958595098);
    effector:SetKey(_TRACK_SY, 0.26840000629425, 0.48537958595098);
    effector:SetKey(_TRACK_SX, 1.97640004634857, 1.86961331472992);
    effector:SetKey(_TRACK_SY, 1.97640004634857, 1.86961331472992);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 0.26840000629425, 1);
    effector:SetKey(_TRACK_O, 1.22000002861023, 1);
    effector:SetKey(_TRACK_O, 1.95200004577637, 0);
    
    effector:Play();
    
    
    -- Layer head
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/head.png");
    element:SetName("head");
    composition:AddElement(element);
    element:SetHotSpot(28, 41.5);
    composition:RegisterParentInfo("head", "torse");
    element:SetXY(37, 26);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 60);
    
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 1.04, -0.12775763541115);
    effector:SetKey(_TRACK_A, 1.96, -0.17584641521712);
    effector:SetKey(_TRACK_A, 3.32, -0.17584641521712);
    effector:SetKey(_TRACK_A, 4.24, 0.1124855221362);
    effector:SetKey(_TRACK_A, 5.88, 0.27193991897274);
    effector:SetKey(_TRACK_A, 6.96, 0.36729308380609);
    effector:SetKey(_TRACK_A, 7.96, 0.43429864098049);
    effector:SetKey(_TRACK_A, 9.84, -0.26415134108875);
    effector:SetKey(_TRACK_A, 11.92, -0.36968314149297);
    effector:SetKey(_TRACK_A, 13.44, 0.12378377910218);
    effector:SetKey(_TRACK_A, 16.08, -0.46317094971931);
    effector:SetKey(_TRACK_A, 19.72, -0.09380343628692);
    effector:SetKey(_TRACK_A, 22.28, -0.62545516751665);
    effector:SetKey(_TRACK_A, 23.2, -0.37583209263353);
    effector:SetKey(_TRACK_A, 24.32, -0.12656065497447);
    effector:SetKey(_TRACK_A, 26.24, -0.50407122747397);
    
    effector:Play();
    
    
    -- Layer hand
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/hand.png");
    element:SetName("hand");
    composition:AddElement(element);
    element:SetHotSpot(7.5, -0.5);
    composition:RegisterParentInfo("hand", "forearm");
    element:SetXY(15.6805658925825, 63.3936605153597);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 60);
    
    effector:SetKey(_TRACK_A, 0, 0.03640415796418);
    effector:SetKey(_TRACK_A, 1.16, -0.14460974450708);
    effector:SetKey(_TRACK_A, 1.96, 0.58751110297913);
    effector:SetKey(_TRACK_A, 3.28, -0.01763152036521);
    effector:SetKey(_TRACK_A, 4.2, 0.5808455456142);
    effector:SetKey(_TRACK_A, 5.88, 0.5808455456142);
    effector:SetKey(_TRACK_A, 6.96, 1.4083283847786);
    effector:SetKey(_TRACK_A, 7.96, -0.36931653853806);
    effector:SetKey(_TRACK_A, 9.84, 0.68482936703266);
    effector:SetKey(_TRACK_A, 11.92, 0.93933590038164);
    effector:SetKey(_TRACK_A, 14, 0.26240108922823);
    effector:SetKey(_TRACK_A, 14.96, 0.74203328951042);
    effector:SetKey(_TRACK_A, 16.08, 1.70548002294498);
    effector:SetKey(_TRACK_A, 16.96, 0.64996459636783);
    effector:SetKey(_TRACK_A, 17.88, 1.13538350369571);
    effector:SetKey(_TRACK_A, 18.68, 0.64996459636783);
    effector:SetKey(_TRACK_A, 19.72, 1.13538350369571);
    effector:SetKey(_TRACK_A, 22.28, 0.64996459636783);
    effector:SetKey(_TRACK_A, 23.2, -0.44637312360492);
    effector:SetKey(_TRACK_A, 24.76, 0.9387615219863);
    
    effector:Play();
    
    
    -- Layer bow
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/smy4ok.png");
    element:SetName("bow");
    composition:AddElement(element);
    element:SetHotSpot(159.5, 8.5);
    composition:RegisterParentInfo("bow", "hand");
    element:SetXY(14.357194948886, 15.5022246686275);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 60);
    
    effector:SetKey(_TRACK_A, 0, -0.03303300371888);
    effector:SetKey(_TRACK_A, 0.8, -1.07242249707991);
    effector:SetKey(_TRACK_A, 1.16, -0.49783962362925);
    effector:SetKey(_TRACK_A, 1.96, -1.78792841032941);
    effector:SetKey(_TRACK_A, 3.28, -0.47967727477851);
    effector:SetKey(_TRACK_A, 4.2, -1.73973776274412);
    effector:SetKey(_TRACK_A, 5.88, -1.37225681206623);
    effector:SetKey(_TRACK_A, 6.96, -1.68404063994939);
    effector:SetKey(_TRACK_A, 7.96, -0.06843653655446);
    effector:SetKey(_TRACK_A, 9.84, -0.74422860217896);
    effector:SetKey(_TRACK_A, 11.92, -1.78338520274442);
    effector:SetKey(_TRACK_A, 14, -0.21124733423706);
    effector:SetKey(_TRACK_A, 14.96, -0.86203483853702);
    effector:SetKey(_TRACK_A, 16.08, -2.24526987402117);
    effector:SetKey(_TRACK_A, 16.96, -0.51019675301136);
    effector:SetKey(_TRACK_A, 17.88, -1.77799158775366);
    effector:SetKey(_TRACK_A, 18.68, -0.51019675301136);
    effector:SetKey(_TRACK_A, 19.72, -1.77799158775366);
    effector:SetKey(_TRACK_A, 22.28, -0.51019675301136);
    effector:SetKey(_TRACK_A, 23.2, -0.26795815580777);
    effector:SetKey(_TRACK_A, 24.76, -2.70840105814234);
    
    effector:Play();
    
    
    -- Layer violin
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/skripka.png");
    element:SetName("violin");
    composition:AddElement(element);
    element:SetHotSpot(30, 4.5);
    composition:RegisterParentInfo("violin", "torse");
    element:SetXY(18.5, 33.5);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 60);
    
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 0.8, 0.08688422187761);
    effector:SetKey(_TRACK_A, 1.96, 0.19123358954491);
    effector:SetKey(_TRACK_A, 3.28, 0.24549633354212);
    effector:SetKey(_TRACK_A, 4.88, 0.28532583565775);
    effector:SetKey(_TRACK_A, 6.96, 0.38949653679223);
    effector:SetKey(_TRACK_A, 9.84, 0.43257488777642);
    effector:SetKey(_TRACK_A, 11.92, 0.55824870278428);
    effector:SetKey(_TRACK_A, 16.08, 0.74880971532456);
    effector:SetKey(_TRACK_A, 18.08, 0.59879860597153);
    effector:SetKey(_TRACK_A, 19.96, 0.70874947908665);
    effector:SetKey(_TRACK_A, 22.28, 0.4704881295936);
    effector:SetKey(_TRACK_A, 23.2, 0.51496634403314);
    effector:SetKey(_TRACK_A, 24.76, 0.0526859267742);
    
    effector:Play();
    
    
    -- Layer forearm
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/forearm.png");
    element:SetName("forearm");
    composition:AddElement(element);
    element:SetHotSpot(4.5, 7);
    composition:RegisterParentInfo("forearm", "arm");
    element:SetXY(44.5, 16);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 60);
    
    effector:SetKey(_TRACK_A, 0, 0.09901163038148);
    effector:SetKey(_TRACK_A, 1.16, 0.65525426886935);
    effector:SetKey(_TRACK_A, 1.96, 0.28375834264085);
    effector:SetKey(_TRACK_A, 5.88, 0.46931498564616);
    effector:SetKey(_TRACK_A, 6.96, 0.25084083505504);
    effector:SetKey(_TRACK_A, 7.96, -0.51516253166237);
    effector:SetKey(_TRACK_A, 9.84, -0.25742297492015);
    effector:SetKey(_TRACK_A, 11.92, -0.17370824873546);
    effector:SetKey(_TRACK_A, 14, -0.54455454834528);
    effector:SetKey(_TRACK_A, 16.08, -0.38452918672901);
    effector:SetKey(_TRACK_A, 16.96, -0.59781836640302);
    effector:SetKey(_TRACK_A, 17.88, -0.0807073675803);
    effector:SetKey(_TRACK_A, 18.68, -0.59781836640302);
    effector:SetKey(_TRACK_A, 19.72, -0.0807073675803);
    effector:SetKey(_TRACK_A, 22.28, -0.59781836640302);
    effector:SetKey(_TRACK_A, 24.76, -1.22407986458966);
    
    effector:Play();
    
    
    -- Layer arm
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/Arm.png");
    element:SetName("arm");
    composition:AddElement(element);
    element:SetHotSpot(-0.5, 20.5);
    composition:RegisterParentInfo("arm", "torse");
    element:SetXY(82, 26);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 60);
    
    effector:SetKey(_TRACK_A, 0, -0.10238278462678);
    effector:SetKey(_TRACK_A, 0.8, 0.81678538587094);
    effector:SetKey(_TRACK_A, 1.16, 0.0819116775761);
    effector:SetKey(_TRACK_A, 1.96, 1.10164644792401);
    effector:SetKey(_TRACK_A, 3.28, 0.41221800192282);
    effector:SetKey(_TRACK_A, 4.2, 1.05799386221511);
    effector:SetKey(_TRACK_A, 5.88, 0.46794504202164);
    effector:SetKey(_TRACK_A, 6.96, 0.07537228054987);
    effector:SetKey(_TRACK_A, 7.96, 1.60553039383499);
    effector:SetKey(_TRACK_A, 9.84, 0.66039505943182);
    effector:SetKey(_TRACK_A, 11.92, 1.42350524570895);
    effector:SetKey(_TRACK_A, 14, 0.9678052799162);
    effector:SetKey(_TRACK_A, 16.08, 1.56793235096207);
    effector:SetKey(_TRACK_A, 16.96, 1.06866408898734);
    effector:SetKey(_TRACK_A, 17.88, 1.34710599956715);
    effector:SetKey(_TRACK_A, 18.68, 1.06866408898734);
    effector:SetKey(_TRACK_A, 19.72, 1.34710599956715);
    effector:SetKey(_TRACK_A, 22.28, 1.06866408898734);
    effector:SetKey(_TRACK_A, 24.76, 1.0592391574188);
    
    effector:Play();
    
    
    -- Layer torse
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/torse.png");
    element:SetName("torse");
    composition:AddElement(element);
    element:SetHotSpot(67.5, 98);
    composition:RegisterParentInfo("torse", "legs");
    element:SetXY(120.5, 11.5);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 60);
    
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 1.2, 0.08912329596978);
    effector:SetKey(_TRACK_A, 2.36, -0.12700788439866);
    effector:SetKey(_TRACK_A, 3.28, -0.02681050221256);
    effector:SetKey(_TRACK_A, 4.2, 0.09532227363039);
    effector:SetKey(_TRACK_A, 5.88, 0.1855982579577);
    effector:SetKey(_TRACK_A, 6.96, 0.23941455238623);
    effector:SetKey(_TRACK_A, 7.96, -0.31949337367166);
    effector:SetKey(_TRACK_A, 11.92, -0.19419897137155);
    effector:SetKey(_TRACK_A, 16.08, 0.29022949317736);
    effector:SetKey(_TRACK_A, 19.72, 0.19633598760511);
    effector:SetKey(_TRACK_A, 22.28, -0.07283150487303);
    effector:SetKey(_TRACK_A, 23.2, 0.09146356607378);
    effector:SetKey(_TRACK_A, 24.76, 0.31336099028475);
    effector:SetKey(_TRACK_A, 26.24, 0.33138954991829);
    
    effector:Play();
    
    
    -- Layer legs
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/ViolinPlayer/legs.png");
    element:SetName("legs");
    composition:AddElement(element);
    element:SetHotSpot(87, 174.5);
    element:SetParentElement(composition);
    element:SetXY(386.5, 379);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 60);
    
    effector:SetKey(_TRACK_A, 0, 0);
    effector:SetKey(_TRACK_A, 6.96, 0);
    effector:SetKey(_TRACK_A, 11.92, 0);
    
    effector:Play();
    
end

function BuildCemeteryDoorOpeningAnimation()

    local screen = play_field;

    cemetryDoorOpeningCompilation = CreateCompositionSequence();
    local composition = cemetryDoorOpeningCompilation;
    local compositionDuration = 14.9666666666667;

    composition:SetDuration(compositionDuration);
    composition:SetDestroysOnEnd(false);
    composition:AttachTo(screen);
    composition:SetZ(109);
    
    
    -- Layer CemeteryDoor_1
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/CemeteryDoor/cemetery5_1.png");
    element:SetName("CemeteryDoor_1");
    composition:AddElement(element);
    element:SetHotSpot(215, 187.5);
    element:SetParentElement(composition);
    element:SetXY(475, 439.5);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 3.46666666666667);
    
    effector:SetKey(_TRACK_O, 0.1, 1);
    effector:SetKey(_TRACK_O, 2.46666666666667, 1);
    effector:SetKey(_TRACK_O, 3.33333333333333, 0);
    
    effector:Play();
    
    
    -- Layer CemeteryDoor_2
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/CemeteryDoor/cemetery5_3.png");
    element:SetName("CemeteryDoor_2");
    composition:AddElement(element);
    element:SetHotSpot(215, 187.5);
    element:SetParentElement(composition);
    element:SetXY(475, 439.5);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(2.06666666666667, 5.53333333333333);
    
    effector:SetKey(_TRACK_O, 2.06666666666667, 0);
    effector:SetKey(_TRACK_O, 3, 1);
    effector:SetKey(_TRACK_O, 4.53333333333333, 1);
    effector:SetKey(_TRACK_O, 5.4, 0);
    
    effector:Play();
    
    
    -- Layer CemeteryDoor_3
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/CemeteryDoor/cemetery5_5.png");
    element:SetName("CemeteryDoor_3");
    composition:AddElement(element);
    element:SetHotSpot(215, 187.5);
    element:SetParentElement(composition);
    element:SetXY(475, 439.5);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(4.16666666666667, 7.63333333333333);
    
    effector:SetKey(_TRACK_O, 4.16666666666667, 0);
    effector:SetKey(_TRACK_O, 5.1, 1);
    effector:SetKey(_TRACK_O, 6.63333333333333, 1);
    effector:SetKey(_TRACK_O, 7.5, 0);
    
    effector:Play();
    
    
    -- Layer CemeteryDoor_4
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/CemeteryDoor/cemetery5_7.png");
    element:SetName("CemeteryDoor_4");
    composition:AddElement(element);
    element:SetHotSpot(215, 187.5);
    element:SetParentElement(composition);
    element:SetXY(475, 439.5);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(6.16666666666667, 9.63333333333333);
    
    effector:SetKey(_TRACK_O, 6.16666666666667, 0);
    effector:SetKey(_TRACK_O, 7.1, 1);
    effector:SetKey(_TRACK_O, 8.63333333333333, 1);
    effector:SetKey(_TRACK_O, 9.5, 0);
    
    effector:Play();
    
    
    -- Layer CemeteryDoor_5
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/CemeteryDoor/cemetery5_9.png");
    element:SetName("CemeteryDoor_5");
    composition:AddElement(element);
    element:SetHotSpot(215, 187.5);
    element:SetParentElement(composition);
    element:SetXY(475, 439.5);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(8.2, 11.6666666666667);
    
    effector:SetKey(_TRACK_O, 8.2, 0);
    effector:SetKey(_TRACK_O, 9.13333333333333, 1);
    effector:SetKey(_TRACK_O, 10.6666666666667, 1);
    effector:SetKey(_TRACK_O, 11.5333333333333, 0);
    
    effector:Play();
    
    
    -- Layer CemeteryDoor_6
    local element = CreateCompositionElement("data/Texture/Scenes/07_Cemetery/Zone_Main/Animations/CemeteryDoor/cemetery5_10.png");
    element:SetName("CemeteryDoor_6");
    composition:AddElement(element);
    element:SetHotSpot(215, 187.5);
    element:SetParentElement(composition);
    element:SetXY(475, 439.5);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(10.2666666666667, 15);
    
    effector:SetKey(_TRACK_O, 10.2666666666667, 0);
    effector:SetKey(_TRACK_O, 11.2, 1);
    effector:SetKey(_TRACK_O, 12.7333333333333, 1);
    
    effector:Play();
    
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_Main/Layers/BG_Cemetery.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Cemetery',anim,512,384,40,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_ho',anim,495,424,100,5,35,30)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_grave',anim,537,374,90,0,20,20)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_street',anim,342,690,100,0,100,20)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_Main/Zoom_Monument/BG_Zoom_Violin.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('BG_Zoom_Violin',anim,512,384,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_Main/Zoom_Monument/rust_1.png',0,0,145,167,1,0)
	anim:SetHotSpot(72,83)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('rust_1',anim,325,357,201,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_Main/Zoom_Monument/rust_2.png',0,0,170,164,1,0)
	anim:SetHotSpot(85,82)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('rust_2',anim,521,269,201,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/07_Cemetery/Zone_Main/Zoom_Monument/rust_3.png',0,0,86,121,1,0)
	anim:SetHotSpot(43,60)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('rust_3',anim,659,498,201,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(2,2)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_monument',anim,784,390,120,0,18.5,50)
	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,231,398,150,25,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
