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

build_pillageitem_arrays( var_0 )
{
    if ( !isdefined( level.pillageitems ) )
        level.pillageitems = [];

    if ( !isdefined( level.pillageitems[var_0] ) )
        level.pillageitems[var_0] = [];

    switch ( var_0 )
    {
        case "easy":
            build_pillageitem_array( var_0, "attachment", level.pillageinfo.easy_attachment );
            build_pillageitem_array( var_0, "soflam", level.pillageinfo.easy_soflam );
            build_pillageitem_array( var_0, "explosive", level.pillageinfo.easy_explosive );
            build_pillageitem_array( var_0, "clip", level.pillageinfo.easy_clip );
            build_pillageitem_array( var_0, "money", level.pillageinfo.easy_money );
            build_pillageitem_array( var_0, "pet_leash", level.pillageinfo.easy_leash );
            build_pillageitem_array( var_0, "specialammo", level.pillageinfo.easy_specialammo );
            break;
        case "medium":
            build_pillageitem_array( var_0, "attachment", level.pillageinfo.medium_attachment );
            build_pillageitem_array( var_0, "explosive", level.pillageinfo.medium_explosive );
            build_pillageitem_array( var_0, "soflam", level.pillageinfo.medium_soflam );
            build_pillageitem_array( var_0, "clip", level.pillageinfo.medium_clip );
            build_pillageitem_array( var_0, "money", level.pillageinfo.medium_money );
            build_pillageitem_array( var_0, "pet_leash", level.pillageinfo.medium_leash );
            build_pillageitem_array( var_0, "trophy", level.pillageinfo.medium_trophy );
            build_pillageitem_array( var_0, "specialammo", level.pillageinfo.medium_specialammo );
            break;
        case "hard":
            build_pillageitem_array( var_0, "attachment", level.pillageinfo.hard_attachment );
            build_pillageitem_array( var_0, "soflam", level.pillageinfo.hard_soflam );
            build_pillageitem_array( var_0, "explosive", level.pillageinfo.hard_explosive );
            build_pillageitem_array( var_0, "maxammo", level.pillageinfo.hard_maxammo );
            build_pillageitem_array( var_0, "money", level.pillageinfo.hard_money );
            build_pillageitem_array( var_0, "pet_leash", level.pillageinfo.hard_leash );
            build_pillageitem_array( var_0, "trophy", level.pillageinfo.hard_trophy );
            build_pillageitem_array( var_0, "specialammo", level.pillageinfo.hard_specialammo );
            break;
    }

    if ( isdefined( level.custom_build_pillageitem_array_func ) )
        [[ level.custom_build_pillageitem_array_func ]]( var_0 );

    if ( isdefined( level.locker_build_pillageitem_array_func ) )
        [[ level.locker_build_pillageitem_array_func ]]( var_0 );
}

build_pillageitem_array( var_0, var_1, var_2 )
{
    if ( !isdefined( var_2 ) )
        return;

    var_3 = spawnstruct();
    var_3.ref = var_1;
    var_3.chance = var_2;
    level.pillageitems[var_0][level.pillageitems[var_0].size] = var_3;
}

