function CreateChapter(f)
    local characters = {
        f.Character("Sherlock", "s01c03_character_Sherlock_name"),
        f.Character("Swifty", "s01c03_character_Swifty_name"),
        f.Character("Lestrade", "s01c03_character_Lestrade_name"),
        f.Character("Timmy", "s01c03_character_Timmy_name"),
        f.Character("Wise", "s01c03_character_Wise_name"),
        f.Character("Pennyworth", "s01c03_character_Pennyworth_name")
    }
    local locations = {
        f.Location("0005_Whitechapel", {"Assets/Scenes/Locations/s01c03/0005_Whitechapel.unity"}),
        f.Location("0006_WhitechapelPoliceStation", {"Assets/Scenes/Locations/s01c03/0006_WhitechapelPoliceStation.unity"})
    }

    local points = {
        f.KeyPointPage(1, "s01c03_key_point_1", {1}),
        f.KeyPointPage(2, "s01c03_key_point_2", {5}),
        f.KeyPointPage(3, "s01c03_key_point_3", {7}),
        f.KeyPointPage(4, "s01c03_key_point_4", {10}),
        f.KeyPointPage(5, "s01c03_key_point_5", {16}),
        f.KeyPointPage(6, "s01c03_key_point_6", {17})
    }

    local newspaper = f.Newspaper("Hamster", "s01c03_newspaper_title", "s01c03_newspaper_article", "s01c03_newspaper_author")
    return f.Chapter(1, 3, "s01c03_chapter_title", characters, locations, points, newspaper)
end

function CreateInvestigation(f)
    local missions = {
        f.Mission(1, "s01c03_mission_1", {0}, {f.SimpleAction()}, 1),
        f.Mission(2, "s01c03_mission_2", {1}, {f.SimpleAction()}, 1),
        f.Mission(3, "s01c03_mission_3", {2}, {f.SimpleAction()}, 1),
        f.Mission(4, "s01c03_mission_4", {2}, {f.SimpleAction()}, 1),
        f.Mission(5, "s01c03_mission_5", {2}, {f.SimpleAction()}, 1),
        f.Mission(6, "s01c03_mission_6", {4, 5}, {f.SimpleAction()}, 2),
        f.Mission(7, "s01c03_mission_7", {6}, {f.SimpleAction()}, 1),
        f.Mission(8, "s01c03_mission_8", {3, 7}, {f.SimpleAction()}, 1),
        f.Mission(9, "s01c03_mission_9", {7}, {f.ActionWithTimer(600, "s01c03_mission_9_0_motivation")}, 1),
        f.Mission(10, "s01c03_mission_10", {9, 8}, {f.SimpleAction()}, 1),
        f.Mission(11, "s01c03_mission_11", {10}, {f.SimpleAction()}, 1),
        f.Mission(12, "s01c03_mission_12", {11}, {f.SimpleAction()}, 1),
        f.Mission(13, "s01c03_mission_13", {12}, {f.ActionWithTimer(600, "s01c03_mission_13_0_motivation")}, 1),
        f.Mission(14, "s01c03_mission_14", {12}, {f.SimpleAction()}, 1),
        f.Mission(15, "s01c03_mission_15", {13, 14}, {f.SimpleAction()}, 2),
        f.Mission(16, "s01c03_mission_16", {15}, {f.SimpleAction()}, 1),
        f.Mission(17, "s01c03_mission_17", {16}, {f.SimpleAction()}, 1)
    }

    return f.Investigation(4, missions)
end

function PrepareLocation()
    SetupLocation(function()
        SetupAnim('Wise', 'TalkAggressivelyLong')
        ApplyAnim('Wise')
        SetupAnim('Lestrade', 'TalkRampandLong')
        ApplyAnim('Lestrade')
        ZoomCamera(1.5, 0);
    end)
    ChangeLocation('0005_Whitechapel')
end

function StartInvestigation()
    ShowLocationCaption('s01c03_location_0_caption', 's01c03_location_0_time')
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_0_1')
        MoveCamera('camera_point_0_0', 2.8, 1)
    end)
    StartDialog()
    Say('Sherlock', 'Interested', 's01c03_Sherlock_start_investigation_phrase_0')
    Say('Sherlock', 'Interested', 's01c03_Sherlock_start_investigation_phrase_1')
    EndDialog()
    
    Parallel(function()
        StartDialog()
        Say('Sherlock', 'Enchanted', 's01c03_Sherlock_start_investigation_phrase_2')
        EndDialog()
        MoveCamera('camera_point_0_1', 0.5)
    end)
    ShowChapterTitle()
end

