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

init()
{
    register_end_game_string_index();
}

playpainoverlay( var_0, var_1, var_2 )
{
    if ( maps\mp\_utility::isusingremote() && maps\mp\alien\_utility::is_true( self.vanguard_num ) )
        return;

    var_3 = get_damage_direction( var_2 );

    if ( is_spitter_spit( var_1 ) )
        play_spitter_pain_overlay( var_3 );
    else if ( is_spitter_gas( var_1 ) )
        play_spitter_pain_overlay( "center" );
    else if ( is_elite_attack( var_0 ) )
        playfxontagforclients( level._effect["vfx_melee_blood_spray"], self, "tag_eye", self );
    else
        play_basic_pain_overlay( var_3 );
}

get_damage_direction( var_0 )
{
    var_1 = 0.965;
    var_2 = [ "left", "center", "right" ];

    if ( !isdefined( var_0 ) )
        return var_2[randomint( var_2.size )];

    var_0 = var_0 * -1;
    var_3 = anglestoforward( self.angles );
    var_4 = vectordot( var_0, var_3 );

    if ( var_4 > var_1 )
        return "center";

    var_5 = anglestoright( self.angles );
    var_6 = vectordot( var_0, var_5 );

    if ( var_6 > 0 )
        return "right";
    else
        return "left";
}

play_basic_pain_overlay( var_0 )
{
    if ( var_0 == "left" )
        playfxontagforclients( level._effect["vfx_blood_hit_left"], self, "tag_eye", self );
    else if ( var_0 == "center" )
        playfxontagforclients( level._effect["vfx_melee_blood_spray"], self, "tag_eye", self );
    else if ( var_0 == "right" )
        playfxontagforclients( level._effect["vfx_blood_hit_right"], self, "tag_eye", self );
    else
    {

    }
}

play_spitter_pain_overlay( var_0 )
{
    if ( var_0 == "left" )
        playfxontagforclients( level._effect["vfx_alien_spitter_hit_left"], self, "tag_eye", self );
    else if ( var_0 == "center" )
        playfxontagforclients( level._effect["vfx_alien_spitter_hit_center"], self, "tag_eye", self );
    else if ( var_0 == "right" )
        playfxontagforclients( level._effect["vfx_alien_spitter_hit_right"], self, "tag_eye", self );
    else
    {

    }
}

play_slash_pain_overlay( var_0 )
{
    if ( var_0 == "center" )
        var_0 = random_pick_r_or_l();

    if ( var_0 == "left" )
        playfxontagforclients( level._effect["vfx_blood_hit_left"], self, "tag_eye", self );
    else if ( var_0 == "right" )
        playfxontagforclients( level._effect["vfx_blood_hit_right"], self, "tag_eye", self );
    else
    {

    }
}

play_goo_pain_overlay( var_0 )
{
    if ( var_0 == "left" )
        playfxontagforclients( level._effect["vfx_alien_spitter_hit_left"], self, "tag_eye", self );
    else if ( var_0 == "center" )
        playfxontagforclients( level._effect["vfx_alien_spitter_hit_center"], self, "tag_eye", self );
    else if ( var_0 == "right" )
        playfxontagforclients( level._effect["vfx_alien_spitter_hit_right"], self, "tag_eye", self );
    else
    {

    }
}

random_pick_r_or_l()
{
    if ( common_scripts\utility::cointoss() )
        return "right";
    else
        return "left";
}

is_spitter_spit( var_0 )
{
    if ( !isdefined( var_0 ) )
        return 0;

    return var_0 == "alienspit_mp";
}

is_spitter_gas( var_0 )
{
    if ( !isdefined( var_0 ) )
        return 0;

    return var_0 == "alienspit_gas_mp";
}

is_elite_attack( var_0 )
{
    if ( !isdefined( var_0 ) || !var_0 maps\mp\alien\_utility::is_alien_agent() )
        return 0;

    return var_0 maps\mp\alien\_utility::get_alien_type() == "elite";
}

