local give_coin_comics;

function OnGivenCoin()
    
    if not HasGameState('ActionCompleted', game_state.scene_path..'Gorilla_shown') then
        TimerDoString("ShowGorilla();", 2, play_field:GetTimer());
    end
    
    RegisterActiveObject('area_carriage',
                            function(obj_name)
                                local door_anim = play_field:GetObject('door_animation'):GetAnimation();
                                local anim_time = GetAnimationLength(door_anim);
                                
                                play_field:GetObject('area_carriage'):SetVisible(false);
                                door_anim:SetMode(HGEANIM_FWD + HGEANIM_NOLOOP);
                                door_anim:Play();
                                
                                local light = play_field:GetObject('light_from_carriage');
                                local light_effector = CreateAnimationEffector();
                                
                                light_effector:AttachTo( light )
                                light_effector:SetMode(HGEANIM_FWD + HGEANIM_NOLOOP);
                                light_effector:SetKey(_TRACK_O, 0.0,       light:GetOpacity());
                                light_effector:SetKey(_TRACK_O, anim_time, 1.0);
                                light_effector:Play();
                                
                                PlaySound('03_OpenCarriageDoor');
                                
                                AddGameState('ActionCompleted', '03_CarriageDoorOpened');
                                
                                TimerDoString('OnDoorOpen()', anim_time, play_field:GetTimer());
                            end,
                            
                            function(obj_name)
                                play_field:GetObject('area_carriage'):SetVisible(false);
                                play_field:GetObject('door_animation'):GetAnimation():SetFrame( play_field:GetObject('door_animation'):GetAnimation():GetFrames() - 1 );
                                play_field:GetObject('light_from_carriage'):SetOpacity(1.0);
                                
                                OnDoorOpen();
                            end
                        );
end

function ShowGorilla()
    local obj = play_field:GetObject('Gorilla_anim');
    
    obj:SetVisible(true);
    obj:GetAnimation():Play();
    
    PlaySound('02_Horror');
    
    TimerDoString("OnGorillaShown();", GetAnimationLength(obj:GetAnimation()), play_field:GetTimer());
end

function OnGorillaShown()
    if not HasGameState('ActionCompleted', game_state.scene_path..'Gorilla_shown') then 
        AddGameState('ActionCompleted', game_state.scene_path..'Gorilla_shown')
    end
    
    play_field:GetObject('Gorilla_anim'):SetVisible(false);
end

function OnDoorOpen()
     play_field:GetObject('area_ho'):SetVisible(true);
     
     LinkScene( 'area_ho',
                'CursorUpLeft',
                'data/Scenes/03_Dupens_House_Exit_Carriage_HO.lua',
                true,
                nil,
                nil,
                nil);
end

function ShowGatherMapArea()
    play_field:GetObject('area_gather_map'):SetVisible(true);
    
    LinkScene(  'area_gather_map',
                'CursorGlass',
                'data/Scenes/Minigames/04_puzzle.lua',
                false);
end