function ApplyMission1Action0()

    CameraTo('camera_point_0_1', 1, 1)

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_1_0')
        MoveCamera('camera_point_1_0', 1)
    end)

    -- [Вайс и Лестрейд разговаривают. Шерлок подходит поближе, но в разговор не вмешивается]
    ResetAnim('Wise')
    ResetAnim('Lestrade')
    SetupAnim('Wise', 'TalkAggressively')
    MoveCamera('camera_point_1_0_1', 1, 1.5)
        
    StartDialog()
    Say('Wise', 'Arrogantly', 's01c03_Wise_mission_1_0_phrase_0', 'Lestrade', nil, 'Restrained')
    SetupAnim('Wise', 'PokeFinger', {notLoop=true})
    Say('Wise', 'Rampant', 's01c03_Wise_mission_1_0_phrase_1','Lestrade', nil, 'Restrained')
    SetupAnim('Lestrade', 'TalkDissatisfied', {notLoop=true})
    Say('Lestrade', 'Restrained', 's01c03_Lestrade_mission_1_0_phrase_2')
    SetupAnim('Wise', 'TalkGrin', {notLoop=true})
    Say('Wise', 'Grin', 's01c03_Wise_mission_1_0_phrase_3')
    EndDialog()
    
    -- [Анимация: Вайс протягивает Лестрейду бумагу]
    Parallel(function()
        Play('Wise', 'ShowPapers')
        Sequence(function()
            Delay(0.8)
            Play('Lestrade', 'ReactOnPaper')
        end)
    end)
    
    StartDialog()
    SetupAnim('Lestrade', 'TalkGuiltily', {notLoop=true})
    Say('Lestrade', 'Guiltily', 's01c03_Lestrade_mission_1_0_phrase_4')

    Say('Lestrade', 'Restrained', 's01c03_Lestrade_mission_1_0_phrase_5')
    ActionCompleted()

    SetupAnim('Wise', 'IdleArrogantly')
    Say('Wise', 'Arrogantly', 's01c03_Wise_mission_1_0_phrase_6')
    ResetAnim('Wise')
    EndDialog()
    
    -- [Вайс отходит к стеночке, Лестрейд отходит на другую сторону улицы]
    Parallel(function()
        MoveCamera('camera_point_1_0', 1, 1)
        Sequence(function()
            Delay(0.7)
            --Walk('Wise', 'Wise_point_1_0_1')
            Walk('Wise', 'Wise_point_1_0')
            Play('Wise', 'Lean')
            SetupAnim('Wise', 'MajecticIdle')
            ApplyAnim('Wise')
        end)
        Sequence(function()
            Walk('Lestrade', 'Lestrade_point_1_0_1')
            Walk('Lestrade', 'Lestrade_point_1_0')
        end)
    end)
end

function ApplyMission2Action0()

    --CameraTo('camera_point_1_0', 1, 1.5);

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_2_0')
        CameraTo('camera_point_2_0', 1, 1.5)
    end)

    StartDialog()
    -- [Шерлок подходит к Лестрейду]
    Say('Sherlock', 'Politely', 's01c03_Sherlock_mission_2_0_phrase_0', 'Lestrade', nil, 'Restrained')

    SetupAnim('Lestrade', 'TalkUpset')
    Say('Lestrade', 'Upset', 's01c03_Lestrade_mission_2_0_phrase_1')
    ResetAnim('Lestrade')

    Say('Sherlock', 'Politely', 's01c03_Sherlock_mission_2_0_phrase_2')
    Say('Lestrade', 'Restrained', 's01c03_Lestrade_mission_2_0_phrase_3')
    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_2_0_phrase_4')
    Say('Lestrade', 'Sad', 's01c03_Lestrade_mission_2_0_phrase_5')

    SetupAnim('Lestrade', 'TalkRampant', {notLoop=true})
    Say('Lestrade', 'Wrathfully', 's01c03_Lestrade_mission_2_0_phrase_6')

    SetupAnim('Lestrade', 'TalkGuiltily', {notLoop=true})
    Say('Lestrade', 'Guiltily', 's01c03_Lestrade_mission_2_0_phrase_7')

    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_2_0_phrase_8')
    Say('Sherlock', 'Confidently', 's01c03_Sherlock_mission_2_0_phrase_9')
    Say('Lestrade', 'Restrained', 's01c03_Lestrade_mission_2_0_phrase_10')
    ActionCompleted()
    Say('Sherlock', 'Crafty', 's01c03_Sherlock_mission_2_0_phrase_11')
    EndDialog()
    
    -- [Шерлок отходит на свободное пространство]
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_2_1')
        MoveCamera('camera_point_1_0', .5, 1)
    end)
end

function ApplyMission3Action0()

    --CameraTo('Sherlock', 1, 1)

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_3_1')
        CameraTo('camera_point_3_0_1', 1, 1)
    end)
    ZoomCamera(1.5, 0.9)
    -- [Шерлок подходит к Вайсу]
    Play('Wise', 'LeanBack')
    ResetAnim("Wise")
    
    StartDialog()
    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_3_0_phrase_0', 'Wise', nil, 'Arrogantly')
    Say('Wise', 'Arrogantly', 's01c03_Wise_mission_3_0_phrase_1')
    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_3_0_phrase_2')
    SetupAnim('Wise', 'TalkArrogantly', {notLoop=true})
    Say('Wise', 'Arrogantly', 's01c03_Wise_mission_3_0_phrase_3')

    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_3_0_phrase_4')

    SetupAnim('Wise', 'IdleArrogantly')
    Say('Wise', 'Arrogantly', 's01c03_Wise_mission_3_0_phrase_5')
    ResetAnim('Wise')

    Say('Sherlock', 'Guiltily', 's01c03_Sherlock_mission_3_0_phrase_6')
    EndDialog()
    
    Play('Wise', 'Lean')
    SetupAnim('Wise', 'MajecticIdle')
    ApplyAnim('Wise')
    -- [Шерлок отходит в сторонку]
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_3_2')
        MoveCamera('camera_point_3_1', 1.5, 1)
    end)
    ActionCompleted()
    
    StartDialog()
    SetupAnim('Sherlock', 'Thinking', {notLoop=true})
    Say('Sherlock', 'Thoughtful', 's01c03_Sherlock_mission_3_0_phrase_7', 'Sherlock')
    EndDialog()
end

function ApplyMission4Action0()

    --CameraTo('Sherlock', 1, 1)

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_4_0')
        CameraTo('camera_point_4_0', 1, 1)
    end)
    
    StartDialog()
    -- [Шерлок подходит к углу локации, так, что ему становится виден Тимми]
    Say('Sherlock', 'Thoughtful', 's01c03_Sherlock_mission_4_0_phrase_0')
    EndDialog()
    
    -- [Анимация: Шерлок оглядывается]
    Parallel(function()
        Play('Sherlock', 'LookAround')
        Sequence(function()
           MoveCamera('camera_point_4_0_1', 1.5)
           MoveCamera('camera_point_4_0', 1.5)
        end)
    end)
    Walk('Sherlock', 'Sherlock_point_4_0_1')
    
    StartDialog()
    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_4_0_phrase_1')
    EndDialog()
    
    -- [Шерлок подходит к решетчатому окну цокольного этажа одного из зданий]
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_4_1')
        MoveCamera('camera_point_4_1', 2)
    end)
    -- [Анимация: Шерлок думает (параллельно реплике)]
    ActionCompleted()
    
    StartDialog()
    SetupAnim('Sherlock', 'Thinking', {notLoop=true})
    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_4_0_phrase_2')
    EndDialog()

    -- [Шерлок отходит на свободное пространство]
    Walk('Sherlock', 'Sherlock_point_4_2')
