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

main()
{
    if ( getdvar( "mapname" ) == "mp_background" )
        return;

    maps\mp\alien\_globallogic::init();
    maps\mp\gametypes\_callbacksetup::setupcallbacks();
    maps\mp\alien\_globallogic::setupcallbacks();
    level.customprematchperiod = ::alien_customprematchperiod;

    if ( isusingmatchrulesdata() )
    {
        level.initializematchrules = ::initializematchrules;
        [[ level.initializematchrules ]]();
        level thread maps\mp\_utility::reinitializematchrulesonmigration();
    }
    else
    {
        maps\mp\_utility::registerroundswitchdvar( level.gametype, 0, 0, 9 );
        maps\mp\_utility::registertimelimitdvar( level.gametype, 0 );
        maps\mp\_utility::registerscorelimitdvar( level.gametype, 500 );
        maps\mp\_utility::registerroundlimitdvar( level.gametype, 1 );
        maps\mp\_utility::registerwinlimitdvar( level.gametype, 1 );
        maps\mp\_utility::registernumlivesdvar( level.gametype, 0 );
        maps\mp\_utility::registerhalftimedvar( level.gametype, 0 );
        level.matchrules_damagemultiplier = 0;
        level.matchrules_vampirism = 0;
        level.prematchperiod = 0;
    }

    if ( level.matchrules_damagemultiplier || level.matchrules_vampirism )
        level.modifyplayerdamage = maps\mp\gametypes\_damage::gamemodemodifyplayerdamage;

    level.teambased = 1;
    level.getteamassignment = ::getteamassignment;
    level.onprecachegametype = ::onprecachegametype;
    level.killstreakinit = ::killstreakinit;
    level.onstartgametype = ::onstartgametype;
    level.onspawnplayer = ::onspawnplayer;
    level.getspawnpoint = ::getspawnpoint;
    level.endgame_alien = ::alienendgame;
    level.forceendgame_alien = ::alienforceendgame;
    level.onnormaldeath = maps\mp\alien\_death::onnormaldeath;
    level.onplayerkilled = maps\mp\alien\_death::onplayerkilled;
    level.ontimelimit = ::ontimelimit;
    level.onxpevent = ::onxpevent;
    level.bypassclasschoicefunc = ::bypassclasschoicefunc;
    level.callbackplayerlaststand = maps\mp\alien\_laststand::callback_playerlaststandalien;
    level.callbackplayerdamage = maps\mp\alien\_damage::callback_alienplayerdamage;
    level.aliens_make_entity_sentient_func = ::alien_make_entity_sentient;
    level.aliens_give_currency_func = maps\mp\alien\_persistence::give_player_currency;
    level.exploimpactmod = 0.1;
    level.shotgundamagemod = 0.1;
    level.armorpiercingmod = 0.2;
    level.custom_giveloadout = ::custom_giveloadout;
    level.boxcapturethink_alien_func = ::boxcapturethink_alien_func;
    level.regenhealthmod = 2;
    level.damagefeedbacknosound = 1;
    level.ischaosmode = getdvarint( "scr_chaos_mode", 0 );
    level.hardcoremode = getdvarint( "scr_aliens_hardcore" );
    level.ricochetdamage = getdvarint( "scr_aliens_ricochet" );
    level.infinitemode = getdvarint( "scr_aliens_infinite" );
    level.casualmode = getdvarint( "scr_aliens_casual" );
    level.playermeleestunregentime = 4000;
    setdvarifuninitialized( "alien_cover_node_retreat", 0 );
    setdvarifuninitialized( "alien_retreat_towards_spawn", 1 );

    if ( maps\mp\alien\_utility::is_hardcore_mode() )
        setomnvar( "ui_aliens_hardcore", 1 );

    if ( maps\mp\alien\_utility::is_chaos_mode() )
    {
        setomnvar( "ui_alien_chaos", 1 );
        maps\mp\alien\_chaos::set_chaos_area();
    }

    if ( !isdefined( level.ricochetdamagemax ) )
        level.ricochetdamagemax = 25;

    level.getnodearrayfunction = ::getnodearray;
    level.nodefiltertracestime = 0;
    level.nodefiltertracesthisframe = 0;
    level.maxalienattackerdifficultyvalue = 10.0;
    setalienloadout();
    healthregeninit();
    maps\mp\agents\alien\_alien_anim_utils::initalienanims();
    level thread onplayerconnect();
    level thread maps\mp\alien\_music_and_dialog::init();
    level thread maps\mp\alien\_deployablebox_functions::specialammo_init();
    level thread maps\mp\alien\_deployablebox_functions::deployables_init();
    level thread maps\mp\alien\_autosentry_alien::init();
    maps\mp\alien\_outline_proto::outline_init();
    maps\mp\alien\_ffotd::init();
    common_scripts\utility::array_thread( getentarray( "misc_turret", "classname" ), maps\mp\alien\_trap::turret_monitoruse );
}

healthregeninit()
{
    level.healthregendisabled = 0;
    level.healthregencap = getdvarfloat( "alien_playerHealthRegenCap", 1.0 );
}

getteamassignment()
{
    return "allies";
}

initializematchrules()
{
    maps\mp\_utility::setcommonrulesfrommatchrulesdata();
    setdynamicdvar( "scr_aliens_roundswitch", 0 );
    maps\mp\_utility::registerroundswitchdvar( "aliens", 0, 0, 9 );
    setdynamicdvar( "scr_aliens_roundlimit", 1 );
    maps\mp\_utility::registerroundlimitdvar( "aliens", 1 );
    setdynamicdvar( "scr_aliens_winlimit", 1 );
    maps\mp\_utility::registerwinlimitdvar( "aliens", 1 );
    setdynamicdvar( "scr_aliens_halftime", 0 );
    maps\mp\_utility::registerhalftimedvar( "aliens", 0 );
    setdynamicdvar( "scr_aliens_promode", 0 );
}

onprecachegametype()
{
    precachestring( &"ALIEN_COLLECTIBLES_SELF_REVIVED" );
    precachestring( &"ALIEN_COLLECTIBLES_PLANT_BOMB" );
    precachestring( &"ALIEN_COLLECTIBLES_NO_BOMB" );
    precachestring( &"ALIEN_COLLECTIBLES_GO_PLANT_BOMB" );
    precachestring( &"ALIEN_COLLECTIBLES_PICKUP_BOMB" );
    precachestring( &"ALIEN_COLLECTIBLES_REPAIR_DRILL" );
    precachestring( &"ALIEN_COLLECTIBLES_ACTIVATE_NUKE" );
    precachestring( &"ALIEN_COLLECTIBLES_COUNTDOWN_NUKE" );
    precachestring( &"ALIEN_COLLECTIBLES_DRILL_DESTROYED" );
    level._effect["alien_teleport"] = loadfx( "vfx/test/vfx_alien_teleport" );
    level._effect["alien_teleport_dist"] = loadfx( "vfx/test/vfx_alien_teleport_dist" );
    level._effect["Riotshield_fire"] = loadfx( "vfx/gameplay/alien/vfx_alien_on_fire" );
    level._effect["arcade_death"] = loadfx( "vfx/moments/alien/vfx_alien_arcade_death" );
    maps\mp\agents\alien\_alien_elite::load_queen_fx();
    maps\mp\agents\alien\_alien_spitter::load_spitter_fx();
    level._effect["drone_ground_spawn"] = loadfx( "vfx/gameplay/alien/vfx_alien_drone_ground_spawn" );
    level._effect["deployablebox_crate_destroy"] = loadfx( "vfx/test/vfx_alien_teleport" );
    maps\mp\agents\alien\_alien_minion::load_minion_fx();
    level._effect["bomb_impact"] = loadfx( "vfx/ambient/sparks/electrical_sparks" );
    level._effect["shield_impact"] = loadfx( "fx/impacts/large_metalhit_1" );
    level._effect["airdrop_crate_destroy"] = loadfx( "vfx/gameplay/mp/killstreaks/vfx_ims_explosion" );
    level._effect["melee_blood"] = loadfx( "vfx/gameplay/impacts/small/impact_alien_flesh_hit_b_fatal" );
    precacheturret( "turret_minigun_alien" );

    if ( maps\mp\alien\_utility::alien_mode_has( "airdrop" ) )
    {
        precachevehicle( "littlebird_alien" );
        precachevehicle( "nh90_alien" );
        precachempanim( "alien_drill_enter" );
        precachempanim( "alien_drill_loop" );
        precachempanim( "alien_drill_end" );
        precachempanim( "alien_drill_operate_enter" );
        precachempanim( "alien_drill_nonoperate" );
        precachempanim( "alien_drill_operate_end" );
        precachempanim( "alien_drill_attack_drill_F_enter" );
        precachempanim( "alien_drill_attack_drill_F_exit" );
        precachempanim( "alien_drill_attack_drill_F_loop" );
        precachempanim( "alien_drill_attack_drill_L_enter" );
        precachempanim( "alien_drill_attack_drill_L_exit" );
        precachempanim( "alien_drill_attack_drill_L_loop" );
        precachempanim( "alien_drill_attack_drill_R_enter" );
        precachempanim( "alien_drill_attack_drill_R_exit" );
        precachempanim( "alien_drill_attack_drill_R_loop" );
        precachempanim( "alien_goon_drill_attack_drill_F_enter" );
        precachempanim( "alien_goon_drill_attack_drill_F_loop" );
        precachempanim( "alien_goon_drill_attack_drill_F_exit" );
        precachempanim( "alien_goon_drill_attack_drill_R_enter" );
        precachempanim( "alien_goon_drill_attack_drill_R_loop" );
        precachempanim( "alien_goon_drill_attack_drill_R_exit" );
        precachempanim( "alien_goon_drill_attack_drill_L_enter" );
        precachempanim( "alien_goon_drill_attack_drill_L_loop" );
        precachempanim( "alien_goon_drill_attack_drill_L_exit" );
        precachempanim( "alien_sentry_attack_sentry_front_enter" );
        precachempanim( "alien_sentry_attack_sentry_front_exit" );
        precachempanim( "alien_sentry_attack_sentry_front_loop" );
        precachempanim( "alien_sentry_attack_sentry_side_r_enter" );
        precachempanim( "alien_sentry_attack_sentry_side_r_exit" );
        precachempanim( "alien_sentry_attack_sentry_side_r_loop" );
        precachempanim( "alien_sentry_attack_sentry_side_l_enter" );
        precachempanim( "alien_sentry_attack_sentry_side_l_exit" );
        precachempanim( "alien_sentry_attack_sentry_side_l_loop" );
        precachempanim( "alien_goon_sentry_attack_sentry_F_enter" );
        precachempanim( "alien_goon_sentry_attack_sentry_F_exit" );
        precachempanim( "alien_goon_sentry_attack_sentry_F_loop" );
        precachempanim( "alien_goon_sentry_attack_sentry_L_enter" );
        precachempanim( "alien_goon_sentry_attack_sentry_L_exit" );
        precachempanim( "alien_goon_sentry_attack_sentry_L_loop" );
        precachempanim( "alien_goon_sentry_attack_sentry_R_enter" );
        precachempanim( "alien_goon_sentry_attack_sentry_R_exit" );
        precachempanim( "alien_goon_sentry_attack_sentry_R_loop" );
    }

    if ( maps\mp\alien\_intro_sequence::intro_sequence_enabled() )
        maps\mp\alien\_intro_sequence::intro_sequence_precache();
}