pillage_init()
{
    level.pillage_areas = [];
    level.pillageable_explosives = [ "alienclaymore_mp", "alienbetty_mp", "alienmortar_shell_mp" ];
    level.pillageable_attachments = [ "reflex", "eotech", "rof", "grip", "barrelrange", "acog", "firetypeburst", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_dmr = [ "eotech", "reflex", "firetypeburst", "barrelrange", "acog", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_sg = [ "reflex", "grip", "eotech", "barrelrange", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_sg_fp6 = [ "reflex", "grip", "eotech", "barrelrange", "alienmuzzlebrake" ];
    level.pillageable_attachments_ar = [ "reflex", "eotech", "grip", "rof", "barrelrange", "acog", "firetypeburst", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_ar_sc2010 = [ "reflex", "eotech", "grip", "firetypeburst", "acog", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_ar_honeybadger = [ "reflex", "eotech", "grip", "rof", "acog", "firetypeburst", "xmags" ];
    level.pillageable_attachments_smg_k7 = [ "reflex", "eotech", "rof", "grip", "acog", "barrelrange", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_smg = [ "reflex", "eotech", "rof", "grip", "barrelrange", "acog", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_aliendlc23 = [ "rof", "grip", "barrelrange", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_sr = [ "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_lmg = [ "rof", "grip", "reflex", "eotech", "acog", "barrelrange", "xmags", "alienmuzzlebrake" ];
    level.pillageable_attachments_lmg_kac = [ "rof", "barrelrange", "xmags", "alienmuzzlebrake" ];
    level.offhand_explosives = [ "alienclaymore_mp", "alienbetty_mp", "alienmortar_shell_mp", "aliensemtex_mp" ];
    level.offhand_secondaries = [ "alienflare_mp", "alienthrowingknife_mp", "alientrophy_mp" ];

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

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

    level.alien_crafting_items = undefined;

    if ( isdefined( level.crafting_item_table ) )
        level.alien_crafting_items = level.crafting_item_table;

    var_0 = common_scripts\utility::getstructarray( "pillage_area", "targetname" );

    foreach ( var_8, var_2 in var_0 )
    {
        if ( !isdefined( level.pillage_areas[var_8] ) )
            level.pillage_areas[var_8] = [];

        level.pillage_areas[var_8]["easy"] = [];
        level.pillage_areas[var_8]["medium"] = [];
        level.pillage_areas[var_8]["hard"] = [];
        var_3 = common_scripts\utility::getstructarray( var_2.target, "targetname" );

        foreach ( var_5 in var_3 )
        {
            if ( isdefined( var_5.script_noteworthy ) )
            {
                var_6 = strtok( var_5.script_noteworthy, "," );
                var_5.pillage_type = var_6[0];

                if ( isdefined( var_6[1] ) )
                    var_5.script_model = var_6[1];

                if ( isdefined( var_6[2] ) )
                    var_5.default_item_type = var_6[2];

                switch ( var_5.pillage_type )
                {
                    case "easy":
                        level.pillage_areas[var_8]["easy"][level.pillage_areas[var_8]["easy"].size] = var_5;
                        break;
                    case "medium":
                        level.pillage_areas[var_8]["medium"][level.pillage_areas[var_8]["medium"].size] = var_5;
                        break;
                    case "hard":
                        level.pillage_areas[var_8]["hard"][level.pillage_areas[var_8]["hard"].size] = var_5;
                        break;
                }
            }
        }
    }

    foreach ( var_8, var_2 in level.pillage_areas )
    {
        if ( getdvar( "scr_debug_pillage" ) != "1" )
        {
            level.pillage_areas[var_8]["easy"] = remove_random_pillage_spots( level.pillage_areas[var_8]["easy"] );
            level.pillage_areas[var_8]["medium"] = remove_random_pillage_spots( level.pillage_areas[var_8]["medium"] );
            level.pillage_areas[var_8]["hard"] = remove_random_pillage_spots( level.pillage_areas[var_8]["hard"] );
        }

        level thread create_pillage_spots( level.pillage_areas[var_8]["easy"] );
        level thread create_pillage_spots( level.pillage_areas[var_8]["medium"] );
        level thread create_pillage_spots( level.pillage_areas[var_8]["hard"] );
    }

    build_pillageitem_arrays( "easy" );
    build_pillageitem_arrays( "medium" );
    build_pillageitem_arrays( "hard" );
    level.use_alternate_specialammo_pillage_amounts = 0;
}

get_hintstring_for_pillaged_item( var_0 )
{
    var_0 = "" + var_0;

    switch ( var_0 )
    {
        case "50":
            return &"ALIEN_COLLECTIBLES_FOUND_50";
        case "100":
            return &"ALIEN_COLLECTIBLES_FOUND_100";
        case "200":
            return &"ALIEN_COLLECTIBLES_FOUND_200";
        case "250":
            return &"ALIEN_COLLECTIBLES_FOUND_250";
        case "500":
            return &"ALIEN_COLLECTIBLES_FOUND_500";
        case "alienclaymore_mp":
            return &"ALIEN_COLLECTIBLES_FOUND_CLAYMORE";
        case "alienbetty_mp":
            return &"ALIEN_COLLECTIBLES_FOUND_BETTY";
        case "alienmortar_shell_mp":
            return &"ALIEN_COLLECTIBLES_FOUND_MORTARSHELL";
        case "flare":
            return &"ALIEN_COLLECTIBLES_FOUND_FLARE";
        case "maxammo":
            return &"ALIEN_COLLECTIBLES_FOUND_AMMO";
        case "grenade":
            return &"ALIEN_COLLECTIBLES_FOUND_GRENADE";
        case "attachment_noGL":
        case "attachment":
            return &"ALIEN_COLLECTIBLES_FOUND_ATTACHMENT";
        case "clip":
            return &"ALIEN_COLLECTIBLES_FOUND_CLIP";
        case "soflam":
            return &"ALIEN_COLLECTIBLES_FOUND_SOFLAM";
        case "pet_leash":
            return &"ALIEN_COLLECTIBLES_FOUND_PET_LEASH";
        case "trophy":
            return &"ALIEN_COLLECTIBLES_FOUND_TROPHY";
        case "combined_ammo":
        case "specialammo":
        case "explosive_ammo":
        case "incendiary_ammo":
        case "ap_ammo":
        case "stun_ammo":
            return &"ALIEN_COLLECTIBLES_FOUND_SPECIALAMMO";
    }

    if ( isdefined( level.get_hintstring_for_pillaged_item_func ) )
        return [[ level.get_hintstring_for_pillaged_item_func ]]( var_0 );
}

get_hintstring_for_item_pickup( var_0 )
{
    var_0 = "" + var_0;

    switch ( var_0 )
    {
        case "alienclaymore_mp":
            return &"ALIEN_COLLECTIBLES_PICKUP_CLAYMORE";
        case "alienbetty_mp":
            return &"ALIEN_COLLECTIBLES_PICKUP_BOUNCING_BETTY";
        case "alienmortar_shell_mp":
            return &"ALIEN_COLLECTIBLES_PICKUP_MORTARSHELL";
        case "aliensemtex_mp":
            return &"ALIEN_COLLECTIBLES_PICKUP_GRENADE";
        case "viewmodel_flare":
        case "flare":
        case "alienflare_mp":
            return &"ALIEN_COLLECTIBLES_PICKUP_FLARE";
        case "maxammo":
            return &"ALIEN_COLLECTIBLES_PICKUP_AMMO";
        case "money":
            return &"ALIEN_COLLECTIBLES_PICKUP_MONEY";
        case "reflex":
            return &"ALIEN_COLLECTIBLES_FOUND_REFLEX";
        case "reflexsmg":
            return &"ALIEN_COLLECTIBLES_FOUND_REFLEX";
        case "eotech":
            return &"ALIEN_COLLECTIBLES_FOUND_EOTECH";
        case "thermal":
            return &"ALIEN_COLLECTIBLES_FOUND_THERMAL";
        case "firetypeburst":
            return &"ALIEN_COLLECTIBLES_FOUND_FIRETYPEBURST";
        case "firetypeburstdmr":
            return &"ALIEN_COLLECTIBLES_FOUND_FIRETYPEBURST";
        case "barrelrange":
            return &"ALIEN_COLLECTIBLES_FOUND_BARRELRANGE";
        case "barrelrange03":
            return &"ALIEN_COLLECTIBLES_FOUND_BARRELRANGE";
        case "rof":
            return &"ALIEN_COLLECTIBLES_FOUND_ROF";
        case "acog":
            return &"ALIEN_COLLECTIBLES_FOUND_ACOG";
        case "clip":
            return &"ALIEN_COLLECTIBLES_PICKUP_CLIP";
        case "soflam":
            return &"ALIEN_COLLECTIBLES_PICKUP_SOFLAM";
        case "grip":
            return &"ALIEN_COLLECTIBLES_FOUND_GRIP";
        case "griphide":
            return &"ALIEN_COLLECTIBLES_FOUND_GRIP";
        case "alienmuzzlebrakesn":
        case "alienmuzzlebrakesg":
        case "alienmuzzlebrake":
            return &"ALIENS_PATCH_FOUND_ARK";
        case "pet_leash":
        case "alienthrowingknife_mp":
            return &"ALIEN_COLLECTIBLES_PICKUP_PET_LEASH";
        case "alientrophy_mp":
        case "trophy":
            return &"ALIEN_COLLECTIBLES_PICKUP_TROPHY";
        case "ap_ammo":
            return &"ALIEN_COLLECTIBLES_PICKUP_AP_AMMO";
        case "incendiary_ammo":
            return &"ALIEN_COLLECTIBLES_PICKUP_IN_AMMO";
        case "explosive_ammo":
            return &"ALIEN_COLLECTIBLES_PICKUP_EXP_AMMO";
        case "stun_ammo":
            return &"ALIEN_COLLECTIBLES_PICKUP_STUN_AMMO";
        case "combined_ammo":
            return &"ALIENS_PATCH_PICKUP_COMBINED_AMMO";
        case "xmags":
            return &"ALIENS_PATCH_FOUND_XMAGS";
    }

    if ( isdefined( level.get_hintstring_for_item_pickup_func ) )
        return [[ level.get_hintstring_for_item_pickup_func ]]( var_0 );
}

remove_random_pillage_spots( var_0 )
{
    var_1 = int( var_0.size * 0.5 );
    var_0 = common_scripts\utility::array_randomize( var_0 );
    var_2 = [];

    for ( var_3 = 0; var_3 < var_0.size; var_3++ )
    {
        if ( var_3 < var_1 )
        {
            var_0[var_3].not_used = 1;
            continue;
        }

        var_2[var_2.size] = var_0[var_3];
    }

    return var_2;
}

create_pillage_spots( var_0 )
{
    var_1 = 22500;
    var_2 = 90000;
    var_3 = cos( 75 );

    foreach ( var_11, var_5 in var_0 )
    {
        if ( !isdefined( var_5.is_locker ) )
        {
            var_6 = 0;
            var_7 = 0;

            foreach ( var_9 in level.players )
            {
                if ( distance2dsquared( var_9.origin, var_5.origin ) < var_1 )
                    var_6 = 1;

                if ( !var_6 && distance2dsquared( var_9.origin, var_5.origin ) < var_2 )
                    var_6 = common_scripts\utility::within_fov( var_9 geteye(), var_9.angles, var_5.origin + ( 0, 0, 5 ), var_3 );
            }

            if ( var_6 )
            {
                var_7 = 1;
                continue;
            }
        }

        var_5.pillage_trigger = spawn( "script_model", var_5.origin );

        if ( isdefined( var_5.script_model ) )
        {
            var_5.pillage_trigger setmodel( var_5.script_model );
            var_5.pillage_trigger.angles = var_5.angles;
        }
        else
            var_5.pillage_trigger setmodel( "tag_origin" );

        var_5.pillage_trigger setcursorhint( "HINT_NOICON" );
        var_5.pillage_trigger makeusable();
        var_5.pillage_trigger sethintstring( &"ALIEN_COLLECTIBLES_OPEN" );

        if ( isdefined( var_5.is_locker ) && var_5.is_locker )
        {
            var_5.pillage_trigger.angles = var_5.angles;
            var_5.pillage_trigger.is_locker = 1;
        }

        if ( maps\mp\alien\_utility::alien_mode_has( "outline" ) )
            maps\mp\alien\_outline_proto::add_to_outline_pillage_watch_list( var_5.pillage_trigger, 0 );

        var_5 thread pillage_spot_think();
        var_5.enabled = 1;

        if ( var_11 % 2 == 0 )
            wait 0.05;
    }
}

pillage_spot_think()
{
    self notify( "stop_pillage_spot_think" );
    self endon( "stop_pillage_spot_think" );

    for (;;)
    {
        self.pillage_trigger waittill( "trigger", var_0 );

        if ( !isplayer( var_0 ) )
            continue;

        if ( var_0 maps\mp\alien\_utility::is_holding_deployable() || var_0 maps\mp\alien\_utility::has_special_weapon() )
        {
            var_0 maps\mp\_utility::setlowermessage( "cant_buy", &"ALIEN_COLLECTIBLES_PLAYER_HOLDING", 3 );
            continue;
        }

        if ( var_0 maps\mp\alien\_prestige::prestige_getnodeployables() == 1.0 )
        {
            var_0 maps\mp\_utility::setlowermessage( "cant_buy", &"ALIENS_PRESTIGE_NO_DEPLOYABLES_PICKUP", 3 );
            continue;
        }

        if ( !isdefined( var_0.current_crafting_recipe ) && isdefined( self.default_item_type ) && self.default_item_type == "crafting" )
        {
            var_0 maps\mp\_utility::setlowermessage( "cant_buy", &"ALIEN_CRAFTING_NO_RECIPE", 3 );
            continue;
        }

        if ( !isdefined( self.searched ) )
        {
            if ( isdefined( level.locker_key_check_func ) )
            {
                if ( [[ level.locker_key_check_func ]]( var_0 ) )
                    continue;
            }

            self.pillage_trigger makeunusable();
            self.enabled = 0;

            if ( self.pillage_trigger useholdthink( var_0, level.pillageinfo.default_use_time ) )
            {
                self.searched = 1;
                var_1 = get_pillaged_item( self, var_0 );
                self.pillage_trigger setmodel( "tag_origin" );
                self.pillageinfo = spawnstruct();
                var_0 maps\mp\alien\_achievement::update_scavenge_achievement();

                switch ( var_1.type )
                {
                    case "money":
                        if ( var_0 maps\mp\alien\_persistence::get_player_currency() < var_0.maxcurrency )
                        {
                            var_0 maps\mp\alien\_persistence::give_player_currency( var_1.count, undefined, undefined, 1 );
                            delete_pillage_trigger();
                        }
                        else
                        {
                            self.pillage_trigger setmodel( level.pillageinfo.money_stack );
                            var_2 = get_hintstring_for_item_pickup( var_1.type );
                            self.pillage_trigger sethintstring( var_2 );
                            self.pillage_trigger makeusable();
                            self.pillageinfo.type = "money";
                            self.pillageinfo.amount = var_1.count;
                        }

                        var_2 = get_hintstring_for_pillaged_item( var_1.count );
                        var_0 thread show_pillage_text( var_2 );

                        if ( var_1.count == 500 )
                            level thread maps\mp\alien\_music_and_dialog::playvoforpillage( var_0 );

                        break;
                    case "pet_leash":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( level.pillageinfo.leash_model );
                        var_2 = get_hintstring_for_item_pickup( var_1.type );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "pet_leash";
                        self.pillageinfo.item = "alienthrowingknife_mp";
                        self.pillageinfo.ammo = 1;
                        level thread maps\mp\alien\_music_and_dialog::playvoforpillage( var_0 );
                        break;
                    case "explosive":
                        var_2 = get_hintstring_for_pillaged_item( var_1.explosive_type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( getweaponmodel( var_1.explosive_type ) );
                        var_2 = get_hintstring_for_item_pickup( var_1.explosive_type );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "explosive";
                        self.pillageinfo.item = var_1.explosive_type;
                        self.pillageinfo.ammo = 2;
                        break;
                    case "grenade":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( getweaponmodel( "aliensemtex_mp" ) );
                        var_2 = get_hintstring_for_item_pickup( "aliensemtex_mp" );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "explosive";
                        self.pillageinfo.item = "aliensemtex_mp";
                        self.pillageinfo.ammo = 2;
                        break;
                    case "flare":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( level.pillageinfo.flare_model );
                        var_2 = get_hintstring_for_item_pickup( var_1.type );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "flare";
                        self.pillageinfo.item = "alienflare_mp";
                        self.pillageinfo.ammo = 1;
                        level thread maps\mp\alien\_music_and_dialog::playvoforpillage( var_0 );
                        break;
                    case "attachment_noGL":
                    case "attachment":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        var_3 = var_0 get_attachment_for_weapon();

                        if ( var_3 == "alienmuzzlebrake" )
                            self.pillage_trigger setmodel( level.pillageinfo.alienattachment_model );
                        else
                            self.pillage_trigger setmodel( level.pillageinfo.attachment_model );

                        var_2 = get_hintstring_for_item_pickup( var_3 );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "attachment";
                        self.pillageinfo.attachment = var_3;
                        break;
                    case "maxammo":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( level.pillageinfo.maxammo_model );
                        var_2 = get_hintstring_for_item_pickup( "maxammo" );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "maxammo";
                        level thread maps\mp\alien\_music_and_dialog::playvoforpillage( var_0 );
                        break;
                    case "clip":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( level.pillageinfo.clip_model );
                        var_2 = get_hintstring_for_item_pickup( var_1.type );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "clip";
                        break;
                    case "specialammo":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( level.pillageinfo.clip_model );
                        self.pillage_trigger makeusable();

                        if ( var_0 maps\mp\alien\_utility::has_stun_ammo() && var_0 maps\mp\alien\_utility::has_incendiary_ammo() && var_0 maps\mp\alien\_utility::has_explosive_ammo() && var_0 maps\mp\alien\_utility::has_ap_ammo() )
                            self.pillageinfo.type = "combined_ammo";
                        else if ( var_0 maps\mp\alien\_utility::has_stun_ammo() )
                            self.pillageinfo.type = "stun_ammo";
                        else if ( var_0 maps\mp\alien\_utility::has_incendiary_ammo() )
                            self.pillageinfo.type = "incendiary_ammo";
                        else if ( var_0 maps\mp\alien\_utility::has_explosive_ammo() )
                            self.pillageinfo.type = "explosive_ammo";
                        else if ( var_0 maps\mp\alien\_utility::has_ap_ammo() )
                            self.pillageinfo.type = "ap_ammo";
                        else
                            self.pillageinfo.type = common_scripts\utility::random( [ "ap_ammo", "explosive_ammo", "incendiary_ammo", "stun_ammo" ] );

                        var_2 = get_hintstring_for_item_pickup( self.pillageinfo.type );
                        self.pillage_trigger sethintstring( var_2 );
                        break;
                    case "soflam":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( level.pillageinfo.soflam_model );
                        var_2 = get_hintstring_for_item_pickup( var_1.type );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "soflam";
                        level thread maps\mp\alien\_music_and_dialog::playvoforpillage( var_0 );
                        break;
                    case "trophy":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        self.pillage_trigger setmodel( level.pillageinfo.trophy_model );
                        var_2 = get_hintstring_for_item_pickup( var_1.type );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "trophy";
                        self.pillageinfo.item = "alientrophy_mp";
                        self.pillageinfo.ammo = 1;
                        break;
                    case "crafting":
                        var_2 = get_hintstring_for_pillaged_item( var_1.type );
                        var_0 thread show_pillage_text( var_2 );
                        var_4 = var_0 get_crafting_ingredient();
                        self.pillage_trigger setmodel( get_crafting_model( var_4 ) );
                        var_2 = get_hintstring_for_item_pickup( var_4 );
                        self.pillage_trigger sethintstring( var_2 );
                        self.pillage_trigger makeusable();
                        self.pillageinfo.type = "crafting";
                        self.pillageinfo.craftingitem = var_4;
                        break;
                    case "intel":
                        if ( isdefined( level.intel_pillage_show_func ) )
                            self [[ level.intel_pillage_show_func ]]();

                        break;
                    default:
                        if ( isdefined( level.level_specific_pillage_show_func ) )
                            self [[ level.level_specific_pillage_show_func ]]( var_0, "searched", var_1 );

                        break;
                }

                if ( isdefined( self.drop_override_func ) )
                    self [[ self.drop_override_func ]]( var_0 );
                else if ( isdefined( self.pillage_trigger ) )
                    self.pillage_trigger drop_pillage_item_on_ground();
            }
            else
            {
                self.pillage_trigger makeusable();
                self.enabled = 1;
            }

            continue;
        }

        if ( isdefined( self.pillageinfo ) )
        {
            switch ( self.pillageinfo.type )
            {
                case "explosive":
                    var_0 try_to_give_player_explosives( self );
                    break;
                case "maxammo":
                    if ( var_0 cangive_maxammo() )
                    {
                        var_0 give_maxammo();
                        delete_pillage_trigger();
                    }
                    else
                    {
                        self.pillage_trigger makeusable();
                        var_0 maps\mp\_utility::setlowermessage( "max_ammo", &"ALIEN_COLLECTIBLES_AMMO_MAX", 3 );
                    }

                    break;
                case "money":
                    if ( var_0 maps\mp\alien\_persistence::get_player_currency() < var_0.maxcurrency )
                    {
                        var_0 maps\mp\alien\_persistence::give_player_currency( self.pillageinfo.amount, undefined, undefined, 1 );
                        var_2 = get_hintstring_for_pillaged_item( self.pillageinfo.amount );
                        var_0 thread show_pillage_text( var_2 );
                        delete_pillage_trigger();
                    }
                    else
                        var_0 maps\mp\_utility::setlowermessage( "max_money", &"ALIEN_COLLECTIBLES_MONEY_MAX", 3 );

                    break;
                case "attachment":
                    if ( var_0 add_attachment_to_weapon( self.pillageinfo.attachment, self ) )
                        delete_pillage_trigger();

                    break;
                case "flare":
                    var_0 try_to_give_player_flares( self );
                    break;
                case "clip":
                    if ( var_0 cangive_ammo_clip() )
                    {
                        var_0 give_ammo_clip();
                        delete_pillage_trigger();
                    }
                    else
                    {
                        self.pillage_trigger makeusable();
                        var_0 maps\mp\_utility::setlowermessage( "max_ammo", &"ALIEN_COLLECTIBLES_AMMO_MAX", 3 );
                    }

                    break;
                case "soflam":
                    if ( var_0 cangive_soflam() )
                    {
                        var_0 give_soflam();
                        delete_pillage_trigger();
                    }
                    else
                    {
                        self.pillage_trigger makeusable();

                        if ( var_0 hasweapon( "aliensoflam_mp" ) )
                            var_0 maps\mp\_utility::setlowermessage( "have_soflam", &"ALIEN_COLLECTIBLES_SOFLAM_HAD", 3 );
                        else
                            var_0 maps\mp\_utility::setlowermessage( "too_many", &"ALIEN_COLLECTIBLES_SOFLAM_HAD", 3 );
                    }

                    break;
                case "pet_leash":
                    var_0 try_to_give_player_the_leash( self );
                    break;
                case "trophy":
                    var_0 try_to_give_player_trophy( self );
                    break;
                case "stun_ammo":
                    var_0 maps\mp\alien\_deployablebox_functions::default_specialammo_onusedeployable( undefined, 0, 1, "deployable_specialammo" );
                    delete_pillage_trigger();
                    break;
                case "incendiary_ammo":
                    var_0 maps\mp\alien\_deployablebox_functions::default_specialammo_onusedeployable( undefined, 0, 1, "deployable_specialammo_in" );
                    delete_pillage_trigger();
                    break;
                case "ap_ammo":
                    var_0 maps\mp\alien\_deployablebox_functions::default_specialammo_onusedeployable( undefined, 0, 1, "deployable_specialammo_ap" );
                    delete_pillage_trigger();
                    break;
                case "explosive_ammo":
                    var_0 maps\mp\alien\_deployablebox_functions::default_specialammo_onusedeployable( undefined, 0, 1, "deployable_specialammo_explo" );
                    delete_pillage_trigger();
                    break;
                case "combined_ammo":
                    var_0 maps\mp\alien\_deployablebox_functions::default_specialammo_onusedeployable( undefined, 0, 1, "deployable_specialammo_comb" );
                    delete_pillage_trigger();
                    break;
                case "crafting":
                    if ( var_0 cangive_crafting_item( self.pillageinfo.craftingitem ) )
                    {
                        var_0 give_crafting_item( self.pillageinfo.craftingitem );
                        var_0 playlocalsound( "extinction_item_pickup" );
                        delete_pillage_trigger();
                    }
                    else
                        self.pillage_trigger makeusable();

                    break;
                default:
                    if ( isdefined( level.level_specific_pillage_show_func ) )
                        self [[ level.level_specific_pillage_show_func ]]( var_0, "pick_up" );

                    break;
            }
        }
    }
}

drop_pillage_item_on_ground()
{
    if ( self.model != "tag_origin" )
    {
        var_0 = ( 0, 0, 20 );
        var_1 = ( 0, 0, 2 );
        var_2 = ( 0, 0, 0 );
        var_3 = getgroundposition( self.origin + var_0, 2 );

        switch ( self.model )
        {
            case "weapon_baseweapon_clip":
                var_2 = ( 0, 0, 4 );
                break;
            case "mp_trophy_system_folded_iw6":
                var_2 = ( 0, 0, 12 );
                break;
            case "weapon_scavenger_grenadebag":
                var_2 = ( 0, 0, 6 );
                break;
            case "weapon_soflam":
                var_2 = ( 0, 0, 6 );
                break;
            case "vehicle_pickup_keys":
                var_2 = ( 0, 0, 6 );
                self.angles = ( 0, 0, 83 );
                break;
            case "weapon_alien_muzzlebreak":
                var_2 = ( 0, 0, 4 );
                break;
            case "weapon_alien_cortex_container":
                var_2 = ( 0, 0, 7 );
                break;
            case "weapon_knife_iw6":
            case "weapon_canister_bomb":
            case "weapon_concussion_grenade":
            case "mil_emergency_flare_mp":
                var_2 = var_1;
                break;
        }

        self.origin = var_3 + var_2;
    }
}

delete_pillage_trigger()
{
    if ( maps\mp\alien\_utility::alien_mode_has( "outline" ) )
        maps\mp\alien\_outline_proto::remove_from_outline_pillage_watch_list( self.pillage_trigger );

    self.pillage_trigger delete();
    self.pillageinfo.type = undefined;
}

get_pillaged_item( var_0, var_1 )
{
    var_5 = [];

    if ( check_for_existing_pet_bombs() > 1 )
        var_5[var_5.size] = "pet_leash";

    if ( !var_1 can_use_attachment() )
        var_5[var_5.size] = "attachment";

    if ( isdefined( level.intel_pillage_allowed_func ) && !var_1 [[ level.intel_pillage_allowed_func ]]() )
        var_5[var_5.size] = "intel";

    if ( !var_1 should_find_crafting_items() )
        var_5[var_5.size] = "crafting";

    var_2 = get_random_pillage_item( level.pillageitems[var_0.pillage_type], var_5 );
    var_6 = 0;

    while ( isdefined( var_1.last_item ) && var_1.last_item == var_2 )
    {
        var_2 = get_random_pillage_item( level.pillageitems[var_0.pillage_type], var_5 );
        var_6++;

        if ( var_6 % 10 == 0 )
            break;
    }

    var_1.last_item = var_2;

    if ( isdefined( var_0.default_item_type ) )
        var_2 = var_0.default_item_type;

    var_3 = spawnstruct();

    switch ( var_2 )
    {
        case "attachment":
            var_3.type = "attachment";
            break;
        case "soflam":
            var_3.type = "soflam";
            break;
        case "explosive":
            switch ( randomint( 3 ) )
            {
                case 0:
                    var_3.type = "grenade";
                    var_3.count = 2;
                    break;
                case 1:
                    if ( var_0.pillage_type != "easy" )
                    {
                        var_3.explosive_type = choose_random_explosive_type();
                        var_3.type = "explosive";
                        var_3.count = 2;
                    }
                    else
                    {
                        var_3.type = "flare";
                        var_3.count = 1;
                    }

                    break;
                case 2:
                    var_3.type = "flare";
                    var_3.count = 1;
                    break;
            }

            break;
        case "clip":
            var_3.type = "clip";
            var_3.count = 1;
            break;
        case "maxammo":
            var_3.type = "maxammo";
            var_3.count = 1;
            break;
        case "money":
            var_4 = 50 + randomint( 2 ) * 50;

            if ( var_0.pillage_type == "medium" )
                var_4 = 200 + randomint( 2 ) * 50;

            if ( var_0.pillage_type == "hard" )
                var_4 = 500;

            var_3.type = "money";
            var_3.count = var_4;
            break;
        case "pet_leash":
            var_3.type = "pet_leash";
            var_3.count = 1;
            break;
        case "trophy":
            var_3.type = "trophy";
            var_3.count = 1;
            break;
        case "specialammo":
            var_3.type = "specialammo";
            break;
        case "crafting":
            var_3.type = "crafting";
            break;
        case "locker_weapon":
            var_3.type = "locker_weapon";
            var_3.count = 1;
            break;
        case "locker_key":
            var_3.type = "locker_key";
            var_3.count = 1;
            break;
        case "intel":
            var_3.type = "intel";
            var_3.count = 1;
            break;
    }

    var_1 playlocalsound( "extinction_item_pickup" );
    return var_3;
}

get_random_pillage_item( var_0, var_1 )
{
    var_2 = [];
    var_3 = 0;

    foreach ( var_5 in var_0 )
    {
        if ( common_scripts\utility::array_contains( var_1, var_5.ref ) )
            continue;

        if ( var_5.chance == 0 )
            continue;

        var_2[var_2.size] = var_5;
        var_3 = var_3 + var_5.chance;
    }

    var_7 = randomintrange( 0, var_3 + 1 );
    var_8 = 0;

    foreach ( var_5 in var_2 )
    {
        var_8 = var_8 + var_5.chance;

        if ( var_7 <= var_8 )
            return var_5.ref;
    }
}

show_pillage_text( var_0 )
{
    self endon( "death" );
    self endon( "disconnect" );

    if ( isdefined( self.usebartext ) )
        return;

    var_1 = level.primaryprogressbarfontsize;
    var_2 = "objective";

    if ( level.splitscreen )
        var_1 = 1.3;

    self.usebartext = maps\mp\gametypes\_hud_util::createprimaryprogressbartext( 0, 25, var_1, var_2 );
    self.usebartext settext( var_0 );
    self.usebartext setpulsefx( 50, 2000, 800 );
    wait 3;
    self.usebartext maps\mp\gametypes\_hud_util::destroyelem();
    self.usebartext = undefined;
}

choose_random_explosive_type()
{
    return common_scripts\utility::random( level.pillageable_explosives );
}

try_to_give_player_explosives( var_0 )
{
    var_1 = var_0.pillageinfo.item;
    var_2 = var_0.pillageinfo.ammo;

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

    if ( self hasweapon( var_1 ) && self getammocount( var_1 ) > 0 )
    {
        var_3 = self getfractionmaxammo( var_1 );

        if ( var_3 < 1 )
        {
            var_4 = self getweaponammoclip( var_1 );
            self setweaponammoclip( var_1, var_4 + var_2 );
            self playlocalsound( "grenade_pickup" );
            var_0 delete_pillage_trigger();
            return;
        }

        maps\mp\_utility::setlowermessage( "max_explosvies", &"ALIEN_COLLECTIBLES_EXPLO_MAX", 3 );
        return;
    }
    else
    {
        var_5 = should_swap_weapon( level.offhand_explosives );
        self setoffhandprimaryclass( "other" );

        if ( !isdefined( var_5 ) )
        {
            self giveweapon( var_1 );
            self setweaponammoclip( var_1, var_2 );
            self playlocalsound( "grenade_pickup" );
            var_0 delete_pillage_trigger();
        }
        else
        {
            self takeweapon( var_5 );
            self giveweapon( var_1 );
            self setweaponammoclip( var_1, var_2 );
            self playlocalsound( "grenade_pickup" );
            var_0.pillage_trigger setmodel( getweaponmodel( var_5 ) );
            var_6 = get_hintstring_for_item_pickup( var_5 );
            var_0.pillage_trigger sethintstring( var_6 );
            var_0.pillage_trigger makeusable();
            var_0.pillageinfo = spawnstruct();
            var_0.pillageinfo.type = "explosive";
            var_0.pillageinfo.item = var_5;
            var_0.pillageinfo.ammo = self.swapped_weapon_ammocount;
            var_0.pillage_trigger drop_pillage_item_on_ground();
        }
    }
}

try_to_give_player_flares( var_0 )
{
    self endon( "disconnect" );
    wait 1;
    var_1 = var_0.pillageinfo.item;
    var_2 = var_0.pillageinfo.ammo;

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

    if ( self hasweapon( var_1 ) && self getammocount( var_1 ) > 0 )
    {
        var_3 = self getfractionmaxammo( var_1 );

        if ( var_3 < 1 )
        {
            var_4 = self getweaponammoclip( var_1 );
            var_5 = self getweaponammostock( var_1 );
            self setweaponammoclip( var_1, var_4 + var_5 + 1 );
            var_0 delete_pillage_trigger();
            return;
        }

        maps\mp\_utility::setlowermessage( "max_flares", &"ALIEN_COLLECTIBLES_FLARE_MAX", 3 );
        return;
    }
    else
    {
        var_6 = should_swap_weapon( level.offhand_secondaries );

        if ( !isdefined( var_6 ) )
        {
            self setoffhandsecondaryclass( "flash" );
            self giveweapon( var_1 );
            self setweaponammoclip( var_1, var_2 );
            var_0 delete_pillage_trigger();
        }
        else
        {
            self setoffhandsecondaryclass( "flash" );
            self takeweapon( var_6 );
            self giveweapon( var_1 );
            self setweaponammoclip( var_1, var_2 );
            var_7 = get_hintstring_for_item_pickup( var_6 );
            var_0.pillage_trigger sethintstring( var_7 );
            var_0.pillage_trigger makeusable();
            var_0.pillageinfo = spawnstruct();

            if ( var_6 == "alienflare_mp" || var_6 == "iw6_aliendlc21_mp" )
            {
                var_0.pillage_trigger setmodel( level.pillageinfo.flare_model );
                var_0.pillageinfo.type = "flare";
            }
            else if ( var_6 == "alienthrowingknife_mp" )
            {
                var_0.pillage_trigger setmodel( level.pillageinfo.leash_model );
                var_0.pillageinfo.type = "pet_leash";
            }
            else if ( var_6 == "alientrophy_mp" )
            {
                var_0.pillage_trigger setmodel( level.pillageinfo.trophy_model );
                var_0.pillageinfo.type = "trophy";
            }

            var_0.pillageinfo.item = var_6;
            var_0.pillageinfo.ammo = self.swapped_weapon_ammocount;

            if ( isdefined( var_0.is_locker ) && isdefined( level.locker_drop_item_on_ground_func ) )
                var_0 [[ level.locker_drop_item_on_ground_func ]]( self );
            else
                var_0.pillage_trigger drop_pillage_item_on_ground();
        }
    }
}

try_to_give_player_trophy( var_0 )
{
    var_1 = var_0.pillageinfo.item;
    var_2 = var_0.pillageinfo.ammo;

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

    if ( self hasweapon( var_1 ) && self getammocount( var_1 ) > 0 )
        maps\mp\_utility::setlowermessage( "max_flares", &"ALIEN_COLLECTIBLES_TROPHY_MAX", 3 );
    else
    {
        var_3 = should_swap_weapon( level.offhand_secondaries );

        if ( !isdefined( var_3 ) )
        {
            self setoffhandsecondaryclass( "flash" );
            self giveweapon( var_1 );
            self setweaponammoclip( var_1, 1 );
            var_0 delete_pillage_trigger();
        }
        else
        {
            self setoffhandsecondaryclass( "flash" );
            self takeweapon( var_3 );
            self giveweapon( var_1 );
            self setweaponammoclip( var_1, 1 );
            var_4 = get_hintstring_for_item_pickup( var_3 );
            var_0.pillage_trigger sethintstring( var_4 );
            var_0.pillage_trigger makeusable();
            var_0.pillageinfo = spawnstruct();

            if ( var_3 == "alienflare_mp" || var_3 == "iw6_aliendlc21_mp" )
            {
                var_0.pillage_trigger setmodel( level.pillageinfo.flare_model );
                var_0.pillageinfo.type = "flare";
            }
            else if ( var_3 == "alienthrowingknife_mp" )
            {
                var_0.pillage_trigger setmodel( level.pillageinfo.leash_model );
                var_0.pillageinfo.type = "pet_leash";
            }
            else if ( var_3 == "alientrophy_mp" )
                var_0.pillage_trigger setmodel( level.pillageinfo.trophy_model );

            var_0.pillageinfo.item = var_3;
            var_0.pillageinfo.ammo = self.swapped_weapon_ammocount;

            if ( isdefined( var_0.is_locker ) && isdefined( level.locker_drop_item_on_ground_func ) )
                var_0 [[ level.locker_drop_item_on_ground_func ]]( self );
            else
                var_0.pillage_trigger drop_pillage_item_on_ground();
        }
    }
}

try_to_give_player_the_leash( var_0 )
{
    var_1 = var_0.pillageinfo.item;
    var_2 = var_0.pillageinfo.ammo;

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

    if ( self hasweapon( var_1 ) && self getammocount( var_1 ) > 0 )
    {
        var_3 = self getfractionmaxammo( var_1 );

        if ( var_3 < 1 )
        {
            var_4 = self getweaponammoclip( var_1 );
            var_5 = self getweaponammostock( var_1 );
            self setweaponammoclip( var_1, var_4 + var_5 + 1 );
            var_0 delete_pillage_trigger();
            return;
        }

        maps\mp\_utility::setlowermessage( "max_leash", &"ALIENS_PATCH_LEASH_MAX", 3 );
        return;
    }
    else
    {
        var_6 = should_swap_weapon( level.offhand_secondaries );

        if ( !isdefined( var_6 ) )
        {
            self setoffhandsecondaryclass( "throwingknife" );
            self giveweapon( var_1 );
            self setweaponammoclip( var_1, var_2 );
            var_0 delete_pillage_trigger();
        }
        else
        {
            self setoffhandsecondaryclass( "throwingknife" );
            self takeweapon( var_6 );
            self giveweapon( var_1 );
            self setweaponammoclip( var_1, var_2 );
            var_7 = get_hintstring_for_item_pickup( var_6 );
            var_0.pillage_trigger sethintstring( var_7 );
            var_0.pillage_trigger makeusable();
            var_0.pillageinfo = spawnstruct();

            if ( var_6 == "alienflare_mp" || var_6 == "iw6_aliendlc21_mp" )
            {
                var_0.pillage_trigger setmodel( level.pillageinfo.flare_model );
                var_0.pillageinfo.type = "flare";
            }
            else if ( var_6 == "alienthrowingknife_mp" )
                var_0.pillage_trigger setmodel( level.pillageinfo.leash_model );
            else if ( var_6 == "alientrophy_mp" )
            {
                var_0.pillageinfo.type = "trophy";
                var_0.pillage_trigger setmodel( level.pillageinfo.trophy_model );
            }

            var_0.pillageinfo.item = var_6;
            var_0.pillageinfo.ammo = self.swapped_weapon_ammocount;

            if ( isdefined( var_0.is_locker ) && isdefined( level.locker_drop_item_on_ground_func ) )
                var_0 [[ level.locker_drop_item_on_ground_func ]]( self );
            else
                var_0.pillage_trigger drop_pillage_item_on_ground();
        }
    }
}

should_swap_weapon( var_0 )
{
    var_1 = 0;
    var_2 = undefined;
    var_3 = 0;
    var_4 = self getweaponslistoffhands();

    foreach ( var_6 in var_4 )
    {
        foreach ( var_8 in var_0 )
        {
            if ( var_6 != var_8 )
                continue;

            if ( isdefined( var_6 ) && var_6 != "none" && self getammocount( var_6 ) > 0 )
            {
                var_2 = var_6;
                var_3 = self getweaponammoclip( var_6 );
                var_1 = 1;
                break;
            }

            if ( var_1 )
                break;
        }
    }

    if ( isdefined( var_2 ) )
        self.swapped_weapon_ammocount = var_3;

    return var_2;
}

is_frag_grenade( var_0 )
{
    return var_0 == "aliensemtex_mp" || var_0 == "alienmortar_shell_mp";
}

get_attachment_for_weapon()
{
    var_0 = self getcurrentweapon();
    var_1 = getweaponbasename( var_0 );
    var_2 = maps\mp\_utility::getweaponclass( var_0 );
    var_3 = common_scripts\utility::random( level.pillageable_attachments );

    switch ( var_2 )
    {
        case "weapon_sniper":
            var_3 = check_upgrade_return_attchment( level.pillageable_attachments, var_1 );
            break;
        case "weapon_assault":
            if ( issubstr( var_1, "sc2010" ) )
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_ar_sc2010, var_1 );
            else if ( issubstr( var_1, "honeybadger" ) )
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_ar_honeybadger, var_1 );
            else
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_ar, var_1 );

            break;
        case "weapon_lmg":
            if ( issubstr( var_1, "kac" ) )
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_lmg_kac, var_1 );
            else
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_lmg, var_1 );

            break;
        case "weapon_shotgun":
            if ( issubstr( var_1, "fp6" ) )
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_sg_fp6, var_1 );
            else
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_sg, var_1 );

            break;
        case "weapon_dmr":
            var_3 = check_upgrade_return_attchment( level.pillageable_attachments_dmr, var_1 );
            break;
        case "weapon_smg":
            if ( issubstr( var_1, "aliendlc23" ) )
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_aliendlc23, var_1 );
            else if ( issubstr( var_1, "arkalienk7" ) )
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_smg_k7, var_1 );
            else
                var_3 = check_upgrade_return_attchment( level.pillageable_attachments_smg, var_1 );

            break;
        default:
            var_3 = check_upgrade_return_attchment( level.pillageable_attachments, var_1 );
            break;
    }

    return var_3;
}

check_upgrade_return_attchment( var_0, var_1 )
{
    var_2 = getdvar( "ui_mapname" );
    var_3 = common_scripts\utility::random( var_0 );

    while ( var_3 == "alienmuzzlebrake" || var_3 == "xmags" )
    {
        if ( var_3 == "alienmuzzlebrake" )
        {
            if ( maps\mp\alien\_persistence::is_upgrade_enabled( "master_scavenger_upgrade" ) )
                return var_3;
            else
                var_3 = common_scripts\utility::random( var_0 );
        }
        else if ( var_3 == "xmags" )
        {
            if ( maps\mp\alien\_persistence::is_upgrade_enabled( "master_scavenger_upgrade" ) )
                return var_3;
            else
                var_3 = common_scripts\utility::random( var_0 );
        }

        wait 0.05;
    }

    return var_3;
}

add_attachment_to_weapon( var_0, var_1 )
{
    var_2 = self getcurrentweapon();
    var_3 = getweaponbasename( var_2 );
    var_4 = getweaponbasename( var_2 );
    var_5 = 0;
    var_6 = "none";
    var_7 = "none";
    var_8 = "none";
    var_9 = "none";
    var_10 = 0;
    var_11 = 0;
    var_12 = 0;
    var_13 = maps\mp\_utility::getweaponclass( var_3 );

    if ( maps\mp\_utility::weaponhasattachment( var_2, "xmags" ) )
        var_10 = 1;

    var_14 = get_possible_attachments_by_weaponclass( var_13, var_3 );
    var_15 = 0;

    foreach ( var_17 in var_14 )
    {
        if ( var_0 == var_17 )
            var_15 = 1;
    }

    if ( !var_15 )
    {
        maps\mp\_utility::setlowermessage( "cant_attach", &"ALIEN_COLLECTIBLES_CANT_USE", 3 );
        return 0;
    }

    var_19 = getweaponattachments( var_2 );

    if ( var_19.size > 0 && var_19.size < 5 )
    {
        for ( var_20 = 0; var_20 < var_19.size; var_20++ )
        {
            if ( var_20 == 0 )
                var_6 = var_19[var_20];

            if ( var_20 == 1 )
                var_7 = var_19[var_20];

            if ( var_20 == 2 )
                var_8 = var_19[var_20];

            if ( var_20 == 3 )
                var_9 = var_19[var_20];
        }

        if ( var_6 != "none" && maps\mp\_utility::getattachmenttype( var_6 ) == maps\mp\_utility::getattachmenttype( var_0 ) )
        {
            swap_attachment( var_6, var_1 );
            var_6 = var_0;
            var_5 = 1;
        }

        if ( var_7 != "none" && maps\mp\_utility::getattachmenttype( var_7 ) == maps\mp\_utility::getattachmenttype( var_0 ) )
        {
            swap_attachment( var_7, var_1 );
            var_7 = var_0;
            var_5 = 1;
        }

        if ( var_8 != "none" && maps\mp\_utility::getattachmenttype( var_8 ) == maps\mp\_utility::getattachmenttype( var_0 ) )
        {
            swap_attachment( var_8, var_1 );
            var_8 = var_0;
            var_5 = 1;
        }

        if ( var_9 != "none" && maps\mp\_utility::getattachmenttype( var_9 ) == maps\mp\_utility::getattachmenttype( var_0 ) )
        {
            swap_attachment( var_9, var_1 );
            var_9 = var_0;
            var_5 = 1;
        }

        if ( var_5 == 0 )
        {
            if ( var_6 == "none" )
                var_6 = var_0;
            else if ( var_7 == "none" && var_0 != var_6 )
                var_7 = var_0;
            else if ( var_8 == "none" && var_0 != var_6 && var_0 != var_7 )
                var_8 = var_0;
            else if ( var_9 == "none" && var_0 != var_6 && var_0 != var_7 && var_0 != var_8 )
                var_9 = var_0;
            else
            {
                maps\mp\_utility::setlowermessage( "cant_attach", &"ALIEN_COLLECTIBLES_CANT_USE", 3 );
                return 0;
            }
        }
    }
    else
        var_6 = var_0;

    var_21 = maps\mp\_utility::strip_suffix( var_4, "_mp" );
    var_11 = get_weapon_camo( var_3 );
    var_12 = randomintrange( 1, 7 );

    if ( issubstr( var_3, "aliendlc23" ) )
        var_12 = 0;

    if ( var_6 != "thermal" && var_6 != "thermalsmg" && var_7 != "thermal" && var_7 != "thermalsmg" && var_8 != "thermal" && var_8 != "thermalsmg" && var_9 != "thermal" && var_9 != "thermalsmg" )
        var_22 = maps\mp\alien\_utility::buildalienweaponname( var_21, var_6, var_7, var_8, var_9, var_11, var_12 );
    else
        var_22 = maps\mp\alien\_utility::buildalienweaponname( var_21, var_6, var_7, var_8, var_9, var_11 );

    var_23 = self getweaponammoclip( var_2 );
    var_24 = self getweaponammostock( var_2 );
    self takeweapon( var_2 );
    self giveweapon( var_22 );

    if ( maps\mp\_utility::weaponhasattachment( var_22, "xmags" ) && !var_10 )
        var_23 = weaponclipsize( var_22 );

    self setweaponammoclip( var_22, var_23 );
    self setweaponammostock( var_22, var_24 );
    self playlocalsound( "weap_raise_large_plr" );
    self switchtoweapon( var_22 );

    if ( var_5 == 0 )
        return 1;
    else
        return 0;
}

get_weapon_camo( var_0 )
{
    if ( issubstr( var_0, "alienfp6" ) || issubstr( var_0, "alienmts255" ) || issubstr( var_0, "aliendlc12" ) || issubstr( var_0, "aliendlc13" ) || issubstr( var_0, "aliendlc14" ) || issubstr( var_0, "aliendlc15" ) || issubstr( var_0, "alienameli" ) || issubstr( var_0, "alienk7" ) || issubstr( var_0, "alienmk14" ) || issubstr( var_0, "alienr5rgp" ) || issubstr( var_0, "alienusr" ) || issubstr( var_0, "alienuts15" ) || issubstr( var_0, "arkalienameli" ) || issubstr( var_0, "arkaliendlc15" ) || issubstr( var_0, "arkaliendlc23" ) || issubstr( var_0, "arkalienimbel" ) || issubstr( var_0, "arkalienk7" ) || issubstr( var_0, "arkalienkac" ) || issubstr( var_0, "arkalienmaul" ) || issubstr( var_0, "arkalienmk14" ) || issubstr( var_0, "arkalienr5rgp" ) || issubstr( var_0, "arkalienusr" ) || issubstr( var_0, "arkalienuts15" ) || issubstr( var_0, "arkalienvks" ) || issubstr( var_0, "aliendlc23" ) )
        return 0;
    else
        return randomintrange( 1, 10 );
}

swap_attachment( var_0, var_1 )
{
    var_2 = var_1.origin;
    var_1.pillageinfo.type = "attachment";
    var_1.pillageinfo.attachment = var_0;

    switch ( var_0 )
    {
        case "griphide":
            var_0 = "grip";
            break;
        case "barrelrange03":
            var_0 = "barrelrange";
            break;
        case "alienfiretypeburstdmr":
            var_0 = "firetypeburst";
            break;
        case "alienfiretypeburstg28":
            var_0 = "firetypeburst";
            break;
        case "alienfiretypeburstlight":
            var_0 = "firetypeburst";
            break;
        case "alienfiretypeburst":
            var_0 = "firetypeburst";
            break;
        case "reflexsmg":
            var_0 = "reflex";
            break;
        case "reflexlmg":
            var_0 = "reflex";
            break;
        case "reflexshotgun":
            var_0 = "reflex";
            break;
        case "eotechsmg":
            var_0 = "eotech";
            break;
        case "eotechlmg":
            var_0 = "eotech";
            break;
        case "eotechshotgun":
            var_0 = "eotech";
            break;
        case "acogsmg":
            var_0 = "acog";
            break;
        case "thermalsmg":
            var_0 = "thermal";
            break;
        case "alienmuzzlebrakesn":
        case "alienmuzzlebrakesg":
        case "alienmuzzlebrake":
            var_0 = "alienmuzzlebrake";
            break;
        default:
            break;
    }

    var_1.pillage_trigger.origin = var_2;
    var_3 = get_hintstring_for_pillaged_item( "attachment" );
    var_4 = get_hintstring_for_item_pickup( var_0 );
    var_1.pillage_trigger sethintstring( var_4 );
    var_1.pillage_trigger makeusable();
    thread show_pillage_text( var_3 );
    var_5 = level.pillageinfo.attachment_model;

    if ( var_0 == "alienmuzzlebrake" )
        var_5 = level.pillageinfo.alienattachment_model;

    var_1.pillage_trigger setmodel( var_5 );
    var_1.pillageinfo.type = "attachment";
    var_1.pillageinfo.attachment = var_0;
    var_1.pillage_trigger drop_pillage_item_on_ground();
}

useholdthink( var_0, var_1 )
{
    var_0 endon( "disconnect" );
    var_0.pillage_spot = spawnstruct();
    var_0.pillage_spot.curprogress = 0;
    var_0.pillage_spot.inuse = 1;
    var_0.pillage_spot.userate = 1;

    if ( isdefined( var_1 ) )
        var_0.pillage_spot.usetime = var_1;
    else
        var_0.pillage_spot.usetime = level.pillageinfo.default_use_time;

    if ( isplayer( var_0 ) )
        var_0 thread personalusebar( self );

    var_0.hasprogressbar = 1;
    var_2 = useholdthinkloop( var_0, self, 40000 );
    var_0.hasprogressbar = 0;

    if ( !isdefined( self ) )
        return 0;

    var_0.pillage_spot.inuse = 0;
    var_0.pillage_spot.curprogress = 0;
    return var_2;
}

personalusebar( var_0 )
{
    self endon( "disconnect" );
    self setclientomnvar( "ui_securing", 1 );
    var_1 = -1;

    while ( maps\mp\_utility::isreallyalive( self ) && isdefined( var_0 ) && self.pillage_spot.inuse && !level.gameended )
    {
        var_1 = self.pillage_spot.userate;
        self setclientomnvar( "ui_securing_progress", self.pillage_spot.curprogress / self.pillage_spot.usetime );
        wait 0.05;
    }

    self setclientomnvar( "ui_securing", 0 );
    self setclientomnvar( "ui_securing_progress", 0 );
}

useholdthinkloop( var_0, var_1, var_2 )
{
    while ( !level.gameended && isdefined( self ) && maps\mp\_utility::isreallyalive( var_0 ) && var_0 usebuttonpressed() && var_0.pillage_spot.curprogress < var_0.pillage_spot.usetime )
    {
        if ( isdefined( var_1 ) && isdefined( var_2 ) )
        {
            if ( distancesquared( var_0.origin, var_1.origin ) > var_2 )
                return 0;
        }

        var_0.pillage_spot.curprogress = var_0.pillage_spot.curprogress + 50 * var_0.pillage_spot.userate;
        var_0.pillage_spot.userate = 1;

        if ( var_0.pillage_spot.curprogress >= var_0.pillage_spot.usetime )
            return maps\mp\_utility::isreallyalive( var_0 );

        wait 0.05;
    }

    return 0;
}

get_possible_attachments_by_weaponclass( var_0, var_1 )
{
    switch ( var_0 )
    {
        case "weapon_smg":
            if ( issubstr( var_1, "aliendlc23" ) )
            {
                var_2 = level.pillageable_attachments_aliendlc23;
                return var_2;
            }

            if ( issubstr( var_1, "arkalienk7" ) )
            {
                var_2 = level.pillageable_attachments_smg_k7;
                return var_2;
            }

            var_2 = level.pillageable_attachments_smg;
            return var_2;
        case "weapon_assault":
            if ( issubstr( var_1, "sc2010" ) )
            {
                var_2 = level.pillageable_attachments_ar_sc2010;
                return var_2;
            }

            if ( issubstr( var_1, "honeybadger" ) )
            {
                var_2 = level.pillageable_attachments_ar_honeybadger;
                return var_2;
            }

            var_2 = level.pillageable_attachments_ar;
            return var_2;
        case "weapon_lmg":
            if ( issubstr( var_1, "kac" ) )
            {
                var_2 = level.pillageable_attachments_lmg_kac;
                return var_2;
            }

            var_2 = level.pillageable_attachments_lmg;
            return var_2;
        case "weapon_shotgun":
            if ( issubstr( var_1, "fp6" ) )
            {
                var_2 = level.pillageable_attachments_sg_fp6;
                return var_2;
            }

            var_2 = level.pillageable_attachments_sg;
            return var_2;
        case "weapon_pistol":
            var_2 = [];
            return var_2;
        case "weapon_dmr":
            var_2 = level.pillageable_attachments_dmr;
            return var_2;
        case "weapon_sniper":
            var_2 = level.pillageable_attachments_sr;
            return var_2;
        default:
            var_2 = [];
            return var_2;
    }
}

cangive_ammo_clip()
{
    var_0 = self getcurrentweapon();
    var_1 = weaponmaxammo( var_0 );
    var_2 = weaponclipsize( var_0 );
    var_3 = maps\mp\alien\_utility::getrawbaseweaponname( var_0 );

    if ( maps\mp\alien\_utility::player_has_specialized_ammo( var_3 ) )
    {
        if ( isdefined( self.stored_ammo[var_3] ) )
        {
            if ( self.stored_ammo[var_3].ammostock < weaponmaxammo( var_0 ) )
                return 1;
        }
    }
    else if ( self getweaponammostock( var_0 ) < var_1 )
        return 1;

    if ( var_0 == "aliensoflam_mp" || weapontype( var_0 ) == "riotshield" || maps\mp\alien\_utility::is_incompatible_weapon( var_0 ) )
    {
        var_4 = self getweaponslistprimaries();

        foreach ( var_6 in var_4 )
        {
            if ( var_6 == var_0 )
                continue;

            var_1 = weaponmaxammo( var_6 );
            var_2 = weaponclipsize( var_6 );
            var_3 = maps\mp\alien\_utility::getrawbaseweaponname( var_6 );

            if ( maps\mp\alien\_utility::player_has_specialized_ammo( var_3 ) )
            {
                if ( isdefined( self.stored_ammo[var_3] ) )
                {
                    if ( self.stored_ammo[var_3].ammostock < weaponmaxammo( var_6 ) )
                        return 1;
                }
            }
            else if ( self getweaponammostock( var_6 ) < var_1 )
                return 1;
        }
    }

    return 0;
}

give_ammo_clip()
{
    var_0 = self getcurrentweapon();
    var_1 = maps\mp\alien\_utility::getrawbaseweaponname( var_0 );
    var_2 = weaponclipsize( var_0 );

    if ( maps\mp\alien\_utility::player_has_specialized_ammo( var_1 ) )
    {
        if ( isdefined( self.stored_ammo[var_1] ) )
        {
            if ( self.stored_ammo[var_1].ammostock < weaponmaxammo( var_0 ) )
                self.stored_ammo[var_1].ammostock = self.stored_ammo[var_1].ammostock + var_2;
        }
    }
    else if ( var_0 == "aliensoflam_mp" || weapontype( var_0 ) == "riotshield" || maps\mp\alien\_utility::is_incompatible_weapon( var_0 ) )
    {
        var_3 = self getweaponslistprimaries();

        foreach ( var_5 in var_3 )
        {
            if ( var_5 == var_0 )
                continue;

            if ( !maps\mp\gametypes\_weapons::isbulletweapon( var_0 ) )
                continue;

            var_2 = weaponclipsize( var_5 );
            var_1 = maps\mp\alien\_utility::getrawbaseweaponname( var_5 );

            if ( maps\mp\alien\_utility::player_has_specialized_ammo( var_1 ) )
            {
                if ( isdefined( self.stored_ammo[var_1] ) )
                {
                    if ( self.stored_ammo[var_1].ammostock < weaponmaxammo( var_5 ) )
                        self.stored_ammo[var_1].ammostock = self.stored_ammo[var_1].ammostock + var_2;
                }
            }
            else if ( self getweaponammostock( var_5 ) < weaponmaxammo( var_5 ) )
            {
                var_6 = self getweaponammostock( var_5 );
                self setweaponammostock( var_5, var_2 + var_6 );
            }

            return;
        }
    }
    else
    {
        var_6 = self getweaponammostock( var_0 );
        self setweaponammostock( var_0, var_2 + var_6 );
    }

    self playlocalsound( "weap_ammo_pickup" );
}

give_maxammo()
{
    var_0 = self getweaponslistprimaries();

    foreach ( var_2 in var_0 )
    {
        if ( var_2 == "aliensoflam_mp" || weapontype( var_2 ) == "riotshield" )
            continue;

        if ( maps\mp\alien\_utility::is_incompatible_weapon( var_2 ) )
            continue;

        var_3 = maps\mp\alien\_utility::getrawbaseweaponname( var_2 );

        if ( maps\mp\alien\_utility::player_has_specialized_ammo( var_3 ) )
        {
            if ( isdefined( self.stored_ammo[var_3] ) )
            {
                if ( self.stored_ammo[var_3].ammostock < weaponmaxammo( var_2 ) )
                    self.stored_ammo[var_3].ammostock = maps\mp\alien\_utility::return_nerf_scaled_ammo( var_2 );
            }

            continue;
        }

        var_4 = weaponmaxammo( var_2 );
        var_5 = int( var_4 * maps\mp\alien\_prestige::prestige_getminammo() );
        self setweaponammostock( var_2, var_5 );
    }

    self playlocalsound( "weap_ammo_pickup" );
}

cangive_maxammo()
{
    var_0 = self getweaponslistprimaries();

    foreach ( var_2 in var_0 )
    {
        if ( var_2 == "aliensoflam_mp" || weapontype( var_2 ) == "riotshield" )
            continue;

        if ( maps\mp\alien\_utility::is_incompatible_weapon( var_2 ) )
            continue;

        var_3 = maps\mp\alien\_utility::getrawbaseweaponname( var_2 );

        if ( maps\mp\alien\_utility::player_has_specialized_ammo( var_3 ) )
        {
            if ( isdefined( self.stored_ammo[var_3] ) )
            {
                var_4 = weaponmaxammo( var_2 );

                if ( maps\mp\alien\_prestige::prestige_getminammo() != 1 )
                    var_4 = maps\mp\alien\_prestige::prestige_getminammo() * weaponmaxammo( var_2 );

                if ( self.stored_ammo[var_3].ammostock < var_4 )
                    return 1;
            }

            continue;
        }

        var_4 = weaponmaxammo( var_2 );

        if ( maps\mp\alien\_prestige::prestige_getminammo() != 1 )
            var_4 = maps\mp\alien\_prestige::prestige_getminammo() * weaponmaxammo( var_2 );

        var_5 = var_4;
        var_6 = self getweaponammostock( var_2 );

        if ( var_6 < var_5 )
            return 1;
    }

    return 0;
}

cangive_soflam()
{
    var_0 = "aliensoflam_mp";
    var_1 = self getcurrentweapon();
    var_2 = self getweaponslistprimaries();

    if ( self.hasriotshieldequipped && var_2.size > 2 )
        return 0;

    if ( maps\mp\alien\_utility::is_holding_deployable() || self hasweapon( var_0 ) )
        return 0;

    return 1;
}

give_soflam()
{
    self giveweapon( "aliensoflam_mp" );
    self switchtoweapon( "aliensoflam_mp" );
}

cangive_crafting_item( var_0 )
{
    if ( !isdefined( self.current_crafting_recipe ) )
    {
        maps\mp\_utility::setlowermessage( "cant_pickup", &"ALIEN_CRAFTING_NO_RECIPE", 3 );
        self playlocalsound( "ui_craft_deny" );
        return 0;
    }

    if ( self.craftingitems.size == level.max_crafting_items )
    {
        maps\mp\_utility::setlowermessage( "cant_pickup", &"ALIEN_CRAFTING_MAX_CRAFTING_ITEMS", 3 );
        return 0;
    }

    foreach ( var_2 in self.craftingitems )
    {
        if ( var_2 == var_0 )
        {
            maps\mp\_utility::setlowermessage( "cant_pickup", &"ALIEN_CRAFTING_ALREADY_HAVE", 3 );
            return 0;
        }
    }

    if ( common_scripts\utility::array_contains( self.swappable_crafting_ingredient_list, var_0 ) )
        return 1;
    else if ( common_scripts\utility::array_contains( self.crafting_ingredient_list, var_0 ) )
        return 1;

    maps\mp\_utility::setlowermessage( "cant_pickup", &"ALIEN_CRAFTING_NO_RECIPE", 3 );
    return 0;
}

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

    for (;;)
    {
        level waittill( "drill_detonated" );
        var_0 = common_scripts\utility::getstructarray( "pillage_area", "targetname" );

        foreach ( var_8, var_2 in var_0 )
        {
            level.pillage_areas[var_8] = [];
            level.pillage_areas[var_8]["easy"] = [];
            level.pillage_areas[var_8]["medium"] = [];
            level.pillage_areas[var_8]["hard"] = [];
            var_3 = common_scripts\utility::getstructarray( var_2.target, "targetname" );

            foreach ( var_5 in var_3 )
            {
                if ( isdefined( var_5.script_noteworthy ) )
                {
                    var_6 = strtok( var_5.script_noteworthy, "," );
                    var_5.pillage_type = var_6[0];

                    if ( isdefined( var_6[1] ) )
                        var_5.script_model = var_6[1];

                    switch ( var_5.pillage_type )
                    {
                        case "easy":
                            level.pillage_areas[var_8]["easy"][level.pillage_areas[var_8]["easy"].size] = var_5;
                            break;
                        case "medium":
                            level.pillage_areas[var_8]["medium"][level.pillage_areas[var_8]["medium"].size] = var_5;
                            break;
                        case "hard":
                            level.pillage_areas[var_8]["hard"][level.pillage_areas[var_8]["hard"].size] = var_5;
                            break;
                    }
                }
            }
        }

        foreach ( var_8, var_2 in level.pillage_areas )
        {
            level.pillage_areas[var_8]["easy"] = remove_used_pillage_spots( level.pillage_areas[var_8]["easy"] );
            level.pillage_areas[var_8]["medium"] = remove_used_pillage_spots( level.pillage_areas[var_8]["medium"] );
            level.pillage_areas[var_8]["hard"] = remove_used_pillage_spots( level.pillage_areas[var_8]["hard"] );
            level thread create_pillage_spots( level.pillage_areas[var_8]["easy"] );
            level thread create_pillage_spots( level.pillage_areas[var_8]["medium"] );
            level thread create_pillage_spots( level.pillage_areas[var_8]["hard"] );
        }
    }
}