end

function ApplyMission5Action0()

    --CameraTo('Sherlock', 1, 1)

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_5_1')
        CameraTo('camera_point_5_1', 1, 1)
    end)
    --MoveCamera('camera_point_5_1_1', .5, 1.5)
    ZoomCamera(1.5, 1)
    -- [Шерлок подходит к Тимми]
    StartDialog()
    Say('Sherlock', 'Amiable', 's01c03_Sherlock_mission_5_0_phrase_0')
    SetupAnim('Timmy', 'TalkJoyous')
    Say('Timmy', 'Joyous', 's01c03_Timmy_mission_5_0_phrase_1')
    ResetAnim('Timmy')
    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_5_0_phrase_2')
    Say('Timmy', 'Cheerful', 's01c03_Timmy_mission_5_0_phrase_3')
    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_5_0_phrase_4')
    SetupAnim('Timmy', 'TalkCheerful', {notLoop=true})
    Say('Timmy', 'Moody', 's01c03_Timmy_mission_5_0_phrase_5')
    SetupAnim('Timmy', 'TalkMoody', {notLoop=true})
    Say('Timmy', 'Dissatisfied', 's01c03_Timmy_mission_5_0_phrase_6')
    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_5_0_phrase_7')
    SetupAnim('Timmy', 'TalkThoughtful', {notLoop=true})
    Say('Timmy', 'Thoughtful', 's01c03_Timmy_mission_5_0_phrase_8')

    ActionCompleted()
    Say('Sherlock', 'Thoughtful', 's01c03_Sherlock_mission_5_0_phrase_9')
    EndDialog()
    
    -- [Шерлок отходит от Тимми]
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_5_2')
        MoveCamera('camera_point_5_2', 2, 1)
    end)
end

function ApplyMission6Action0()

    --CameraTo('Sherlock', 1, 1)

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_6_1')
        CameraTo('camera_point_6_1', 1, 1)
    end)
    ZoomCamera(1.5, 1.5);
    -- [Шерлок подходит к решетке окна на цокольный этаж]
    -- [Анимация: Шерлок выпускает Свифти]
    ReleaseMouse();
    Walk('Swifty', 'Swifty_point_6_0_1')

    StartDialog()
    Say('Sherlock', 'Enchanted', 's01c03_Sherlock_mission_6_0_phrase_0')
    SetupAnim('Swifty', 'EmotionYes', {notLoop=true})
    Say('Swifty', 'Confidently', 's01c03_Swifty_mission_6_0_phrase_1')
    EndDialog()
    
    -- [Свифти забегает в окно, через решётку]
    Walk('Swifty', 'Swifty_point_6_0_2')
    Play('Swifty', 'JumpIn')
    SetActive('Swifty', false)
    SetTo('Swifty', 'Swifty_point_6_0')

    -- [Анимация: Шерлок заглядывает в окошко]
    Walk('Sherlock', 'Sherlock_point_6_2')
    Parallel(function()
        Play('Sherlock', 'SearchOnTable')
        Play('RustleSwifty', 'RustleSwifty')
    end)
    
    StartDialog()
    Say('Sherlock', 'Anxious', 's01c03_Sherlock_mission_6_0_phrase_2')
    Say('Swifty', 'Confidently', 's01c03_Swifty_mission_6_0_phrase_3')
    EndDialog()
    
    -- [Свифти выбегает из подвала, подбегает к Шерлоку и останавливается с ключом в лапках]
    Walk('Sherlock', 'Sherlock_point_6_3')
    Parallel(function()
        SetActive('Swifty', true)
        SetActive('KeyMouse', true)
    end)

    Parallel(function()
        Sequence(function()
            Play('Swifty', 'JumpOut')
            SetTo('Swifty', 'Swifty_point_6_1')
            Walk('Swifty', 'Swifty_point_6_1_1')
            Walk('Swifty', 'Swifty_point_6_1_2')
        end)
    end)
    
    StartDialog()
    Say('Swifty', 'spec:WithKey', 's01c03_Swifty_mission_6_0_phrase_4')
    ActionCompleted()
    Say('Sherlock', 'Satisfied', 's01c03_Sherlock_mission_6_0_phrase_5')
    EndDialog()
    
    -- [Анимация: Шерлок забирает ключ у Свифти]
    Parallel(function()
        Play('Sherlock', 'TakeBendingOver')
        Sequence(function()
            Delay(0.8)
            Play('Swifty', 'Take')
            SetActive('KeyMouse', false)
            SetActive('KeySherlock', true)
            Parallel(function ()
                Play('Swifty', 'TakeEnd')
                Sequence(function()
                    Delay(1.5)
                    SetActive('KeySherlock', false)
                end)
            end)
        end)
    end)

    -- [Шерлок немного отходит от стены дома, Свифти держится рядом]
    Walk('Sherlock', 'Sherlock_point_6_4')
    Walk('Swifty', 'Swifty_point_6_2')
end

