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

init()
{
    level.dlcalieneggs = [];
    level.dlcalieneggs["mp_boneyard_ns"] = 1;
    level.dlcalieneggs["mp_swamp"] = 2;
    level.dlcalieneggs["mp_ca_red_river"] = 4;
    level.dlcalieneggs["mp_ca_rumble"] = 8;
    level.dlcalieneggs["mp_dome_ns"] = 16;
    level.dlcalieneggs["mp_battery3"] = 32;
    level.dlcalieneggs["mp_ca_impact"] = 64;
    level.dlcalieneggs["mp_ca_behemoth"] = 128;
    level.dlcalieneggs["mp_dig"] = 256;
    level.dlcalieneggs["mp_favela_iw6"] = 512;
    level.dlcalieneggs["mp_pirate"] = 1024;
    level.dlcalieneggs["mp_zulu"] = 2048;
    level.dlcalieneggs["mp_conflict"] = 4096;
    level.dlcalieneggs["mp_mine"] = 8192;
    level.dlcalieneggs["mp_zerosub"] = 16384;
    level.dlcalieneggs["mp_shipment_ns"] = 32768;
    level.dlcaliengeggmaptopack["mp_boneyard_ns"] = 0;
    level.dlcaliengeggmaptopack["mp_swamp"] = 0;
    level.dlcaliengeggmaptopack["mp_ca_red_river"] = 0;
    level.dlcaliengeggmaptopack["mp_ca_rumble"] = 0;
    level.dlcaliengeggmaptopack["mp_dome_ns"] = 1;
    level.dlcaliengeggmaptopack["mp_battery3"] = 1;
    level.dlcaliengeggmaptopack["mp_ca_impact"] = 1;
    level.dlcaliengeggmaptopack["mp_ca_behemoth"] = 1;
    level.dlcaliengeggmaptopack["mp_dig"] = 2;
    level.dlcaliengeggmaptopack["mp_favela_iw6"] = 2;
    level.dlcaliengeggmaptopack["mp_pirate"] = 2;
    level.dlcaliengeggmaptopack["mp_zulu"] = 2;
    level.dlcaliengeggmaptopack["mp_conflict"] = 3;
    level.dlcaliengeggmaptopack["mp_mine"] = 3;
    level.dlcaliengeggmaptopack["mp_zerosub"] = 3;
    level.dlcaliengeggmaptopack["mp_shipment_ns"] = 3;
    level.bitcounts = [ 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 ];
    level._effect["vfx_alien_easter_egg_hit"] = loadfx( "vfx/gameplay/alien/vfx_alien_easter_egg_hit" );
}

setupeggformap( var_0 )
{
    if ( level.rankedmatch )
    {
        init();
        var_1 = level.dlcalieneggs[maps\mp\_utility::getmapname()];
        var_2 = getent( var_0, "targetname" );

        if ( isdefined( var_2 ) )
        {
            if ( var_2.classname == "script_model" )
                var_2 setcandamage( 1 );

            var_2 thread eggtrackhits();
        }
    }
}

eggtrackhits()
{
    level endon( "game_ended" );
    self.health = 99999;
    level.egghits = [];

    for (;;)
    {
        self waittill( "damage", var_0, var_1, var_2, var_3, var_4 );
        playfx( common_scripts\utility::getfx( "vfx_alien_easter_egg_hit" ), var_3, anglestoforward( var_2 ), anglestoup( var_2 ) );

        if ( isplayer( var_1 ) && !isai( var_1 ) )
        {
            var_5 = var_1 maps\mp\_utility::getuniqueid();

            if ( !isdefined( level.egghits[var_5] ) )
            {
                level.egghits[var_5] = 1;
                eggregisterhit( var_0, var_1, var_2, var_3, var_4 );
            }
        }
    }
}

eggregisterhit( var_0, var_1, var_2, var_3, var_4 )
{
    self.health = self.health + var_0;

    if ( !var_1 egghascompletedformap( maps\mp\_utility::getmapname() ) )
        var_1 eggsetcompletedformap( maps\mp\_utility::getmapname() );
    else if ( var_1 eggallfound() && var_1 maps\mp\gametypes\_hud_util::ch_getstate( "ch_weekly_1" ) < 2 )
        var_1 eggawardpatch();
}

egghascompletedformap( var_0 )
{
    var_1 = self getrankedplayerdatareservedint( "dlcEggStatus" );
    var_2 = level.dlcalieneggs[var_0];

    if ( isdefined( var_2 ) && ( var_1 & var_2 ) != 0 )
        return 1;

    return 0;
}

eggsetcompletedformap( var_0 )
{
    var_1 = level.dlcalieneggs[var_0];

    if ( isdefined( var_1 ) )
    {
        var_2 = self getrankedplayerdatareservedint( "dlcEggStatus" );
        var_2 = var_2 | var_1;
        self setrankedplayerdatareservedint( "dlcEggStatus", var_2 );
        var_3 = level.dlcaliengeggmaptopack[var_0];
        var_4 = eggcountcompletedeggsforpack( var_3, var_2 );
        var_3++;

        if ( var_4 < 4 )
            maps\mp\gametypes\_hud_message::playercardsplashnotify( "dlc_eggFound_" + var_3, self, var_4 );
        else if ( eggallfound() && maps\mp\gametypes\_hud_util::ch_getstate( "ch_weekly_1" ) < 2 )
            eggawardpatch();
        else
        {
            maps\mp\gametypes\_hud_message::playercardsplashnotify( "dlc_eggAllFound_" + var_3, self );
            thread maps\mp\gametypes\_rank::giverankxp( "dlc_egg_hunt" );
        }

        self playlocalsound( "ui_extinction_egg_splash" );
    }
}

eggawardpatch()
{
    maps\mp\gametypes\_hud_message::playercardsplashnotify( "dlc_eggAllFound", self );
    thread maps\mp\gametypes\_rank::giverankxp( "dlc_egg_hunt_all" );
    maps\mp\gametypes\_hud_util::ch_setstate( "ch_weekly_1", 2 );
}

eggcountcompletedeggsforpack( var_0, var_1 )
{
    var_2 = var_1 >> var_0 * 4;
    var_2 = var_2 & 15;
    return level.bitcounts[var_2];
}

eggallfoundforpack( var_0 )
{
    var_1 = self getrankedplayerdatareservedint( "dlcEggStatus" );
    var_2 = var_1 >> var_0 * 4 & 15;
    return var_2 != 0;
}

eggallfound()
{
    var_0 = self getrankedplayerdatareservedint( "dlcEggStatus" );
    return var_0 == 65535;
}