remove_used_pillage_spots( var_0 )
{
    var_1 = [];
    var_2 = 22500;
    var_3 = 90000;
    var_4 = cos( 75 );

    for ( var_5 = 0; var_5 < var_0.size; var_5++ )
    {
        var_6 = 0;

        if ( isdefined( var_0[var_5].not_used ) )
        {
            var_1[var_1.size] = var_0[var_5];
            var_0[var_5].not_used = undefined;
            var_0[var_5].searched = undefined;
        }
        else if ( isdefined( var_0[var_5].searched ) )
        {
            if ( !isdefined( var_0[var_5].pillage_trigger ) )
            {
                var_0[var_5].searched = undefined;
                var_1[var_1.size] = var_0[var_5];
                continue;
            }
            else
                continue;
        }
        else if ( isdefined( var_0[var_5].pillage_trigger ) )
        {
            var_7 = 0;

            foreach ( var_9 in level.players )
            {
                var_6 = 0;

                if ( !isalive( var_9 ) )
                    continue;

                if ( distance2dsquared( var_9.origin, var_0[var_5].origin ) < var_2 )
                    var_6 = 1;

                if ( !var_6 && distance2dsquared( var_9.origin, var_0[var_5].origin ) < var_3 )
                    var_6 = common_scripts\utility::within_fov( var_9 geteye(), var_9.angles, var_0[var_5].origin + ( 0, 0, 5 ), var_4 );

                if ( var_6 )
                    var_7 = 1;
            }

            if ( var_7 )
                continue;

            maps\mp\alien\_outline_proto::remove_from_outline_pillage_watch_list( var_0[var_5].pillage_trigger );
            var_0[var_5].pillage_trigger delete();
            var_0[var_5].not_used = 1;
            var_0[var_5].searched = undefined;
            var_0[var_5].enabled = undefined;
        }

        if ( var_5 % 2 == 0 )
            wait 0.05;
    }

    return var_1;
}