function ApplyMission7Action0()

    --CameraTo('Sherlock', 1, 1)

    Parallel(function()
        SetActive('Swifty', true)
        Walk('Sherlock', 'Sherlock_point_7_0_1')
        CameraTo('camera_point_7_0', 1, 1)
        Sequence(function()
            Delay(0.8)
            Walk('Swifty', 'Swifty_point_7_0')
        end)
    end)

    -- [Шерлок подходит к двери, открывает её и исчезает в помещении, Свифти следует за ним. Камера показывает улицу]
    Parallel(function()
        Play('Sherlock', 'OpenLockWithKey')
        Sequence(function()
            Delay(4)
            SetActive('decoration_1-lock', false)
        end)
    end)

    Play('TheDoorToTheBasement', 'Open')
    Parallel(function()
        Sequence(function()
            Delay(1)
            Walk('Sherlock', 'Sherlock_point_7_1')
        end)
        Walk('Swifty', 'Swifty_point_7_2')
        Sequence(function()
            Delay(1.5)
            Play('TheDoorToTheBasement', 'Close')
        end)
    end)
    SetActive('Swifty', false)
    -- [Анимация: Из подвала доносятся звуки (визуализированные). Может быть, даже вылетает какой-нибудь хлам, но это уж на любителя]
    Parallel(function()
        SetActive('RustleDoor', true);
        Sequence(function()
            StartDialog()
            Say('Sherlock', 'Thoughtful', 's01c03_Sherlock_mission_7_0_phrase_0', nil, nil, nil, nil, true, false)
            Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_7_0_phrase_1', nil, nil, nil, nil, true, false)
            EndDialog()
        end)
    end)
    SetActive('RustleDoor', false);
    
    StartDialog()
    Say('Sherlock', 'spec:TriumphantlyWithPurse', 's01c03_Sherlock_mission_7_0_phrase_2', nil, nil, nil, nil, true, false)
    ActionCompleted()
    Say('Sherlock', 'Excited', 's01c03_Sherlock_mission_7_0_phrase_3', nil, nil, nil, nil, true, false)
    EndDialog()
    
    --Walk('Sherlock', 'Sherlock_point_7_2')
    Parallel(function()
        Play('TheDoorToTheBasement', 'Open')
        Sequence(function()
            Delay(2)
            Play('TheDoorToTheBasement', 'Close')
        end)
        --SetActive('Sherlock', true)
        -- [Шерлок выходит из подвала. Свифти не видно, он у Шерлока в кармане]
        -- [Анимация: дверь закрывается]
        Sequence(function()
            Delay(1)
            Walk('Sherlock', 'Sherlock_point_7_3')
        end)
    end)
    ZoomCamera(1, 1);
end

function ApplyMission8Action0()

    --CameraTo('Sherlock', 1, 1)

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_8_1')
        CameraTo('camera_point_8_0', 1, 1)
    end)
    ZoomCamera(1.5, 1);
    StartDialog()
    -- [Шерлок подходит к Лестрейду]
    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_8_0_phrase_0', 'Lestrade', nil, 'Restrained')
    Say('Lestrade', 'Restrained', 's01c03_Lestrade_mission_8_0_phrase_1')
    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_8_0_phrase_2')
    SetupAnim('Lestrade', 'TalkSad')
    Say('Lestrade', 'Sad', 's01c03_Lestrade_mission_8_0_phrase_3')
    ResetAnim('Lestrade')
    SetupAnim('Lestrade', 'TalkGuiltily')
    Say('Lestrade', 'Frightened', 's01c03_Lestrade_mission_8_0_phrase_4')
    ResetAnim('Lestrade')
    Say('Sherlock', 'Interested', 's01c03_Sherlock_mission_8_0_phrase_5')
    SetupAnim('Lestrade', 'TalkDissatisfied', {notLoop=true})
    Say('Lestrade', 'Sad', 's01c03_Lestrade_mission_8_0_phrase_6')
    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_8_0_phrase_7')
    SetupAnim('Lestrade', 'TalkUpset')
    Say('Lestrade', 'Sad', 's01c03_Lestrade_mission_8_0_phrase_8')
    ResetAnim('Lestrade')
    SetupAnim('Sherlock', 'Enlightened', {notLoop=true})
    Say('Sherlock', 'Excited', 's01c03_Sherlock_mission_8_0_phrase_9')
    ActionCompleted()
    Say('Sherlock', 'Confidently', 's01c03_Sherlock_mission_8_0_phrase_10')
    EndDialog()
    
    -- [Лестрейд уходит с локации]
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_8_1_1')
        MoveCamera('camera_point_8_1', 2.5, 1, 1)
        Sequence(function()
            Walk('Lestrade', 'Lestrade_point_8_1')
            Walk('Lestrade', 'Lestrade_point_8_2', 1.5)
        end)
        Sequence(function()
            Delay(3)
            Parallel(function()
                Walk('Sherlock', 'Sherlock_point_8_3')
                MoveCamera('camera_point_8_2', 1.7, 1, 1)
            end)
        end)
    end)
    -- [Шерлок отходит на свободное пространство]
end

function ApplyMission9Action0Start()

    CameraTo('Sherlock', 1, 1)

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_9_1')
        Sequence(function()
            MoveCamera('camera_point_9_0', 2.5)
            MoveCamera('camera_point_9_1', 2.5)
        end)
    end)
    --MoveCamera('camera_point_9_1_1', 1, 1.5)
    ZoomCamera(1.5, 1)
    
    StartDialog()
    -- [Шерлок подходит к Тимми]
    Say('Sherlock', 'Amiable', 's01c03_Sherlock_mission_9_0_phrase_0')
    SetupAnim('Timmy', 'TalkConcentrated', {notLoop=true})
    Say('Timmy', 'Concentrated', 's01c03_Timmy_mission_9_0_phrase_1')
    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_9_0_phrase_2')
    Say('Sherlock', 'Crafty', 's01c03_Sherlock_mission_9_0_phrase_3')
    SetupAnim('Timmy', 'TalkAgree', {notLoop=true})
    Say('Timmy', 'Joyous', 's01c03_Timmy_mission_9_0_phrase_4')
    -- [Тимми убегает с локации]
    SetupAnim('Timmy', 'Run')
    EndDialog()
    
    Walk('Timmy', 'Timmy_point_9_0', 2)
    ResetAnim('Timmy')
    SetActive('Timmy', false)
    SetTo('Timmy', 'Timmy_point_9_0_1')
    -- [Шерлок отходит на свободное пространство]
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_9_2')
        MoveCamera('camera_point_9_1_1', 1, 1)
    end)