laststandupdatereviveiconcoloralien( var_0 )
{
    self endon( "death" );
    level endon( "game_ended" );
    wait( var_0 / 3 );
    self.color = ( 1, 0.64, 0 );
    wait( var_0 / 3 );
    self.color = ( 1, 0, 0 );
}

makereviveicon( var_0, var_1, var_2 )
{
    var_3 = newteamhudelem( var_0.team );
    var_3 setshader( "waypoint_alien_revive", 8, 8 );
    var_3 setwaypoint( 1, 1 );
    var_3 settargetent( self );
    var_3.color = var_1;
    var_3 thread deletereviveicon( var_0 );

    if ( isdefined( var_2 ) )
        var_3 thread laststandupdatereviveiconcoloralien( var_2 );

    return var_3;
}

deletereviveicon( var_0 )
{
    self endon( "death" );
    var_0 common_scripts\utility::waittill_any( "disconnect", "revive", "death" );
    self destroy();
}

hidehudelementongameend( var_0 )
{
    level waittill( "game_ended" );

    if ( isdefined( var_0 ) )
        var_0.alpha = 0;
}

blocker_hive_hp_bar()
{
    var_0 = 100000;

    while ( isdefined( self ) && self.health > 0 )
    {
        common_scripts\utility::waittill_notify_or_timeout( "damage", 2 );

        if ( !isdefined( self ) || self.health <= 0 )
            break;

        var_1 = max( 0.005, self.health / self.maxhealth );
        var_2 = 100 - var_1 * 100;
        var_3 = 0.5;

        if ( abs( abs( var_0 ) - abs( var_2 ) ) > var_3 )
        {
            setomnvar( "ui_alien_boss_progression", var_2 );
            var_0 = var_2;
        }
    }

    setomnvar( "ui_alien_boss_status", 0 );
}

blocker_hive_chopper_hp_bar()
{
    while ( isdefined( self ) && self.health > 0 )
    {
        common_scripts\utility::waittill_notify_or_timeout( "damage", 2 );

        if ( !isdefined( self ) || self.health <= 0 )
            break;

        var_0 = self.health / self.maxhealth;
        var_1 = var_0 * 100;
    }
}

init_player_hud_onconnect()
{
    visionsetpain( "near_death_mp" );
}

createspendhinthud( var_0, var_1, var_2 )
{
    if ( !isdefined( var_2 ) )
        maps\mp\_utility::setlowermessage( "spend_hint", &"ALIEN_COLLECTIBLES_PULL_TO_SPEND" );
    else
        maps\mp\_utility::setlowermessage( "spend_hint", var_2 );

    thread hidespendhinticon();
}

hidespendhinticon()
{
    self endon( "death" );
    self endon( "disconnect" );
    common_scripts\utility::waittill_any_timeout( 3, "action_finish_used", "player_action_slot_restart", "kill_spendhint" );
    maps\mp\_utility::clearlowermessage( "spend_hint" );
}

intro_black_screen()
{
    self endon( "disconnect" );
    self endon( "stop_intro" );
    self.introscreen_overlay = newclienthudelem( self );
    self.introscreen_overlay.x = 0;
    self.introscreen_overlay.y = 0;
    self.introscreen_overlay setshader( "black", 640, 480 );
    self.introscreen_overlay.alignx = "left";
    self.introscreen_overlay.aligny = "top";
    self.introscreen_overlay.sort = 1;
    self.introscreen_overlay.horzalign = "fullscreen";
    self.introscreen_overlay.vertalign = "fullscreen";
    self.introscreen_overlay.alpha = 1;
    self.introscreen_overlay.foreground = 1;
    level waittill( "introscreen_over" );
    self.introscreen_overlay fadeovertime( 3 );
    self.introscreen_overlay.alpha = 0;
    wait 3.5;
    self.introscreen_overlay destroy();
}