onstartgametype()
{
    if ( isdefined( level.custom_onstartgametypefunc ) )
        [[ level.custom_onstartgametypefunc ]]();

    setnojiptime( 1 );
    setclientnamemode( "auto_change" );
    thread maps\mp\alien\_utility::mp_ents_clean_up();
    level.disableforfeit = 1;
    level.damagelistsize = 20;
    maps\mp\_utility::setobjectivetext( "allies", &"ALIEN_OBJECTIVES_ALIENS" );
    maps\mp\_utility::setobjectivetext( "axis", &"ALIEN_OBJECTIVES_ALIENS" );

    if ( level.splitscreen )
    {
        maps\mp\_utility::setobjectivescoretext( "allies", &"ALIEN_OBJECTIVES_ALIENS" );
        maps\mp\_utility::setobjectivescoretext( "axis", &"ALIEN_OBJECTIVES_ALIENS" );
    }
    else
    {
        maps\mp\_utility::setobjectivescoretext( "allies", &"ALIEN_OBJECTIVES_ALIENS_SCORE" );
        maps\mp\_utility::setobjectivescoretext( "axis", &"ALIEN_OBJECTIVES_ALIENS_SCORE" );
    }

    maps\mp\_utility::setobjectivehinttext( "allies", &"ALIEN_OBJECTIVES_ALIENS_HINT" );
    maps\mp\_utility::setobjectivehinttext( "axis", &"ALIEN_OBJECTIVES_ALIENS_HINT" );
    maps\mp\alien\_persistence::bbdata_init();
    maps\mp\alien\_persistence::rank_init();
    maps\mp\alien\_persistence::register_eog_to_lb_playerdata_mapping();
    maps\mp\alien\_progression::main();
    init_threatbiasgroups();

    if ( maps\mp\alien\_utility::alien_mode_has( "collectible" ) )
        maps\mp\alien\_collectibles::pre_load();

    maps\mp\alien\_deployablebox_functions::pre_load();

    if ( maps\mp\alien\_utility::alien_mode_has( "scenes" ) )
        maps\mp\alien\_spawnlogic::alien_scene_init();

    maps\mp\alien\_alien_fx::main();
    maps\mp\alien\_spawnlogic::alien_health_per_player_init();
    initspawns();
    var_0[0] = level.gametype;
    maps\mp\gametypes\_gameobjects::main( var_0 );
    level.current_cycle_num = 0;
    level.num_hive_destroyed = 0;
    level thread maps\mp\alien\_trap::traps_init();
    maps\mp\alien\_gamescore::init_gamescore();
    level.spitter_gas_cloud_count = 0;
    level.gametweaks["spectatetype"].value = 1;

    if ( should_enable_pillage() )
        thread maps\mp\alien\_pillage::pillage_init();

    if ( maps\mp\alien\_utility::alien_mode_has( "challenge" ) )
        maps\mp\alien\_challenge::init_challenge();

    maps\mp\alien\_unlock::init_unlock();
    maps\mp\alien\_prestige::init_prestige();
    maps\mp\alien\_hud::init();
    level.lowermessagefont = "objective";

    if ( level.splitscreen )
        level.lowertextfontsize = 1.35;

    if ( !level.console )
        level.lowertextfontsize = 1;

    level.teamtweaks["fftype"].value = 1;
    maps\mp\alien\_death::kill_trigger_spawn_init();
    level thread handle_nondeterministic_entities();
    level thread maps\mp\alien\_trap::easter_egg_lodge_sign();
    level.xpscale = getdvarint( "scr_aliens_xpscale" );
    level.xpscale = min( level.xpscale, 4 );
    level.xpscale = max( level.xpscale, 0 );
    maps\mp\alien\_alien_matchdata::start_game_type();
    maps\mp\alien\_ffotd::onstartgametype();
    level thread run_encounters();
}

should_enable_pillage()
{
    if ( maps\mp\alien\_utility::is_chaos_mode() )
        return 0;

    return maps\mp\alien\_utility::alien_mode_has( "pillage" );
}

handle_nondeterministic_entities()
{
    wait 5;
    handle_nondeterministic_entities_internal();
    level notify( "spawn_nondeterministic_entities" );
}

handle_nondeterministic_entities_internal()
{
    if ( maps\mp\alien\_utility::alien_mode_has( "collectible" ) )
        maps\mp\alien\_collectibles::post_load();

    if ( !maps\mp\alien\_utility::alien_mode_has( "nogame" ) && maps\mp\alien\_utility::alien_mode_has( "wave" ) && maps\mp\alien\_spawnlogic::use_spawn_director() )
    {
        maps\mp\alien\_hive::remove_unused_hives( level.removed_hives );
        level.removed_hives = undefined;
    }

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        maps\mp\alien\_chaos::create_alien_eggs();
}

spawnallypet( var_0, var_1, var_2, var_3, var_4, var_5 )
{
    wait 0.05;
    var_6 = "wave " + var_0;

    for ( var_7 = 0; var_7 < var_1; var_7++ )
    {
        var_8 = var_2;

        if ( var_6 == "wave elite" )
        {
            var_9 = bullettrace( var_2 + ( 0, 0, 128 ), var_2 + ( 0, 0, -128 ), 0 );

            if ( var_9["fraction"] == 0 || var_9["fraction"] == 1 )
                continue;

            var_8 = var_9["position"];
        }

        var_10 = var_4;
        var_11 = var_8;
        var_12 = addalienagent( "allies", var_11, var_10, var_6 );
        var_12.pet = 1;
        var_12.owner = var_3;
        var_12.petfollowdist = 1024;
        var_12.threatbias = -800;

        if ( var_0 == "goon" )
        {
            var_12.maxhealth = int( 100 * level.alien_health_per_player_scalar[level.players.size] );
            var_12.health = int( 100 * level.alien_health_per_player_scalar[level.players.size] );
        }
        else if ( var_0 == "brute" )
        {
            var_12.maxhealth = int( 200 * level.alien_health_per_player_scalar[level.players.size] );
            var_12.health = int( 200 * level.alien_health_per_player_scalar[level.players.size] );
        }
        else if ( var_0 == "spitter" )
        {
            var_12.maxhealth = int( 150 * level.alien_health_per_player_scalar[level.players.size] );
            var_12.health = int( 150 * level.alien_health_per_player_scalar[level.players.size] );
        }
        else if ( var_0 == "locust" )
        {
            var_12.maxhealth = int( 250 * level.alien_health_per_player_scalar[level.players.size] );
            var_12.health = int( 250 * level.alien_health_per_player_scalar[level.players.size] );
        }
        else if ( var_0 == "elite" )
        {
            var_12.maxhealth = int( 350 * level.alien_health_per_player_scalar[level.players.size] );
            var_12.health = int( 350 * level.alien_health_per_player_scalar[level.players.size] );
        }

        if ( maps\mp\alien\_utility::is_true( var_5 ) )
        {
            var_12.maxhealth = int( var_12.maxhealth * 1.25 );
            var_12.health = int( var_12.maxhealth * 1.25 );
        }

        var_12 maps\mp\alien\_utility::set_alien_emissive( 0.5, 0.0 );

        if ( var_3 maps\mp\alien\_persistence::is_upgrade_enabled( "master_scavenger_upgrade" ) )
        {
            var_12.upgraded = 1;
            maps\mp\alien\_outline_proto::enable_outline( var_12, 2, 0 );
        }
        else
            maps\mp\alien\_outline_proto::enable_outline( var_12, 3, 0 );

        var_12 setscriptablepartstate( "body", "pet" );

        if ( isdefined( self.entityheadicon ) )
            self.entityheadicon destroy();

        var_12 thread ally_pet_time_out( var_5 );
        var_12 thread kill_alien_on_owner_disconnect( var_3 );
    }
}