end

function ApplyMission9Action0TimeUp()
    -- [Тимми возвращается с чемоданом и останавливается недалеко от прежнего места. Чемодан держит в руках]
    SetActive('Timmy', true)
    SetupAnim('Timmy', 'WalkWithCase')
    Walk('Timmy', 'Timmy_point_9_1', 0.3)
    SetupAnim('Timmy', 'IdleWithCase')
    ApplyAnim('Timmy')
end

function ApplyMission9Action0Completed()

    --CameraTo('Sherlock', 1, 1)

    -- [Шерлок подходит к Тимми]
    Parallel(function()
        CameraTo('camera_point_9_2', 1, 1)
        Walk('Sherlock', 'Sherlock_point_9_3')
    end)

    --MoveCamera('camera_point_9_2_1', 1, 1.5)
    ZoomCamera(1.5, 1)

    StartDialog()
    SetupAnim('Timmy', 'IdleWithCase')
    Say('Timmy', 'Joyous', 's01c03_Timmy_mission_9_0_phrase_5')
    EndDialog()
    
    -- [Анимация: Тимми ставит чемодан перед Шерлоком]
    Parallel(function()
        Sequence(function()
            Play('Timmy', 'PutsTheCase')
            ResetAnim('Timmy')
        end)
        Sequence(function()
            Delay(.35)
            SetActive('Case', true)
        end)
    end)

    StartDialog()
    Say('Sherlock', 'spec:SatisfiedGiveCoin', 's01c03_Sherlock_mission_9_0_phrase_6')
    EndDialog()
    
    -- [Анимация: Шерлок даёт Тимми монетку]
    SetActive('CoinHand', true)
    Parallel(function()
        Sequence(function()
            Delay(2.2)
            Play('Timmy', 'TakeCoin')
        end)
        Sequence(function()
            Delay(2)
            SetActive('CoinHand', false)
            SetActive('Coin', true)
            Play('Coin', 'CoinAnimation')
        end)
        Play('Sherlock', 'GiveCoin')
    end)
    SetActive('Coin', false)

    StartDialog()
    ActionCompleted()
    Say('Timmy', 'spec:HappyWithCoin', 's01c03_Timmy_mission_9_0_phrase_7', 'Sherlock', nil, 'Thankfully')
    EndDialog()

    Parallel(function()
        -- [Тимми отходит на прежнее место под аркой]
        Sequence(function()
            Walk('Timmy', 'Timmy_point_9_2')
            Walk('Timmy', 'Timmy_point_9_3')
        end)
        ZoomCamera(1, .6)
    end)
end

function ApplyMission10Action0()

    --CameraTo('Sherlock', 1, 1)

    Parallel(function()
        CameraTo('camera_point_9_2', 1, 1)
        Walk('Sherlock', 'Sherlock_point_10_0')
    end)

    -- [Анимация: Шерлок подходит к чемодану и наклоняется над ним]
    -- [Анимация: Шерлок переодевается]
    Parallel(function()
        Play('FoldingScreen', 'Appearance')
        Sequence(function()
            Delay(1.3)
            SetActive('Sherlock', false)
            SetActive('Case', false)
            SetPlayerCharacter('Pennyworth')
            SetActive('Pennyworth', true)
        end)
    end)
    -- [Шерлок перевоплотился в “мистера Пенниворта”]
    StartDialog()
    ActionCompleted()
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_10_0_phrase_0')
    EndDialog()
    -- [“Пенниворт” отходит на свободное пространство]

    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_10_1')
        MoveCamera('camera_point_10_0', 2, 1, 1)
    end)
end

function ApplyMission11Action0()

    CameraTo('camera_point_10_0', 1, 1)

    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_11_2')
        CameraTo('camera_point_11_2', 0.8)
    end)
    ZoomCamera(1.5, 1);
    -- [“Пенниворт” подходит к Вайсу]
    Play('Wise', 'LeanBack')
    ResetAnim('Wise')
    
    StartDialog()
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_11_0_phrase_0', 'Wise', nil, 'Arrogantly')
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_11_0_phrase_1', 'Wise', nil, 'Arrogantly')
    SetupAnim('Wise', 'TalkWarily')
    Say('Wise', 'Warily', 's01c03_Wise_mission_11_0_phrase_2')
    ResetAnim('Wise')
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_11_0_phrase_3')
    Say('Wise', 'Warily', 's01c03_Wise_mission_11_0_phrase_4')
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_11_0_phrase_5')
    Say('Pennyworth', 'Strictly', 's01c03_Pennyworth_mission_11_0_phrase_6')
    SetupAnim('Wise', 'TalkEmotional', {notLoop=true})
    Say('Wise', 'Excited', 's01c03_Wise_mission_11_0_phrase_7')
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_11_0_phrase_8')
    SetupAnim('Wise', 'TalkEmotional', {notLoop=true})
    Say('Wise', 'Excited', 's01c03_Wise_mission_11_0_phrase_9')
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_11_0_phrase_10')
    ActionCompleted()
    SetupAnim('Wise', 'TalkJoyous', {notLoop=true})
    Say('Wise', 'Joyous', 's01c03_Wise_mission_11_0_phrase_11')
    EndDialog()
    
    -- [Вайс подходит к выходу из Локации и нетерпеливо ждёт “Пенниворта”]
    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_11_3')
        Walk('Wise', 'Wise_point_11_0')
    end)

    Parallel(function()
        Walk('Wise', 'Wise_point_11_1')
        MoveCamera('camera_point_11_3', 1, 1)
    end)
end