function OnSceneLoad(screen)
    LoadData(screen)
    DefaultOnSceneLoad('data/Scenes/03_Dupens_House_Exit_Carriage.lua', 'quest', 'data/Scenes/03_Dupens_House_Exit_Main.lua')
    
    CreateAmbient(screen);
    CreateLeafes(screen, 104);
    
    StopMusic("03_InterNoise", false);
    PlayAmbientMusic("03_InterNoise", true);
    
    play_field:GetObject('door_animation' ):GetAnimation():Stop();
    play_field:GetObject('area_gather_map'):SetVisible(false);
    play_field:GetObject('area_ho'        ):SetVisible(false);
    play_field:GetObject('light_from_carriage'):SetOpacity(0.0);
    play_field:GetObject('body'               ):SetOpacity(0.0);
    play_field:GetObject('head2'              ):SetOpacity(0.0);
    play_field:GetObject('HandWithCoin'       ):SetOpacity(0.0);
    
    play_field:GetObject('Gorilla_anim'):GetAnimation():SetMode(HGEANIM_FWD + HGEANIM_NOLOOP);
    play_field:GetObject('Gorilla_anim'):GetAnimation():Stop();
    play_field:GetObject('Gorilla_anim'):SetVisible(false);
    
    if not HasGameState('ToolFound', '03_screwdriver') then
        play_field:GetObject('Layer_map_puzzle'):SetVisible(false);
    end
    
    give_coin_comics = CreateComics('03_GiveCoin', CreateComicsFrame('Coachman', 'C_03_COACHMAN_MONET'))
    
    if give_coin_comics then
        give_coin_comics.SetVisible(true)
    end
    
    RegisterToolApplyInfo('02_coin', 'area_coachman', nil, nil,
                                                        function(tool_name)
                                                            play_field:GetObject('area_coachman'):SetVisible(false);
                                                            
                                                            give_coin_comics2 = CreateComics('03_GiveCoin2', CreateComicsFrame('Coachman', 'C_03_GIVE_COIN', 'HandWithCoin'))
                                                            
                                                            if give_coin_comics2 then
                                                                give_coin_comics2.on_finish = function()
                                                                    play_field:GetObject('Coachman'):ChangeOpacity(1.0, 0.0, ZOOM_ZONE_APPEARING_TIME);
                                                                    
                                                                    AddNoteToNotebook('STAGECOACH');
                                                                    
                                                                    OnGivenCoin();
                                                                end
                                                                
                                                                give_coin_comics2.SetVisible(true)
                                                            end
                                                        end,
                                                        
                                                        function(tool_name)
                                                            play_field:GetObject('area_coachman'):SetVisible(false);
                                                            
                                                            give_coin_comics2 = CreateComics('03_GiveCoin2', CreateComicsFrame('Coachman', 'C_03_GIVE_COIN', 'HandWithCoin'))
                                                            
                                                            if give_coin_comics2 then
                                                                give_coin_comics2.on_finish = function()
                                                                    play_field:GetObject('Coachman'):ChangeOpacity(1.0, 0.0, ZOOM_ZONE_APPEARING_TIME);
                                                                    OnGivenCoin()
                                                                end
                                                                
                                                                give_coin_comics2.SetVisible(true)
                                                            else
                                                                play_field:GetObject('Coachman'):SetOpacity(0);
                                                                OnGivenCoin()
                                                            end
                                                        end,
                                                        function(tool_name, target_name)
                                                            if not game_state.comics then
                                                                ShowMonolog('C_03_NEED_COIN', 'C_03_NEED_COIN');
                                                            end
                                                        end);
    
    game_state.ho_completed             = HasGameState('ClosedScene', 'data/Scenes/03_Dupens_House_Exit_Carriage_HO.lua');
    game_state.gather_map_dialog_shown  = HasGameState('ComicsShown', '03_gather_map');
    
    if game_state.gather_map_dialog_shown then
        ShowGatherMapArea();
    end
    
    PlayAnimationPeriodicallyVsDelay('Moth_anim', 15);
end

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

function OnUpdate(dt)
    
    if not game_state.gather_map_dialog_shown
        and game_state.ho_completed
        and game_state.fly_tools:GetNReferences() == 0
        and game_state.locker:GetNReferences() == 0
    then
        game_state.gather_map_dialog_shown = true;
        
        local map_comics = CreateComics('03_gather_map', CreateComicsFrame('Dupen', 'C_03_GATHER_MAP', 'body', 'head2'));
        
        map_comics.on_finish = function()
            ShowGatherMapArea();
        end
        
        if map_comics then
            map_comics.SetVisible(true)
        end
    end
    
    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)
end

function OnSceneDestroy(playfield)
    DefaultOnSceneDestroy(playfield)
end

