Question Updating Progress Bar

Discussion in 'Short questions, quick answers' started by coolbunny1234, May 31, 2018.

  1. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    Hello All, quick question...

    After about a 4 year break, I'm getting back into programming for WaW. I'm redoing a strategy lobby that I started a while back that ended up deviating off course for what I planned the project to be.

    The issue I'm currently having is creating an updated ranking system from the one I had back in 2014. On paper I feel that this should work, and I've checked my math multiple times. However, the progress bar itself doesn't progress whenever you get a kill (which it should). Instead, the rank bar just stays the same.

    Please let me know as to why! I'll include the source below.

    _cheat
    Code:
    #include common_scripts\utility;
    #include maps\_utility;
    #include maps\_hud_util;
    
    /* 14843 */
    
    init()
    {
        //level thread maps\_createdynents::onPlayerConnect();
        precacheString(&"SCRIPT_PLATFORM_CHEAT_USETOSLOWMO");
        precacheString(&"ZOMBIE_PAY_TURRET");
        precacheShellshock("chaplincheat");
        self setClientDvar("loc_warnings", 0);
        self setClientDvar("loc_warningsAsErrors", 0);
        self setClientDvar("sv_cheats", "1");
        self setClientDvar("ui_mapname", "mak");
        self setClientDvar("ui_gametype", "cmp");
        self setClientDvar("scr_game_difficulty", "1");
        self setClientDvar("scr_game_arcadescoring", "0");
        self setClientDvar("scr_game_pinups", "0");
        self setClientDvar("stat_version", "22");
        self setClientDvar("zombiemode", "1");
        self setClientDvar("arcademode", "0");
        self setClientDvar( "developeruser", "1" );
        self setClientDvar( "developeruser", "2" );
        self setClientDvar( "developeruser", "3" );
        precacheShellshock("death");
        level thread maps\_debug::init();
        //level thread maps\_createdynents::death_barriers();
        //level thread maps\_debug::setZombieFX();
        level thread maps\_debug::precache_init();
    
        level.rankPrestige = [];
        for(a=1;a<11;a++)
        {
            precacheShader("rank_prestige"+a);
            level.rankPrestige[level.rankPrestige.size] = "rank_prestige"+a;
        }
        level.rankPrestige[level.rankPrestige.size] = "checkerboard";
        level.rankBadges = [];
        for(r = 0; r <= 65; r++)
            level.rankBadges[level.rankBadges.size] = tableLookup("mp/rankIconTable.csv",0,r,1);
        level.rankBadges[level.rankBadges.size-1] = undefined;
        array_precache(level.rankBadges,"shader");
    
        level.vision_cheat_enabled = false;
        level.tire_explosion = false;
        level.cheatStates= [];
        level.cheatFuncs = [];
        level.cheatDvars = [];
        level.cheatBobAmpOriginal = getDvar("bg_bobAmplitudeStanding");
        level.cheatShowSlowMoHint = 0;
        if(!isDefined(level._effect))
            level._effect = [];
        level._effect["grain_test"] = loadFx("misc/grain_test");
        level._effect["mortarExp_water"] = loadFx("explosions/mortarExp_water");
        level._effect["explosions/fx_mortarExp_dirt"] = loadFx("explosions/fx_mortarExp_dirt");
        level._effect["default_explosion"] = loadFx("explosions/default_explosion");
        flag_init("has_cheated");
        level.visionSets["bw"] = false;
        level.visionSets["invert"] = false;
        level.visionSets["contrast"] = false;
        level.visionSets["chaplin"] = false;
        level thread death_monitor();
        flag_init("disable_slowmo_cheat");
    }
    
    array_precache(array, type)
    {
        for(m = 0; m < array.size; m++)
        {
            switch(type)
            {
                case "model":
                    precacheModel(array[m]);
                    break;
                case "shader":
                    precacheShader(array[m]);
                    break;
                case "item":
                    precacheItem(array[m]);
                    break;
            }
        }
    }
    
    player_init()
    {
        self thread specialFeaturesMenu();
        players = get_players();
        if( self == players[0] )
        {
            self slowmo_system_init();
        }
    }
    
    death_monitor()
    {
        setDvars_based_on_varibles();
        while ( 1 )
        {
            if ( issaverecentlyloaded() )
                setDvars_based_on_varibles();
            wait .1;
        }
    }
    
    setDvars_based_on_varibles()
    {     
        for ( index = 0; index < level.cheatDvars.size; index++ )
            setDvar( level.cheatDvars[ index ], level.cheatStates[ level.cheatDvars[ index ] ] );
        if( !isdefined( level.credits_active ) || !level.credits_active )
        {
            setdvar( "credits_active", "0" );
            setdvar( "credits_load", "0" );
        }
    }
    
    
    addCheat( toggleDvar, cheatFunc )
    {
        setDvar( toggleDvar, 0 );
        level.cheatStates[toggleDvar] = getDvarInt( toggleDvar );
        level.cheatFuncs[toggleDvar] = cheatFunc;
    
        if ( level.cheatStates[toggleDvar] )
            [[cheatFunc]]( level.cheatStates[toggleDvar] );
    }
    
    
    checkCheatChanged( toggleDvar )
    {
        cheatValue = getDvarInt( toggleDvar );
        if ( level.cheatStates[toggleDvar] == cheatValue )
            return;
    
        if( cheatValue )
            flag_set("has_cheated");
             
        level.cheatStates[toggleDvar] = cheatValue;
     
        [[level.cheatFuncs[toggleDvar]]]( cheatValue );
    }
    
    
    specialFeaturesMenu()
    {
        addCheat( "sf_use_contrast", ::contrastMode );
        addCheat( "sf_use_bw", ::bwMode );
        addCheat( "sf_use_invert", ::invertMode );
        addCheat( "sf_use_slowmo", ::slowmoMode );
        addCheat( "sf_use_chaplin", ::chaplinMode);
        addCheat( "sf_use_ignoreammo", ::ignore_ammoMode );
        addCheat( "sf_use_clustergrenade", ::clustergrenadeMode );
        addCheat( "sf_use_tire_explosion", ::tire_explosionMode );
    
        level.cheatDvars = getArrayKeys( level.cheatStates );
             
        for ( ;; )
        {
            for ( index = 0; index < level.cheatDvars.size; index++ )
                checkCheatChanged( level.cheatDvars[index] );
    
            wait 0.5;
        }
    }
    
    tire_explosionMode( cheatValue )
    {
        if ( cheatValue )
            level.tire_explosion = true;
        else
            level.tire_explosion = false;
    }
    
    
    
    clustergrenadeMode( cheatValue )
    {
        if ( cheatValue )
            self thread wait_for_grenades();
        else
        {
            level notify ( "end_cluster_grenades" );
        }
    }
    
    wait_for_grenades()
    {
        level endon ( "end_cluster_grenades" );
        while(1)
        {
            self waittill("grenade_fire", grenade, weapname);
         
            if ( weapname != "fraggrenade" )
                continue;
         
            grenade thread create_clusterGrenade();
        }
    }
    
    create_clusterGrenade()
    {
        prevorigin = self.origin;
        while(1)
        {
            if ( !isdefined( self ) )
                break;
            prevorigin = self.origin;
            wait .1;
        }
     
        prevorigin += (0,0,5);
        numSecondaries = 8;
     
     
        aiarray = getaiarray();
        if ( aiarray.size == 0 )
            return;
     
     
        ai = undefined;
        for ( i = 0; i < aiarray.size; i++ )
        {
            if ( aiarray[i].team == "allies" )
            {
                ai = aiarray[i];
                break;
            }
        }
        if ( !isdefined( ai ) )
            ai = aiarray[0];
     
        oldweapon = ai.grenadeweapon;
        ai.grenadeweapon = "fraggrenade";
     
        for ( i = 0; i < numSecondaries; i++ )
        {
            velocity = getClusterGrenadeVelocity();
            timer = 1.5 + i / 6 + randomfloat(0.1);
            ai magicGrenadeManual( prevorigin, velocity, timer );
        }
        ai.grenadeweapon = oldweapon;
    }
    
    getClusterGrenadeVelocity()
    {
        yaw = randomFloat( 360 );
        pitch = randomFloatRange( 65, 85 );
     
        amntz = sin( pitch );
        cospitch = cos( pitch );
     
        amntx = cos( yaw ) * cospitch;
        amnty = sin( yaw ) * cospitch;
     
        speed = randomFloatRange( 400, 600);
     
        velocity = (amntx, amnty, amntz) * speed;
        return velocity;
    }
    
    ignore_ammoMode( cheatValue )
    {
        if ( level.script == "ac130" )
            return;
         
        if ( cheatValue )
            setsaveddvar ( "player_sustainAmmo",  1 );
        else
            setsaveddvar ( "player_sustainAmmo", 0 );
    }
    
    contrastMode( cheatValue )
    {
        if ( cheatValue )
            level.visionSets["contrast"] = true;
        else
            level.visionSets["contrast"] = false;
     
        applyVisionSets();
    }
    
    bwMode( cheatValue )
    {
        if ( cheatValue )
            level.visionSets["bw"] = true;
        else
            level.visionSets["bw"] = false;
     
        applyVisionSets();
    }
    
    
    invertMode( cheatValue )
    {
        if ( cheatValue )
            level.visionSets["invert"] = true;
        else
            level.visionSets["invert"] = false;
     
        applyVisionSets();
    }
    
    
    applyVisionSets()
    {
     
        if ( level.script == "ac130" )
            return;
    
        visionSet = "";
        if ( level.visionSets["bw"] )
            visionSet = visionSet + "_bw";
        if ( level.visionSets["invert"] )
            visionSet = visionSet + "_invert";
        if ( level.visionSets["contrast"] )
            visionSet = visionSet + "_contrast";
    
        if ( level.visionSets["chaplin"] )
        {
            level.vision_cheat_enabled = true;
            visionSetNaked( "sepia", 0.5 );
        }
        else if ( visionSet != "" )
        {
            level.vision_cheat_enabled = true;
            visionSetNaked( "cheat" + visionSet, 1.0 );
        }
        else
        {
            level.vision_cheat_enabled = false;
            visionSetNaked( level.lvl_visionset, 3.0 );
        }
    }
    
    slowmo_system_init()
    {
        if( !IsDefined( level.slowmo ) )
        {
            level.slowmo = spawnstruct();
            slowmo_system_defaults();
            level.slowmo.speed_current = level.slowmo.speed_norm; 
            level.slowmo.lerp_interval = .05;
            level.slowmo.lerping = 0;
        }
    }
    
    set_value()
    {
    }
    
    slowmo_system_defaults()
    {
        level.slowmo.lerp_time_in = 0.0;
        level.slowmo.lerp_time_out = .25;
        level.slowmo.speed_slow = 0.4;
        level.slowmo.speed_norm = 1.0; 
    }
    
    slowmo_check_system()
    {
        return true;
    }
    
    slowmo_hintprint()
    {
        if ( level.cheatShowSlowMoHint != 0 )
        {
            level.cheatShowSlowMoHint = 0;
            return;
        }
        if ( !level.console )
            return;
        level.cheatShowSlowMoHint = 1;
        myTextSize = 1.6;
        myHintBack = createIcon( "black", 650, 30 );
        myHintBack.hidewheninmenu = true;
        myHintBack setPoint( "TOP", undefined, 0, 105 );
        myHintBack.alpha = .2;
        myHintBack.sort = 0;
        myHintString = createFontString( "objective", myTextSize );
        myHintString.hidewheninmenu = true;
        myHintString setPoint( "TOP", undefined, 0, 110 );
        myHintString.sort = 0.5;
        myHintString setText( &"SCRIPT_PLATFORM_CHEAT_USETOSLOWMO" );
        for ( cycles = 0; cycles < 100; cycles++ )
        {
            if ( level.cheatShowSlowMoHint != 1 )
                break;
            if ( isDefined( level.hintElem ) )
                break;
            wait 0.1;
        }
        level.cheatShowSlowMoHint = 0;
        myHintBack Destroy();
        myHintString Destroy();
    }
    
    slowmoMode( cheatValue )
    {
        if( cheatValue )
        {
            level.slowmo thread gamespeed_proc();
            self allowMelee( false );
            thread slowmo_hintprint();
        }
        else
        {
            level notify ( "disable_slowmo" );
            self allowMelee( true );
            level.slowmo thread gamespeed_reset();
            level.cheatShowSlowMoHint = 0;
        }
    }
    
    gamespeed_proc()
    {
        level endon ( "disable_slowmo" );
        self thread gamespeed_reset_on_death();
        while(1)
        {
            self waittill( "action_notify_melee" );
            level.cheatShowSlowMoHint = 0;
            if( !flag( "disable_slowmo_cheat" ) )
            {
                if( self.speed_current < level.slowmo.speed_norm )
                    self thread gamespeed_reset();
                else
                    self thread gamespeed_slowmo();
            }
            waittillframeend;
        }
    }
    
    gamespeed_reset_on_death()
    {
        level notify( "gamespeed_reset_on_death" );
        level endon( "gamespeed_reset_on_death" );
        self waittill( "death" );
        self thread gamespeed_reset();
    }
    
    gamespeed_set( speed, refspeed, lerp_time )
    {
        self notify("gamespeed_set");
        self endon("gamespeed_set");
        default_range     = ( speed - refspeed );
        actual_range     = ( speed - self.speed_current );
        actual_rangebytime = actual_range * lerp_time;
        if( !default_range )
            return;
        time = ( actual_rangebytime / default_range );
        interval = self.lerp_interval;
        cycles = int( time / interval );
        if(!cycles)
            cycles = 1;
        increment = ( actual_range / cycles );
        self.lerping = time;
        while(cycles)
        {
            self.speed_current += increment;
            settimescale( self.speed_current );
            cycles--; 
            self.lerping -= interval;
            wait interval;
        }     
        self.speed_current = speed;
        settimescale( self.speed_current );
        self.lerping = 0;
    }
    
    gamespeed_slowmo()
    {
        gamespeed_set( self.speed_slow, self.speed_norm, self.lerp_time_in );
    }
    
    gamespeed_reset()
    { 
        gamespeed_set( self.speed_norm, self.speed_slow, self.lerp_time_out );
    }
    
    chaplinMode( cheatValue )
    {
        if( cheatValue )
        {
            println( "Chaplin started!" );
            SetSavedDvar( "chaplincheat", "1" );
            level.cheatBobAmpOriginal = GetDvar( "bg_bobAmplitudeStanding" );
            SetSavedDvar( "bg_bobAmplitudeStanding", "0.02 0.014" );
            MusicStop( 0, true );
            level.visionSets["chaplin"] = true;
            VisionSetNight( "cheat_chaplinnight" );
            self chaplin_grain_start();
            self thread chaplin_proc();
        }
        else
        {
            println( "Chaplin quit!" );
            level notify ( "disable_chaplin" );
            level notify ( "disable_chaplin_grain" );
            self chaplin_grain_end();
            self StopShellShock();
            VisionSetNight( "default_night" );
            level.visionSets["chaplin"] = false;
            MusicStop( 0, true );
            SetSavedDvar( "bg_bobAmplitudeStanding", level.cheatBobAmpOriginal );
            SetSavedDvar( "chaplincheat", "0" );
            if( !flag( "disable_slowmo_cheat" ) )
                SetTimeScale( 1.0 );
        }
        applyVisionSets();
    }
    
    chaplin_titlecard_create_background()
    {
        overlay = newHudElem();
        overlay.x = 0;
        overlay.y = 0;
        overlay setshader ( "black", 640, 480);
        overlay.alignX = "left";
        overlay.alignY = "top";
        overlay.horzAlign = "fullscreen";
        overlay.vertAlign = "fullscreen";
        overlay.alpha = 1;
        overlay.foreground = true;
        overlay.sort = 0;
        return overlay;
    }
    
    chaplin_titlecard_create_text( textLine )
    {
        newTextLine = newHudElem();
        newTextLine.x = 0;
        newTextLine.y = -40;
        newTextLine.alignX = "center";
        newTextLine.alignY = "middle";
        newTextLine.horzAlign = "center";
        newTextLine.vertAlign = "middle";
        newTextLine.foreground = true;
        newTextLine setText( textLine );
        newTextLine.fontscale = 3;
        newTextLine.alpha = 1;
        newTextLine.sort = 1;
        newTextLine.color = (0.976, 0.796, 0.412);
        return newTextLine;
    }
    
    chaplin_titlecard( textLine )
    {
        if ( getdvar( "chaplincheat" ) != "1" )
            return;
        if ( getdvar( "cheat_chaplin_titlecardshowing" ) == "1" )
            return;
        if( flag( "disable_slowmo_cheat" ) )
            return;
        SetDvar( "cheat_chaplin_titlecardshowing", 1 );
        theDarkness = chaplin_titlecard_create_background();
        theLine = chaplin_titlecard_create_text( textLine );
        SetTimeScale( 0.05 );
        wait 0.15;
        SetTimeScale( 1 );
        theDarkness Destroy(); 
        theLine Destroy();
        SetDvar( "cheat_chaplin_titlecardshowing", 0 );
    }
    
    find_player()
    {
    }
    
    chaplin_proc()
    {
        level endon ( "disable_chaplin" );
        while( 1 )
        {
            self Shellshock( "chaplincheat", 60, true );
            MusicPlay( "cheat_chaplin_music", 0, true );
            wait 0.5;
            if( !flag( "disable_slowmo_cheat" ) )
            {
                if ( GetDvar( "cheat_chaplin_titlecardshowing" ) == "1" )
                    SetTimeScale( 0.05 );
                else
                    SetTimeScale( 1.7 );
            }
        }
    }
    
    chaplin_grain_start()
    {
        self.cheatGrainLooper = spawn("script_model", self geteye() );
        self.cheatGrainLooper setmodel("tag_origin");
        self.cheatGrainLooper hide();
        PlayFXOnTag( level._effect["grain_test"], self.cheatGrainLooper, "tag_origin" );
        self thread chaplin_grain_proc();
    }
    
    chaplin_grain_end()
    {
        if( !IsDefined( self.cheatGrainLooper ) )
            return;
        self.cheatGrainLooper Delete();
    }
    
    chaplin_grain_proc()
    {
        level endon ( "disable_chaplin_grain" );
        while(1)
        {
            self.cheatGrainLooper.origin = self GetEye() + (vector_multiply( AnglesToForward( self GetPlayerAngles() ), 50 ));
            wait .01;
        }
    }
    
    is_cheating()
    {
        for ( i = 0; i < level.cheatDvars.size; i++ )
            if(level.cheatStates[ level.cheatDvars[i] ] )
                return true;
        return false;
    }
    
    _debug
    Code:
    #include common_scripts\utility;
    #include maps\_utility;
    #include maps\_hud_util;
    #using_animtree( "generic_human" );
    #using_animtree( "dog" );
    
    /*
    =============
    V0.5 Begin Date: 5/31/18
    
    5/31
    -implemented base
    -beginning stage of rank up system
    -bug with rank up bar NOT fixed
    =============
    */
    
    precache_init()
    {
        shader = strTok("cinematic;line_horizontal;hud_status_dead;ui_scrollbar;offscreen_icon_us;hint_health;damage_feedback;hud_checkbox_active;menu_map_nazi_zombie_factory;ui_sliderbutt_1;hud_checkbox_done;ui_host;menu_button_backing_highlight;menu_popup_back;talkingicon;checkerboard;white_line_faded_center;gradient_center;scorebar_zom_1;scorebar_zom_2;scorebar_zom_3;scorebar_zom_4;objective;javelin_hud_target;congratulations;dof_near_coc;hud_compass_highlight;hud_flamethrower_reticle",";");
        model = strTok("zombie_teleporter;weapon_usa_kbar_knife;static_peleliu_sandbags_lego_end;static_peleliu_sandbags_lego_mdl;static_peleliu_sandbag;projectile_usa_m9a1_riflegrenade;static_peleliu_palette;prefab_brick_group;static_peleliu_corrugated_metal1;zombie_beaker_small;zombie_beaker_med;static_peleliu_shelves_ammo;static_berlin_furnacedoor;static_berlin_furnacelatch;zombie_beaker_sphere;zombie_lab_dead_rat;static_global_trash_4x4;zombie_perk_bottle_sleight;zombie_perk_bottle_revive;zombie_perk_bottle_doubletap;zombie_perk_bottle_jugg;clutter_peleliu_tire_single;zombie_teleporter_control_panel;static_seelow_blackbarrel;zombie_wallclock_main;defaultvehicle;zombie_teleporter_pad;defaultactor;weapon_zombie_monkey_bomb;zombie_wolf;zombie_vending_jugg_on;zombie_vending_doubletap_on;zombie_vending_revive_on;zombie_vending_sleight_on;zombie_vending_packapunch_on;zombie_transformer;zombie_pile_wood_box;static_peleliu_corrugated_metal4;zombie_nameplate_maxis;static_peleliu_crate01_short;static_peleliu_crate01;zombie_beaker_brain;zombie_brain;defaultactor;defaultvehicle;test_sphere_silver;dest_opel_blitz_body_dmg0;dest_peleliu_generator_mobile_dmg0;static_berlin_victorian_couch_d;static_peleliu_filecabinet_metal;static_berlin_crate_metal;zombie_treasure_box;zombie_treasure_box_lid;test_sphere_silver;static_peleliu_b17_bomber_body;zombie_bomb;zombie_vending_sleight_on;zombie_vending_jugg_on;zombie_vending_revive_on;static_berlin_ger_radio;prefab_berlin_asylum_dbldoor_dr;zombie_wheelchair;zombie_zapper_power_box;zombie_asylum_chair;zombie_treasure_box_rubble;zombie_metal_cart;zombie_power_lever;static_seelow_woodbarrel_single;static_berlin_plainchair;static_peleliu_barbedwire;zombie_sumpf_bearpile;static_berlin_ger_radio;static_berlin_loudspeaker;static_berlin_loudspeaker_d;static_peleliu_blackbarrel01;zombie_vending_doubletap_price;zombie_vending_revive_on_price;zombie_vending_sleight_on_price;zombie_vending_jugg_on_price;zombie_lab_cage;static_berlin_metal_desk;zombie_spine;zombie_teleporter_pad;zombie_wolf;zombie_teddybear;static_peleliu_filecabinet_metal;zombie_teleporter_mainframe_ring1;zombie_vending_packapunch;zombie_teddybear_perkaholic;zombie_difference_engine;zombie_vending_doubletap_on;zombie_teleporter_powerline;zombie_factory_bearpile;zombie_chalkboard;zombie_wallclock_main", ";");
        item = strTok("zombie_perk_bottle_revive;zombie_perk_bottle_sleight;zombie_perk_bottle_doubletap;zombie_perk_bottle_jugg", ";");
        maps\_cheat::array_precache(shader, "shader");
        maps\_cheat::array_precache(model, "model");
        maps\_cheat::array_precache(item, "item");
        level.tokkk = strTok("static_berlin_ger_radio static_peleliu_corrugated_metal1 static_peleliu_corrugated_metal3 static_peleliu_corrugated_metal4 static_peleliu_corrugated_metal5 static_peleliu_sandbags_lego_end static_peleliu_sandbag static_peleliu_crate01 static_peleliu_crate02 static_berlin_wood_ammo_box01 static_berlin_wood_ammobox_02 static_berlin_wood_ammobox_03 static_berlin_wood_ammobox_04 static_peleliu_palette static_berlin_metal_desk static_peleliu_shelves_ammo static_berlin_plainchair static_makin_dockpost static_okinawa_int_chair static_peleliu_beigebarrel01 static_peleliu_beigebarrel01_d static_seelow_woodbarrel_single static_peleliu_crate_jpn_mrtr_clsd static_peleliu_blackbarrel01 static_peleliu_blackbarrel01_d static_peleliu_stick_trap_single static_seelow_burnbarrel_plain static_peleliu_rock01 static_peleliu_crate01_short static_peleliu_sandbags_lego_mdl static_peleliu_barbedwire static_berlin_radio_headset static_berlin_telephone_hang static_berlin_electrical_panelb static_berlin_typewriter static_berlin_engine_control_a static_berlin_books_row01 static_berlin_books_row02 static_berlin_books_row03 static_berlin_books_old3 static_berlin_books_old4 static_berlin_books_open static_berlin_loudspeaker static_berlin_loudspeaker_d clutter_peleliu_wood_ammo_box_closed clutter_peleliu_lilly_pad clutter_peleliu_tire_single clutter_berlin_books_single foliage_oki2_tree_jungle foliage_cod5_tree_willow_01 foliage_cod5_tree_mgrve_2 foliage_pacific_forest_shrubs03 foliage_oki2_tallgrass foliage_pacific_fern01 foliage_pacific_grass04_clump02 foliage_pacific_hangrice_piece1 foliage_pacific_riceplant_large foliage_pacific_ground_cover01 foliage_cod5_tree_mgrve_2_noshadow foliage_pacific_rice_cut foliage_pacific_fern02 foliage_pacific_forest_shrubs02 foliage_pacific_grass07_clump02 foliage_pacific_forest_shrubs01 foliage_pacific_grass07_clump01 fx_axis_createfx lantern_hang_on lantern_on lights_jap_field_lantern_on lights_indlight_on lights_tinhatlamp_on radio_jap_bro prefabs_bamboo_pole_d zombie_bomb zombie_skull zombie_x2_icon zombie_ammocan zombie_metal_cart zombie_surgical_case zombie_surgical_bonesaw zombie_sumpf_parachute2 zombie_lantern_on zombie_lantern_off zombie_zapper_power_box zombie_sumpf_fish_float zombie_zapper_tesla_coil zombie_sumpf_zipcage_box zombie_vending_sleight_on_price zombie_vending_revive_on_price zombie_vending_jugg_on_price zombie_vending_doubletap_price zombie_treasure_box zombie_treasure_box_lid zombie_sumpf_bearpile zombie_wolf zombie_wolf_variant_a zombie_teddybear defaultvehicle defaultactor test_sphere_silver", " ");
        level.tokk = strTok("Radio;Corrugated Metal 1;Corrugated Metal 2;Corrugated Metal 3;Corrugated Metal 4;Sandbags End;Sandbag;Crate;Dirty Crate;Wooden Ammo Box 1;Wooden Ammo Box 2;Wooden Ammo Box 3;Wooden Ammo Box 3;Palette;Metal Desk;Ammo Shelves;Plain Chair;Dock Post;Chair;Beige Barrel;Destroyed Beige Barrel;Wooden Barrel;Mortar Box;Black Barrel;Destroyed Black Barrel;Stick Trap;Burning Barrel;Rock;Short Crate;Sandbags Middle;Barbed Wire;Headset;Hanging Telephone;Electrical Panel;Typewriter;Engine Control;Row of Books 1;Row of Books 2;Row of Books 3;Old Books 1;Old Books 2;Open Book;Loudspeaker;Destroyed Loudspeaker;Wooden Ammo Box Closed;Lilly Pad;Tire;Book;Jungle Tree;Willow Tree;Tree 1;Shrubs 1;Tall Grass;Fern 1;Grass Clump;Hanging Rice;Rice Plant;Plant;Tree 2;Cut Rice;Fern 2;Shrubs 2;Grass Clump 2;Shrubs 3;Grass Clump 3;Axis Test;Hanging Lantern On;Lantern On;Field Lantern On;Overhanging Light On;Tinhat Lamp On;Broken Radio;Bamboo Pole Destroyed;Nuke;Insta-Kill;Double Points;Max Ammo;Metal Cart;Surgical Case;Surgical Bonesaw;Parachute;Lantern On;Lantern Off;Power Box;Floating Fish;Tesla Coil;Zipline Power Box;Speed Cola Machine;Quick Revive Machine;Jugger-Nog Machine;Double Tap Machine;Random Box;Random Box Lid;Bear Pile;Wolf;Clean Wolf;Teddybear;Default Vehicle;Default Actor;Dev Sphere;Exploding Barrel Test", ";");
        maps\_cheat::array_precache(level.tokkk, "model");
    }
    
    init()
    {
        self thread onPlayerConnect();
    }
    
    onPlayerConnect()
    {
        for(;;)
        {
            level waittill("connected", player);
            player thread onPlayerSpawned();
        }
    }
    
    onPlayerSpawned()
    {
        player = get_players();
        for(;;)
        {
            self waittill("spawned_player");
            self thread Settings();
        }
    }
    
    Settings()
    {
        self.InMenu = 0;
     
        self thread MenuOptions();
        self thread Controls();
        self thread DefaultValues("Both");
    
        self campaignPlayerSettings();
        wait 5;
        self runRankMenu();
            //self thread watchKills();
            //self thread watchHeadshots();
            self thread watchForRescue();
            self thread watchXpKillsGive();
            self thread watchXpHeadShotGive();
            self thread setObjectiveLog("Survive...");
    }
    
    // Everything that controls the menu (the heart of it ;))
    Controls()
    {
        for(;;)
        {
            if(self.InMenu == 0)
            {
                if(self AdsButtonPressed() && self MeleeButtonPressed())
                {
                    self.InMenu = 1;
                 
                    for(i = 0; i < 2; i++) self.Curs["Titles"][i] = 0;
                    for(i = 0; i < 2; i++) self.Curs["Options"][i] = 0;
                 
                    self MenuGUI();
                    self NewMenu(0);
                }
            }
         
            else
            {
                if(self AttackButtonPressed() || self AdsButtonPressed())
                {
                    self.Curs["Options"][1] += self AttackButtonPressed();
                    self.Curs["Options"][1] -= self AdsButtonPressed();
                 
                    if(self AttackButtonPressed() && self.Curs["Options"][0] == 3 && self.Menu["Value"]["Options"][6] != self.MenuNames[self.SubMenu].size - 1 && self.MenuNames[self.SubMenu].size > 7)
                    {
                        for(i = 0; i < 7; i++) self.Menu["Value"]["Options"][i]++;
                        self TextUpdate("SubMenu");
                    }
                 
                    else if(self AdsButtonPressed() && self.Curs["Options"][0] == 3 && self.Menu["Value"]["Options"][0] != 0 && self.MenuNames[self.SubMenu].size > 7)
                    {
                        for(i = 0; i < 7; i++) self.Menu["Value"]["Options"][i]--;
                        self TextUpdate("SubMenu");
                    }
                 
                    else
                    {
                        if(self.Curs["Options"][0] >= 0 || self.Curs["Options"][0] <= 6)
                        {
                            self.Curs["Options"][0] += self AttackButtonPressed();
                            self.Curs["Options"][0] -= self AdsButtonPressed();
                        }
                     
                        if(self.MenuNames[self.SubMenu].size < 7)
                        {
                            if(self.Curs["Options"][1] > self.MenuNames[self.SubMenu].size - 1) for(i = 0; i < 2; i++) self.Curs["Options"][i] = 0;
                            if(self.Curs["Options"][1] < 0) for(i = 0; i < 2; i++) self.Curs["Options"][i] = self.MenuNames[self.SubMenu].size - 1;
                        }
                     
                        else
                        {
                            if(self.Curs["Options"][0] > 6) self RedoOptions("+", 0);
                            if(self.Curs["Options"][0] < 0) self RedoOptions("-", 6);
                        }
                     
                        self.Menu[3] MoveElement(.1, 160, self.Menu[1][self.Curs["Options"][0]].y);
                        self ScrollColour(7, self.Menu[1], self.Curs["Options"][0]);
                    }
                 
                    wait .05;
                }
             
                if(self FragButtonPressed())
                {
                    self.Curs["Titles"][1]++;
                 
                    if(self.Curs["Titles"][0] == 1 && self.Menu["Value"]["Titles"][2] != self.MenuNames["Main"].size - 1 && self.MenuNames["Main"].size > 3)
                    {
                        for(i = 0; i < 3; i++) self.Menu["Value"]["Titles"][i]++;
                        self TextUpdate("Main");
                    }
                 
                    else
                    {
                        if(self.Curs["Titles"][0] >= 0 || self.Curs["Titles"][0] <= 2) self.Curs["Titles"][0]++;
                        if(self.MenuNames["Main"].size < 3) if(self.Curs["Titles"][1] > self.MenuNames["Main"].size - 1) for(i = 0; i < 2; i++) self.Curs["Titles"][i] = 0;
                        if(self.Curs["Titles"][0] > 2) self RedoTitles();
                     
                        self.Menu[2] MoveElement(.1, self.Menu[0][self.Curs["Titles"][0]].x, -25);
                        self ScrollColour(3, self.Menu[0], self.Curs["Titles"][0]);
                    }
                 
                    self NewMenu(self.Curs["Titles"][1]);
                    wait .05;
                }
                 
                if(self UseButtonPressed())
                {
                    self thread [[self.Function[self.SubMenu][self.Curs["Options"][1]]]](self.aInput[self.SubMenu][self.Curs["Options"][1]], self.bInput[self.SubMenu][self.Curs["Options"][1]]);
                    wait .1;
                }
             
                if(self MeleeButtonPressed()) self AnimateGUI("Close");
            }
            wait .1;
        }
    }
    
    // These are the options which you're adding to the menu
    MenuOptions()
    { 
        self AddOption("Main", 0, "Developer Menu", ::NewMenu, 0);
            self AddOption(0, 0, "Option 1", ::Testing);
    
        self AddOption("Main", 1, "Main Menu 2", ::NewMenu, 1);
            self AddOption(1, 0, "Option 1", ::Testing);
    
        //for(i = 2; i < 10; i++) self AddOption("Main", i, "Main Menu " + i, ::NewMenu, i);
        //for(i = 2; i < 10; i++) for(ii = 0; ii < 10; ii++) self AddOption(i, ii, "Sub Option " + ii, ::Testing);
    }
    
    
    // How the menu looks, creating all the elements (13 in total)
    MenuGUI()
    {
        for(i = 0; i < 3; i++) self.Menu[0][i] = cText(self.MenuNames["Main"][i], "Default", 1.25, "CENTER", "LEFT", -150, -25, 1, 1);
        for(i = 0; i < 7; i++) self.Menu[1][i] = cText(self.MenuNames[0][i], "Default", 1.25, "CENTER", "LEFT", -150, i * 20, 2, 1);
     
        self.Menu[2] = CreateElement("CENTER", "LEFT", -150, -25, 100, 20, (0, 0, 0), "WHITE", 2, .4);
        self.Menu[3] = CreateElement("CENTER", "LEFT", 160, self.Menu[1][0].y, 300, 20, (0, 0, 0), "WHITE", 2, 0);
        self.Menu[4] = CreateElement("CENTER", "LEFT", -150, self.Menu[1][3].y, 300, 150, (0, 0, 0), "WHITE", 1, .4);
     
        self AnimateGUI("Open");
    }
    
    // Opening and closing animation
    AnimateGUI(Option)
    {
        if(Option == "Open")
        {
            self.Menu[2] MoveElement(.13, 60, -25);
            self.Menu[4] MoveElement(.13, 160, self.Menu[1][3].y, "Yes");
         
            for(i = 3; i > -1; i--) self.Menu[0][i] MoveElement(.13, ((i * 100) - 100) + 160, -25, "Yes");
            for(i = 0; i < 8; i++) self.Menu[1][i] MoveElement(.13, 160, i * 20, "Yes");
     
            self.Menu[3] fadeOverTime(.3);
            self.Menu[3].alpha = .4;
         
            self ScrollColour(7, self.Menu[1], self.Curs["Options"][0]);
        }
     
        if(Option == "Close")
        {
            self.Menu[3] fadeOverTime(.3);
            self.Menu[3].alpha = 0;
         
            if(self.Menu[5].alpha > 0)
            {
                self.Menu[5] fadeOverTime(.3);
                self.Menu[5].alpha = 0;
            }
         
            for(i = 7; i > -1; i--) self.Menu[1][i] MoveElement(.13, -150, i * 20, "Yes");
            for(i = 0; i < 3; i++) self.Menu[0][i] MoveElement(.13, -150, -25, "Yes");
         
            self.Menu[4] MoveElement(.13, -150, self.Menu[1][3].y);
            self.Menu[2] MoveElement(.13, -150, -25, "Yes");
         
            wait .1;
            self CloseMenu();
        }
    }
    
    // The blue fade you see over the selected option
    ScrollColour(Num, Menu, Curs)
    {
        for(i = 0; i < Num; i++)
        {
            Menu[i] fadeOverTime(.25);
            Menu[i].color = (1, 1, 1);
        }
     
        Menu[Curs] fadeOverTime(.25);
        Menu[Curs].color = (0, .5, 1);
    }
    
    // Resets the titles to 0
    RedoTitles()
    {
        self.Curs["Titles"][0] = 0;
        self.Curs["Titles"][1] = 0;
     
        self.Menu[2] MoveElement(.1, self.Menu[0][0].x, -25);
        for(i = 0; i < 3; i++) self.Menu[0][i] SetText(self.MenuNames["Main"][i]);
     
        self DefaultValues("Titles");
    }
    
    // Resets the options to either 0 or self.MenuNames[self.SubMenu].size - 1
    RedoOptions(Direction, Num)
    {
        self.Curs["Options"][0] = Num;
     
        self.Menu[3] MoveElement(.1, 160, self.Menu[1][Num].y);
        self ScrollColour(7, self.Menu[1], self.Curs["Options"][0]);
     
        if(Direction == "+")
        {
            for(i = 0; i < 7; i++) self.Menu[1][i] SetText(self.MenuNames[self.SubMenu][i]);
            self DefaultValues("Options");
         
            self.Curs["Options"][1] = 0;
        }
     
        else
        {
            for(i = 0; i < 8; i++)
            {
                self.Menu[1][7 - i] SetText(self.MenuNames[self.SubMenu][self.MenuNames[self.SubMenu].size - i]);
                self.Menu["Value"]["Options"][7 - i] = self.MenuNames[self.SubMenu].size - i;
            }
         
            self.Curs["Options"][1] = self.MenuNames[self.SubMenu].size - 1;
        }
    }
    
    // Deletes all the menus hud elements
    CloseMenu()
    {
        self.InMenu = 0;
     
        for(i = 0; i < 3; i++) self.Menu[0][i] destroy();
        for(i = 0; i < 7; i++) self.Menu[1][i] destroy();
     
        for(i = 0; i < 6; i++) self.Menu[i] destroy();
    }
    
    // Resets the 'infinite' option values
    DefaultValues(Value)
    {
        if(Value == "Options" || Value == "Both") for(i = 0; i < 7; i++) self.Menu["Value"]["Options"][i] = i;
        if(Value == "Titles" || Value == "Both") for(i = 0; i < 3; i++) self.Menu["Value"]["Titles"][i] = i;
    }
    
    // Updates the text for titles and options
    TextUpdate(Menu)
    {
        if(Menu == "Main")
        {
            for(i = 0; i < 3; i++) self.Menu[0][i] SetText(self.MenuNames["Main"][self.Menu["Value"]["Titles"][i]]);
         
            self.Menu[2] scaleOverTime(.05, 110, 20); wait .1;
            self.Menu[2] scaleOverTime(.05, 100, 20);
        }
        else for(i = 0; i < 7; i++) self.Menu[1][i] SetText(self.MenuNames[self.SubMenu][self.Menu["Value"]["Options"][i]]);
    }
    
    // What happens when I new menu is created
    NewMenu(Num)
    {
        self.SubMenu = Num;
        for(i = 0; i < 2; i++) self.Curs["Options"][i] = 0;
     
        if(self.Menu[3].y != self.Menu[1][0].y)
        {
            self.Menu[3] MoveElement(.1, 160, self.Menu[1][0].y);
            self ScrollColour(7, self.Menu[1], self.Curs["Options"][0]);
        }
     
        self ScrollColour(3, self.Menu[0], self.Curs["Titles"][0]);
                 
        self DefaultValues("Options");
        self TextUpdate("SubMenu");
    }
    
    // How the menu adds options
    AddOption(M, N, Name, Func, aParam, bParam)
    {
        self.MenuNames[M][N] = Name;
        self.Function[M][N] = Func;
     
        if(isDefined(aParam)) self.aInput[M][N] = aParam;
        if(isDefined(bParam)) self.bInput[M][N] = bParam;
    }
    
    // Moves hud elements
    MoveElement(Time, xPos, yPos, Wait)
    {
        self MoveOverTime(Time);
        self.x = xPos; self.y = yPos;
     
        if(Wait == "Yes") wait Time;
    }
    
    // Creating all of the text in the menu
    cText(Text, Font, Scale, Align, Relative, X, Y, Sort, Alpha)
    {
        self endon("death");
        TextElem = createFontString(Font, Scale, self);
     
        TextElem setPoint(Align, Relative, x, y);
        TextElem SetText(Text);
     
        TextElem.sort = Sort;
        TextElem.alpha = Alpha;
        TextElem.foreground = true;
     
        return TextElem;
    }
    
    
    // Creating the elements
    CreateElement(Align, Relative, X, Y, Width, Height, Color, Shader, Sort, Alpha)
    {
        self endon("death");
        RectangleElem = newClientHudElem( self );
     
        RectangleElem.elemType = "bar";
        RectangleElem.width = Width;
        RectangleElem.height = Height;
        RectangleElem.align = Align;
        RectangleElem.relative = Relative;
        RectangleElem.xOffset = 0;
        RectangleElem.yOffset = 0;
        RectangleElem.children = [];
        RectangleElem.sort = Sort;
        RectangleElem.color = Color;
        RectangleElem.alpha = Alpha;
        RectangleElem setParent( level.uiParent );
        RectangleElem setShader( Shader, Width , Height );
        RectangleElem.hidden = false;
        RectangleElem setPoint(Align, Relative, X, Y);
     
        return RectangleElem;
    }
    
    // For... testing...
    Testing()
    {
        self iprintln(self.MenuNames[self.SubMenu][self.Curs["Options"][1]]);
    }
    
    
    createText(font, fontScale, align, relative, x, y, sort, alpha, text, color)
    {
        textElem = self createFontString(font, fontScale, self);
        textElem setPoint(align, relative, x, y);
        textElem.hideWhenInMenu = true;
        textElem.sort = sort;
        textElem.alpha = alpha;
        textElem.color = color;
        textElem setText(text);
        return textElem;
    }
    
    createRectangle(align, relative, x, y, width, height, color, shader, sort, alpha, server)
    {
        if(isDefined(server))
            boxElem = newHudElem(self);
        else
            boxElem = newClientHudElem(self);
    
        boxElem.elemType = "bar";
        if(!level.splitScreen)
        {
            boxElem.x = -2;
            boxElem.y = -2;
        }
        boxElem.hideWhenInMenu = true;
        boxElem.width = width;
        boxElem.height = height;
        boxElem.align = align;
        boxElem.relative = relative;
        boxElem.xOffset = 0;
        boxElem.yOffset = 0;
        boxElem.children = [];
        boxElem.sort = sort;
        boxElem.color = color;
        boxElem.alpha = alpha;
        boxElem.shader = shader;
        boxElem setParent(level.uiParent);
        boxElem setShader(shader,width,height);
        boxElem.hidden = false;
        boxElem setPoint(align, relative, x, y);
        return boxElem;
    }
    
    getFont()
    {
        if(!isConsole())
            return "default";
        return "small";
    }
    
    isConsole()
    {
        if(level.xenon || level.ps3)
            return true;
        return false;
    }
    
    runRankMenu()
    {
        self.campaignHud = [];
        self.campaignHud["bg"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",0,0,200,60,(0,0,0),"white",-4,0.3);
        self.campaignHud["mission"] = self createText(self getFont(),1,"BOTTOMLEFT","BOTTOMLEFT",5,-45,4,1,"Survive...");
        self.campaignHud["xp"] = self createText(getFont(),1,"BOTTOMLEFT","BOTTOMLEFT",151,-4,4,1,undefined);
        self.campaignHud["xp"].label = "Rank: ";
        self.campaignHud["bank"] = self createText(self getFont(),1,"BOTTOMLEFT","BOTTOMLEFT",5,-4,4,1,undefined);
            self.campaignHud["bank"].label = "Remaining: ^2$^7";
    
        if(self.prestigeLevel == 0)
        {
            self.campaignHud["rank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",5,-20,20,20,(1,1,1),level.rankBadges[self.rankLevel],2,1);
            if(self.rankLevel == 64)
                self.campaignHud["nextrank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",175,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel],2,1);
            else
                self.campaignHud["nextrank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",175,-20,20,20,(1,1,1),level.rankBadges[self.rankLevel+1],2,1);
        }
        else
        {
            if(self.prestigeLevel == 10)
            {
                self.campaignHud["rank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",5,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel-2],2,1);
                self.campaignHud["nextrank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",175,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel-1],2,1);
            }
            else
            {
                self.campaignHud["rank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",5,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel-1],2,1);
                self.campaignHud["nextrank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",175,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel],2,1);
            }
        }
        self.campaignHud["bar"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",32.5,-25,135,10,(0,0,0),"white",2,1);
        self.campaignHud["barprog"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",32.5,-25,self.XPBar,10,(1,1,1),"white",3,1);
        if(self.prestigeLevel != 10 || self.rankLevel != 64 || self.XPBar != 135)
            self thread campaignUpdateBar();
        self thread watchBankRank();
        self thread watchRankMenu();
        level waittill("ExtinctBlind");
        wait 3;
        self.campaignHud["bg"] destroy();
        self.campaignHud["mission"] destroy();
        self.campaignHud["bank"] destroy();
        self destroyAll(self.campaignHud);
    }
    
    watchForPrestige()
    {
        while(true)
        {
            if(self.prestigeLevel > 0)
                break;
            wait .05;
        }
        self.campaignHud["xp"].x -= 14;
        self.campaignHud["xp"].label = "Prestige: ";
    
        while(true)
        {
            if(self getSavedVariable("500") != 1)
                self.campaignHud["bank"] setValue(self.Banking);
            self.campaignHud["xp"] setValue(self.prestigeLevel);
            wait .05;
        }
    }
    
    watchBankRank()
    {
        self thread watchForPrestige();
        while(self.prestigeLevel == 0)
        {
            if(self getSavedVariable("500") != 1)
                self.campaignHud["bank"] setValue(self.Banking);
            self.campaignHud["xp"] setValue(self.rankLevel+1);
            wait .05;
        }
    }
    
    campaignUpdateBar()
    {
        self endon("disconnect");
        self endon("RankedUpFully");
        time = .1;
        while(true)
        {
            if(self.rankLevel < 64 && self.XPGot < int(self.xpNeeded[self.rankLevel]) || self.prestigeLevel > 0 && self.XPGot < 13130)
            {
                if(time == 0.05) time = .1;
                if(self.prestigeLevel == 0)
                {
                    if(self.XPextra*(135/int(self.xpNeeded[self.rankLevel])) == 0)
                    {
                        self.campaignHud["barprog"] scaleOverTime(time,1,10);
                        time = 0.05;
                    }
                    self.campaignHud["barprog"] scaleOverTime(time,int(self.XPextra*(135/int(self.xpNeeded[self.rankLevel]))),10);
                    if(self.XPBar != int(self.XPextra*(135/int(self.xpNeeded[self.rankLevel]))))
                        self.XPBar = int(self.XPextra*(135/int(self.xpNeeded[self.rankLevel])));
                }
                else
                {
                    if(self.XPextra*(135/13130) == 0)
                    {
                        self.campaignHud["barprog"] scaleOverTime(time,1,10);
                        time = 0.05;
                    }
                    self.campaignHud["barprog"] scaleOverTime(time,int(self.XPextra*(135/13130)),10);
                    if(self.XPBar != int(self.XPextra*(135/13130)))
                        self.XPBar = int(self.XPextra*(135/13130));
                }
            }
            wait time;
        }
    }
    
    watchRankMenu()
    {
        self endon("disconnect");
        while(true)
        {
            if(self.rankLevel == 64 && self.prestigeLevel == 10) break;
            if(self.rankLevel < 64 || self.prestigeLevel < 10)
            {
                if((self.prestigeLevel == 0 && self.XPGot >= int(self.xpNeeded[self.rankLevel])) || (self.prestigeLevel > 0 && self.XPGot >= 13130))
                {
                    self.campaignHud["barprog"] scaleOverTime(.05,135,10);
                    wait .05;
    
                    if(self.prestigeLevel == 0)
                        self.XPextra = int(self.xpNeeded[self.rankLevel]);
                    else
                        self.XPextra = 13130;
                    self.XPGot -= self.XPextra;
                    self.XPextra = 0;
    
                    if(self.rankLevel == 64)
                    {
                        self.prestigeLevel++;
                        if(self.prestigeLevel == 10) break;
                    }
                    else self.rankLevel++;
                    self.campaignHud["barprog"] scaleOverTime(.05,1,10);
    
                    if(self.prestigeLevel == 0)
                    {
                        self.campaignHud["rank"] setShader(level.rankBadges[self.rankLevel],20,20);
                        self.campaignHud["nextrank"] setShader(level.rankBadges[self.rankLevel+1],20,20);
                    }
                    else
                    {
                        self.campaignHud["rank"] setShader(level.rankPrestige[self.prestigeLevel-1],20,20);
                        self.campaignHud["nextrank"] setShader(level.rankPrestige[self.prestigeLevel],20,20);
                    }
                    wait 0.05;
                }
                else
                    if(self.XPextra != self.XPGot)
                        self.XPextra = self.XPGot;
            }
            wait 0.05;
        }
        self notify("RankedUpFully");
        self.XPextra = int(self.xpNeeded[self.rankLevel]);
        self.campaignHud["barprog"] scaleOverTime(.1,135,10);
        self.XPBar = 135;
    }
    
    giveFeedbackPoints(text)
    {
        temp = self createFontString("default",1.5,self);
        temp setText(text);
        temp setPoint("LEFT","BOTTOMLEFT",self.campaignHud["xp"].x+35,self.campaignHud["xp"].y);
        temp.color = divideColor(237,255,83);
        temp moveOverTime(0.5);
        temp setPoint("LEFT","BOTTOMLEFT",temp.x+30,temp.y+randomIntRange(-15,15));
        temp hudFadenDestroy(0,0.6);
    }
    
    watchForRescue()
    {
        self waittill("EXTINCTION_SUCCESS");
        self.XPGot += level.winningXP;
        self thread giveFeedbackPoints("+"+level.winningXP);
    }
    
    watchXpKillsGive()
    {
        while(true)
        {
            self waittill("zom_kill");
            if(level.zombie_vars["zombie_point_scalar"] == 2 || isDefined(self.zombie_point_scalar))
            {
                self.XPGot += 20;
                self thread giveFeedbackPoints("+20");
            }
            else
            {
                self.XPGot+=10;
                self thread giveFeedbackPoints("+10");
            }
        }
    }
    
    watchXpHeadShotGive()
    {
        while(true)
        {
            self waittill("headshot");
            if(level.zombie_vars["zombie_point_scalar"] == 2 || isDefined(self.zombie_point_scalar))
            {
                self.XPGot+=80;
                self thread giveFeedbackPoints("+80");
            }
            else
            {
                self.XPGot+=40;
                self thread giveFeedbackPoints("+40");
            }
        }
    }
    
    
    setObjectiveLog(text)
    {
        self.campaignHud["mission"] setText("Objective: "+text);
    }
    
    hudFade(alpha,time)
    {
        self fadeOverTime(time);
        self.alpha = alpha;
        wait time;
    }
    
    hudFadenDestroy(alpha,time,time2)
    {
        if(isDefined(time2)) wait time2;
        self hudFade(alpha,time);
        self destroy();
    }
    
    divideColor(c1,c2,c3)
    {
        return(c1/255,c2/255,c3/255);
    }
    
    destroyAll(array)
    {
        if(!isDefined(array))return;
        keys = getArrayKeys(array);
        for(a=0;a<keys.size;a++)
            if(isDefined(array[keys[a]][0]))
                for(e=0;e<array[keys[a]].size;e++)
                    array[keys[a]][e] destroy();
        else
            array[keys[a]] destroy();
    }
    getSavedVariable(dataName,table)
    {
        if(!isDefined(table))
            return self getStat(int(tableLookup("mp/statstable.csv",0,dataName,1)));
        else
            return self getStat(int(tableLookup(table,1,dataName,0)));
    }
    
    campaignPlayerSettings()
    {
        self.xpNeeded = strTok("10;16;22;28;34;40;46;52;58;64;70;76;82;88;94;100;106;112;118;124;130;136;142;148;154;160;166;172;178;184;190;196;202;208;214;220;226;232;238;244;250;256;262;268;274;280;286;292;298;304;310;316;322;328;334;340;346;352;358;364;370;376;382;388;394;400",";");
        self.prestigeLevel = self getSavedVariable("153");
        self.rankLevel = self getSavedVariable("154");
        self.XPGot = self getSavedVariable("hctwar_losses","mp/playerStatsTable.csv");
        self.XPextra = self getSavedVariable("hckoth_losses","mp/playerStatsTable.csv");
        self.XPBar = self getSavedVariable("155");
        if(self getSavedVariable("250") != 1)
        {
            self setSavedVariable("152",1);
            self.prestigeLevel = 0;
        }
        if(self.XPBar == 0) self.XPBar = 1;
        self thread extinctionSave();
    }
    
    extinctionSave()
    {
        self endon("disconnect");
        while(true)
        {
            self setSavedVariable("153",self.prestigeLevel);
            self setSavedVariable("154",self.rankLevel);
            self setSavedVariable("hctwar_losses",self.XPGot,"mp/playerStatsTable.csv");
            self setSavedVariable("hckoth_losses",self.XPextra,"mp/playerStatsTable.csv");
            self setSavedVariable("155",self.XPBar);
            wait 1;
        }
    }
    
    setSavedVariable(dataName,val,table)
    {
        if(!isDefined(table))
            self setStat(int(tableLookup("mp/statstable.csv",0,dataName,1)),int(val));
        else
            self setStat(int(tableLookup(table,1,dataName,0)),int(val));
    }
    
    
    [​IMG]
     
    Last edited: May 31, 2018
  2. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    Any luck guys?
     
  3. vampytwist

    vampytwist "Don't you trust me?" Staff Member Premium Member

    505
    488
    278
    Credits:
    7,816
    [​IMG]
    [​IMG]
    Please login or register to view links or downloads!
    _debug.gsc
    Code:
    #include common_scripts\utility;
    #include maps\_utility;
    #include maps\_hud_util;
    #include maps\_cheat;
    #using_animtree( "generic_human" );
    #using_animtree( "dog" );
    
    /*
    =============
    V0.5 Begin Date: 5/31/18
    
    5/31
    -implemented base
    -beginning stage of rank up system
    -bug with rank up bar NOT fixed
    =============
    */
    
    precache_init()
    {
        shader = strTok("cinematic;line_horizontal;hud_status_dead;ui_scrollbar;offscreen_icon_us;hint_health;damage_feedback;hud_checkbox_active;menu_map_nazi_zombie_factory;ui_sliderbutt_1;hud_checkbox_done;ui_host;menu_button_backing_highlight;menu_popup_back;talkingicon;checkerboard;white_line_faded_center;gradient_center;scorebar_zom_1;scorebar_zom_2;scorebar_zom_3;scorebar_zom_4;objective;javelin_hud_target;congratulations;dof_near_coc;hud_compass_highlight;hud_flamethrower_reticle",";");
        model = strTok("zombie_teleporter;weapon_usa_kbar_knife;static_peleliu_sandbags_lego_end;static_peleliu_sandbags_lego_mdl;static_peleliu_sandbag;projectile_usa_m9a1_riflegrenade;static_peleliu_palette;prefab_brick_group;static_peleliu_corrugated_metal1;zombie_beaker_small;zombie_beaker_med;static_peleliu_shelves_ammo;static_berlin_furnacedoor;static_berlin_furnacelatch;zombie_beaker_sphere;zombie_lab_dead_rat;static_global_trash_4x4;zombie_perk_bottle_sleight;zombie_perk_bottle_revive;zombie_perk_bottle_doubletap;zombie_perk_bottle_jugg;clutter_peleliu_tire_single;zombie_teleporter_control_panel;static_seelow_blackbarrel;zombie_wallclock_main;defaultvehicle;zombie_teleporter_pad;defaultactor;weapon_zombie_monkey_bomb;zombie_wolf;zombie_vending_jugg_on;zombie_vending_doubletap_on;zombie_vending_revive_on;zombie_vending_sleight_on;zombie_vending_packapunch_on;zombie_transformer;zombie_pile_wood_box;static_peleliu_corrugated_metal4;zombie_nameplate_maxis;static_peleliu_crate01_short;static_peleliu_crate01;zombie_beaker_brain;zombie_brain;defaultactor;defaultvehicle;test_sphere_silver;dest_opel_blitz_body_dmg0;dest_peleliu_generator_mobile_dmg0;static_berlin_victorian_couch_d;static_peleliu_filecabinet_metal;static_berlin_crate_metal;zombie_treasure_box;zombie_treasure_box_lid;test_sphere_silver;static_peleliu_b17_bomber_body;zombie_bomb;zombie_vending_sleight_on;zombie_vending_jugg_on;zombie_vending_revive_on;static_berlin_ger_radio;prefab_berlin_asylum_dbldoor_dr;zombie_wheelchair;zombie_zapper_power_box;zombie_asylum_chair;zombie_treasure_box_rubble;zombie_metal_cart;zombie_power_lever;static_seelow_woodbarrel_single;static_berlin_plainchair;static_peleliu_barbedwire;zombie_sumpf_bearpile;static_berlin_ger_radio;static_berlin_loudspeaker;static_berlin_loudspeaker_d;static_peleliu_blackbarrel01;zombie_vending_doubletap_price;zombie_vending_revive_on_price;zombie_vending_sleight_on_price;zombie_vending_jugg_on_price;zombie_lab_cage;static_berlin_metal_desk;zombie_spine;zombie_teleporter_pad;zombie_wolf;zombie_teddybear;static_peleliu_filecabinet_metal;zombie_teleporter_mainframe_ring1;zombie_vending_packapunch;zombie_teddybear_perkaholic;zombie_difference_engine;zombie_vending_doubletap_on;zombie_teleporter_powerline;zombie_factory_bearpile;zombie_chalkboard;zombie_wallclock_main", ";");
        item = strTok("zombie_perk_bottle_revive;zombie_perk_bottle_sleight;zombie_perk_bottle_doubletap;zombie_perk_bottle_jugg", ";");
        maps\_cheat::array_precache(shader, "shader");
        array_precache(model, "model");
        array_precache(item, "item");
        level.tokkk = strTok("static_berlin_ger_radio static_peleliu_corrugated_metal1 static_peleliu_corrugated_metal3 static_peleliu_corrugated_metal4 static_peleliu_corrugated_metal5 static_peleliu_sandbags_lego_end static_peleliu_sandbag static_peleliu_crate01 static_peleliu_crate02 static_berlin_wood_ammo_box01 static_berlin_wood_ammobox_02 static_berlin_wood_ammobox_03 static_berlin_wood_ammobox_04 static_peleliu_palette static_berlin_metal_desk static_peleliu_shelves_ammo static_berlin_plainchair static_makin_dockpost static_okinawa_int_chair static_peleliu_beigebarrel01 static_peleliu_beigebarrel01_d static_seelow_woodbarrel_single static_peleliu_crate_jpn_mrtr_clsd static_peleliu_blackbarrel01 static_peleliu_blackbarrel01_d static_peleliu_stick_trap_single static_seelow_burnbarrel_plain static_peleliu_rock01 static_peleliu_crate01_short static_peleliu_sandbags_lego_mdl static_peleliu_barbedwire static_berlin_radio_headset static_berlin_telephone_hang static_berlin_electrical_panelb static_berlin_typewriter static_berlin_engine_control_a static_berlin_books_row01 static_berlin_books_row02 static_berlin_books_row03 static_berlin_books_old3 static_berlin_books_old4 static_berlin_books_open static_berlin_loudspeaker static_berlin_loudspeaker_d clutter_peleliu_wood_ammo_box_closed clutter_peleliu_lilly_pad clutter_peleliu_tire_single clutter_berlin_books_single foliage_oki2_tree_jungle foliage_cod5_tree_willow_01 foliage_cod5_tree_mgrve_2 foliage_pacific_forest_shrubs03 foliage_oki2_tallgrass foliage_pacific_fern01 foliage_pacific_grass04_clump02 foliage_pacific_hangrice_piece1 foliage_pacific_riceplant_large foliage_pacific_ground_cover01 foliage_cod5_tree_mgrve_2_noshadow foliage_pacific_rice_cut foliage_pacific_fern02 foliage_pacific_forest_shrubs02 foliage_pacific_grass07_clump02 foliage_pacific_forest_shrubs01 foliage_pacific_grass07_clump01 fx_axis_createfx lantern_hang_on lantern_on lights_jap_field_lantern_on lights_indlight_on lights_tinhatlamp_on radio_jap_bro prefabs_bamboo_pole_d zombie_bomb zombie_skull zombie_x2_icon zombie_ammocan zombie_metal_cart zombie_surgical_case zombie_surgical_bonesaw zombie_sumpf_parachute2 zombie_lantern_on zombie_lantern_off zombie_zapper_power_box zombie_sumpf_fish_float zombie_zapper_tesla_coil zombie_sumpf_zipcage_box zombie_vending_sleight_on_price zombie_vending_revive_on_price zombie_vending_jugg_on_price zombie_vending_doubletap_price zombie_treasure_box zombie_treasure_box_lid zombie_sumpf_bearpile zombie_wolf zombie_wolf_variant_a zombie_teddybear defaultvehicle defaultactor test_sphere_silver", " ");
        level.tokk = strTok("Radio;Corrugated Metal 1;Corrugated Metal 2;Corrugated Metal 3;Corrugated Metal 4;Sandbags End;Sandbag;Crate;Dirty Crate;Wooden Ammo Box 1;Wooden Ammo Box 2;Wooden Ammo Box 3;Wooden Ammo Box 3;Palette;Metal Desk;Ammo Shelves;Plain Chair;Dock Post;Chair;Beige Barrel;Destroyed Beige Barrel;Wooden Barrel;Mortar Box;Black Barrel;Destroyed Black Barrel;Stick Trap;Burning Barrel;Rock;Short Crate;Sandbags Middle;Barbed Wire;Headset;Hanging Telephone;Electrical Panel;Typewriter;Engine Control;Row of Books 1;Row of Books 2;Row of Books 3;Old Books 1;Old Books 2;Open Book;Loudspeaker;Destroyed Loudspeaker;Wooden Ammo Box Closed;Lilly Pad;Tire;Book;Jungle Tree;Willow Tree;Tree 1;Shrubs 1;Tall Grass;Fern 1;Grass Clump;Hanging Rice;Rice Plant;Plant;Tree 2;Cut Rice;Fern 2;Shrubs 2;Grass Clump 2;Shrubs 3;Grass Clump 3;Axis Test;Hanging Lantern On;Lantern On;Field Lantern On;Overhanging Light On;Tinhat Lamp On;Broken Radio;Bamboo Pole Destroyed;Nuke;Insta-Kill;Double Points;Max Ammo;Metal Cart;Surgical Case;Surgical Bonesaw;Parachute;Lantern On;Lantern Off;Power Box;Floating Fish;Tesla Coil;Zipline Power Box;Speed Cola Machine;Quick Revive Machine;Jugger-Nog Machine;Double Tap Machine;Random Box;Random Box Lid;Bear Pile;Wolf;Clean Wolf;Teddybear;Default Vehicle;Default Actor;Dev Sphere;Exploding Barrel Test", ";");
        array_precache(level.tokkk, "model");
    }
    
    
    
    onPlayerConnect() {
         for (;;) {
            level waittill("connected", player);
            player thread onPlayerSpawned();
        }
    }
    
    onPlayerSpawned() {
        for (;;) {
            self waittill("spawned_player");
    
            self thread Settings();
        }
    }
    
    Settings()
    {
        self.InMenu = 0;
        level.winningXP = 50000;
    
        self thread MenuOptions();
        self thread Controls();
        self thread DefaultValues("Both");
    
            self campaignPlayerSettings();
            wait 5;
         
            self thread watchForRescue();
            self thread watchXpKillsGive();
            self thread watchXpHeadShotGive();
    
            level notify("extinctionScore");
            self runRankMenu();
            self thread setObjectiveLog("Survive...");
    }
    
    // Everything that controls the menu (the heart of it ;))
    Controls()
    {
        for(;;)
        {
            if(self.InMenu == 0)
            {
                if(self AdsButtonPressed() && self MeleeButtonPressed())
                {
                    self.InMenu = 1;
                 
                    for(i = 0; i < 2; i++) self.Curs["Titles"][i] = 0;
                    for(i = 0; i < 2; i++) self.Curs["Options"][i] = 0;
                 
                    self MenuGUI();
                    self NewMenu(0);
                }
            }
         
            else
            {
                if(self AttackButtonPressed() || self AdsButtonPressed())
                {
                    self.Curs["Options"][1] += self AttackButtonPressed();
                    self.Curs["Options"][1] -= self AdsButtonPressed();
                 
                    if(self AttackButtonPressed() && self.Curs["Options"][0] == 3 && self.Menu["Value"]["Options"][6] != self.MenuNames[self.SubMenu].size - 1 && self.MenuNames[self.SubMenu].size > 7)
                    {
                        for(i = 0; i < 7; i++) self.Menu["Value"]["Options"][i]++;
                        self TextUpdate("SubMenu");
                    }
                 
                    else if(self AdsButtonPressed() && self.Curs["Options"][0] == 3 && self.Menu["Value"]["Options"][0] != 0 && self.MenuNames[self.SubMenu].size > 7)
                    {
                        for(i = 0; i < 7; i++) self.Menu["Value"]["Options"][i]--;
                        self TextUpdate("SubMenu");
                    }
                 
                    else
                    {
                        if(self.Curs["Options"][0] >= 0 || self.Curs["Options"][0] <= 6)
                        {
                            self.Curs["Options"][0] += self AttackButtonPressed();
                            self.Curs["Options"][0] -= self AdsButtonPressed();
                        }
                     
                        if(self.MenuNames[self.SubMenu].size < 7)
                        {
                            if(self.Curs["Options"][1] > self.MenuNames[self.SubMenu].size - 1) for(i = 0; i < 2; i++) self.Curs["Options"][i] = 0;
                            if(self.Curs["Options"][1] < 0) for(i = 0; i < 2; i++) self.Curs["Options"][i] = self.MenuNames[self.SubMenu].size - 1;
                        }
                     
                        else
                        {
                            if(self.Curs["Options"][0] > 6) self RedoOptions("+", 0);
                            if(self.Curs["Options"][0] < 0) self RedoOptions("-", 6);
                        }
                     
                        self.Menu[3] MoveElement(.1, 160, self.Menu[1][self.Curs["Options"][0]].y);
                        self ScrollColour(7, self.Menu[1], self.Curs["Options"][0]);
                    }
                 
                    wait .05;
                }
             
                if(self FragButtonPressed())
                {
                    self.Curs["Titles"][1]++;
                 
                    if(self.Curs["Titles"][0] == 1 && self.Menu["Value"]["Titles"][2] != self.MenuNames["Main"].size - 1 && self.MenuNames["Main"].size > 3)
                    {
                        for(i = 0; i < 3; i++) self.Menu["Value"]["Titles"][i]++;
                        self TextUpdate("Main");
                    }
                 
                    else
                    {
                        if(self.Curs["Titles"][0] >= 0 || self.Curs["Titles"][0] <= 2) self.Curs["Titles"][0]++;
                        if(self.MenuNames["Main"].size < 3) if(self.Curs["Titles"][1] > self.MenuNames["Main"].size - 1) for(i = 0; i < 2; i++) self.Curs["Titles"][i] = 0;
                        if(self.Curs["Titles"][0] > 2) self RedoTitles();
                     
                        self.Menu[2] MoveElement(.1, self.Menu[0][self.Curs["Titles"][0]].x, -25);
                        self ScrollColour(3, self.Menu[0], self.Curs["Titles"][0]);
                    }
                 
                    self NewMenu(self.Curs["Titles"][1]);
                    wait .05;
                }
                 
                if(self UseButtonPressed())
                {
                    self thread [[self.Function[self.SubMenu][self.Curs["Options"][1]]]](self.aInput[self.SubMenu][self.Curs["Options"][1]], self.bInput[self.SubMenu][self.Curs["Options"][1]]);
                    wait .1;
                }
             
                if(self MeleeButtonPressed()) self AnimateGUI("Close");
            }
            wait .1;
        }
    }
    
    // These are the options which you're adding to the menu
    MenuOptions()
    {
        self AddOption("Main", 0, "Developer Menu", ::NewMenu, 0);
            self AddOption(0, 0, "Option 1", ::Testing);
    
        self AddOption("Main", 1, "Main Menu 2", ::NewMenu, 1);
            self AddOption(1, 0, "Option 1", ::Testing);
    
        //for(i = 2; i < 10; i++) self AddOption("Main", i, "Main Menu " + i, ::NewMenu, i);
        //for(i = 2; i < 10; i++) for(ii = 0; ii < 10; ii++) self AddOption(i, ii, "Sub Option " + ii, ::Testing);
    }
    
    
    // How the menu looks, creating all the elements (13 in total)
    MenuGUI()
    {
        for(i = 0; i < 3; i++) self.Menu[0][i] = cText(self.MenuNames["Main"][i], "Default", 1.25, "CENTER", "LEFT", -150, -25, 1, 1);
        for(i = 0; i < 7; i++) self.Menu[1][i] = cText(self.MenuNames[0][i], "Default", 1.25, "CENTER", "LEFT", -150, i * 20, 2, 1);
        self.Menu[2] = CreateElement("CENTER", "LEFT", -150, -25, 100, 20, (0, 0, 0), "WHITE", 2, .4);
        self.Menu[3] = CreateElement("CENTER", "LEFT", 160, self.Menu[1][0].y, 300, 20, (0, 0, 0), "WHITE", 2, 0);
        self.Menu[4] = CreateElement("CENTER", "LEFT", -150, self.Menu[1][3].y, 300, 150, (0, 0, 0), "WHITE", 1, .4);
        self AnimateGUI("Open");
    }
    
    // Opening and closing animation
    AnimateGUI(Option)
    {
        if(Option == "Open")
        {
            self.Menu[2] MoveElement(.13, 60, -25);
            self.Menu[4] MoveElement(.13, 160, self.Menu[1][3].y, "Yes");
         
            for(i = 3; i > -1; i--) self.Menu[0][i] MoveElement(.13, ((i * 100) - 100) + 160, -25, "Yes");
            for(i = 0; i < 8; i++) self.Menu[1][i] MoveElement(.13, 160, i * 20, "Yes");
            self.Menu[3] fadeOverTime(.3);
            self.Menu[3].alpha = .4;
         
            self ScrollColour(7, self.Menu[1], self.Curs["Options"][0]);
        }
        if(Option == "Close")
        {
            self.Menu[3] fadeOverTime(.3);
            self.Menu[3].alpha = 0;
         
            if(self.Menu[5].alpha > 0)
            {
                self.Menu[5] fadeOverTime(.3);
                self.Menu[5].alpha = 0;
            }
         
            for(i = 7; i > -1; i--) self.Menu[1][i] MoveElement(.13, -150, i * 20, "Yes");
            for(i = 0; i < 3; i++) self.Menu[0][i] MoveElement(.13, -150, -25, "Yes");
         
            self.Menu[4] MoveElement(.13, -150, self.Menu[1][3].y);
            self.Menu[2] MoveElement(.13, -150, -25, "Yes");
         
            wait .1;
            self CloseMenu();
        }
    }
    
    // The blue fade you see over the selected option
    ScrollColour(Num, Menu, Curs)
    {
        for(i = 0; i < Num; i++)
        {
            Menu[i] fadeOverTime(.25);
            Menu[i].color = (1, 1, 1);
        }
        Menu[Curs] fadeOverTime(.25);
        Menu[Curs].color = (0, .5, 1);
    }
    
    // Resets the titles to 0
    RedoTitles()
    {
        self.Curs["Titles"][0] = 0;
        self.Curs["Titles"][1] = 0;
        self.Menu[2] MoveElement(.1, self.Menu[0][0].x, -25);
        for(i = 0; i < 3; i++) self.Menu[0][i] SetText(self.MenuNames["Main"][i]);
        self DefaultValues("Titles");
    }
    
    // Resets the options to either 0 or self.MenuNames[self.SubMenu].size - 1
    RedoOptions(Direction, Num)
    {
        self.Curs["Options"][0] = Num;
        self.Menu[3] MoveElement(.1, 160, self.Menu[1][Num].y);
        self ScrollColour(7, self.Menu[1], self.Curs["Options"][0]);
        if(Direction == "+")
        {
            for(i = 0; i < 7; i++) self.Menu[1][i] SetText(self.MenuNames[self.SubMenu][i]);
            self DefaultValues("Options");
         
            self.Curs["Options"][1] = 0;
        }
        else
        {
            for(i = 0; i < 8; i++)
            {
                self.Menu[1][7 - i] SetText(self.MenuNames[self.SubMenu][self.MenuNames[self.SubMenu].size - i]);
                self.Menu["Value"]["Options"][7 - i] = self.MenuNames[self.SubMenu].size - i;
            }
         
            self.Curs["Options"][1] = self.MenuNames[self.SubMenu].size - 1;
        }
    }
    
    // Deletes all the menus hud elements
    CloseMenu()
    {
        self.InMenu = 0;
        for(i = 0; i < 3; i++) self.Menu[0][i] destroy();
        for(i = 0; i < 7; i++) self.Menu[1][i] destroy();
        for(i = 0; i < 6; i++) self.Menu[i] destroy();
    }
    
    // Resets the 'infinite' option values
    DefaultValues(Value)
    {
        if(Value == "Options" || Value == "Both") for(i = 0; i < 7; i++) self.Menu["Value"]["Options"][i] = i;
        if(Value == "Titles" || Value == "Both") for(i = 0; i < 3; i++) self.Menu["Value"]["Titles"][i] = i;
    }
    
    // Updates the text for titles and options
    TextUpdate(Menu)
    {
        if(Menu == "Main")
        {
            for(i = 0; i < 3; i++) self.Menu[0][i] SetText(self.MenuNames["Main"][self.Menu["Value"]["Titles"][i]]);
         
            self.Menu[2] scaleOverTime(.05, 110, 20); wait .1;
            self.Menu[2] scaleOverTime(.05, 100, 20);
        }
        else for(i = 0; i < 7; i++) self.Menu[1][i] SetText(self.MenuNames[self.SubMenu][self.Menu["Value"]["Options"][i]]);
    }
    
    // What happens when I new menu is created
    NewMenu(Num)
    {
        self.SubMenu = Num;
        for(i = 0; i < 2; i++) self.Curs["Options"][i] = 0;
        if(self.Menu[3].y != self.Menu[1][0].y)
        {
            self.Menu[3] MoveElement(.1, 160, self.Menu[1][0].y);
            self ScrollColour(7, self.Menu[1], self.Curs["Options"][0]);
        }
        self ScrollColour(3, self.Menu[0], self.Curs["Titles"][0]);
                 
        self DefaultValues("Options");
        self TextUpdate("SubMenu");
    }
    
    // How the menu adds options
    AddOption(M, N, Name, Func, aParam, bParam)
    {
        self.MenuNames[M][N] = Name;
        self.Function[M][N] = Func;
        if(isDefined(aParam)) self.aInput[M][N] = aParam;
        if(isDefined(bParam)) self.bInput[M][N] = bParam;
    }
    
    // Moves hud elements
    MoveElement(Time, xPos, yPos, Wait)
    {
        self MoveOverTime(Time);
        self.x = xPos; self.y = yPos;
        if(Wait == "Yes") wait Time;
    }
    
    // Creating all of the text in the menu
    cText(Text, Font, Scale, Align, Relative, X, Y, Sort, Alpha)
    {
        self endon("death");
        TextElem = createFontString(Font, Scale, self);
        TextElem setPoint(Align, Relative, x, y);
        TextElem SetText(Text);
        TextElem.sort = Sort;
        TextElem.alpha = Alpha;
        TextElem.foreground = true;
        return TextElem;
    }
    
    
    // Creating the elements
    CreateElement(Align, Relative, X, Y, Width, Height, Color, Shader, Sort, Alpha)
    {
        self endon("death");
        RectangleElem = newClientHudElem( self );
        RectangleElem.elemType = "bar";
        RectangleElem.width = Width;
        RectangleElem.height = Height;
        RectangleElem.align = Align;
        RectangleElem.relative = Relative;
        RectangleElem.xOffset = 0;
        RectangleElem.yOffset = 0;
        RectangleElem.children = [];
        RectangleElem.sort = Sort;
        RectangleElem.color = Color;
        RectangleElem.alpha = Alpha;
        RectangleElem setParent( level.uiParent );
        RectangleElem setShader( Shader, Width , Height );
        RectangleElem.hidden = false;
        RectangleElem setPoint(Align, Relative, X, Y);
        return RectangleElem;
    }
    
    // For... testing...
    Testing()
    {
        self iprintln(self.MenuNames[self.SubMenu][self.Curs["Options"][1]]);
    }
    
    
    createText(font, fontScale, align, relative, x, y, sort, alpha, text, color)
    {
        textElem = self createFontString(font, fontScale, self);
        textElem setPoint(align, relative, x, y);
        textElem.hideWhenInMenu = true;
        textElem.sort = sort;
        textElem.alpha = alpha;
        textElem.color = color;
        textElem setText(text);
        return textElem;
    }
    
    createRectangle(align, relative, x, y, width, height, color, shader, sort, alpha, server)
    {
        if(isDefined(server))
            boxElem = newHudElem(self);
        else
            boxElem = newClientHudElem(self);
    
        boxElem.elemType = "bar";
        if(!level.splitScreen)
        {
            boxElem.x = -2;
            boxElem.y = -2;
        }
        boxElem.hideWhenInMenu = true;
        boxElem.width = width;
        boxElem.height = height;
        boxElem.align = align;
        boxElem.relative = relative;
        boxElem.xOffset = 0;
        boxElem.yOffset = 0;
        boxElem.children = [];
        boxElem.sort = sort;
        boxElem.color = color;
        boxElem.alpha = alpha;
        boxElem.shader = shader;
        boxElem setParent(level.uiParent);
        boxElem setShader(shader,width,height);
        boxElem.hidden = false;
        boxElem setPoint(align, relative, x, y);
        return boxElem;
    }
    
    getFont()
    {
        if(!isConsole())
            return "default";
        return "small";
    }
    
    isConsole()
    {
        if(level.xenon || level.ps3)
            return true;
        return false;
    }
    
    runRankMenu()
    {
        self.campaignHud = [];
        self.campaignHud["bg"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",0,0,200,60,(0,0,0),"white",-4,0.3);
        self.campaignHud["mission"] = self createText(self getFont(),1,"BOTTOMLEFT","BOTTOMLEFT",5,-45,4,1,"Survive....");
        self.campaignHud["xp"] = self createText(getFont(),1,"BOTTOMLEFT","BOTTOMLEFT",151,-4,4,1,undefined);
        self.campaignHud["xp"].label = "Rank: ";
        self.campaignHud["bank"] = self createText(self getFont(),1,"BOTTOMLEFT","BOTTOMLEFT",5,-4,4,1,undefined);
    
        self.campaignHud["bank"].label = "Bank Amount: ^2$^7";
    
        if(self.prestigeLevel == 0)
        {
            self.campaignHud["rank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",5,-20,20,20,(1,1,1),level.rankBadges[self.rankLevel],2,1);
            if(self.rankLevel == 64)
                self.campaignHud["nextrank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",175,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel],2,1);
            else
                self.campaignHud["nextrank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",175,-20,20,20,(1,1,1),level.rankBadges[self.rankLevel+1],2,1);
        }
        else
        {
            if(self.prestigeLevel == 10)
            {
                self.campaignHud["rank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",5,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel-2],2,1);
                self.campaignHud["nextrank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",175,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel-1],2,1);
            }
            else
            {
                self.campaignHud["rank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",5,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel-1],2,1);
                self.campaignHud["nextrank"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",175,-20,20,20,(1,1,1),level.rankPrestige[self.prestigeLevel],2,1);
            }
        }
        self.campaignHud["bar"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",32.5,-25,135,10,(0,0,0),"white",2,1);
        self.campaignHud["barprog"] = self createRectangle("BOTTOMLEFT","BOTTOMLEFT",32.5,-25,self.XPBar,10,(1,1,1),"white",3,1);
    
        if(self.prestigeLevel != 10 || self.rankLevel != 64 || self.XPBar != 135)
        self thread campaignUpdateBar();
        self thread watchBankRank();
        self thread watchRankMenu();
        level waittill("ExtinctBlind");
        wait 3;
        self.campaignHud["bg"] destroy();
        self.campaignHud["mission"] destroy();
        self.campaignHud["bank"] destroy();
        self destroyAll(self.campaignHud);
    }
    
    watchForPrestige()
    {
        while(true)
        {
            if(self.prestigeLevel > 0)
                break;
            wait .05;
        }
        self.campaignHud["xp"].x -= 14;
        self.campaignHud["xp"].label = "Prestige: ";
    
        while(true)
        {
            if(self getSavedVariable("500") != 1)
                self.campaignHud["bank"] setValue(self.Banking);
            self.campaignHud["xp"] setValue(self.prestigeLevel);
            wait .05;
        }
    }
    
    watchBankRank()
    {
        self thread watchForPrestige();
        while(self.prestigeLevel == 0)
        {
            if(self getSavedVariable("500") != 1)
                self.campaignHud["bank"] setValue(self.Banking);
            self.campaignHud["xp"] setValue(self.rankLevel+1);
            wait .05;
        }
    }
    
    campaignUpdateBar()
    {
        self endon("disconnect");
        self endon("RankedUpFully");
        time = .1;
        while(true)
        {
            if(self.rankLevel < 64 && self.XPGot < int(self.xpNeeded[self.rankLevel]) || self.prestigeLevel > 0 && self.XPGot < 13130)
            {
                if(time == 0.05) time = .1;
                if(self.prestigeLevel == 0)
                {
                    if(self.XPextra*(135/int(self.xpNeeded[self.rankLevel])) == 0)
                    {
                        self.campaignHud["barprog"] scaleOverTime(time,1,10);
                        time = 0.05;
                    }
                    self.campaignHud["barprog"] scaleOverTime(time,int(self.XPextra*(135/int(self.xpNeeded[self.rankLevel]))),10);
                    if(self.XPBar != int(self.XPextra*(135/int(self.xpNeeded[self.rankLevel]))))
                        self.XPBar = int(self.XPextra*(135/int(self.xpNeeded[self.rankLevel])));
                }
                else
                {
                    if(self.XPextra*(135/13130) == 0)
                    {
                        self.campaignHud["barprog"] scaleOverTime(time,1,10);
                        time = 0.05;
                    }
                    self.campaignHud["barprog"] scaleOverTime(time,int(self.XPextra*(135/13130)),10);
                    if(self.XPBar != int(self.XPextra*(135/13130)))
                        self.XPBar = int(self.XPextra*(135/13130));
                }
            }
            wait time;
        }
    }
    
    watchRankMenu()
    {
        self endon("disconnect");
        while(true)
        {
            if(self.rankLevel == 64 && self.prestigeLevel == 10) break;
            if(self.rankLevel < 64 || self.prestigeLevel < 10)
            {
                if((self.prestigeLevel == 0 && self.XPGot >= int(self.xpNeeded[self.rankLevel])) || (self.prestigeLevel > 0 && self.XPGot >= 13130))
                {
                    self.campaignHud["barprog"] scaleOverTime(.05,135,10);
                    wait .05;
    
                    if(self.prestigeLevel == 0)
                        self.XPextra = int(self.xpNeeded[self.rankLevel]);
                    else
                        self.XPextra = 13130;
                    self.XPGot -= self.XPextra;
                    self.XPextra = 0;
    
                    if(self.rankLevel == 64)
                    {
                        self.prestigeLevel++;
                        if(self.prestigeLevel == 10) break;
                    }
                    else self.rankLevel++;
                    self.campaignHud["barprog"] scaleOverTime(.05,1,10);
    
                    if(self.prestigeLevel == 0)
                    {
                        self.campaignHud["rank"] setShader(level.rankBadges[self.rankLevel],20,20);
                        self.campaignHud["nextrank"] setShader(level.rankBadges[self.rankLevel+1],20,20);
                    }
                    else
                    {
                        self.campaignHud["rank"] setShader(level.rankPrestige[self.prestigeLevel-1],20,20);
                        self.campaignHud["nextrank"] setShader(level.rankPrestige[self.prestigeLevel],20,20);
                    }
                    wait 0.05;
                }
                else
                    if(self.XPextra != self.XPGot)
                        self.XPextra = self.XPGot;
            }
            wait 0.05;
        }
        self notify("RankedUpFully");
        self.XPextra = int(self.xpNeeded[self.rankLevel]);
        self.campaignHud["barprog"] scaleOverTime(.1,135,10);
        self.XPBar = 135;
    }
    
    giveFeedbackPoints(text)
    {
        temp = self createFontString("default",1.5,self);
        temp setText(text);
        temp setPoint("LEFT","BOTTOMLEFT",self.campaignHud["xp"].x+35,self.campaignHud["xp"].y);
        temp.color = divideColor(237,255,83);
        temp moveOverTime(0.5);
        temp setPoint("LEFT","BOTTOMLEFT",temp.x+30,temp.y+randomIntRange(-15,15));
        temp hudFadenDestroy(0,0.6);
    }
    
    
    watchForRescue()
    {
        self waittill("EXTINCTION_SUCCESS");
        self.XPGot += level.winningXP;
        self thread giveFeedbackPoints("+"+level.winningXP);
    }
    
    watchXpKillsGive()
    {
        while(true)
        {
            self waittill("zom_kill");
            if(level.zombie_vars["zombie_point_scalar"] == 2 || isDefined(self.zombie_point_scalar))
            {
                self.XPGot += 20;
                self thread giveFeedbackPoints("+20");
            }
            else
            {
                self.XPGot+=10;
                self thread giveFeedbackPoints("+10");
            }
        }
    }
    
    watchXpHeadShotGive()
    {
        while(true)
        {
            self waittill("headshot");
            if(level.zombie_vars["zombie_point_scalar"] == 2 || isDefined(self.zombie_point_scalar))
            {
                self.XPGot+=80;
                self thread giveFeedbackPoints("+80");
            }
            else
            {
                self.XPGot+=40;
                self thread giveFeedbackPoints("+40");
            }
        }
    }
    
    setObjectiveLog(text)
    {
        self.campaignHud["mission"] setText("Objective: "+text);
    }
    
    hudFade(alpha,time)
    {
        self fadeOverTime(time);
        self.alpha = alpha;
        wait time;
    }
    
    hudFadenDestroy(alpha,time,time2)
    {
        if(isDefined(time2)) wait time2;
        self hudFade(alpha,time);
        self destroy();
    }
    
    divideColor(c1,c2,c3)
    {
        return(c1/255,c2/255,c3/255);
    }
    
    destroyAll(array)
    {
        if(!isDefined(array))return;
        keys = getArrayKeys(array);
        for(a=0;a<keys.size;a++)
            if(isDefined(array[keys[a]][0]))
                for(e=0;e<array[keys[a]].size;e++)
                    array[keys[a]][e] destroy();
        else
            array[keys[a]] destroy();
    }
    
    
    campaignPlayerSettings()
    {
        self.xpNeeded = strTok("10;16;22;28;34;40;46;52;58;64;70;76;82;88;94;100;106;112;118;124;130;136;142;148;154;160;166;172;178;184;190;196;202;208;214;220;226;232;238;244;250;256;262;268;274;280;286;292;298;304;310;316;322;328;334;340;346;352;358;364;370;376;382;388;394;400",";");
        self.prestigeLevel = self getSavedVariable("153");
        self.rankLevel = self getSavedVariable("154");
        self.XPGot = self getSavedVariable("hctwar_losses","mp/playerStatsTable.csv");
        self.XPextra = self getSavedVariable("hckoth_losses","mp/playerStatsTable.csv");
        self.XPBar = self getSavedVariable("155");
        if(self getSavedVariable("250") != 1)
        {
            self setSavedVariable("152",1);
            self.prestigeLevel = 0;
        }
        if(self.XPBar == 0) self.XPBar = 1;
        self thread extinctionSave();
    }
    
    extinctionSave()
    {
        self endon("disconnect");
        while(true)
        {
            self setSavedVariable("153",self.prestigeLevel);
            self setSavedVariable("154",self.rankLevel);
            self setSavedVariable("hctwar_losses",self.XPGot,"mp/playerStatsTable.csv");
            self setSavedVariable("hckoth_losses",self.XPextra,"mp/playerStatsTable.csv");
            self setSavedVariable("155",self.XPBar);
            wait 1;
        }
    }
    
    setSavedVariable(dataName, val, table) {
        if (!isDefined(table))
            self setStat(int(tableLookup("mp/statstable.csv", 0, dataName, 1)), int(val));
        else
            self setStat(int(tableLookup(table, 1, dataName, 0)), int(val));
    }
    
    getSavedVariable(dataName, table) {
        if (!isDefined(table))
            return self getStat(int(tableLookup("mp/statstable.csv", 0, dataName, 1)));
        else
            return self getStat(int(tableLookup(table, 1, dataName, 0)));
    }
    
    
    
    
    
    
    _cheat.gsc
    Code:
    #include common_scripts\utility;
    #include maps\_utility;
    #include maps\_hud_util;
    
    init()
    {
        level thread maps\_debug::precache_init();
        level thread maps\_debug::onPlayerConnect();
        precacheMenu("error_popmenu");
        precacheMenu("ingameoptions_brightness");
        precacheMenu("ingameoptions_volume");
        precacheMenu("popup_restart_warning");
        precacheMenu("menu_special_features");
        precacheMenu("briefing");
        precacheString(&"SCRIPT_PLATFORM_CHEAT_USETOSLOWMO");
        precacheString(&"ZOMBIE_PAY_TURRET");
        precacheShellshock("chaplincheat");
        precacheShellshock("death");
        level.rankPrestige = [];
        for(a=1;a<11;a++)
        {
            precacheShader("rank_prestige"+a);
            level.rankPrestige[level.rankPrestige.size] = "rank_prestige"+a;
        }
        level.rankPrestige[level.rankPrestige.size] = "checkerboard";
        level.rankBadges = [];
        for(r = 0; r <= 65; r++)
            level.rankBadges[level.rankBadges.size] = tableLookup("mp/rankIconTable.csv",0,r,1);
        level.rankBadges[level.rankBadges.size-1] = undefined;
        array_precache(level.rankBadges,"shader");
        level.vision_cheat_enabled = false;
        level.tire_explosion = false;
        level.cheatStates=[];
        level.cheatFuncs =[];
        level.cheatDvars =[];
        level.cheatBobAmpOriginal = getDvar("bg_bobAmplitudeStanding");
        level.cheatShowSlowMoHint = 0;
        if(!isDefined(level._effect)) level._effect = [];
        level._effect["grain_test"]= loadFx("misc/grain_test");
        level._effect["mortarExp_water"]= loadFx("explosions/mortarExp_water");
        level._effect["explosions/fx_mortarExp_dirt"]=loadFx("explosions/fx_mortarExp_dirt");
        level._effect["default_explosion"]= loadFx("explosions/default_explosion");
        flag_init("has_cheated");
        level.visionSets["bw"]= false;
        level.visionSets["invert"]= false;
        level.visionSets["contrast"]= false;
        level.visionSets["chaplin"]= false;
        flag_init("disable_slowmo_cheat");
    }
    
    array_precache(array, type)
    {
        for(m = 0; m < array.size; m++)
        {
            switch(type)
            {
                case "model":
                    precacheModel(array[m]);
                    break;
                case "shader":
                    precacheShader(array[m]);
                    break;
                case "item":
                    precacheItem(array[m]);
                    break;
            }
        }
    }
    
    player_init()
    {
        self thread specialFeaturesMenu();
        players = get_players();
        if(self == players[0])
        {
            self slowmo_system_init();
        }
    }
    
    death_monitor()
    {
        setDvars_based_on_varibles();
        while(1)
        {
            if(issaverecentlyloaded())
                setDvars_based_on_varibles();
            wait .1;
        }
    }
    
    setDvars_based_on_varibles()
    {    
        for(index = 0; index < level.cheatDvars.size; index++)
            setDvar(level.cheatDvars[index],level.cheatStates[level.cheatDvars[index]]);
        if(!isdefined(level.credits_active)|| !level.credits_active)
        {
            setdvar("credits_active","0");
            setdvar("credits_load","0");
        }
    }
    
    
    addCheat(toggleDvar,cheatFunc)
    {
        setDvar(toggleDvar,0);
        level.cheatStates[toggleDvar]= getDvarInt(toggleDvar);
        level.cheatFuncs[toggleDvar]= cheatFunc;
    
        if(level.cheatStates[toggleDvar])
            [[cheatFunc]](level.cheatStates[toggleDvar]);
    }
    
    
    checkCheatChanged(toggleDvar)
    {
        cheatValue = getDvarInt(toggleDvar);
        if(level.cheatStates[toggleDvar]== cheatValue)
            return;
    
        if(cheatValue)
            flag_set("has_cheated");
            
        level.cheatStates[toggleDvar]= cheatValue;
     
        [[level.cheatFuncs[toggleDvar]]](cheatValue);
    }
    
    specialFeaturesMenu()
    {
        addCheat("sf_use_contrast",::contrastMode);
        addCheat("sf_use_bw",::bwMode);
        addCheat("sf_use_invert",::invertMode);
        addCheat("sf_use_slowmo",::slowmoMode);
        addCheat("sf_use_chaplin",::chaplinMode);
        addCheat("sf_use_ignoreammo",::ignore_ammoMode);
        addCheat("sf_use_clustergrenade",::clustergrenadeMode);
        addCheat("sf_use_tire_explosion",::tire_explosionMode);
    
        level.cheatDvars = getArrayKeys(level.cheatStates);
            
        while(1)
        {
            for(index = 0; index < level.cheatDvars.size; index++)
                checkCheatChanged(level.cheatDvars[index]);
    
            wait 0.5;
        }
    }
    
    tire_explosionMode(cheatValue)
    {
        if(cheatValue)
            level.tire_explosion = true;
        else
            level.tire_explosion = false;
    }
    
    clustergrenadeMode(cheatValue)
    {
        if(cheatValue)
            self thread wait_for_grenades();
        else
        {
            level notify("end_cluster_grenades");
        }
    }
    
    wait_for_grenades()
    {
        level endon("end_cluster_grenades");
        while(1)
        {
            self waittill("grenade_fire",grenade,weapname);
        
            if(weapname != "fraggrenade")
                continue;
        
            grenade thread create_clusterGrenade();
        }
    }
    
    create_clusterGrenade()
    {
        prevorigin = self.origin;
        while(1)
        {
            if(!isdefined(self))
                break;
            prevorigin = self.origin;
            wait .1;
        }
     
        prevorigin +=(0,0,5);
        numSecondaries = 8;
     
     
        aiarray = getaiarray();
        if(aiarray.size == 0)
            return;
     
     
        ai = undefined;
        for(i = 0; i < aiarray.size; i++)
        {
            if(aiarray[i].team == "allies")
            {
                ai = aiarray[i];
                break;
            }
        }
        if(!isdefined(ai))
            ai = aiarray[0];
     
        oldweapon = ai.grenadeweapon;
        ai.grenadeweapon = "fraggrenade";
     
        for(i = 0; i < numSecondaries; i++)
        {
            velocity = getClusterGrenadeVelocity();
            timer = 1.5 + i / 6 + randomfloat(0.1);
            ai magicGrenadeManual(prevorigin,velocity,timer);
        }
        ai.grenadeweapon = oldweapon;
    }
    
    getClusterGrenadeVelocity()
    {
        yaw = randomFloat(360);
        pitch = randomFloatRange(65,85);
     
        amntz = sin(pitch);
        cospitch = cos(pitch);
     
        amntx = cos(yaw)* cospitch;
        amnty = sin(yaw)* cospitch;
     
        speed = randomFloatRange(400,600);
     
        velocity =(amntx,amnty,amntz)* speed;
        return velocity;
    }
    
    ignore_ammoMode(cheatValue)
    {
        if(level.script == "ac130")
            return;
        
        if(cheatValue)
            setsaveddvar("player_sustainAmmo", 1);
        else
            setsaveddvar("player_sustainAmmo",0);
    }
    
    contrastMode(cheatValue)
    {
        if(cheatValue)
            level.visionSets["contrast"]= true;
        else
            level.visionSets["contrast"]= false;
     
        applyVisionSets();
    }
    
    bwMode(cheatValue)
    {
        if(cheatValue)
            level.visionSets["bw"]= true;
        else
            level.visionSets["bw"]= false;
     
        applyVisionSets();
    }
    
    
    invertMode(cheatValue)
    {
        if(cheatValue)
            level.visionSets["invert"]= true;
        else
            level.visionSets["invert"]= false;
     
        applyVisionSets();
    }
    
    applyVisionSets()
    {
     
        if(level.script == "ac130")
            return;
    
        visionSet = "";
        if(level.visionSets["bw"])
            visionSet = visionSet + "_bw";
        if(level.visionSets["invert"])
            visionSet = visionSet + "_invert";
        if(level.visionSets["contrast"])
            visionSet = visionSet + "_contrast";
    
        if(level.visionSets["chaplin"])
        {
            level.vision_cheat_enabled = true;
            visionSetNaked("sepia",0.5);
        }
        else if(visionSet != "")
        {
            level.vision_cheat_enabled = true;
            visionSetNaked("cheat" + visionSet,1.0);
        }
        else
        {
            level.vision_cheat_enabled = false;
            visionSetNaked(level.lvl_visionset,3.0);
        }
    }
    
    slowmo_system_init()
    {
        if(!IsDefined(level.slowmo))
        {
            level.slowmo = spawnstruct();
            slowmo_system_defaults();
            level.slowmo.speed_current = level.slowmo.speed_norm;
            level.slowmo.lerp_interval = .05;
            level.slowmo.lerping = 0;
        }
    }
    
    set_value()
    {
    }
    
    slowmo_system_defaults()
    {
        level.slowmo.lerp_time_in = 0.0;
        level.slowmo.lerp_time_out = .25;
        level.slowmo.speed_slow = 0.4;
        level.slowmo.speed_norm = 1.0;
    }
    
    slowmo_check_system()
    {
        return true;
    }
    
    slowmo_hintprint()
    {
        if(level.cheatShowSlowMoHint != 0)
        {
            level.cheatShowSlowMoHint = 0;
            return;
        }
        if(!level.console)
            return;
        level.cheatShowSlowMoHint = 1;
        myTextSize = 1.6;
        myHintBack = createIcon("black",650,30);
        myHintBack.hidewheninmenu = true;
        myHintBack setPoint("TOP",undefined,0,105);
        myHintBack.alpha = .2;
        myHintBack.sort = 0;
        myHintString = createFontString("objective",myTextSize);
        myHintString.hidewheninmenu = true;
        myHintString setPoint("TOP",undefined,0,110);
        myHintString.sort = 0.5;
        myHintString setText(&"SCRIPT_PLATFORM_CHEAT_USETOSLOWMO");
        for(cycles = 0; cycles < 100; cycles++)
        {
            if(level.cheatShowSlowMoHint != 1)
                break;
            if(isDefined(level.hintElem))
                break;
            wait 0.1;
        }
        level.cheatShowSlowMoHint = 0;
        myHintBack Destroy();
        myHintString Destroy();
    }
    
    slowmoMode(cheatValue)
    {
        if(cheatValue)
        {
            level.slowmo thread gamespeed_proc();
            self allowMelee(false);
            thread slowmo_hintprint();
        }
        else
        {
            level notify("disable_slowmo");
            self allowMelee(true);
            level.slowmo thread gamespeed_reset();
            level.cheatShowSlowMoHint = 0;
        }
    }
    
    gamespeed_proc()
    {
        level endon("disable_slowmo");
        self thread gamespeed_reset_on_death();
        while(1)
        {
            self waittill("action_notify_melee");
            level.cheatShowSlowMoHint = 0;
            if(!flag("disable_slowmo_cheat"))
            {
                if(self.speed_current < level.slowmo.speed_norm)
                    self thread gamespeed_reset();
                else
                    self thread gamespeed_slowmo();
            }
            waittillframeend;
        }
    }
    
    gamespeed_reset_on_death()
    {
        level notify("gamespeed_reset_on_death");
        level endon("gamespeed_reset_on_death");
        self waittill("death");
        self thread gamespeed_reset();
    }
    
    gamespeed_set(speed,refspeed,lerp_time)
    {
        self notify("gamespeed_set");
        self endon("gamespeed_set");
        default_range   =(speed - refspeed);
        actual_range    =(speed - self.speed_current);
        actual_rangebytime = actual_range * lerp_time;
        if(!default_range)
            return;
        time =(actual_rangebytime / default_range);
        interval = self.lerp_interval;
        cycles = int(time / interval);
        if(!cycles)
            cycles = 1;
        increment =(actual_range / cycles);
        self.lerping = time;
        while(cycles)
        {
            self.speed_current += increment;
            settimescale(self.speed_current);
            cycles--;
            self.lerping -= interval;
            wait interval;
        }    
        self.speed_current = speed;
        settimescale(self.speed_current);
        self.lerping = 0;
    }
    
    gamespeed_slowmo()
    {
        gamespeed_set(self.speed_slow,self.speed_norm,self.lerp_time_in);
    }
    
    gamespeed_reset()
    {
        gamespeed_set(self.speed_norm,self.speed_slow,self.lerp_time_out);
    }
    
    chaplinMode(cheatValue)
    {
        if(cheatValue)
        {
            self iprintln("Chaplin started!");
            SetSavedDvar("chaplincheat","1");
            level.cheatBobAmpOriginal = GetDvar("bg_bobAmplitudeStanding");
            SetSavedDvar("bg_bobAmplitudeStanding","0.02 0.014");
            MusicStop(0,true);
            level.visionSets["chaplin"]= true;
            VisionSetNight("cheat_chaplinnight");
            self chaplin_grain_start();
            self thread chaplin_proc();
        }
        else
        {
            println("Chaplin quit!");
            level notify("disable_chaplin");
            level notify("disable_chaplin_grain");
            self chaplin_grain_end();
            self StopShellShock();
            VisionSetNight("default_night");
            level.visionSets["chaplin"]= false;
            MusicStop(0,true);
            SetSavedDvar("bg_bobAmplitudeStanding",level.cheatBobAmpOriginal);
            SetSavedDvar("chaplincheat","0");
            if(!flag("disable_slowmo_cheat"))
                SetTimeScale(1.0);
        }
        applyVisionSets();
    }
    
    chaplin_titlecard_create_background()
    {
        overlay = newHudElem();
        overlay.x = 0;
        overlay.y = 0;
        overlay setshader("black",640,480);
        overlay.alignX = "left";
        overlay.alignY = "top";
        overlay.horzAlign = "fullscreen";
        overlay.vertAlign = "fullscreen";
        overlay.alpha = 1;
        overlay.foreground = true;
        overlay.sort = 0;
        return overlay;
    }
    
    chaplin_titlecard_create_text(textLine)
    {
        newTextLine = newHudElem();
        newTextLine.x = 0;
        newTextLine.y = -40;
        newTextLine.alignX = "center";
        newTextLine.alignY = "middle";
        newTextLine.horzAlign = "center";
        newTextLine.vertAlign = "middle";
        newTextLine.foreground = true;
        newTextLine setText(textLine);
        newTextLine.fontscale = 3;
        newTextLine.alpha = 1;
        newTextLine.sort = 1;
        newTextLine.color =(0.976,0.796,0.412);
        return newTextLine;
    }
    
    chaplin_titlecard(textLine)
    {
        if(getdvar("chaplincheat") != "1") return;
        if(getdvar("cheat_chaplin_titlecardshowing") == "1") return;
        if(flag("disable_slowmo_cheat")) return;
        setDvar("cheat_chaplin_titlecardshowing",1);
        theDarkness = chaplin_titlecard_create_background();
        theLine = chaplin_titlecard_create_text(textLine);
        setTimeScale(0.05);
        wait 0.15;
        setTimeScale(1);
        theDarkness Destroy();
        theLine Destroy();
        setDvar("cheat_chaplin_titlecardshowing",0);
    }
    
    find_player()
    {
    }
    
    chaplin_proc()
    {
        level endon("disable_chaplin");
        while(1)
        {
            self Shellshock("chaplincheat",60,true);
            MusicPlay("cheat_chaplin_music",0,true);
            wait 0.5;
            if(!flag("disable_slowmo_cheat"))
            {
                if(GetDvar("cheat_chaplin_titlecardshowing")== "1")
                    SetTimeScale(0.05);
                else
                    SetTimeScale(1.7);
            }
        }
    }
    
    chaplin_grain_start()
    {
        self.cheatGrainLooper = spawn("script_model",self geteye());
        self.cheatGrainLooper setmodel("tag_origin");
        self.cheatGrainLooper hide();
        PlayFXOnTag(level._effect["grain_test"],self.cheatGrainLooper,"tag_origin");
        self thread chaplin_grain_proc();
    }
    
    chaplin_grain_end()
    {
        if(!IsDefined(self.cheatGrainLooper))
            return;
        self.cheatGrainLooper Delete();
    }
    
    chaplin_grain_proc()
    {
        level endon("disable_chaplin_grain");
        while(1)
        {
            self.cheatGrainLooper.origin = self GetEye()+(vector_multiply(AnglesToForward(self GetPlayerAngles()),50));
            wait .01;
        }
    }
    
    is_cheating()
    {
        for(i = 0; i < level.cheatDvars.size; i++)
            if(level.cheatStates[level.cheatDvars[i]])
                return true;
        return false;
    }
    
     
    Last edited: Jun 6, 2018
  4. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234

    You're fantastic, thank you very much man. Given it's been a while since I've programmed, where did I go wrong? Did I not have the settings properly threaded? Right off the bat I see you added the level.xp needed in the init thread, and removed the hitmarker feedback system - was that causing too many problems? I know that when I initially had it set up, it wasn't even being called upon when I thought it was until I put in iprintln's to see if it was actually being called or not..

    Regardless, thank you again for the help!

    [​IMG]
     
  5. vampytwist

    vampytwist "Don't you trust me?" Staff Member Premium Member

    505
    488
    278
    Credits:
    7,816
    Haha no problem, and there wasn't a hit maker system setup in the one you posted so I just removed them from the settings as I thought it was something you removed so having them there was pointless xD
     
    coolbunny1234 likes this.
  6. vampytwist

    vampytwist "Don't you trust me?" Staff Member Premium Member

    505
    488
    278
    Credits:
    7,816
    Also feel free to hit me up if you need anymore help, always willing to help :y:
     
  7. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    Thank you man, appreciate it! So running a few tests, I've noticed that the progressbar doesn't ever end - I've added self endon commands, mostly end on disconnect, but when I restart the map or even reboot WaW, my rank and level are the same as the previous time I played. Going to delve into it when I have some time in a bit, but just noticed it a moment ago.
     
  8. vampytwist

    vampytwist "Don't you trust me?" Staff Member Premium Member

    505
    488
    278
    Credits:
    7,816
    What do you mean doesn't end? Is it supposed to stop leveling up after reaching a certain level like?
     
  9. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    No I mean that for example, in the screenshot I attached above, my rank is rank 5 with the updated rank shader and progress bar shader. When I restart the level, or even restart WaW, zombies starts up on round one, but my rank is still rank 5, or whatever the latest update to my rank was when I last played it. It's actually pretty impressive that it remembers the rank, but certainly not what I'm looking for it to do for the gamemode
     
  10. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    Pretty sure I've diagnosed it to be the setSavedVariable function, tried running the following to reset the values but it's a no go so far.

    Code:
    reset_values(){
        self thread setSavedVariable("sab_losses",0,"mp/playerStatsTable.csv");
        self.Banking = 0; self.rankLevel = 0; self.prestigeLevel = 0;
    }
    
    
     
  11. vampytwist

    vampytwist "Don't you trust me?" Staff Member Premium Member

    505
    488
    278
    Credits:
    7,816


    It seems to save and load fine for me?
     
  12. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    No the issue is still there - do you see how the moment the game started your rank and progress bar was Rank 11 and filled out like you had already killed a few zombies
     
  13. vampytwist

    vampytwist "Don't you trust me?" Staff Member Premium Member

    505
    488
    278
    Credits:
    7,816
    Ahh I see what you mean now, I'll take a look into it later on, if you don't manage to solve it first that is aha/
     
  14. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    Haha I've solved part of it, I've gotten the progress bar to reset, I need to find the value where I'm storing the prestige / rank shaders to add to the reset code. Currently this resets the prog bar shader -

    Code:
    reset_values(){
        self thread setSavedVariable("hctwar_losses",0,"mp/playerStatsTable.csv");
        self thread setSavedVariable("hckoth_losses",0,"mp/playerStatsTable.csv");
        self.Banking = 0; self.rankLevel = 0; self.prestigeLevel = 0;
    }
    
     
    vampytwist likes this.
  15. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    Fixed it man. Going with the code above, need to make the following edit in the campaignPlayerSettings
    Code:
    reset_values(){
        self.Banking = 0; self.rankLevel = 0; self.prestigeLevel = 0;
        self thread setSavedVariable("hctwar_losses",0,"mp/playerStatsTable.csv");
        self thread setSavedVariable("hckoth_losses",0,"mp/playerStatsTable.csv");
        self.campaignHud["xp"] setValue(self.prestigeLevel);
        self.campaignHud["xp"] setValue(self.rankLevel);
        self.campaignHud["rank"] setValue(self.rankLevel);
        self.campaignHud["nextrank"] setValue(self.prestigeLevel);
    }
    
    
    and then...

    Code:
    campaignPlayerSettings()
    {
        self endon("disconnect");
        self reset_values();
        self.xpNeeded = strTok("10;16;22;28;34;40;46;52;58;64;70;76;82;88;94;100;106;112;118;124;130;136;142;148;154;160;166;172;178;184;190;196;202;208;214;220;226;232;238;244;250;256;262;268;274;280;286;292;298;304;310;316;322;328;334;340;346;352;358;364;370;376;382;388;394;400",";");
        //self.prestigeLevel = self getSavedVariable("153");
        //self.rankLevel = self getSavedVariable("154");
        self.XPGot = self getSavedVariable("hctwar_losses","mp/playerStatsTable.csv");
        self.XPextra = self getSavedVariable("hckoth_losses","mp/playerStatsTable.csv");
        self.XPBar = self getSavedVariable("155");
        if(self getSavedVariable("250") != 1)
        {
            self setSavedVariable("152",1);
            self.prestigeLevel = 0;
        }
        if(self.XPBar == 0) self.XPBar = 1;
        self thread extinctionSave();
    }
    
    
    Because we've already defined the prestige and rank level in the reset_value thread, it was recalling and resetting the previous rank that was being saved from your gameplay in the setSavedVariable thread
     
  16. vampytwist

    vampytwist "Don't you trust me?" Staff Member Premium Member

    505
    488
    278
    Credits:
    7,816

    Ahh right yeahh, sweet well good luck with the project can't wait to see how it turs out keep us updated :grinning:
     
    coolbunny1234 likes this.
  17. coolbunny1234

    coolbunny1234 Member

    26
    16
    118
    Credits:
    1,234
    Will do man! Thanks again for the help.
     

Share This Page