introscreen_corner_line( var_0, var_1 )
{
    if ( !isdefined( level.intro_offset ) )
        level.intro_offset = 0;
    else
        level.intro_offset++;

    var_2 = cornerline_height();
    var_3 = 1.6;

    if ( level.splitscreen )
        var_3 = 2;

    var_4 = newhudelem();
    var_4.x = 20;
    var_4.y = var_2;
    var_4.alignx = "left";
    var_4.aligny = "bottom";
    var_4.horzalign = "left";
    var_4.vertalign = "bottom";
    var_4.sort = 3;
    var_4.foreground = 1;
    var_4 settext( var_0 );
    var_4.alpha = 1;
    var_4.hidewheninmenu = 1;
    var_4.fontscale = var_3;
    var_4.color = ( 0.8, 1, 0.8 );
    var_4.font = "default";
    var_4.glowcolor = ( 0.3, 0.6, 0.3 );
    var_4.glowalpha = 1;
    var_4 setpulsefx( 35, 4000, 1000 );
    return var_4;
}

cornerline_height()
{
    var_0 = -92;

    if ( level.splitscreen )
        var_0 = -110;

    return level.intro_offset * 20 - 92;
}

displayaliengameend( var_0, var_1 )
{
    foreach ( var_3 in level.players )
    {
        if ( isdefined( var_3.connectedpostgame ) || var_3.pers["team"] == "spectator" )
            continue;

        var_3 thread alienoutcomenotify( var_0, var_1 );
        var_3 thread maps\mp\_utility::freezecontrolswrapper( 1 );
    }

    level notify( "game_win", var_0 );
    maps\mp\gametypes\_gamelogic::roundendwait( level.postroundtime, 1 );
}

alienoutcomenotify( var_0, var_1 )
{
    self endon( "disconnect" );
    self notify( "reset_outcome" );
    wait 0.5;
    var_2 = self.pers["team"];

    if ( !isdefined( var_2 ) || var_2 != "allies" && var_2 != "axis" )
        var_2 = "allies";

    while ( maps\mp\gametypes\_hud_message::isdoingsplash() )
        wait 0.05;

    self endon( "reset_outcome" );

    if ( isdefined( self.pers["team"] ) && var_0 == var_2 )
        var_3 = get_end_game_string_index( "win" );
    else
        var_3 = get_end_game_string_index( "fail" );

    self setclientomnvar( "ui_round_end_title", var_3 );
    self setclientomnvar( "ui_round_end_reason", var_1 );
    self setclientomnvar( "ui_alien_show_eog_score", 1 );
}

register_end_game_string_index()
{
    if ( isdefined( level.end_game_string_override ) )
        [[ level.end_game_string_override ]]();
    else
        register_default_end_game_string_index();
}

register_default_end_game_string_index()
{
    level.end_game_string_index = [];
    level.end_game_string_index["win"] = 1;
    level.end_game_string_index["fail"] = 2;
    level.end_game_string_index["all_escape"] = 1;
    level.end_game_string_index["some_escape"] = 2;
    level.end_game_string_index["fail_escape"] = 3;
    level.end_game_string_index["drill_destroyed"] = 4;
    level.end_game_string_index["kia"] = 5;
    level.end_game_string_index["host_end"] = 6;
    level.end_game_string_index["gas_fail"] = 7;
    level.end_game_string_index["generator_destroyed"] = 8;
}

get_end_game_string_index( var_0 )
{
    return level.end_game_string_index[var_0];
}

show_encounter_scores()
{
    level endon( "game_ended " );
    setomnvar( "ui_alien_show_encounter_score", 1 );
    wait 1.0;
    setomnvar( "ui_alien_show_encounter_score", 0 );
}

reset_player_encounter_lua_omnvars( var_0 )
{
    var_1 = 8;

    for ( var_2 = 1; var_2 <= var_1; var_2++ )
    {
        var_3 = "ui_alien_encounter_title_row_" + var_2;
        var_4 = "ui_alien_encounter_score_row_" + var_2;
        var_0 setclientomnvar( var_3, 0 );
        var_0 setclientomnvar( var_4, 0 );
    }
}

set_lua_encounter_score_row( var_0, var_1, var_2, var_3 )
{
    var_4 = "ui_alien_encounter_title_row_" + var_1;
    var_5 = "ui_alien_encounter_score_row_" + var_1;
    var_0 setclientomnvar( var_4, var_2 );
    var_0 setclientomnvar( var_5, var_3 );
}