can_use_attachment()
{
    var_0 = self getweaponslistprimaries();

    foreach ( var_2 in var_0 )
    {
        var_3 = maps\mp\_utility::getweaponclass( var_2 );

        if ( var_3 == "weapon_pistol" )
            continue;

        if ( maps\mp\gametypes\_weapons::isbulletweapon( var_2 ) )
            return 1;
    }

    return 0;
}

check_for_existing_pet_bombs()
{
    var_0 = 0;

    foreach ( var_2 in level.players )
    {
        var_3 = var_2 getweaponslistall();

        foreach ( var_5 in var_3 )
        {
            if ( var_5 == "alienthrowingknife_mp" && ( var_2 getweaponammoclip( "alienthrowingknife_mp" ) > 0 || var_2 getweaponammostock( "alienthrowingknife_mp" ) > 0 ) )
                var_0++;
        }
    }

    foreach ( var_17, var_9 in level.pillage_areas )
    {
        foreach ( var_11 in level.pillage_areas[var_17]["easy"] )
        {
            if ( pillage_area_has_petbomb( var_11 ) )
                var_0++;
        }

        foreach ( var_11 in level.pillage_areas[var_17]["medium"] )
        {
            if ( pillage_area_has_petbomb( var_11 ) )
                var_0++;
        }

        foreach ( var_11 in level.pillage_areas[var_17]["hard"] )
        {
            if ( pillage_area_has_petbomb( var_11 ) )
                var_0++;
        }
    }

    var_18 = maps\mp\agents\_agent_utility::getactiveagentsoftype( "alien" );

    foreach ( var_20 in var_18 )
    {
        if ( isdefined( var_20.pet ) && var_20.pet )
            var_0++;
    }

    if ( isdefined( level.custom_pet_bomb_check ) )
        var_0 = var_0 + [[ level.custom_pet_bomb_check ]]();

    return var_0;
}