ally_pet_time_out( var_0 )
{
    level endon( "game_ended" );
    self endon( "death" );
    var_1 = 180;

    if ( maps\mp\alien\_utility::is_true( var_0 ) )
        var_1 = var_1 * 1.25;

    wait( var_1 );
    playfx( level._effect["alien_minion_explode"], self.origin + ( 0, 0, 32 ) );
    self suicide();
}

kill_alien_on_owner_disconnect( var_0 )
{
    self endon( "death" );
    var_0 waittill( "disconnect" );
    playfx( level._effect["alien_minion_explode"], self.origin + ( 0, 0, 32 ) );
    self suicide();
}

onplayerconnect()
{
    for (;;)
    {
        level waittill( "connected", var_0 );

        if ( !isai( var_0 ) )
        {
            if ( maps\mp\alien\_utility::is_chaos_mode() )
                maps\mp\alien\_chaos::chaos_onplayerconnect( var_0 );

            var_0 maps\mp\alien\_alien_matchdata::on_player_connect();

            if ( isdefined( var_0.connecttime ) )
                var_0.connect_time = var_0.connecttime;
            else
                var_0.connect_time = gettime();

            var_0 maps\mp\alien\_prestige::init_player_prestige();
            var_0 maps\mp\alien\_persistence::player_persistence_init();
            var_0 thread maps\mp\alien\_utility::weapon_change_monitor();
            var_0 thread threat_bias_grouping();
            var_0 thread player_init_health_regen();
            var_0 maps\mp\alien\_hud::init_player_hud_onconnect();
            var_0 maps\mp\alien\_gamescore::init_player_score();
            var_0 thread maps\mp\alien\_progression::player_setup();
            var_0 maps\mp\alien\_achievement::init_player_achievement();
            var_0 maps\mp\alien\_unlock::init_player_unlock();
            var_0 thread maps\mp\alien\_persistence::play_time_monitor();
            var_0 initial_spawn_pos_override();

            if ( !maps\mp\alien\_utility::is_casual_mode() )
                var_0 setclientomnvar( "allow_write_leaderboards", 1 );
            else
                var_0 setclientomnvar( "allow_write_leaderboards", 0 );

            if ( common_scripts\utility::flag_exist( "hives_cleared" ) && common_scripts\utility::flag( "hives_cleared" ) )
            {
                var_0.threatbias = 100000;
                var_0 thread maps\mp\alien\_persistence::set_game_state( "escaping" );
            }
            else if ( !isdefined( level.cycle_count ) || level.cycle_count < 1 )
                var_0 thread maps\mp\alien\_persistence::set_game_state( "pregame" );
            else if ( isdefined( level.cycle_count ) && level.cycle_count == 1 )
                var_0 thread maps\mp\alien\_persistence::set_game_state( "prehive" );
            else
                var_0 thread maps\mp\alien\_persistence::set_game_state( "progressing" );

            if ( maps\mp\alien\_utility::alien_mode_has( "kill_resource" ) )
                var_0 thread player_init_assist_bonus();

            var_1 = get_hotjoin_skill_points();

            if ( var_1 > 0 )
                var_0 maps\mp\alien\_persistence::give_player_points( var_1 );

            var_0 resetuidvarsonconnect();

            if ( maps\mp\alien\_utility::alien_mode_has( "outline" ) )
                var_0 thread maps\mp\alien\_outline_proto::outline_monitor();

            if ( maps\mp\alien\_utility::alien_mode_has( "challenge" ) )
            {
                if ( maps\mp\alien\_challenge::current_challenge_exist() && maps\mp\alien\_utility::alien_mode_has( "challenge" ) )
                    var_0 thread maps\mp\alien\_challenge::handle_challenge_hotjoin();
            }

            var_0 thread special_weapon_hints();
            var_0 thread enable_disable_usability_monitor();
            var_0 thread monitordisownkillstreaks();

            if ( common_scripts\utility::flag_exist( "drill_drilling" ) )
                var_0 thread maps\mp\alien\_drill::check_for_player_near_hive_with_drill();

            var_0 thread maps\mp\alien\_hud::intro_black_screen();

            if ( maps\mp\alien\_utility::is_true( level.introscreen_done ) )
                var_0 thread player_hotjoin();

            var_0 maps\mp\alien\_ffotd::onplayerconnect();
        }
    }
}

initial_spawn_pos_override()
{
    if ( isdefined( level.initial_spawn_loc_override_func ) )
        self [[ level.initial_spawn_loc_override_func ]]();
}

get_hotjoin_skill_points()
{
    if ( isdefined( level.hotjoin_skill_points_fun ) )
        return [[ level.hotjoin_skill_points_fun ]]();
    else
        return default_hotjoin_skill_points();
}

default_hotjoin_skill_points()
{
    var_0 = 1;

    if ( maps\mp\alien\_utility::is_hardcore_mode() )
        var_1 = 0;
    else
        var_1 = max( 0, level.num_hive_destroyed - var_0 );

    var_2 = maps\mp\alien\_challenge::get_num_challenge_completed();
    return var_1 + var_2;
}

init_threatbiasgroups()
{
    createthreatbiasgroup( "players" );
    createthreatbiasgroup( "hive_heli" );
    createthreatbiasgroup( "other_aliens" );
    createthreatbiasgroup( "spitters" );
    createthreatbiasgroup( "dontattackdrill" );
    createthreatbiasgroup( "drill" );
    setthreatbias( "hive_heli", "spitters", 10000 );
    setignoremegroup( "hive_heli", "other_aliens" );
    setignoremegroup( "drill", "dontattackdrill" );
    setignoremegroup( "hive_heli", "dontattackdrill" );
}

threat_bias_grouping()
{
    level endon( "game_ended" );

    while ( !threatbiasgroupexists( "players" ) )
        wait 0.05;

    self setthreatbiasgroup( "players" );
}

player_hotjoin()
{
    self endon( "disconnect" );
    self notify( "intro_done" );
    self waittill( "spawned" );
    self.pers["hotjoined"] = 1;
    self.introscreen_overlay fadeovertime( 1 );
    wait 1;
    self.introscreen_overlay destroy();
    var_0 = maps\mp\alien\_spawnlogic::get_alive_enemies();

    if ( !isdefined( var_0 ) || var_0.size < 1 )
        return;

    foreach ( var_2 in var_0 )
    {
        if ( isdefined( var_2 ) && maps\mp\alien\_utility::is_true( var_2.pet ) )
            maps\mp\alien\_outline_proto::enable_outline_for_player( var_2, self, 3, 0, "high" );
    }
}

player_init_health_regen()
{
    self.healthregenmaxpercent = level.healthregencap;
    self.regenspeed = 1;
}

player_init_invulnerability()
{
    self.haveinvulnerabilityavailable = 1;
}

player_init_damageshield()
{
    self.damageshieldexpiretime = gettime();
}

player_init_assist_bonus()
{
    self.leftover_assist_bonus = 0;
}

onspawnplayer()
{
    self.pers["gamemodeLoadout"] = level.alien_loadout;
    self.drillspeedmodifier = 1.0;
    self.fireshield = 0;
    self.isreviving = 0;
    self.isrepairing = 0;
    self.iscarrying = 0;
    self.isboosted = undefined;
    self.ishealthboosted = undefined;
    self.burning = undefined;
    self.shocked = undefined;
    self.player_action_disabled = undefined;

    if ( maps\mp\alien\_perk_utility::has_perk( "perk_health" ) )
    {
        self.maxhealth = maps\mp\alien\_perk_utility::perk_getmaxhealth();
        self.health = self.maxhealth;
    }

    thread player_last_death_pos();
    thread alienplayerhealthhints();
    player_init_invulnerability();
    player_init_damageshield();
    maps\mp\alien\_laststand::player_init_laststand();

    if ( maps\mp\alien\_persistence::is_upgrade_enabled( "shock_melee_upgrade" ) )
        thread melee_strength_timer();

    if ( maps\mp\alien\_persistence::is_upgrade_enabled( "locker_key_upgrade" ) )
    {
        var_0 = getdvar( "ui_mapname" );

        if ( var_0 == "mp_alien_armory" || var_0 == "mp_alien_beacon" || var_0 == "mp_alien_dlc3" || var_0 == "mp_alien_last" )
            thread init_locker_key_upgrade();
    }

    if ( maps\mp\alien\_utility::alien_mode_has( "loot" ) )
        maps\mp\alien\_collectibles::player_loot_init();

    if ( maps\mp\alien\_utility::alien_mode_has( "airdrop" ) )
        thread maps\mp\alien\_drill::watchbomb();

    thread maps\mp\alien\_collectibles::watchthrowableitems();
    thread maps\mp\alien\_utility::trackriotshield();
    thread alienplayerhealthregen();
    thread alienplayerarmor();
    thread maps\mp\alien\_perkfunctions::watchcombatspeedscaler();
    self.threatbias = maps\mp\alien\_prestige::prestige_getthreatbiasscalar();
    resetuidvarsonspawn();
    thread maps\mp\alien\_trap::monitor_flare_use();
    thread watchdisconnectendgame();

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        maps\mp\alien\_chaos::chaos_onspawnplayer( self );

    if ( isdefined( level.custom_onspawnplayer_func ) )
        self [[ level.custom_onspawnplayer_func ]]();

    if ( isdefined( level.resetplayercraftingitemsonrespawn ) )
        self [[ level.resetplayercraftingitemsonrespawn ]]();

    if ( maps\mp\alien\_utility::has_pistols_only_relic_and_no_deployables() )
        thread maps\mp\alien\_collectibles::check_for_player_near_weapon();

    thread maps\mp\alien\_utility::setup_class_nameplates();
    thread kick_for_inactivity();
    maps\mp\alien\_ffotd::onspawnplayer();
}

