//
// Copyright(C) 2014-2015 Samuel Villarreal
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// DESCRIPTION:
//      Level Script For snow64a.map
//

#include "scripts/common.txt"

/*
==============================================================
Script 0
==============================================================
*/

$script 0
{
    Camera.StartCinematic(CMF_LOCK_PLAYER|CMF_NO_LETTERBOX|CMF_NO_INITIAL_FADEOUT|CMF_SHOW_CREDITS);
    
    Game.CallDelayedMapScript(1, instigator, 0);
    Game.CallDelayedMapScript(2, instigator, 4.0f);
    
    Camera.fov = 74.0f;
    
    Camera.SetFinalView(0);
    Camera.SetPositionTrack(0, 
                            kVec3(17.04f, -409.2798f, 332.48f),
                            kVec3(1153.2288f, -6279.0654f, 61.44f),
                            kVec3(163.84f, -7598.08f, 737.28f),
                            kVec3(102.4f, -9031.6797f, 1638.4f));
                                       
    Camera.AutoPlayPositionTrack(0, 60.0f, CMLT_COSINE);
}

/*
==============================================================
Script 1
==============================================================
*/

$script 1
{
    float x = Math::RandRange(-409.6f, 122.88f);
    float y = Math::RandRange(-9011.2f, -9113.6f);
    float z = Math::RandRange(3481.6f, 3891.2f);
    
    Game.SpawnFx("fx/generic_238.kfx", kVec3(x, y, z), 0);
    
    delay(0.125f);
    $restart;
}

/*
==============================================================
Script 2
==============================================================
*/

$script 2
{
    if(Camera.UserInterrupted())
    {
        Game.HaltMapScript(1);
        Game.Restart();
        return;
    }
    
    $restart;
}