pillage_area_has_petbomb( var_0 )
{
    return isdefined( var_0.pillageinfo ) && isdefined( var_0.pillageinfo.type ) && var_0.pillageinfo.type == "pet_leash";
}

get_crafting_ingredient()
{
    var_0 = [];

    if ( self.craftingitems.size < 1 || self.crafting_ingredient_list.size > 0 )
        return common_scripts\utility::random( self.crafting_ingredient_list );
    else if ( self.craftingitems.size < 3 )
        return common_scripts\utility::random( self.swappable_crafting_ingredient_list );
    else
    {
        foreach ( var_2 in level.players )
        {
            if ( !isdefined( var_2.current_crafting_recipe ) )
                continue;

            if ( var_2.craftingitems.size == 3 )
                continue;

            if ( var_2.craftingitems.size < 1 || var_2.crafting_ingredient_list.size > 0 )
            {
                var_0 = common_scripts\utility::array_combine( var_2.crafting_ingredient_list, var_0 );
                continue;
            }

            var_0 = common_scripts\utility::array_combine( var_2.swappable_crafting_ingredient_list, var_0 );
        }
    }

    if ( var_0.size > 0 )
        return common_scripts\utility::random( var_0 );
    else if ( isdefined( level.random_crafting_list ) )
        return common_scripts\utility::random( level.random_crafting_list );
    else
        return common_scripts\utility::random( [ "venomx", "nucleicbattery", "bluebiolum", "biolum", "orangebiolum", "amethystbiolum", "fuse", "tnt", "pipe", "resin", "biolum", "cellbattery" ] );
}