watchdisconnectendgame()
{
    level endon( "game_ended" );
    self waittill( "disconnect" );

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        var_0 = maps\mp\alien\_chaos_laststand::chaos_gameshouldend( self );
    else
        var_0 = maps\mp\alien\_laststand::gameshouldend( self );

    if ( var_0 )
        level thread alienendgame( "axis", maps\mp\alien\_hud::get_end_game_string_index( "kia" ) );
}

kick_for_inactivity()
{
    level endon( "game_ended" );
    self endon( "disconnect" );
    var_0 = level.onlinegame && !getdvarint( "xblive_privatematch" );

    if ( var_0 )
    {
        var_1 = self getnormalizedmovement();
        var_2 = gettime();

        for (;;)
        {
            wait 0.2;
            var_3 = self getnormalizedmovement();

            if ( var_3[0] == var_1[0] && var_3[1] == var_1[1] )
            {
                if ( gettime() - var_2 > 300000 && level.players.size > 1 )
                    kick( self getentitynumber(), "EXE_PLAYERKICKED_INACTIVE" );

                continue;
            }

            return;
        }
    }
}

player_last_death_pos()
{
    level endon( "game_ended" );
    self endon( "death" );
    self endon( "disconnect" );
    self.last_death_pos = self.origin;

    for (;;)
    {
        self waittill( "damage" );
        self.last_death_pos = self.origin;
    }
}

alienplayerhealthhints()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );

    for (;;)
    {
        var_0 = 0.33;
        var_0 = int( var_0 * 100 ) / 100;
        var_1 = self.health / self.maxhealth;

        if ( isdefined( self.laststand ) && self.laststand )
        {
            wait 0.05;
            continue;
        }

        if ( var_1 < var_0 )
        {
            if ( has_healthpack() )
            {

            }
            else
            {

            }
        }

        common_scripts\utility::waittill_any_timeout( 5, "health_regened", "damage" );
        waittillframeend;
    }
}

has_healthpack()
{
    if ( isdefined( self.has_health_pack ) && self.has_health_pack )
        return 1;

    return 0;
}

ontimelimit()
{
    maps\mp\gametypes\_gamelogic::default_ontimelimit();
}

onxpevent( var_0 )
{
    maps\mp\alien\_globallogic::onxpevent( var_0 );
}

getspawnpoint()
{
    var_0 = self.pers["team"];

    if ( level.graceperiod && isdefined( level.alien_player_spawn_group ) )
    {
        var_1 = [ "group0", "group1", "group2", "group3" ];
        var_1 = common_scripts\utility::array_randomize( var_1 );
        level.group = var_1[0];
        var_2 = level.group;
        var_3 = maps\mp\gametypes\_spawnlogic::getspawnpointarray( "mp_alien_spawn_" + var_2 + "_start" );
        var_4 = maps\mp\gametypes\_spawnlogic::getspawnpoint_random( var_3 );
    }
    else
    {
        var_3 = maps\mp\gametypes\_spawnlogic::getspawnpointarray( "mp_tdm_spawn_axis_start" );
        var_4 = maps\mp\gametypes\_spawnlogic::getspawnpoint_random( var_3 );
    }

    return var_4;
}

initspawns()
{
    maps\mp\alien\_director::alien_attribute_table_init();

    if ( maps\mp\alien\_utility::alien_mode_has( "wave" ) )
    {
        maps\mp\alien\_spawnlogic::alien_wave_init();
        thread maps\mp\alien\_spawnlogic::setup_meteoroid_paths();
        maps\mp\alien\_spawnlogic::alien_lurker_init();
    }

    level.spawnmins = ( 0, 0, 0 );
    level.spawnmaxs = ( 0, 0, 0 );
    maps\mp\gametypes\_spawnlogic::addstartspawnpoints( "mp_tdm_spawn_axis_start" );

    if ( isdefined( level.alien_player_spawn_group ) )
    {
        maps\mp\gametypes\_spawnlogic::addstartspawnpoints( "mp_alien_spawn_group3_start" );
        maps\mp\gametypes\_spawnlogic::addstartspawnpoints( "mp_alien_spawn_group1_start" );
        maps\mp\gametypes\_spawnlogic::addstartspawnpoints( "mp_alien_spawn_group0_start" );
    }

    level.mapcenter = maps\mp\gametypes\_spawnlogic::findboxcenter( level.spawnmins, level.spawnmaxs );
    setmapcenter( level.mapcenter );
}

addalienagent( var_0, var_1, var_2, var_3, var_4 )
{
    var_5 = maps\mp\agents\_agent_common::connectnewagent( "alien", var_0 );

    if ( isdefined( var_5 ) )
        var_5 thread [[ var_5 maps\mp\agents\_agent_utility::agentfunc( "spawn" ) ]]( var_1, var_2, var_3, var_4 );

    return var_5;
}

setalienloadout()
{
    level.alien_loadout["loadoutPrimary"] = "none";
    level.alien_loadout["loadoutPrimaryAttachment"] = "none";
    level.alien_loadout["loadoutPrimaryAttachment2"] = "none";
    level.alien_loadout["loadoutPrimaryBuff"] = "specialty_null";
    level.alien_loadout["loadoutPrimaryCamo"] = "none";
    level.alien_loadout["loadoutPrimaryReticle"] = "none";
    level.alien_loadout["loadoutSecondary"] = "iw6_alienp226";
    level.alien_loadout["loadoutSecondaryAttachment"] = "none";
    level.alien_loadout["loadoutSecondaryAttachment2"] = "none";
    level.alien_loadout["loadoutSecondaryBuff"] = "specialty_null";
    level.alien_loadout["loadoutSecondaryCamo"] = "none";
    level.alien_loadout["loadoutSecondaryReticle"] = "none";
    level.alien_loadout["loadoutEquipment"] = "none";
    level.alien_loadout["loadoutOffhand"] = "none";
    level.alien_loadout["loadoutPerk1"] = "specialty_pistoldeath";
    level.alien_loadout["loadoutPerk2"] = "specialty_null";
    level.alien_loadout["loadoutPerk3"] = "specialty_null";
    level.alien_loadout["loadoutJuggernaut"] = 0;
}

pistol_ammo_regen( var_0 )
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    var_1 = self getweaponslistprimaries();

    foreach ( var_3 in var_1 )
    {
        var_4 = getweaponbasename( var_3 );

        if ( var_4 == "iw6_alienp226_mp" || var_4 == "iw6_alienmagnum_mp" || var_4 == "iw6_alienm9a1_mp" || var_4 == "iw6_alienmp443_mp" )
        {
            var_5 = weaponclipsize( var_3 );
            self setweaponammoclip( var_3, var_5 );
        }
    }

    var_7 = 0.2;

    for (;;)
    {
        if ( maps\mp\alien\_perk_utility::perk_getpistolregen() == 1 )
        {
            if ( maps\mp\alien\_utility::player_has_specialized_ammo( "iw6_alienp226" ) || maps\mp\alien\_utility::player_has_specialized_ammo( "iw6_alienmagnum" ) || maps\mp\alien\_utility::player_has_specialized_ammo( "iw6_alienm9a1" ) || maps\mp\alien\_utility::player_has_specialized_ammo( "iw6_alienmp443" ) )
            {
                wait( var_7 );
                continue;
            }

            var_1 = self getweaponslistprimaries();

            foreach ( var_3 in var_1 )
            {
                var_4 = getweaponbasename( var_3 );

                if ( var_4 == "iw6_alienp226_mp" || var_4 == "iw6_alienmagnum_mp" || var_4 == "iw6_alienm9a1_mp" || var_4 == "iw6_alienmp443_mp" )
                {
                    var_9 = self getweaponammostock( var_3 );
                    self setweaponammostock( var_3, var_9 + 1 );
                }
            }

            wait( var_7 );
        }

        wait 0.05;
    }
}

bypassclasschoicefunc()
{
    return "gamemode";
}

alienplayerhealthregen()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "joined_team" );
    self endon( "joined_spectators" );
    self endon( "faux_spawn" );
    level endon( "game_ended" );
    thread maps\mp\alien\_music_and_dialog::alienplayerpainbreathingsound();

    for (;;)
    {
        common_scripts\utility::waittill_any( "damage", "health_perk_upgrade" );

        if ( !canregenhealth() )
            continue;

        var_0 = gethealthcap();
        var_1 = self.health / var_0;
        thread healthregen( gettime(), var_1, var_0 );
        thread maps\mp\gametypes\_healthoverlay::breathingmanager( gettime(), var_1 );
    }
}

alienplayerarmor()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "joined_team" );
    self endon( "joined_spectators" );
    self endon( "faux_spawn" );
    self endon( "game_ended" );

    if ( !isdefined( self.bodyarmorhp ) )
        self.bodyarmorhp = 0;

    self setcoopplayerdata( "alienSession", "armor", 0 );
    var_0 = 0;

    for (;;)
    {
        common_scripts\utility::waittill_any( "player_damaged", "enable_armor" );

        if ( !isdefined( self.bodyarmorhp ) )
        {
            if ( var_0 > 0 )
            {
                self setcoopplayerdata( "alienSession", "armor", 0 );
                var_0 = 0;
            }

            continue;
        }

        if ( var_0 != self.bodyarmorhp )
        {
            var_1 = int( self.bodyarmorhp );
            self setcoopplayerdata( "alienSession", "armor", var_1 );
            var_0 = self.bodyarmorhp;
        }
    }
}

gethealthcap()
{
    self.healthregenmaxpercent = 1.0;
    var_0 = clamp( self.maxhealth * self.healthregenmaxpercent, 0, self.maxhealth );
    return int( var_0 );
}