function ApplyMission12Action0()

    CameraTo('camera_point_11_3', 1, 1)

    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_12_0')
        MoveCamera('camera_point_12_0', 1)
    end)

    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_12_1')
        Walk('Wise', 'Wise_point_12_0')
    end)
    -- [“Пенниворт” подходит к Вайсу и они выходят из локации]
    -- [Локация меняется на Полицейский участок Уайтчепел]
    ChangeLocation('0006_WhitechapelPoliceStation')

    Parallel(function()
        ShowLocationCaption('s01c03_location_1_caption', 's01c03_location_1_time')
        Walk('Pennyworth', 'Pennyworth_point_12_3_1')
        Walk('Wise', 'Wise_point_12_0_1')
    end)
    
    StartDialog()
    -- [“Пенниворт” и Вайс входят в участок и останавливаются недалеко от входа. Лестрейд уже в участке.]
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_12_0_phrase_0', 'Wise', nil, 'Arrogantly')
    ActionCompleted()
    Say('Wise', 'Excited', 's01c03_Wise_mission_12_0_phrase_1')
    EndDialog()
    -- [“Пенниворт” проходит немного вперед, Вайс остается на месте]
    Walk('Pennyworth', 'Pennyworth_point_12_3')
end

function ApplyMission13Action0Start()

    -- [“Пенниворт” подходит к Лестрейду]
    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_13_1')
        CameraTo('camera_point_13_1', 1, 1)
    end)

    Walk('Lestrade', 'Lestrade_point_13_0_1')
    
    StartDialog()
    Say('Pennyworth', 'Restrained', 's01c03_Pennyworth_mission_13_0_phrase_0', 'Lestrade', nil, 'Restrained')
    SetupAnim('Lestrade', 'TalkSurprised', {notLoop=true})
    Say('Lestrade', 'Surprised', 's01c03_Lestrade_mission_13_0_phrase_1')

    --ResetAnim('Lestrade');
    Say('Pennyworth', 'Smile', 's01c03_Pennyworth_mission_13_0_phrase_2')

    SetupAnim('Lestrade', 'TalkIndignantly', {notLoop=true})
    Say('Lestrade', 'Dissatisfied', 's01c03_Lestrade_mission_13_0_phrase_3')

    --ResetAnim('Lestrade');
    Say('Pennyworth', 'Smile', 's01c03_Pennyworth_mission_13_0_phrase_4')

    SetupAnim('Lestrade', 'TalkDissatisfied', {notLoop=true})
    Say('Lestrade', 'Mistrustfully', 's01c03_Lestrade_mission_13_0_phrase_5')

    --ResetAnim('Lestrade');
    Say('Pennyworth', 'Smile', 's01c03_Pennyworth_mission_13_0_phrase_6')
    Say('Lestrade', 'Mistrustfully', 's01c03_Lestrade_mission_13_0_phrase_7')
    -- [Лестрейд уходит]
    EndDialog()
    
    Play('TheDoorToThePoliceStation', 'Open')
    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_13_2')
        Walk('Lestrade', 'Lestrade_point_13_1')
        MoveCamera('camera_point_13_1_1', 1)
    end)
    Play('TheDoorToThePoliceStation', 'Close')
end

function ApplyMission13Action0TimeUp()
    -- [Лестрейд возвращается и останавливается недалеко от двери]
    Play('TheDoorToThePoliceStation', 'Open')
    Walk('Lestrade', 'Lestrade_point_13_2_1')
    Walk('Lestrade', 'Lestrade_point_13_2')
    Play('TheDoorToThePoliceStation', 'Close')
end

function ApplyMission13Action0Completed()

    --CameraTo('Pennyworth')

    -- [“Пенниворт” подходит к Лестрейду]
    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_13_3')
        CameraTo('camera_point_13_1_1', 1, 1)
    end)
    -- [Анимация: протягивает “Пенниворту” лист]

    Parallel(function()
        Play('Lestrade', 'GivePaper')
        Sequence(function()
            Delay(1.8)
            Play('Pennyworth', 'TakePapers')
        end)
        Sequence(function()
            Delay(2.4)
            SetActive('List', true)
        end)
        Sequence(function()
            Delay(4.5)
            SetActive('List', false)
        end)
    end)

    -- [Анимация: “Пенниворт” забирает бумагу и прячет в карман]
    
    StartDialog()
    SetupAnim('Lestrade', 'TalkWrathfully', {notLoop=true})
    Say('Lestrade', 'Dissatisfied', 's01c03_Lestrade_mission_13_0_phrase_8', 'Pennyworth', nil, 'Restrained')
    --ResetAnim('Lestrade');
    ActionCompleted()
    Say('Pennyworth', 'Smile', 's01c03_Pennyworth_mission_13_0_phrase_9')
    EndDialog()
    
    -- [“Пенниворт” отходит в сторону. Лестрейд тоже отходит на свою изначальную позицию]
    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_13_4')
        Walk('Lestrade', 'Lestrade_point_13_3')
    end)
end

function ApplyMission14Action0()

    --CameraTo("Pennyworth")

    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_14_0')
        CameraTo('camera_point_14_0', 1, 1)
    end)
    
    StartDialog()
    -- [“Пенниворт” подходит к Вайсу]
    Say('Pennyworth', 'Strictly', 's01c03_Pennyworth_mission_14_0_phrase_0', 'Wise', nil, 'Arrogantly')
    SetupAnim('Wise', 'TalkGrin')
    Say('Wise', 'Dissatisfied', 's01c03_Wise_mission_14_0_phrase_1')
    Say('Pennyworth', 'Strictly', 's01c03_Pennyworth_mission_14_0_phrase_2')
    SetupAnim('Wise', 'PokeFinger', {notLoop=true})
    Say('Wise', 'Gloatingly', 's01c03_Wise_mission_14_0_phrase_3')
    Say('Pennyworth', 'Strictly', 's01c03_Pennyworth_mission_14_0_phrase_4')
    SetupAnim('Wise', 'TalkWarily')
    Say('Wise', 'Mistrustfully', 's01c03_Wise_mission_14_0_phrase_5')
    Say('Pennyworth', 'Strictly', 's01c03_Pennyworth_mission_14_0_phrase_6')
    ActionCompleted()
    Say('Wise', 'Relaxed', 's01c03_Wise_mission_14_0_phrase_7')
    EndDialog()
    
    Parallel(function()
        -- [Анимация: Вайс отдаёт бумаги “Пенниворту”]
        Play('Wise', 'GivePapers')
        -- [Анимация: “Пенниворт” забирает бумаги и прячет в карман]
        Sequence(function()
            Delay(1.7)
            Play('Pennyworth', 'TakePapers')
        end)
        Sequence(function()
            Delay(2.2)
            SetActive('List', true)
        end)
        Sequence(function()
            Delay(4.4)
            SetActive('List', false)
        end)
    end)
    -- [“Пенниворт” отходит от Вайса]
    Parallel(function()
        Walk('Pennyworth', 'Pennyworth_point_14_1')
        Walk('Wise', 'Wise_point_14_0')
        MoveCamera('camera_point_14_1', 1)
    end)