get_crafting_model( var_0 )
{
    var_1 = 2;
    var_2 = 1;
    var_3 = tablelookup( level.alien_crafting_items, var_2, var_0, var_1 );

    if ( isdefined( var_3 ) )
        return var_3;
    else
        return level.crafting_model;
}

give_crafting_item( var_0 )
{
    if ( isdefined( self.current_crafting_recipe ) )
        self notify( "dlc_vo_notify", self.current_crafting_recipe, self );

    var_1 = get_crafting_item_slot( var_0 );
    self.crafting_ingredient_list = common_scripts\utility::array_remove( self.crafting_ingredient_list, var_0 );

    switch ( var_1 )
    {
        case 1:
            self setclientomnvar( "ui_alien_craft_slot_1", 1 );
            break;
        case 2:
            self setclientomnvar( "ui_alien_craft_slot_2", 1 );
            break;
        case 3:
            self setclientomnvar( "ui_alien_craft_slot_3", 1 );
            break;
    }

    if ( common_scripts\utility::array_contains( self.swappable_crafting_ingredient_list, var_0 ) )
    {
        var_2 = undefined;

        foreach ( var_4 in self.craftingitems )
        {
            if ( common_scripts\utility::array_contains( self.swappable_crafting_ingredient_list, var_4 ) )
                var_2 = var_4;
        }

        if ( isdefined( var_2 ) )
            self.craftingitems = common_scripts\utility::array_remove( self.craftingitems, var_2 );
    }
    else
        self.crafting_ingredient_list = common_scripts\utility::array_remove( self.crafting_ingredient_list, var_0 );

    self.craftingitems[self.craftingitems.size] = var_0;

    if ( self.craftingitems.size == 3 )
    {
        var_6 = get_crafting_item_table_index();
        self setclientomnvar( "ui_alien_hudcraftinginfo", var_6 );

        if ( isalive( self ) && !maps\mp\alien\_utility::is_in_laststand() )
            self iprintlnbold( &"ALIEN_CRAFTING_OPEN_MENU" );
    }
}