canregenhealth()
{
    if ( isdefined( self.inlaststand ) && self.inlaststand )
        return 0;

    return 1;
}

healthregen( var_0, var_1, var_2 )
{
    self notify( "healthRegeneration" );
    self endon( "healthRegeneration" );
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "joined_team" );
    self endon( "joined_spectators" );
    level endon( "game_ended" );

    if ( ishealthregendisabled() )
        return;

    var_3 = spawnstruct();
    getregendata( var_3 );
    wait( var_3.activatetime );

    for (;;)
    {
        var_3 = spawnstruct();
        getregendata( var_3 );

        if ( !maps\mp\alien\_utility::has_fragile_relic_and_is_sprinting() )
        {
            if ( self.health < int( var_2 ) )
            {
                if ( self.health + var_3.regenamount > int( var_2 ) )
                    self.health = int( var_2 );
                else
                    self.health = self.health + var_3.regenamount;
            }
            else
                break;
        }

        wait( var_3.waittimebetweenregen );
    }

    self notify( "healed" );
    player_init_invulnerability();
    maps\mp\gametypes\_damage::resetattackerlist();
}

getregendata( var_0 )
{
    self.prestigehealthregennerfscalar = maps\mp\alien\_prestige::prestige_getslowhealthregenscalar();

    if ( self.prestigehealthregennerfscalar == 1.0 )
    {
        if ( isdefined( self.ishealthboosted ) )
        {
            var_0.activatetime = 2.25;
            var_0.waittimebetweenregen = 0.2625;
            var_0.regenamount = 1;
        }
        else if ( maps\mp\alien\_persistence::is_upgrade_enabled( "faster_health_regen_upgrade" ) )
        {
            var_0.activatetime = 2.7;
            var_0.waittimebetweenregen = 0.315;
            var_0.regenamount = 1;
        }
        else
        {
            var_0.activatetime = 3.0;
            var_0.waittimebetweenregen = 0.35;
            var_0.regenamount = 1;
        }
    }
    else
    {
        var_0.activatetime = 3.0 * self.prestigehealthregennerfscalar;
        var_0.waittimebetweenregen = 0.35 * self.prestigehealthregennerfscalar;
        var_0.regenamount = 1;
    }
}

ishealthregendisabled()
{
    return isdefined( level.healthregendisabled ) && level.healthregendisabled || isdefined( self.healthregendisabled ) && self.healthregendisabled;
}

resetuidvarsonspawn()
{

}

resetuidvarsonconnect()
{
    self setclientomnvar( "ui_alien_max_currency", self.maxcurrency );
    setdvar( "cg_drawCrosshairNames", 0 );
}

resetuidvarsonspectate()
{

}

alien_make_entity_sentient( var_0, var_1 )
{
    if ( should_make_entity_sentient() )
    {
        if ( isdefined( var_1 ) )
            return self makeentitysentient( var_0, var_1 );
        else
            return self makeentitysentient( var_0 );
    }
}

should_make_entity_sentient()
{
    if ( isdefined( self.sentrytype ) )
        return 1;

    if ( isdefined( level.drill ) && self == level.drill )
        return 1;

    if ( isdefined( self.flaretype ) )
        return 1;

    return 0;
}

custom_giveloadout( var_0 )
{
    self takeallweapons();
    self.changingweapon = undefined;
    self.loadoutprimaryattachments = [];
    self.loadoutsecondaryattachments = [];
    maps\mp\_utility::_setactionslot( 1, "" );
    maps\mp\_utility::_setactionslot( 2, "" );
    maps\mp\_utility::_setactionslot( 3, "altMode" );
    maps\mp\_utility::_setactionslot( 4, "" );

    if ( !level.console )
    {
        maps\mp\_utility::_setactionslot( 5, "" );
        maps\mp\_utility::_setactionslot( 6, "" );
        maps\mp\_utility::_setactionslot( 7, "" );
    }

    maps\mp\_utility::_clearperks();
    maps\mp\alien\_utility::_detachall();
    self.spawnperk = 0;

    if ( isdefined( self.headmodel ) )
        self.headmodel = undefined;

    set_player_character_model();
    var_1 = getplayermodelindex();
    var_2 = getplayerfoleytype( var_1 );
    self setclothtype( var_2 );
    maps\mp\gametypes\_weapons::updatemovespeedscale();
    self.killstreaktype = "none";
    self.primaryweapon = "none";
    var_3 = self getcoopplayerdata( "alienPlayerLoadout", "perks", 1 );

    switch ( var_3 )
    {
        case "perk_pistol_p226_4":
        case "perk_pistol_p226_3":
        case "perk_pistol_p226_2":
        case "perk_pistol_p226_1":
        case "perk_pistol_p226":
            self.default_starting_pistol = "iw6_alienp226_mp";
            break;
        case "perk_pistol_magnum_4":
        case "perk_pistol_magnum_3":
        case "perk_pistol_magnum_2":
        case "perk_pistol_magnum_1":
        case "perk_pistol_magnum":
            if ( maps\mp\alien\_persistence::is_upgrade_enabled( "magnum_acog_upgrade" ) )
                self.default_starting_pistol = "iw6_alienmagnum_mp_acogpistol_scope5";
            else
                self.default_starting_pistol = "iw6_alienmagnum_mp";

            break;
        case "perk_pistol_m9a1_4":
        case "perk_pistol_m9a1_3":
        case "perk_pistol_m9a1_2":
        case "perk_pistol_m9a1_1":
        case "perk_pistol_m9a1":
            self.default_starting_pistol = "iw6_alienm9a1_mp";
            break;
        case "perk_pistol_mp443_4":
        case "perk_pistol_mp443_3":
        case "perk_pistol_mp443_2":
        case "perk_pistol_mp443_1":
        case "perk_pistol_mp443":
            self.default_starting_pistol = "iw6_alienmp443_mp";
            break;
    }

    self notify( "changed_kit" );
    self notify( "giveLoadout" );
    maps\mp\_utility::giveperk( "specialty_pistoldeath", 0 );
    self.movespeedscaler = maps\mp\alien\_prestige::prestige_getmoveslowscalar();

    if ( self.movespeedscaler == 1.0 )
        maps\mp\_utility::giveperk( "specialty_sprintreload", 0 );

    if ( maps\mp\alien\_prestige::prestige_getslowhealthregenscalar() == 1.0 )
        maps\mp\_utility::giveperk( "specialty_falldamage", 0 );

    if ( isdefined( var_0 ) && var_0 )
        return;

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        self.default_starting_pistol = "iw6_alienp226_mp";

    self giveweapon( self.default_starting_pistol );
    maps\mp\alien\_collectibles::scale_ammo_based_on_nerf( self.default_starting_pistol );

    if ( issplitscreen() )
        thread wait_and_force_weapon_switch();
    else
        self setspawnweapon( self.default_starting_pistol );

    if ( should_give_starting_flare() )
    {
        self setoffhandsecondaryclass( "flash" );
        self giveweapon( "alienflare_mp" );
        self setweaponammoclip( "alienflare_mp", 1 );
    }

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        maps\mp\alien\_chaos::chaos_custom_giveloadout( self );
}

getplayermodelindex()
{
    return self getcoopplayerdata( "coopSquadMembers", 0, "body" );
}

getplayerfoleytype( var_0 )
{
    return tablelookup( "mp/cac/bodies.csv", 0, var_0, 5 );
}

wait_and_force_weapon_switch()
{
    self endon( "disconnect" );
    self endon( "death" );
    level endon( "game_ended" );
    wait 0.5;
    self setspawnweapon( self.default_starting_pistol );
}

set_player_character_model()
{
    thread setmodelfromcustomization();
    setvoprefix();
}

setcharactermodels( var_0, var_1, var_2 )
{
    if ( isdefined( self.headmodel ) )
        self detach( self.headmodel );

    self setmodel( var_0 );
    self setviewmodel( var_2 );
    self attach( var_1, "", 1 );
    self.headmodel = var_1;
}

setmodelfromcustomization()
{
    wait 0.05;
    var_0 = self getcustomizationbody();
    var_1 = self getcustomizationhead();
    var_2 = self getcustomizationviewmodel();
    setcharactermodels( var_0, var_1, var_2 );
}

setvoprefix()
{
    if ( !isdefined( level.cac_vo_male ) )
        level.cac_vo_male = common_scripts\utility::array_randomize( [ "p2_", "p4_", "p3_" ] );

    if ( !isdefined( level.cac_vo_female ) )
        level.cac_vo_female = common_scripts\utility::array_randomize( [ "p1_" ] );

    if ( !isdefined( level.male_index ) )
        level.male_index = 0;

    if ( !isdefined( level.female_index ) )
        level.female_index = 0;

    if ( !isdefined( self.vo_prefix ) )
    {
        if ( self hasfemalecustomizationmodel() )
        {
            if ( level.female_index < level.cac_vo_female.size )
            {
                self.vo_prefix = level.cac_vo_female[level.female_index];
                level.female_index++;
            }
            else
            {
                level.female_index = 0;
                self.vo_prefix = level.cac_vo_female[level.female_index];
                level.female_index++;
            }
        }
        else if ( level.male_index < level.cac_vo_male.size )
        {
            self.vo_prefix = level.cac_vo_male[level.male_index];
            level.male_index++;
        }
        else
        {
            level.male_index = 0;
            self.vo_prefix = level.cac_vo_male[level.male_index];
            level.male_index++;
        }
    }
}

boxcapturethink_alien_func( var_0 )
{
    return var_0 maps\mp\alien\_utility::is_holding_deployable();
}