end

function ApplyMission15Action0()

    --CameraTo('Pennyworth')

    Parallel(function()
        CameraTo('camera_point_15_1', 1, 1)
        Walk('Pennyworth', 'Pennyworth_point_15_1')
    end)

    -- [“Пенниворт” заходит за стенку, чтобы его не видел Вайса]
    -- [Анимация: Шерлок переодевается]
    -- [“Пенниворт” перевоплотился в Шерлока]
    Parallel(function()
        Play('FoldingScreen', 'Appearance')
        Sequence(function()
            Delay(1.3)
            SetActive('Sherlock', true)
            SetPlayerCharacter('Sherlock')
            SetActive('Pennyworth', false)
        end)
    end)
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_15_2')
        MoveCamera('camera_point_15_2', 1)
    end)
    -- [Анимация: Шерлок достает 2 бумаги]
    Parallel(function()
        Play('Sherlock', 'PaperFromPocketToTable')
        Sequence(function()
            Delay(1)
            SetActive('ListHand', true)
            Play('ListHand', 'SheetUnfolding')
        end)
        Sequence(function()
            Delay(2)
            SetActive('ListHandSimple', true)
        end)
    end)

    SetActive('ListHandSimple', false)
    
    StartDialog()
    SetupAnim('Sherlock', 'CompareOnTable', {const=true})
    Say('Sherlock', 'Thoughtful', 's01c03_Sherlock_mission_15_0_phrase_0')
    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_15_0_phrase_1')
    -- [Анимация: Шерлок сравнивает 2 бумаги]
    Say('Sherlock', 'spec:ThoughtfulComparingPapers', 's01c03_Sherlock_mission_15_0_phrase_2')
    -- [Анимация: Шерлок сравнивает 2 бумаги]
    --Parallel(function()
        Say('Sherlock', 'Excited', 's01c03_Sherlock_mission_15_0_phrase_3')
        --Play('Sherlock', 'Enlightened')
    --end)

    -- [Здесь можно показать два герба, практически одинаковых, которые накладываются друг на друга, и видно что в одном месте они не совпадают]
    ActionCompleted()
    Say('Sherlock', 'Joyous', 's01c03_Sherlock_mission_15_0_phrase_4')
    EndDialog()
    
    Parallel(function()
        Play('Sherlock', 'PaperFromTableToPocket')
        SetActive('ListHand', true)
        SetActive('ListHandSimple', true)
        Sequence(function()
            Delay(1.1)
            SetActive('ListHandSimple', false)
        end)
        Sequence(function()
            Delay(1.5)
            Play('ListHand', 'SheetFolding')
        end)
        Sequence(function()
            Delay(2.0)
            SetActive('ListHand', false)
        end)
    end)

    ResetAnim('Sherlock')
   
    -- [Анимация: Шерлок прячет бумаги]
    -- [Шерлок выходит на свободное пространство]
    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_15_3')
        MoveCamera('camera_point_15_2_1', 1)
    end)
end

function ApplyMission16Action0()

    --CameraTo('camera_point_15_2_1', 1, 1)

    Parallel(function()
        Walk('Sherlock', 'Sherlock_point_16_0')
        --Walk('Lestrade', 'Lestrade_point_16_0')
        CameraTo('camera_point_16_0', 1, 1)
    end)
    StartDialog()
    -- [Шерлок подходит к Лестрейду]
    Say('Sherlock', 'Confidently', 's01c03_Sherlock_mission_16_0_phrase_0', 'Lestrade', nil, 'Restrained')
    -- [Анимация: Шерлок передает бумаги Лестрейду]
    -- [Анимация: Лестрейд забирает бумаги и дальше стоит с ними в руках, поглядывая на них]
    SetupAnim('Lestrade', 'IdleLookPaper')
    ApplyAnim('Lestrade')
    EndDialog()
    
    Parallel(function()
        Play('Lestrade', 'TakePaper')
        Play('Sherlock', 'Give')
        Sequence(function()
            Delay(0.2)
            SetActive('ListHandDouble', true)
        end)
        Sequence(function()
            Delay(1)
            SetActive('ListHandDouble', false)
        end)
    end)
    
    StartDialog()
    SetupAnim('Lestrade', 'TalkLookPaper', {const=true})
    Say('Lestrade', 'Mistrustfully', 's01c03_Lestrade_mission_16_0_phrase_1')
    --SetupAnim('Lestrade', 'IdleLookPaper')
    --ApplyAnim('Lestrade')
    SetupAnim('Sherlock', 'ShowDifference', {notLoop=true})
    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_16_0_phrase_2')

    --SetupAnim('Lestrade', 'TalkLookPaper')
    Say('Lestrade', 'Mistrustfully', 's01c03_Lestrade_mission_16_0_phrase_3')
    --SetupAnim('Lestrade', 'IdleLookPaper')
    --ApplyAnim('Lestrade')
    Say('Sherlock', 'Confidently', 's01c03_Sherlock_mission_16_0_phrase_4')
    Say('Sherlock', 'Calm', 's01c03_Sherlock_mission_16_0_phrase_5')
    SetupAnim('Sherlock', 'Specify', {notLoop=true})
    Say('Sherlock', 'Triumphantly', 's01c03_Sherlock_mission_16_0_phrase_6')

    ActionCompleted()
    --SetupAnim('Lestrade', 'TalkLookPaper')
    SetupAnim('Lestrade', 'SurprisedPaper', {notLoop=true})
    Say('Lestrade', 'Amazedly', 's01c03_Lestrade_mission_16_0_phrase_7')
    EndDialog()
    -- [Анимация: Лестрейд прячет бумаги]
    Play('Lestrade', 'HidePaper')
    ResetAnim('Lestrade')