get_crafting_item_slot( var_0 )
{
    var_1 = 4;
    var_2 = 5;
    var_3 = 6;
    var_4 = 7;
    var_5 = 8;
    var_6 = 9;
    var_7 = undefined;
    var_8 = int( tablelookup( level.crafting_item_table, 1, var_0, 0 ) );
    var_9 = tablelookupbyrow( level.crafting_item_table, var_8, var_1 );

    if ( self.current_crafting_recipe == var_9 )
        var_7 = int( tablelookupbyrow( level.crafting_item_table, var_8, var_2 ) );
    else
    {
        var_9 = tablelookupbyrow( level.crafting_item_table, var_8, var_3 );

        if ( self.current_crafting_recipe != var_9 )
        {
            var_9 = tablelookupbyrow( level.crafting_item_table, var_8, var_5 );
            var_7 = int( tablelookupbyrow( level.crafting_item_table, var_8, var_6 ) );

            if ( self.current_crafting_recipe != var_9 )
            {

            }
        }
        else
            var_7 = int( tablelookupbyrow( level.crafting_item_table, var_8, var_4 ) );
    }

    return var_7;
}

get_crafting_item_table_index()
{
    var_0 = self.craftingitems.size;
    var_1 = [];
    var_2 = getarraykeys( level.crafting_ingredient_lists );

    foreach ( var_4 in var_2 )
    {
        var_5 = var_4;
        var_6 = 0;

        foreach ( var_8 in self.craftingitems )
        {
            if ( common_scripts\utility::array_contains( level.crafting_ingredient_lists[var_5], var_8 ) )
                var_6++;
        }

        if ( var_6 == var_0 )
        {
            var_10 = int( tablelookup( level.alien_crafting_table, 1, var_5, 0 ) );
            return var_10;
        }
    }
}

should_find_crafting_items()
{
    if ( isdefined( self.craftingitems ) && isdefined( level.max_crafting_items ) && self.craftingitems.size >= level.max_crafting_items )
        return 0;
    else if ( !isdefined( self.current_crafting_recipe ) )
        return 0;

    return 1;
}