special_weapon_hints()
{
    self endon( "disconnect" );
    self.flare_tutorial_given = 0;
    self.pet_tutorial_given = 0;
    self.claymore_tutorial_given = 0;
    self.betty_tutorial_given = 0;
    self.deployable_tutorial_given = 0;
    self.semtex_tutorial_given = 0;
    self.mortar_tutorial_given = 0;
    self.trophy_tutorial_given = 0;
    self.soflam_tutorial_given = 0;
    self.drill_tutorial_given = 0;
    thread show_weapon_switch_hints();

    for (;;)
    {
        var_0 = self getweaponslistall();

        foreach ( var_2 in var_0 )
        {
            if ( var_2 == "alienbetty_mp" )
            {
                thread show_tutorial_text( var_2 );
                continue;
            }

            if ( var_2 == "alienclaymore_mp" )
            {
                thread show_tutorial_text( var_2 );
                continue;
            }

            if ( var_2 == "alienflare_mp" )
            {
                thread show_tutorial_text( var_2 );
                continue;
            }

            if ( var_2 == "aliensemtex_mp" )
            {
                if ( !maps\mp\alien\_utility::is_chaos_mode() )
                    thread show_tutorial_text( var_2 );

                continue;
            }

            if ( var_2 == "alienthrowingknife_mp" )
            {
                thread show_tutorial_text( var_2 );
                continue;
            }

            if ( var_2 == "alienmortar_shell_mp" )
            {
                thread show_tutorial_text( var_2 );
                continue;
            }

            if ( var_2 == "alientrophy_mp" )
            {
                thread show_tutorial_text( var_2 );
                continue;
            }

            if ( var_2 == "alienbomb_mp" )
                thread show_tutorial_text( var_2 );
        }

        wait 1;
    }
}

show_weapon_switch_hints()
{
    self endon( "disconnect" );

    for (;;)
    {
        self waittill( "weapon_change", var_0 );

        if ( var_0 == "aliendeployable_crate_marker_mp" || var_0 == "aliensoflam_mp" )
            thread show_tutorial_text( var_0 );

        if ( maps\mp\alien\_utility::is_true( self.hasriotshield ) || maps\mp\alien\_utility::is_true( self.hasriotshieldequipped ) )
        {
            self setclientomnvar( "ui_alien_riotshield_equipped", 1 );
            wait 0.05;

            if ( !self.hasriotshieldequipped && self.hasriotshield )
            {
                var_1 = maps\mp\alien\_utility::riotshieldname();

                if ( !isdefined( var_1 ) )
                    continue;

                var_2 = self getammocount( var_1 );
                self setclientomnvar( "ui_alien_riotshield_equipped", 2 );
                self setclientomnvar( "ui_alien_stowed_riotshield_ammo", var_2 );
            }

            continue;
        }

        self setclientomnvar( "ui_alien_riotshield_equipped", -1 );
    }
}

show_tutorial_text( var_0 )
{
    self endon( "disconnect" );

    switch ( var_0 )
    {
        case "alienbetty_mp":
            if ( !self.betty_tutorial_given )
            {
                self.betty_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "tutorial", &"ALIEN_COLLECTIBLES_TUTORIAL_BETTY", 3.5 );
            }

            break;
        case "alienclaymore_mp":
            if ( !self.claymore_tutorial_given )
            {
                self.claymore_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "tutorial", &"ALIEN_COLLECTIBLES_TUTORIAL_CLAYMORE", 3.5 );
            }

            break;
        case "alienthrowingknife_mp":
            if ( !self.pet_tutorial_given )
            {
                self.pet_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "tutorial", &"ALIEN_COLLECTIBLES_TUTORIAL_PET", 3.5 );
            }

            break;
        case "alienflare_mp":
            if ( !self.flare_tutorial_given )
            {
                self.flare_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "tutorial", &"ALIEN_COLLECTIBLES_TUTORIAL_FLARE", 3.5 );
            }

            break;
        case "aliensemtex_mp":
            if ( !self.semtex_tutorial_given )
            {
                self.semtex_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "tutorial", &"ALIEN_COLLECTIBLES_TUTORIAL_SEMTEX", 3.5 );
            }

            break;
        case "alienmortar_shell_mp":
            if ( !self.mortar_tutorial_given )
            {
                self.mortar_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "tutorial", &"ALIEN_COLLECTIBLES_TUTORIAL_MORTARSHELL", 3.5 );
            }

            break;
        case "aliensoflam_mp":
            if ( !self.soflam_tutorial_given )
            {
                self.soflam_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "tutorial", &"ALIEN_COLLECTIBLES_TUTORIAL_SOFLAM", 3.5 );
            }

            break;
        case "alientrophy_mp":
            if ( !self.trophy_tutorial_given )
            {
                self.trophy_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "tutorial", &"ALIEN_COLLECTIBLES_TUTORIAL_TROPHY", 3.5 );
            }

            break;
        case "alienbomb_mp":
            if ( !self.drill_tutorial_given )
            {
                self.drill_tutorial_given = 1;
                maps\mp\_utility::setlowermessage( "go_plant", get_drill_tutorial_text(), 3.5 );
                return;
            }
    }
}

get_drill_tutorial_text()
{
    if ( isdefined( level.drill_tutorial_text ) )
        return level.drill_tutorial_text;

    return &"ALIEN_COLLECTIBLES_GO_PLANT_BOMB";
}

enable_disable_usability_monitor()
{
    self endon( "disconnect" );

    for (;;)
    {
        if ( maps\mp\alien\_utility::is_holding_deployable() )
        {
            common_scripts\utility::_disableusability();

            while ( maps\mp\alien\_utility::is_holding_deployable() )
                wait 0.05;

            common_scripts\utility::_enableusability();
        }

        wait 0.05;
    }
}

killstreakinit()
{
    maps\mp\killstreaks\_killstreaks::initkillstreakdata();
    level.killstreakfuncs = [];
    level.killstreaksetupfuncs = [];
    level.killstreakweapons = [];
    thread maps\mp\killstreaks\_uav::init();
    thread maps\mp\killstreaks\_airstrike::init();
    thread maps\mp\killstreaks\_plane::init();
    thread maps\mp\killstreaks\_helicopter::init();
    thread maps\mp\alien\_nuke::init();
    thread maps\mp\killstreaks\_portableaoegenerator::init();
    thread maps\mp\killstreaks\_ims::init();
    thread maps\mp\killstreaks\_perkstreaks::init();
    thread maps\mp\killstreaks\_remoteuav::init();
    thread maps\mp\killstreaks\_juggernaut::init();
    thread maps\mp\killstreaks\_ball_drone::init();
    thread maps\mp\killstreaks\_vanguard::init();
    thread maps\mp\killstreaks\_dronehive::init();
    thread maps\mp\killstreaks\_air_superiority::init();
    level.teamemped["allies"] = 0;
    level.teamemped["axis"] = 0;
    level.killstreakweildweapons = [];
    level.killstreakweildweapons["artillery_mp"] = "precision_airstrike";
    level.killstreakweildweapons["stealth_bomb_mp"] = "stealth_airstrike";
    level.killstreakweildweapons["pavelow_minigun_mp"] = "helicopter_flares";
    level.killstreakweildweapons["sentry_minigun_mp"] = "sentry";
    level.killstreakweildweapons["ac130_105mm_mp"] = "ac130";
    level.killstreakweildweapons["ac130_40mm_mp"] = "ac130";
    level.killstreakweildweapons["ac130_25mm_mp"] = "ac130";
    level.killstreakweildweapons["remotemissile_projectile_mp"] = "predator_missile";
    level.killstreakweildweapons["cobra_ffar_mp"] = "helicopter";
    level.killstreakweildweapons["hind_bomb_mp"] = "helicopter";
    level.killstreakweildweapons["cobra_20mm_mp"] = "helicopter";
    level.killstreakweildweapons["nuke_mp"] = "nuke";
    level.killstreakweildweapons["littlebird_guard_minigun_mp"] = "littlebird_support";
    level.killstreakweildweapons["osprey_minigun_mp"] = "escort_airdrop";
    level.killstreakweildweapons["remote_mortar_missile_mp"] = "remote_mortar";
    level.killstreakweildweapons["manned_littlebird_sniper_mp"] = "heli_sniper";
    level.killstreakweildweapons["iw5_mp412jugg_mp"] = "airdrop_juggernaut";
    level.killstreakweildweapons["mortar_shelljugg_mp"] = "airdrop_juggernaut";
    level.killstreakweildweapons["iw6_riotshieldjugg_mp"] = "airdrop_juggernaut_recon";
    level.killstreakweildweapons["iw5_usp45jugg_mp"] = "airdrop_juggernaut_recon";
    level.killstreakweildweapons["smoke_grenadejugg_mp"] = "airdrop_juggernaut_recon";
    level.killstreakweildweapons["iw6_knifeonlyjugg_mp"] = "airdrop_juggernaut_maniac";
    level.killstreakweildweapons["throwingknifejugg_mp"] = "airdrop_juggernaut_maniac";
    level.killstreakweildweapons["remote_turret_mp"] = "remote_mg_turret";
    level.killstreakweildweapons["osprey_player_minigun_mp"] = "osprey_gunner";
    level.killstreakweildweapons["deployable_vest_marker_mp"] = "deployable_vest";
    level.killstreakweildweapons["ugv_turret_mp"] = "remote_tank";
    level.killstreakweildweapons["ugv_gl_turret_mp"] = "remote_tank";
    level.killstreakweildweapons["remote_tank_projectile_mp"] = "vanguard";
    level.killstreakweildweapons["uav_remote_mp"] = "remote_uav";
    level.killstreakweildweapons["heli_pilot_turret_mp"] = "heli_pilot";
    level.killstreakweildweapons["lasedstrike_missile_mp"] = "lasedStrike";
    level.killstreakweildweapons["agent_mp"] = "agent";
    level.killstreakweildweapons["guard_dog_mp"] = "guard_dog";
    level.killstreakweildweapons["ims_projectile_mp"] = "ims";
    level.killstreakweildweapons["ball_drone_gun_mp"] = "ball_drone_backup";
    level.killstreakweildweapons["drone_hive_projectile_mp"] = "drone_hive";
    level.killstreakweildweapons["switch_blade_child_mp"] = "drone_hive";
    level.killstreakweildweapons["iw6_maaws_mp"] = "aa_launcher";
    level.killstreakweildweapons["killstreak_uplink_mp"] = "uplink";
    level.killstreakweildweapons["gas_strike_mp"] = "gas_airstrike";
    level.killstreakweildweapons["a10_30mm_mp"] = "a10_strafe";
    level.killstreakweildweapons["maverick_projectile_mp"] = "a10_strafe";
    level.killstreakweildweapons["odin_projectile_large_rod_mp"] = "odin_assault";
    level.killstreakweildweapons["odin_projectile_small_rod_mp"] = "odin_assault";
    level.killstreakweildweapons["iw5_barrettexp_mp_barrettscope"] = "heli_sniper";
    level.killstreakweildweapons["airdrop_marker_mp"] = "airdrop_assault";

    if ( isdefined( level.mapcustomkillstreakfunc ) )
        [[ level.mapcustomkillstreakfunc ]]();

    level.killstreakrounddelay = maps\mp\_utility::getintproperty( "scr_game_killstreakdelay", 8 );
}