end

function ApplyMission17Action0()

    CameraTo('camera_point_16_0', 1, 1)

    Parallel(function()
        Sequence(function()
            Delay(1)
            Walk('Lestrade', 'Lestrade_point_17_1')
            Walk('Lestrade', 'Lestrade_point_17_3')
        end)
        Sequence(function()
            MoveCamera('camera_point_17_0', 2)
            MoveCamera('camera_point_17_1', 2)
        end)
        Walk('Sherlock', 'Sherlock_point_17_1')
    end)

    -- [Шерлок и Лестрейд подходят к Вайсу, Шерлок со спины]
    Parallel(function()
        Walk('Wise', 'Wise_point_17_0_1')
        
        StartDialog()        
        SetupAnim('Lestrade', 'TalkRampant')
        Say('Lestrade', 'Rampant', 's01c03_Lestrade_mission_17_0_phrase_0', 'Wise', nil, 'Dissatisfied')
        EndDialog()
    end)
    -- [Вайс разворачивается и бросается бежать]
    SetupAnim('Wise', 'Run')
    Parallel(function()
        Sequence(function()
            Walk('Wise', 'Wise_point_17_0', 1.3)
            ResetAnim('Wise')
            Play('Wise', 'Stopped')
        end)
        -- [Анимация: Шерлок загораживает ему дверь]
        Play('Sherlock', 'BlockWay')
    end)
    
    StartDialog()
    Say('Sherlock', 'Strictly', 's01c03_Sherlock_mission_17_0_phrase_1', 'Wise', nil, 'Dissatisfied')
    EndDialog()
    
    -- [Анимация: Вайс останавливается, разворачивается и поднимает руки]
    Walk('Wise', 'Wise_point_17_1')
    Play('Wise', 'HandsUp')
    SetupAnim('Wise', 'IdleHandsUp')
    ApplyAnim('Wise')
    -- [Лестрейд подходит к нему]
    
    StartDialog()
    Parallel(function()
        Say('Sherlock', 'Ironically', 's01c03_Sherlock_mission_17_0_phrase_2', 'Wise', nil, 'Dissatisfied')
        Walk('Lestrade', 'Lestrade_point_17_4')
    end)
    EndDialog()

    -- [Вайс поворачивается спиной]
    Walk('Wise', 'Wise_point_17_2')
    -- [Анимация: опускает руки Вайс и заводит их за спину]

    --Play('Wise', 'IdleHandsUp')
    --ResetAnim('Wise')

    Parallel(function()
       Play('Lestrade', 'Handcuff')
       Play('Wise', 'ArmsBehind')
    end)
    --SetupAnim('Wise', 'IdleArmsBehind')
    
    StartDialog()
    SetupAnim('Wise', 'IdleArmsBehind')
    ApplyAnim('Wise')
    Say('Wise', 'Wrathfully', 's01c03_Wise_mission_17_0_phrase_3', 'Sherlock', nil, 'Annoyed', nil, false)
    Say('Lestrade', 'Rampant', 's01c03_Lestrade_mission_17_0_phrase_4')
    Say('Wise', 'Evilly', 's01c03_Wise_mission_17_0_phrase_5', 'Sherlock', nil, 'Annoyed', nil, false)
    Say('Lestrade', 'Mistrustfully', 's01c03_Lestrade_mission_17_0_phrase_6', 'Sherlock', nil, 'Calm')
    Say('Lestrade', 'Severely', 's01c03_Lestrade_mission_17_0_phrase_7', 'Sherlock', nil, 'Calm')
    ActionCompleted()
    Say('Sherlock', 'Ironically', 's01c03_Sherlock_mission_17_0_phrase_8', 'Lestrade', nil, 'Mistrustfully')
    EndDialog()
    
    SetupAnim('Wise', 'Idle')
    ApplyAnim('Wise')

    -- [Лестрейд уводит Вайса в сторону камер]

    Parallel(function()
        Sequence(function()
            SetupAnim('Wise', 'WalkChained', {const=true})
            Walk('Wise', 'Wise_point_17_3')
            Walk('Wise', 'Wise_point_17_4')
            SetTo('Wise', 'Wise_point_17_8')
            SetupAnim('Wise', 'IdleChained')
            ApplyAnim('Wise')
        end)
        Sequence(function()
            Delay(0.6)
            Walk('Lestrade', 'Lestrade_point_17_6')
            Walk('Lestrade', 'Lestrade_point_17_7')
            SetTo('Lestrade', 'Lestrade_point_17_9')
        end)
        Sequence(function()
            Delay(2)
            InvestigationCompleted()
        end)
    end)
end

function ReleaseMouse()
    Parallel(function()
        SetActive('SwiftyHand', true)
        Play('Sherlock', 'ReleaseMouse')
        Sequence(function()
            Play('SwiftyHand', 'Release')
            Parallel(function()
                SetActive('SwiftyHand', false)
                -- TODO: включить когда будет поддержка вложенных точек
                -- SetTo('Swifty', 'Swifty_release_point')
                SetActive('Swifty', true)
            end)
        end)
    end)
end

function ApplyMissionActionBeforeNextChapter()
end

function CreateInteractiveEnvironment(f)
    return f.InteractiveEnvironment({})
end