// IW6 GSC SOURCE
// Generated by https://github.com/xensik/gsc-tool

main()
{
    maps\mp\mp_warhawk_precache::main();
    maps\createart\mp_warhawk_art::main();
    maps\mp\mp_warhawk_fx::main();
    maps\mp\mp_warhawk_events::precache();
    var_0 = 50.0;
    var_1 = 70.0;
    level thread maps\mp\mp_warhawk_events::random_destruction( var_0, var_1 );
    level thread maps\mp\mp_warhawk_events::air_raid();
    level.mapcustomcratefunc = ::warhawkcustomcratefunc;
    level.mapcustomkillstreakfunc = ::warhawkcustomkillstreakfunc;
    level.mapcustombotkillstreakfunc = ::warhawkcustombotkillstreakfunc;
    maps\mp\_load::main();
    thread maps\mp\_fx::func_glass_handler();
    maps\mp\_compass::setupminimap( "compass_map_mp_warhawk" );
    setdvar( "r_lightGridEnableTweaks", 1 );
    setdvar( "r_lightGridIntensity", 1.33 );
    maps\mp\_utility::setdvar_cg_ng( "r_diffuseColorScale", 1.2, 1.5 );
    maps\mp\_utility::setdvar_cg_ng( "r_specularcolorscale", 1.5, 9 );
    setdvar( "r_ssaorejectdepth", 1500 );
    setdvar( "r_ssaofadedepth", 1200 );

    if ( level.ps3 )
        setdvar( "sm_sunShadowScale", "0.6" );
    else if ( level.xenon )
        setdvar( "sm_sunShadowScale", "0.7" );

    game["attackers"] = "allies";
    game["defenders"] = "axis";
    level thread maps\mp\mp_warhawk_events::plane_crash();
    level thread maps\mp\mp_warhawk_events::heli_anims();
    level thread maps\mp\mp_warhawk_events::chain_gate();
    level thread maps\mp\mp_warhawk_events::exploders_watch_late_players();
    level thread maps\mp\_breach::main();
    level._effect["default"] = loadfx( "vfx/moments/mp_warhawk/vfx_mp_warhawk_breach_01" );
    level thread initextracollision();
}

initextracollision()
{
    var_0 = spawn( "script_model", ( -449.855, 640.906, 203.344 ) );
    var_0 setmodel( "afr_corrugated_metal8x8" );
    var_0.angles = ( 0, 0, 0 );
    var_1 = spawn( "script_model", ( 1457, 159.5, 143 ) );
    var_1 setmodel( "afr_corrugated_metal8x8" );
    var_1.angles = ( 0, 0, 0 );
}

watch_allow_dynamic_events()
{
    while ( getdvarint( "allow_dynamic_events" ) )
        wait 0.05;

    level notify( "stop_dynamic_events" );
}

warhawkcustomcratefunc()
{
    if ( !isdefined( game["player_holding_level_killstrek"] ) )
        game["player_holding_level_killstrek"] = 0;

    if ( !maps\mp\_utility::allowlevelkillstreaks() || game["player_holding_level_killstrek"] )
        return;

    maps\mp\killstreaks\_airdrop::addcratetype( "airdrop_assault", "warhawk_mortars", 85, maps\mp\killstreaks\_airdrop::killstreakcratethink, maps\mp\killstreaks\_airdrop::get_friendly_crate_model(), maps\mp\killstreaks\_airdrop::get_enemy_crate_model(), &"KILLSTREAKS_HINTS_WARHAWK_MORTARS" );
    level thread watch_for_warhawk_mortars_crate();
}

watch_for_warhawk_mortars_crate()
{
    for (;;)
    {
        level waittill( "createAirDropCrate", var_0 );

        if ( isdefined( var_0 ) && isdefined( var_0.cratetype ) && var_0.cratetype == "warhawk_mortars" )
        {
            maps\mp\killstreaks\_airdrop::changecrateweight( "airdrop_assault", "warhawk_mortars", 0 );
            var_1 = wait_for_capture( var_0 );

            if ( !var_1 )
            {
                maps\mp\killstreaks\_airdrop::changecrateweight( "airdrop_assault", "warhawk_mortars", 85 );
                continue;
            }

            game["player_holding_level_killstrek"] = 1;
            break;
        }
    }
}

wait_for_capture( var_0 )
{
    var_1 = watch_for_air_drop_death( var_0 );
    return !isdefined( var_1 );
}

watch_for_air_drop_death( var_0 )
{
    var_0 endon( "captured" );
    var_0 waittill( "death" );
    waittillframeend;
    return 1;
}

warhawkcustomkillstreakfunc()
{
    level.killstreakfuncs["warhawk_mortars"] = ::tryusewarhawkmortars;
    level.killstreakweildweapons["warhawk_mortar_mp"] = "warhawk_mortars";
}

warhawkcustombotkillstreakfunc()
{
    maps\mp\bots\_bots_ks::bot_register_killstreak_func( "warhawk_mortars", maps\mp\bots\_bots_ks::bot_killstreak_simple_use );
}

tryusewarhawkmortars( var_0, var_1 )
{
    if ( level.air_raid_active )
    {
        self iprintlnbold( &"KILLSTREAKS_AIR_SPACE_TOO_CROWDED" );
        return 0;
    }

    game["player_holding_level_killstrek"] = 0;
    level notify( "warhawk_mortar_killstreak", self );
    return 1;
}