set_lua_eog_score_row( var_0, var_1, var_2, var_3 )
{
    var_4 = "ui_alien_eog_title_row_" + var_1;
    var_5 = "ui_alien_eog_score_row_" + var_1;
    var_0 setclientomnvar( var_4, var_2 );
    var_0 setclientomnvar( var_5, var_3 );
}

make_waypoint( var_0, var_1, var_2, var_3, var_4 )
{
    var_5 = newhudelem();
    var_5 setshader( var_0, var_1, var_2 );
    var_5.alpha = var_3;
    var_5 setwaypoint( 1, 1 );
    var_5.x = var_4[0];
    var_5.y = var_4[1];
    var_5.z = var_4[2];
    return var_5;
}

chaos_hud_init()
{
    level.last_combo_meter_reset_time = 0;
}

set_combo_counter( var_0 )
{
    setomnvar( "ui_alien_chaos_combo_counter", var_0 );
}

set_score_streak( var_0 )
{
    setomnvar( "ui_alien_chaos_score_streak", var_0 );
}

set_total_score( var_0 )
{
    setomnvar( "ui_alien_chaos_total_score", var_0 );
}

reset_combo_meter( var_0 )
{
    if ( is_combo_meter_reset_this_frame() )
        return;

    foreach ( var_2 in level.players )
    {
        var_3 = gettime();
        var_2 setclientomnvar( "ui_alien_chaos_combo_meter_start", var_3 );
        var_2 setclientomnvar( "ui_alien_chaos_combo_meter_end", var_3 + int( var_0 * 1000 ) );
    }
}

is_combo_meter_reset_this_frame()
{
    var_0 = gettime();
    var_1 = level.last_combo_meter_reset_time;
    level.last_combo_meter_reset_time = var_0;
    return var_0 == var_1;
}

set_grace_period_clock( var_0 )
{
    setomnvar( "ui_alien_chaos_grace_period", var_0 );
}

unset_grace_period_clock()
{
    setomnvar( "ui_alien_chaos_grace_period", 0 );
}

set_has_combo_freeze( var_0, var_1 )
{
    var_0 setclientomnvar( "ui_alien_chaos_has_meter_freeze", var_1 );
}

freeze_combo_meter( var_0 )
{
    var_1 = gettime();
    setomnvar( "ui_alien_chaos_meter_freeze_start", var_1 );
    setomnvar( "ui_alien_chaos_meter_freeze_end", var_1 + var_0 * 1000 );
}

unfreeze_combo_meter()
{
    setomnvar( "ui_alien_chaos_meter_freeze_start", 0 );
    setomnvar( "ui_alien_chaos_meter_freeze_end", 0 );
}

set_event_count( var_0, var_1 )
{
    foreach ( var_3 in level.players )
        var_3 setclientomnvar( "ui_alien_eog_score_row_" + var_0, var_1 );
}

set_has_chaos_class_skill_bonus( var_0, var_1 )
{
    var_0 setclientomnvar( "ui_alien_chaos_class_skill_bonus", var_1 );
}

unset_has_chaos_class_skill_bonus( var_0 )
{
    var_0 setclientomnvar( "ui_alien_chaos_class_skill_bonus", 0 );
}

set_last_stand_timer( var_0, var_1 )
{
    var_0 setclientomnvar( "ui_laststand_end_milliseconds", gettime() + var_1 * 1000 );
}

clear_last_stand_timer( var_0 )
{
    var_0 setclientomnvar( "ui_laststand_end_milliseconds", 0 );
}

turn_on_drill_meter_hud( var_0 )
{
    setomnvar( "ui_alien_drill_state", 1 );
    var_1 = int( gettime() + var_0 * 1000 );
    setomnvar( "ui_alien_drill_start_milliseconds", gettime() );
    setomnvar( "ui_alien_drill_end_milliseconds", var_1 );
}

update_drill_health( var_0 )
{
    setomnvar( "ui_alien_drill_health_text", var_0 );
}