monitordisownkillstreaks()
{
    while ( isdefined( self ) )
    {
        if ( maps\mp\_utility::bot_is_fireteam_mode() )
            self waittill( "disconnect" );
        else
            common_scripts\utility::waittill_any( "disconnect", "joined_team", "joined_spectators" );

        self notify( "killstreak_disowned" );
    }
}

alienforceendgame()
{
    level thread alienendgame( "axis", maps\mp\alien\_hud::get_end_game_string_index( "host_end" ) );
}

alienendgame( var_0, var_1 )
{
    var_2 = 11.0;

    if ( gamealreadyended() )
        return;

    game["state"] = "postgame";
    level.gameended = 1;
    level.gameendtime = gettime();
    level.ingraceperiod = 0;
    level notify( "game_ended", var_0 );
    common_scripts\utility::waitframe();
    maps\mp\_utility::levelflagset( "game_over" );
    maps\mp\_utility::levelflagset( "block_notifies" );
    setomnvar( "ui_pause_menu_show", 0 );
    setdvar( "ui_game_state", "postgame" );
    setdvar( "g_deadChat", 1 );
    setdvar( "ui_allow_teamchange", 0 );
    setdvar( "bg_compassShowEnemies", 0 );
    setdvar( "scr_gameended", 1 );
    setgameendtime( 0 );
    maps\mp\gametypes\_gamescore::updateteamscore( "axis" );
    maps\mp\gametypes\_gamescore::updateteamscore( "allies" );
    maps\mp\gametypes\_gamescore::updateplacement();
    maps\mp\gametypes\_gamelogic::freezeallplayers( 1.0, "cg_fovScale", 1 );

    foreach ( var_4 in level.players )
    {
        var_4 notify( "reset_outcome" );
        var_4.pers["stats"] = var_4.stats;
        var_4 maps\mp\killstreaks\_killstreaks::clearkillstreaks();
        var_4.ignoreme = 1;
        var_4 maps\mp\_utility::clearlowermessages();
    }

    foreach ( var_7 in level.agentarray )
    {
        if ( isdefined( var_7.isactive ) && var_7.isactive )
        {
            var_7.ignoreall = 1;
            var_7 maps\mp\alien\_utility::enable_alien_scripted();
        }
    }

    maps\mp\alien\_gamescore::calculate_players_total_end_game_score();
    level.intermission = 1;

    if ( isdefined( level.pre_end_game_display_func ) )
        [[ level.pre_end_game_display_func ]]();

    maps\mp\alien\_hud::displayaliengameend( var_0, var_1 );
    maps\mp\_utility::levelflagclear( "block_notifies" );
    level notify( "spawning_intermission" );
    var_9 = maps\mp\gametypes\_playerlogic::spawnintermission;

    if ( isdefined( level.custom_intermission_func ) )
        var_9 = level.custom_intermission_func;

    foreach ( var_4 in level.players )
    {
        var_4 thread [[ var_9 ]]();
        var_4 thread blackbox_endgame_score();
        var_4 setclientdvar( "ui_opensummary", 1 );
        var_4 setroundgamemode();
    }

    var_12 = get_end_condition( var_1 );
    var_13 = get_play_time();
    blackbox_endgame( var_12, var_13 );
    maps\mp\alien\_alien_matchdata::endgame( var_12, var_13 );

    if ( isdefined( level.end_game_scoreboard_wait_time ) )
        var_2 = level.end_game_scoreboard_wait_time;

    wait( var_2 );
    setnojiptime( 0 );
    level notify( "exitLevel_called" );
    exitlevel( 0 );
}

gamealreadyended()
{
    return game["state"] == "postgame" || level.gameended;
}

setroundgamemode()
{
    if ( !maps\mp\alien\_utility::is_chaos_mode() )
        self setcommonplayerdata( "round", "gameMode", "aliens" );
    else
        self setcommonplayerdata( "round", "gameMode", "mugger" );

    self setcommonplayerdata( "round", "map", tolower( getdvar( "mapname" ) ) );
}

blackbox_endgame_score()
{
    var_0 = -1;

    if ( isdefined( level.current_cycle_num ) )
        var_0 = level.current_cycle_num;

    var_1 = "unknown";

    if ( isdefined( self.name ) )
        var_1 = self.name;

    var_2 = "unknown";

    if ( isdefined( level.current_hive_name ) )
        var_2 = level.current_hive_name;

    var_3 = 0;

    if ( isdefined( self.end_game_score ) && isdefined( self.end_game_score["total_score"] ) )
        var_3 = self.end_game_score["total_score"];

    var_4 = maps\mp\alien\_persistence::get_player_session_xp();
    bbprint( "alienfinalscore", "playername %s cyclenum %i hivename %s playerfinalscore %i playerxpearned %i ", var_1, var_0, var_2, var_3, var_4 );
}

blackbox_endgame( var_0, var_1 )
{
    var_2 = -1;

    if ( isdefined( level.players[0] ) )
        var_2 = int( level.players[0] maps\mp\alien\_persistence::get_player_rank() );

    var_3 = -1;

    if ( isdefined( level.players[1] ) )
        var_3 = int( level.players[1] maps\mp\alien\_persistence::get_player_rank() );

    var_4 = -1;

    if ( isdefined( level.players[2] ) )
        var_4 = int( level.players[2] maps\mp\alien\_persistence::get_player_rank() );

    var_5 = -1;

    if ( isdefined( level.players[3] ) )
        var_5 = int( level.players[3] maps\mp\alien\_persistence::get_player_rank() );

    var_6 = 0;

    if ( isdefined( level.current_cycle_num ) )
        var_6 = level.current_cycle_num;

    var_7 = "unknown";

    if ( isdefined( level.current_hive_name ) )
        var_7 = level.current_hive_name;

    var_8 = level.alienbbdata["times_downed"];
    var_9 = level.alienbbdata["times_died"];
    var_10 = level.alienbbdata["times_drill_stuck"];
    var_11 = level.alienbbdata["aliens_killed"];
    var_12 = level.alienbbdata["team_item_deployed"];
    var_13 = level.alienbbdata["team_item_used"];
    var_14 = level.alienbbdata["bullets_shot"];
    var_15 = level.alienbbdata["damage_taken"];
    var_16 = level.alienbbdata["damage_done"];
    var_17 = level.alienbbdata["traps_used"];
    bbprint( "alienendgame", "endcondition %s player0rank %i player1rank %i player2rank %i player3rank %i playtime %f hivescleared %i hivename %s timesdowned %i timesdied %i timesdrillstuck %i alienskilled %i teamitemused %i teamitemdeployed %i bulletsshot %i damagedone %i damagetaken %i trapsused %i ", var_0, var_2, var_3, var_4, var_5, var_1, var_6, var_7, var_8, var_9, var_10, var_11, var_12, var_13, var_14, var_15, var_16, var_17 );

    foreach ( var_20 in level.players )
    {
        var_20 setcoopplayerdata( "alienSession", "team_shots", level.alienbbdata["bullets_shot"] );
        var_20 setcoopplayerdata( "alienSession", "team_kills", level.alienbbdata["aliens_killed"] );
        var_20 setcoopplayerdata( "alienSession", "team_hives", level.num_hive_destroyed );
        var_21 = int( var_20 getentitynumber() );
        var_22 = "EoGPlayer" + var_21;

        if ( isdefined( var_20.name ) )
            var_23 = var_20.name;
        else
            var_23 = "-error";

        var_24 = gettime() - var_20.connect_time;
        var_25 = var_20 getcoopplayerdata( var_22, "kills" );
        var_26 = var_20 getcoopplayerdata( var_22, "score" );
        var_27 = var_20 getcoopplayerdata( var_22, "assists" );
        var_28 = var_20 getcoopplayerdata( var_22, "revives" );
        var_29 = var_20 getcoopplayerdata( var_22, "drillrestarts" );
        var_30 = var_20 getcoopplayerdata( var_22, "deaths" );
        var_31 = var_20 getcoopplayerdata( var_22, "hivesdestroyed" );
        var_32 = var_20 getcoopplayerdata( var_22, "traps" );
        var_33 = var_20 getcoopplayerdata( var_22, "deployables" );
        var_34 = var_20 getcoopplayerdata( var_22, "deployablesused" );
        var_35 = var_20 getcoopplayerdata( var_22, "currencyspent" );
        var_36 = var_20 getcoopplayerdata( var_22, "currencytotal" );
        var_37 = "alienendgame_player" + var_21;
        bbprint( var_37, "playername %s playerplaytime %f playerkills %i playerscore %i playerassists %i playerrevives %i playerdrillrestarts %i playerdeaths %i playerhives %i playertraps %i playertotalcurrency %i playercurrencyspent %i playerdeployables %i playerdeployablesused %i ", var_23, var_24, var_25, var_26, var_27, var_28, var_29, var_30, var_31, var_32, var_36, var_35, var_33, var_34 );
    }
}