function CreateAmbient(screen)
    local composition = CreateCompositionSequence();
    local compositionDuration = 10.08;
    composition:SetDuration(compositionDuration);
    composition:AttachTo(screen);
    composition:SetZ(100);
    composition:SetCyclic(true);
    
    -- Layer BG_13
    local element = CreateCompositionElement("data/Texture/Scenes/03_Dupens_House_Exit/Zone_carriage/Layers/01_zoom_carriage.png");
    element:SetName("BG_13");
    composition:AddElement(element);
    element:SetHotSpot(512, 384);
    element:SetParentElement(composition);
    element:SetXY(512, 384);
    
    element:SetScaleX(1);
    element:SetScaleY(1);
    element:SetAngle(0);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 120);
    
    
    effector:Play();
    
    
    -- Layer Flash_14
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/lighting_04.png");
    element:SetName("Flash_14");
    composition:AddElement(element);
    element:SetHotSpot(171, 167.5);
    element:SetParentElement(composition);
    element:SetXY(243.704162597656, 144.203598022461);
    
    element:SetScaleX(1.29741272783392);
    element:SetScaleY(1.29741272783392);
    element:SetAngle(-0.51257387658254);
    
    effector = element:GetEffector();
    effector:SetLifeTime(6.32, 6.64);
    
    effector:SetKey(_TRACK_O, 6.32, 0);
    effector:SetKey(_TRACK_O, 6.4, 1);
    effector:SetKey(_TRACK_O, 6.6, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_lighting_15
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2_lighting.png");
    element:SetName("Cloud_lighting_15");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetXY(123.17741394043, 113.50944519043);
    
    element:SetScaleX(0.30568677507076);
    element:SetScaleY(0.30568677507076);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(6.32, 6.72);
    
    effector:SetKey(_TRACK_O, 6.32, 0);
    effector:SetKey(_TRACK_O, 6.4, 1);
    effector:SetKey(_TRACK_O, 6.68, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_16
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud1.png");
    element:SetName("Cloud_16");
    composition:AddElement(element);
    element:SetHotSpot(790, 383);
    element:SetParentElement(composition);
    element:SetScaleX(0.57202193746264);
    element:SetScaleY(0.57202193746264);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(5.04, 10.08);
    
    effector:SetKey(_TRACK_X, 5.04, 226.898170936747);
    effector:SetKey(_TRACK_Y, 5.04, 349);
    effector:SetKey(_TRACK_X, 10.04, 316.590203410257);
    effector:SetKey(_TRACK_Y, 10.04, 349);
    effector:SetKey(_TRACK_X, 15.08, 407);
    effector:SetKey(_TRACK_Y, 15.08, 349);
    effector:SetKey(_TRACK_O, 5.04, 0);
    effector:SetKey(_TRACK_O, 10.04, 1);
    effector:SetKey(_TRACK_O, 15.08, 0);
    
    effector:Play();
    
    
    -- Layer Flash_17
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/lighting_04.png");
    element:SetName("Flash_17");
    composition:AddElement(element);
    element:SetHotSpot(171, 167.5);
    element:SetParentElement(composition);
    element:SetXY(580.272689819336, 179.289901733398);
    
    element:SetScaleX(-1.18903573554844);
    element:SetScaleY(1.29741272783392);
    element:SetAngle(-0.27824904979082);
    
    effector = element:GetEffector();
    effector:SetLifeTime(7.2, 7.52);
    
    effector:SetKey(_TRACK_O, 7.2, 0);
    effector:SetKey(_TRACK_O, 7.28, 1);
    effector:SetKey(_TRACK_O, 7.48, 0);
    
    effector:Play();
    
    
    -- Layer Flash_18
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/lighting_04.png");
    element:SetName("Flash_18");
    composition:AddElement(element);
    element:SetHotSpot(171, 167.5);
    element:SetParentElement(composition);
    element:SetXY(498.404678344727, 172.792434692383);
    
    element:SetScaleX(-1.18903573554844);
    element:SetScaleY(1.29741272783392);
    element:SetAngle(0.19982876324502);
    
    effector = element:GetEffector();
    effector:SetLifeTime(7.12, 7.44);
    
    effector:SetKey(_TRACK_O, 7.12, 0);
    effector:SetKey(_TRACK_O, 7.2, 1);
    effector:SetKey(_TRACK_O, 7.4, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_19
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud1.png");
    element:SetName("Cloud_19");
    composition:AddElement(element);
    element:SetHotSpot(790, 383);
    element:SetParentElement(composition);
    element:SetScaleX(0.57202193746264);
    element:SetScaleY(0.57202193746264);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 5.08);
    
    effector:SetKey(_TRACK_X, 0, 316.5905);
    effector:SetKey(_TRACK_Y, 0, 349);
    effector:SetKey(_TRACK_X, 5.04, 407);
    effector:SetKey(_TRACK_Y, 5.04, 349);
    effector:SetKey(_TRACK_O, 0, 1);
    effector:SetKey(_TRACK_O, 5.04, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_20
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud1.png");
    element:SetName("Cloud_20");
    composition:AddElement(element);
    element:SetHotSpot(790, 383);
    element:SetParentElement(composition);
    element:SetScaleX(0.57202193746264);
    element:SetScaleY(0.57202193746264);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 10.08);
    
    effector:SetKey(_TRACK_X, 0, 226.898170936747);
    effector:SetKey(_TRACK_Y, 0, 349);
    effector:SetKey(_TRACK_X, 10.04, 407);
    effector:SetKey(_TRACK_Y, 10.04, 349);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 5, 1);
    effector:SetKey(_TRACK_O, 10.04, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_21
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2.png");
    element:SetName("Cloud_21");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetScaleX(0.32257345571483);
    element:SetScaleY(0.32257345571483);
    element:SetAngle(-0.00280331340704);
    
    effector = element:GetEffector();
    effector:SetLifeTime(5.04, 10.08);
    
    effector:SetKey(_TRACK_X, 5.04, 465.345000431401);
    effector:SetKey(_TRACK_Y, 5.04, 186.720094598897);
    effector:SetKey(_TRACK_X, 10.04, 489.245725404883);
    effector:SetKey(_TRACK_Y, 10.04, 186.720094598897);
    effector:SetKey(_TRACK_X, 15.08, 513.345000431401);
    effector:SetKey(_TRACK_Y, 15.08, 186.720094598897);
    effector:SetKey(_TRACK_O, 5.04, 0);
    effector:SetKey(_TRACK_O, 10.04, 1);
    effector:SetKey(_TRACK_O, 15.08, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_22
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2.png");
    element:SetName("Cloud_22");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetScaleX(0.32257345571483);
    element:SetScaleY(0.32257345571483);
    element:SetAngle(-0.00280331340704);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 5.08);
    
    effector:SetKey(_TRACK_X, 0, 489.2457);
    effector:SetKey(_TRACK_Y, 0, 186.720094598897);
    effector:SetKey(_TRACK_X, 5.04, 513.345000431401);
    effector:SetKey(_TRACK_Y, 5.04, 186.720094598897);
    effector:SetKey(_TRACK_O, 0, 1);
    effector:SetKey(_TRACK_O, 5.04, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_23
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2.png");
    element:SetName("Cloud_23");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetScaleX(0.32257345571483);
    element:SetScaleY(0.32257345571483);
    element:SetAngle(-0.00280331340704);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 10.08);
    
    effector:SetKey(_TRACK_X, 0, 465.345000431401);
    effector:SetKey(_TRACK_Y, 0, 186.720094598897);
    effector:SetKey(_TRACK_X, 10.04, 513.345000431401);
    effector:SetKey(_TRACK_Y, 10.04, 186.720094598897);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 5, 1);
    effector:SetKey(_TRACK_O, 10.04, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_24
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2.png");
    element:SetName("Cloud_24");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetScaleX(0.458);
    element:SetScaleY(0.458);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(5, 10.08);
    
    effector:SetKey(_TRACK_X, 5, 378.396598568038);
    effector:SetKey(_TRACK_Y, 5, 159);
    effector:SetKey(_TRACK_X, 10.04, 430.404585540787);
    effector:SetKey(_TRACK_Y, 10.04, 159);
    effector:SetKey(_TRACK_X, 15.04, 482);
    effector:SetKey(_TRACK_Y, 15.04, 159);
    effector:SetKey(_TRACK_O, 5, 0);
    effector:SetKey(_TRACK_O, 10, 1);
    effector:SetKey(_TRACK_O, 15.04, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_lighting_25
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2_lighting.png");
    element:SetName("Cloud_lighting_25");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetXY(692.901, 121.3064);
    
    element:SetScaleX(-0.34795789498);
    element:SetScaleY(0.30568677507076);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(7.12, 7.52);
    
    effector:SetKey(_TRACK_O, 7.12, 0);
    effector:SetKey(_TRACK_O, 7.2, 1);
    effector:SetKey(_TRACK_O, 7.48, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_26
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2.png");
    element:SetName("Cloud_26");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetScaleX(0.458);
    element:SetScaleY(0.458);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 5.04);
    
    effector:SetKey(_TRACK_X, 0, 430.4046);
    effector:SetKey(_TRACK_Y, 0, 159);
    effector:SetKey(_TRACK_X, 5, 482);
    effector:SetKey(_TRACK_Y, 5, 159);
    effector:SetKey(_TRACK_O, 0, 1);
    effector:SetKey(_TRACK_O, 5, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_27
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2.png");
    element:SetName("Cloud_27");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetScaleX(0.458);
    element:SetScaleY(0.458);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 10.08);
    
    effector:SetKey(_TRACK_X, 0, 378.396598568038);
    effector:SetKey(_TRACK_Y, 0, 159);
    effector:SetKey(_TRACK_X, 10.04, 482);
    effector:SetKey(_TRACK_Y, 10.04, 159);
    effector:SetKey(_TRACK_O, 0, 0);
    effector:SetKey(_TRACK_O, 5, 1);
    effector:SetKey(_TRACK_O, 10.04, 0);
    
    effector:Play();
    
    
    -- Layer Moon_28
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/moon.png");
    element:SetName("Moon_28");
    composition:AddElement(element);
    element:SetHotSpot(315, 315);
    element:SetParentElement(composition);
    element:SetXY(548.038879394531, 106.673873901367);
    
    element:SetScaleX(0.17398608111351);
    element:SetScaleY(0.17398608111351);
    element:SetAngle(0);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 10.08);
    
    
    effector:Play();
    
    
    -- Layer Cloud_lighting_29
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2_lighting.png");
    element:SetName("Cloud_lighting_29");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetXY(533.975372314453, 163.548248291016);
    
    element:SetScaleX(0.34303901437372);
    element:SetScaleY(0.34303901437372);
    element:SetAngle(3.02273472661388);
    
    effector = element:GetEffector();
    effector:SetLifeTime(14.52, 14.530101010101);
    
    effector:SetKey(_TRACK_O, 14.52, 0);
    effector:SetKey(_TRACK_O, 14.6, 1);
    effector:SetKey(_TRACK_O, 14.88, 0);
    
    effector:Play();
    
    
    -- Layer Back_30
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/back1.jpg");
    element:SetName("Back_30");
    composition:AddElement(element);
    element:SetHotSpot(654, 412.5);
    element:SetParentElement(composition);
    element:SetScaleX(0.93251968503937);
    element:SetScaleY(0.84251968503937);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 5.2);
    
    effector:SetKey(_TRACK_X, 0, 480.7443);
    effector:SetKey(_TRACK_Y, 0, 326.155789555475);
    effector:SetKey(_TRACK_X, 5.16, 521.851642518532);
    effector:SetKey(_TRACK_Y, 5.16, 326.155789555475);
    effector:SetKey(_TRACK_O, 0, 1);
    effector:SetKey(_TRACK_O, 5.16, 0);
    
    effector:Play();
    
    
    -- Layer Back_31
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/back1.jpg");
    element:SetName("Back_31");
    composition:AddElement(element);
    element:SetHotSpot(654, 412.5);
    element:SetParentElement(composition);
    element:SetScaleX(0.93251968503937);
    element:SetScaleY(0.84251968503937);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(5.16, 15.24);
    
    effector:SetKey(_TRACK_X, 5.16, 441.851642518532);
    effector:SetKey(_TRACK_Y, 5.16, 326.155789555475);
    effector:SetKey(_TRACK_X, 10.04, 480.744327573196);
    effector:SetKey(_TRACK_Y, 10.04, 326.155789555475);
    effector:SetKey(_TRACK_X, 15.2, 521.851642518532);
    effector:SetKey(_TRACK_Y, 15.2, 326.155789555475);
    effector:SetKey(_TRACK_O, 5.16, 0);
    effector:SetKey(_TRACK_O, 10.04, 1);
    effector:SetKey(_TRACK_O, 15.2, 0);
    
    effector:Play();
    
    
    -- Layer Back_32
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/back1.jpg");
    element:SetName("Back_32");
    composition:AddElement(element);
    element:SetHotSpot(654, 412.5);
    element:SetParentElement(composition);
    element:SetScaleX(0.93251968503937);
    element:SetScaleY(0.84251968503937);
    element:SetAngle(0);
    element:SetOpacity(1);
    
    effector = element:GetEffector();
    effector:SetLifeTime(0, 10.08);
    
    effector:SetKey(_TRACK_X, 0, 441.851642518532);
    effector:SetKey(_TRACK_Y, 0, 326.155789555475);
    effector:SetKey(_TRACK_X, 10.04, 521.851642518532);
    effector:SetKey(_TRACK_Y, 10.04, 326.155789555475);
    
    effector:Play();
    
    
    -- Layer Cloud_lighting_33
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2_lighting.png");
    element:SetName("Cloud_lighting_33");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetXY(186, 298);
    
    element:SetScaleX(1.03);
    element:SetScaleY(1.03);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(7.56, 7.96);
    
    effector:SetKey(_TRACK_O, 7.56, 0);
    effector:SetKey(_TRACK_O, 7.64, 1);
    effector:SetKey(_TRACK_O, 7.92, 0);
    
    effector:Play();
    
    
    -- Layer Flash_34
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/lighting_04.png");
    element:SetName("Flash_34");
    composition:AddElement(element);
    element:SetHotSpot(171, 167.5);
    element:SetParentElement(composition);
    element:SetXY(701.240219116211, 386.628311157227);
    
    element:SetScaleX(1.6904287596923);
    element:SetScaleY(1.6904287596923);
    element:SetAngle(1.13863919750427);
    
    effector = element:GetEffector();
    effector:SetLifeTime(7.8, 8.12);
    
    effector:SetKey(_TRACK_O, 7.8, 0);
    effector:SetKey(_TRACK_O, 7.88, 1);
    effector:SetKey(_TRACK_O, 8.08, 0);
    
    effector:Play();
    
    
    -- Layer Cloud_lighting_35
    local element = CreateCompositionElement("data/Texture/Scenes/Common/Ambient/cloud2_lighting.png");
    element:SetName("Cloud_lighting_35");
    composition:AddElement(element);
    element:SetHotSpot(1000, 444);
    element:SetParentElement(composition);
    element:SetXY(898, 224);
    
    element:SetScaleX(1.03);
    element:SetScaleY(1.03);
    element:SetAngle(0);
    
    effector = element:GetEffector();
    effector:SetLifeTime(7.8, 8.2);
    
    effector:SetKey(_TRACK_O, 7.8, 0);
    effector:SetKey(_TRACK_O, 7.88, 1);
    effector:SetKey(_TRACK_O, 8.16, 0);
    
    effector:Play();
    
    composition: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/Common/area.png',0,0,8,8,1,0)
	anim:SetHotSpot(0,0)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('Background',anim,0,0,99,0,128,96)
	local anim = CreateAnimation('data/Texture/Scenes/03_Dupens_House_Exit/Zone_carriage/Layers/light_from_carriage.png',0,0,243,98,1,0)
	anim:SetHotSpot(121,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('light_from_carriage',anim,621,686,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Dupens_House_Exit/Zone_carriage/Animations/door_animation.png',0,0,204,359,5,7)
	anim:SetHotSpot(102,179)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('door_animation',anim,565,338,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Characters/Coachman/Coachman.png',0,0,558,1040,1,0)
	anim:SetHotSpot(279,520)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Coachman',anim,289,518,105,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_carriage',anim,519,333,110,0,17,42)
	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,516,335,110,0,10,40)
	local anim = CreateAnimation('data/Texture/Characters/Dupen/body.png',0,0,376,520,1,0)
	anim:SetHotSpot(188,260)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('body',anim,273,508,107,0,1,1)
	local anim = CreateAnimation('data/Texture/Characters/Dupen/head2.png',0,0,214,252,1,0)
	anim:SetHotSpot(107,126)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('head2',anim,303,200,108,0,1,1)
	local anim = CreateAnimation('data/Texture/Characters/Coachman/HandWithCoin.png',0,0,138,293,1,0)
	anim:SetHotSpot(69,146)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('HandWithCoin',anim,462,510,106,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_coachman',anim,291,320,111,0,50,70)
	local anim = CreateAnimation('data/Texture/Scenes/05_Gendarmery/Zone_wart/Animations/fly_anim.png',0,0,217,217,8,10)
	anim:SetHotSpot(108,108)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fly_anim',anim,769,159,101,0,0.3,0.3)
	local anim = CreateAnimation('data/Texture/Scenes/05_Gendarmery/Zone_wart/Animations/fly_anim.png',0,0,217,217,8,7)
	anim:SetHotSpot(108,108)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('fly_anim_2',anim,926,164,101,0,0.3,0.3)
	local anim = CreateAnimation('data/Texture/Scenes/12_Restaurant_Kitchen/Zone_HO/Animations/Moth_anim.png',0,0,185,196,56,12)
	anim:SetHotSpot(93,98)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Moth_anim',anim,961,252,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Dupens_House_Exit/Zone_carriage/Animations/Gorilla_anim.png',0,0,298,349,9,12)
	anim:SetHotSpot(149,174)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Gorilla_anim',anim,149,441,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/03_Dupens_House_Exit/Zone_carriage/Layers/Layer_map_puzzle.png',0,0,154,192,1,0)
	anim:SetHotSpot(77,96)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Layer_map_puzzle',anim,545,591,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/area_circle.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	screen:CreateObject('area_gather_map',anim,543,556,111,-14,1.04,1.19)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