get_end_condition( var_0 )
{
    switch ( var_0 )
    {
        case 1:
            return "all_escape";
        case 2:
            return "some_escape";
        case 3:
            return "fail_escape";
        case 8:
        case 4:
            return "drill destroyed";
        case 5:
            return "died";
        case 6:
            return "host_quit";
        case 7:
            return "gas_fail";
        default:
    }
}

get_play_time()
{
    var_0 = 0;

    if ( isdefined( level.starttime ) )
        var_0 = gettime() - level.starttime;

    return var_0;
}

alien_customprematchperiod()
{
    if ( !maps\mp\alien\_utility::is_true( level.introscreen_done ) )
        level.prematchperiod = 10;

    if ( !maps\mp\alien\_intro_sequence::intro_sequence_enabled() )
    {
        var_0 = 3;

        if ( maps\mp\alien\_utility::is_chaos_mode() )
            var_0 = 6;

        wait( var_0 );
        level notify( "introscreen_over" );
        level.introscreen_done = 1;
        level notify( "spawn_intro_drill" );

        if ( maps\mp\alien\_utility::is_true( level.intermission ) )
            return;

        for ( var_1 = 0; var_1 < level.players.size; var_1++ )
        {
            level.players[var_1] maps\mp\_utility::freezecontrolswrapper( 0 );
            level.players[var_1] enableweapons();

            if ( !isdefined( level.players[var_1].pers["team"] ) )
                continue;
        }

        return;
    }

    if ( level.prematchperiod > 0 )
    {
        var_2 = level wait_for_first_player_connect();

        if ( maps\mp\alien\_intro_sequence::intro_sequence_enabled() )
            level thread maps\mp\alien\_intro_sequence::play_intro_sequence( var_2 );

        level thread show_introscreen_text();

        if ( isdefined( level.intro_dialogue_func ) )
            level thread [[ level.intro_dialogue_func ]]();

        wait( level.prematchperiod - 3 );

        if ( isdefined( level.postintroscreenfunc ) )
            [[ level.postintroscreenfunc ]]();

        level notify( "introscreen_over" );
        level.introscreen_done = 1;
    }
    else
    {
        wait 1;
        level notify( "introscreen_over" );
    }

    if ( maps\mp\alien\_utility::is_true( level.intermission ) )
        return;

    for ( var_1 = 0; var_1 < level.players.size; var_1++ )
    {
        level.players[var_1] maps\mp\_utility::freezecontrolswrapper( 0 );
        level.players[var_1] enableweapons();

        if ( !isdefined( level.players[var_1].pers["team"] ) )
            continue;
    }
}

wait_for_first_player_connect()
{
    var_0 = undefined;

    if ( level.players.size == 0 )
        level waittill( "connected", var_0 );
    else
        var_0 = level.players[0];

    return var_0;
}

show_introscreen_text()
{
    wait 2;
    var_0 = maps\mp\alien\_hud::introscreen_corner_line( level.introscreen_line_1, 1 );
    wait 1;
    var_1 = maps\mp\alien\_hud::introscreen_corner_line( level.introscreen_line_2, 2 );
    wait 1;
    var_2 = maps\mp\alien\_hud::introscreen_corner_line( level.introscreen_line_3, 3 );
    wait 1;
    var_3 = maps\mp\alien\_hud::introscreen_corner_line( level.introscreen_line_4, 4 );
    level waittill( "introscreen_over" );
    var_0 fadeovertime( 3 );
    var_1 fadeovertime( 3 );
    var_2 fadeovertime( 3 );
    var_3 fadeovertime( 3 );
    wait 3.1;
    var_0.alpha = 0;
    var_1.alpha = 0;
    var_2.alpha = 0;
    var_3.alpha = 0;
    var_0 destroy();
    var_1 destroy();
    var_2 destroy();
    var_3 destroy();
}

setup_blocker_hives( var_0 )
{
    level.blocker_hives = var_0;
}

setup_cycle_end_area_list( var_0 )
{
    level.cycle_end_area_list = var_0;
}

setup_last_hive( var_0 )
{
    level.last_hive = var_0;
}

register_encounter( var_0, var_1, var_2, var_3, var_4, var_5, var_6 )
{
    if ( !isdefined( level.encounters ) )
        level.encounters = [];

    var_7 = spawnstruct();
    var_7.func = var_0;

    if ( isdefined( var_2 ) )
        var_7.hardcore_skill_point = var_2;

    if ( isdefined( var_1 ) )
        var_7.skill_point = var_1;

    if ( isdefined( var_3 ) )
        var_7.go_next_area = var_3;

    if ( isdefined( var_4 ) )
        var_7.skip_func = var_4;

    if ( isdefined( var_5 ) )
        var_7.pre_encounter_func = var_5;

    if ( isdefined( var_6 ) )
        var_7.force_end_func = var_6;

    level.encounters[level.encounters.size] = var_7;
}

run_encounters()
{
    level endon( "game_ended" );

    if ( isdefined( level.dlc_run_encounters_override ) )
    {
        [[ level.dlc_run_encounters_override ]]();
        return;
    }

    if ( !isdefined( level.encounters ) )
        return;

    var_0 = is_start_point_enable();
    var_1 = 0;
    var_2 = get_start_point_index( var_0 );

    foreach ( var_4 in level.encounters )
    {
        level.current_encounter_info = var_4;

        if ( should_run_pre_encounter_func( var_0, var_1, var_2 ) )
            [[ var_4.pre_encounter_func ]]();

        if ( should_skip_encounter( var_0, var_1, var_2 ) )
        {
            [[ var_4.skip_func ]]();

            if ( isdefined( var_4.skill_point ) )
                inc_starting_skill_point( var_4.skill_point );

            if ( maps\mp\alien\_utility::is_true( var_4.go_next_area ) )
                maps\mp\alien\_utility::inc_current_area_index();
        }
        else
        {
            [[ var_4.func ]]();

            if ( !maps\mp\alien\_utility::is_hardcore_mode() )
            {
                if ( isdefined( var_4.skill_point ) )
                    give_players_points( var_4.skill_point );
            }
            else if ( isdefined( var_4.hardcore_skill_point ) )
                give_players_points( var_4.hardcore_skill_point );

            if ( maps\mp\alien\_utility::is_true( var_4.go_next_area ) )
                maps\mp\alien\_collectibles::advance_to_next_area();
        }

        var_1++;
    }
}

init_locker_key_upgrade()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    wait 5.0;

    if ( !isdefined( level.starting_locker_key_names ) )
        level.starting_locker_key_names = [];

    var_0 = self getxuid();

    if ( maps\mp\alien\_utility::is_true( level.onlinegame ) )
    {
        for ( var_1 = 0; var_1 < level.starting_locker_key_names.size; var_1++ )
        {
            if ( level.starting_locker_key_names[var_1] == var_0 )
                return;
        }
    }

    level.starting_locker_key_names[level.starting_locker_key_names.size] = var_0;
    self.locker_key = 1;
    self setclientomnvar( "ui_alien_locker_key", 1 );
}

should_give_starting_flare()
{
    if ( !maps\mp\alien\_perk_utility::has_perk( "perk_health", [ 0, 1, 2, 3, 4 ] ) )
        return 0;

    if ( !isdefined( level.starting_flare_names ) )
        level.starting_flare_names = [];

    var_0 = self getxuid();

    if ( maps\mp\alien\_utility::is_true( level.onlinegame ) )
    {
        for ( var_1 = 0; var_1 < level.starting_flare_names.size; var_1++ )
        {
            if ( level.starting_flare_names[var_1] == var_0 )
                return 0;
        }
    }

    level.starting_flare_names[level.starting_flare_names.size] = var_0;
    return 1;
}

is_start_point_enable()
{
    return 0;
}

get_start_point_index( var_0 )
{
    return 0;
}

should_run_pre_encounter_func( var_0, var_1, var_2 )
{
    return 0;
}

should_skip_encounter( var_0, var_1, var_2 )
{
    return 0;
}

give_players_points( var_0 )
{
    foreach ( var_2 in level.players )
        var_2 maps\mp\alien\_persistence::give_player_points( int( var_0 ) );
}

inc_starting_skill_point( var_0 )
{

}

melee_strength_timer()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    self.meleestrength = 1.0;
    var_0 = 1;
    self.meleestrength = 0;
    var_1 = gettime();

    for (;;)
    {
        var_2 = gettime();

        if ( var_2 - var_1 >= level.playermeleestunregentime )
            self.meleestrength = 1.0;
        else
            self.meleestrength = 0;

        if ( self meleebuttonpressed() && !self isreloading() && !self usebuttonpressed() )
        {
            var_1 = gettime();

            if ( var_0 == 1 )
                var_0 = 0;
        }
        else if ( !self meleebuttonpressed() )
            var_0 = 1;
        else
            var_0 = 0;

        wait 0.05;
    }
}
