Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Releases & Resources
  3. 🔮 BO2 Zombies – Shared Mystery Box Script

🔮 BO2 Zombies – Shared Mystery Box Script

Scheduled Pinned Locked Moved BO2 Modding Releases & Resources
7 Posts 5 Posters 906 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mahmodhalah2undefined Offline
    mahmodhalah2undefined Offline
    mahmodhalah2
    wrote last edited by
    #1

    🔥 About:
    This script upgrades the way players interact with the Mystery Box in BO2 Zombies,
    adding new co-op focused features that make gameplay smoother, faster, and more fun.

    ✨ Features:

    • Press V while the Mystery Box is open to share it with your teammate.
      No more fighting over rolls – now both players can access the box together.
    • Press Shift while the Mystery Box is open to instantly close it.
      Perfect for shutting it down during hectic moments, trolling your friends,
      or preventing wasted spins.

    💀 Why Use It?

    • Perfect for co-op sessions where teamwork and timing matter.
    • Adds a unique twist to the Mystery Box mechanic, making it feel more dynamic.
    • Helps avoid box-hogging and gives both players fair chances.
    • Quick-close feature with Shift makes the box easier to control.
    • Useful for speedruns, challenge games, and custom fun runs.

    ⚡ Installation:
    Just drop the script into your Plutonium BO2 Zombies GSC mods folder
    and enjoy the upgraded Mystery Box experience!
    [code]

    #include maps/mp/_utility;
    #include common_scripts/utility;
    #include maps/mp/gametypes_zm/_hud_util;
    #include maps/mp/zombies/_zm_weapons;
    #include maps/mp/zombies/_zm_magicbox;
    #include maps/mp/zombies/_zm;
    #include maps/mp/zombies/_zm_unitrigger;
    #include maps/mp/zombies/_zm_utility;
    #include maps/mp/_zm_tomb_capture_zones;
    init()
    {
        if(getdvar( "mapname" ) == "zm_tomb" )
        	thread monitor_boxes();
        else
            thread CheckForCurrentBox();
            
        level.shared_box = 0;
        add_zombie_hint( "default_shared_box", "Hold ^3&&1^7 for weapon");
    }
    
    CheckForCurrentBox()
    {
    	flag_wait( "initial_blackscreen_passed" );
        if( getdvar( "mapname" ) == "zm_nuked" )
        {
            wait 10;
        }
        for(i = 0; i < level.chests.size; i++)
        {
            level.chests[ i ] thread reset_box();
    		if(level.chests[ i ].hidden)
        	{
    			level.chests[ i ] get_chest_pieces();
        	}
    		if(!level.chests[ i ].hidden)
    		{
    			level.chests[ i ].unitrigger_stub.prompt_and_visibility_func = ::boxtrigger_update_prompt;
    		}
    	}
    }
    
    monitor_boxes()
    {
    	flag_wait( "initial_blackscreen_passed" );
        wait 10;
        for(i = 0; i < level.chests.size; i++)
        {
            level.chests[ i ] thread reset_box();		
    	}
        for(;;)
        {
            for(i = 0; i < level.chests.size; i++)
            {
                if(!level.chests[ i ].hidden)
                {
                    level.chests[ i ].unitrigger_stub.prompt_and_visibility_func = ::boxtrigger_update_prompt;
                    level.chests[ i ].zbarrier waittill( "left" );
                    //iPrintLn("left");
                }
            }
            wait 15;
            //iPrintLn("15");
    	}
    }
    
    reset_box()
    {
    	self notify("kill_chest_think");
        wait .1;
    	if(!self.hidden)
        {
    		self.grab_weapon_hint = 0;
    		self thread maps/mp/zombies/_zm_unitrigger::register_static_unitrigger( self.unitrigger_stub, ::magicbox_unitrigger_think );
        	self.unitrigger_stub run_visibility_function_for_all_triggers();
    	}
    	self thread custom_treasure_chest_think();
    }
    
    get_chest_pieces()
    {
    	self.chest_box = getent( self.script_noteworthy + "_zbarrier", "script_noteworthy" );
    	self.chest_rubble = [];
    	rubble = getentarray( self.script_noteworthy + "_rubble", "script_noteworthy" );
    	i = 0;
    	while ( i < rubble.size )
    	{
    		if ( distancesquared( self.origin, rubble[ i ].origin ) < 10000 )
    		{
    			self.chest_rubble[ self.chest_rubble.size ] = rubble[ i ];
    		}
    		i++;
    	}
    	self.zbarrier = getent( self.script_noteworthy + "_zbarrier", "script_noteworthy" );
    	if ( isDefined( self.zbarrier ) )
    	{
    		self.zbarrier zbarrierpieceuseboxriselogic( 3 );
    		self.zbarrier zbarrierpieceuseboxriselogic( 4 );
    	}
    	self.unitrigger_stub = spawnstruct();
    	self.unitrigger_stub.origin = self.origin + ( anglesToRight( self.angles ) * -22.5 );
    	self.unitrigger_stub.angles = self.angles;
    	self.unitrigger_stub.script_unitrigger_type = "unitrigger_box_use";
    	self.unitrigger_stub.script_width = 104;
    	self.unitrigger_stub.script_height = 50;
    	self.unitrigger_stub.script_length = 45;
    	self.unitrigger_stub.trigger_target = self;
    	unitrigger_force_per_player_triggers( self.unitrigger_stub, 1 );
    	self.unitrigger_stub.prompt_and_visibility_func = ::boxtrigger_update_prompt;
    	self.zbarrier.owner = self;
    }
    
    boxtrigger_update_prompt( player )
    {
    	can_use = self custom_boxstub_update_prompt( player );
    	if ( isDefined( self.hint_string ) )
    	{
    		if ( isDefined( self.hint_parm1 ) )
    		{
    			self sethintstring( self.hint_string, self.hint_parm1 );
    		}
    		else
    		{
    			self sethintstring( self.hint_string );
    		}
    	}
    	return can_use;
    }
    
    custom_boxstub_update_prompt( player )
    {
        self setcursorhint( "HINT_NOICON" );
        if(!self trigger_visible_to_player( player ))
        {
            if(level.shared_box)
            {
                self setvisibletoplayer( player );
                self.hint_string = get_hint_string( self, "default_shared_box" );
                return 1;
            }
            return 0;
        }
        self.hint_parm1 = undefined;
                    if(level.shared_box)
        {
                    self.hint_string = "Press ^2F^7 to take weapon"; // Any player can now take it
            return 1;
        }
    
            if ( isDefined( self.stub.trigger_target.grab_weapon_hint ) && self.stub.trigger_target.grab_weapon_hint && !level.shared_box )
        {
            if (isDefined( level.magic_box_check_equipment ) && [[ level.magic_box_check_equipment ]]( self.stub.trigger_target.grab_weapon_name ) )
            {
                self.hint_string = "Press ^2F^7 for Equipment, ^3V^7 to share, or ^1Shift^7 to close";
            }
            else 
            {
                self.hint_string = "Press ^2F^7 for Weapon, ^3V^7 to share, or ^1Shift^7 to close";
            }
        }
        else if(getdvar("mapname") == "zm_tomb" && isDefined(level.zone_capture.zones) && !level.zone_capture.zones[self.stub.zone] ent_flag( "player_controlled" )) 
        {
            self.stub.hint_string = &"ZM_TOMB_ZC";
            return 0;
        }
        else
        {
            if ( isDefined( level.using_locked_magicbox ) && level.using_locked_magicbox && isDefined( self.stub.trigger_target.is_locked ) && self.stub.trigger_target.is_locked )
            {
                self.hint_string = get_hint_string( self, "locked_magic_box_cost" );
            }
            else
            {
                self.hint_parm1 = self.stub.trigger_target.zombie_cost;
                self.hint_string = get_hint_string( self, "default_treasure_chest" );
            }
        }
        return 1;
    }
    
    custom_treasure_chest_think()
    {
    	self endon( "kill_chest_think" );
    	user = undefined;
    	user_cost = undefined;
    	self.box_rerespun = undefined;
    	self.weapon_out = undefined;
    	self thread unregister_unitrigger_on_kill_think();
    	while ( 1 )
    	{
    		if ( !isdefined( self.forced_user ) )
    		{
    			self waittill( "trigger", user );
    			if ( user == level )
    			{
    				wait 0.1;
    				continue;
    			}
    		}
    		else
    		{
    			user = self.forced_user;
    		}
    		if ( user in_revive_trigger() )
    		{
    			wait 0.1;
    			continue;
    		}
    		if ( user.is_drinking > 0 )
    		{
    			wait 0.1;
    			continue;
    		}
    		if ( isdefined( self.disabled ) && self.disabled )
    		{
    			wait 0.1;
    			continue;
    		}
    		if ( user getcurrentweapon() == "none" )
    		{
    			wait 0.1;
    			continue;
    		}
    		reduced_cost = undefined;
    		if ( is_player_valid( user ) && user maps/mp/zombies/_zm_pers_upgrades_functions::is_pers_double_points_active() )
    		{
    			reduced_cost = int( self.zombie_cost / 2 );
    		}
    		if ( isdefined( level.using_locked_magicbox ) && level.using_locked_magicbox && isdefined( self.is_locked ) && self.is_locked ) 
    		{
    			if ( user.score >= level.locked_magic_box_cost )
    			{
    				user maps/mp/zombies/_zm_score::minus_to_player_score( level.locked_magic_box_cost );
    				self.zbarrier set_magic_box_zbarrier_state( "unlocking" );
    				self.unitrigger_stub run_visibility_function_for_all_triggers();
    			}
    			else
    			{
    				user maps/mp/zombies/_zm_audio::create_and_play_dialog( "general", "no_money_box" );
    			}
    			wait 0.1 ;
    			continue;
    		}
    		else if ( isdefined( self.auto_open ) && is_player_valid( user ) )
    		{
    			if ( !isdefined( self.no_charge ) )
    			{
    				user maps/mp/zombies/_zm_score::minus_to_player_score( self.zombie_cost );
    				user_cost = self.zombie_cost;
    			}
    			else
    			{
    				user_cost = 0;
    			}
    			self.chest_user = user;
    			break;
    		}
    		else if ( is_player_valid( user ) && user.score >= self.zombie_cost )
    		{
    			user maps/mp/zombies/_zm_score::minus_to_player_score( self.zombie_cost );
    			user_cost = self.zombie_cost;
    			self.chest_user = user;
    			break;
    		}
    		else if ( isdefined( reduced_cost ) && user.score >= reduced_cost )
    		{
    			user maps/mp/zombies/_zm_score::minus_to_player_score( reduced_cost );
    			user_cost = reduced_cost;
    			self.chest_user = user;
    			break;
    		}
    		else if ( user.score < self.zombie_cost )
    		{
    			play_sound_at_pos( "no_purchase", self.origin );
    			user maps/mp/zombies/_zm_audio::create_and_play_dialog( "general", "no_money_box" );
    			wait 0.1;
    			continue;
    		}
    		wait 0.05;
    	}
    	flag_set( "chest_has_been_used" );
    	maps/mp/_demo::bookmark( "zm_player_use_magicbox", getTime(), user );
    	user maps/mp/zombies/_zm_stats::increment_client_stat( "use_magicbox" );
    	user maps/mp/zombies/_zm_stats::increment_player_stat( "use_magicbox" );
    	if ( isDefined( level._magic_box_used_vo ) )
    	{
    		user thread [[ level._magic_box_used_vo ]]();
    	}
    	self thread watch_for_emp_close();
    	if ( isDefined( level.using_locked_magicbox ) && level.using_locked_magicbox )
    	{
    		self thread custom_watch_for_lock();
    	}
    	self._box_open = 1;
    	level.box_open = 1;
    	self._box_opened_by_fire_sale = 0;
    	if ( isDefined( level.zombie_vars[ "zombie_powerup_fire_sale_on" ] ) && level.zombie_vars[ "zombie_powerup_fire_sale_on" ] && !isDefined( self.auto_open ) && self [[ level._zombiemode_check_firesale_loc_valid_func ]]() )
    	{
    		self._box_opened_by_fire_sale = 1;
    	}
    	if ( isDefined( self.chest_lid ) )
    	{
    		self.chest_lid thread treasure_chest_lid_open();
    	}
    	if ( isDefined( self.zbarrier ) )
    	{
    		play_sound_at_pos( "open_chest", self.origin );
    		play_sound_at_pos( "music_chest", self.origin );
    		self.zbarrier set_magic_box_zbarrier_state( "open" );
    	}
    	self.timedout = 0;
    	self.weapon_out = 1;
    	self.zbarrier thread treasure_chest_weapon_spawn( self, user );
    	self.zbarrier thread treasure_chest_glowfx();
    	thread maps/mp/zombies/_zm_unitrigger::unregister_unitrigger( self.unitrigger_stub );
    	self.zbarrier waittill_any( "randomization_done", "box_hacked_respin" );
    	if ( flag( "moving_chest_now" ) && !self._box_opened_by_fire_sale && isDefined( user_cost ) )
    	{
    		user maps/mp/zombies/_zm_score::add_to_player_score( user_cost, 0 );
    	}
    	if ( flag( "moving_chest_now" ) && !level.zombie_vars[ "zombie_powerup_fire_sale_on" ] && !self._box_opened_by_fire_sale )
    	{
    		self thread treasure_chest_move( self.chest_user );
    	}
    	else
    	{
    		self.grab_weapon_hint = 1;
    		self.grab_weapon_name = self.zbarrier.weapon_string;
    		self.chest_user = user;
    		thread maps/mp/zombies/_zm_unitrigger::register_static_unitrigger( self.unitrigger_stub, ::magicbox_unitrigger_think );
    		if ( isDefined( self.zbarrier ) && !is_true( self.zbarrier.closed_by_emp ) )
    		{
    			self thread treasure_chest_timeout();
    		}
    		timeout_time = 105;
    		grabber = user;
    		for( i=0;i<105;i++ )
    		{
    			// SKIPPING with SHIFT
    			if(user sprintButtonPressed() && isplayer( user ) && distance(self.origin, user.origin) <= 100)
    			{
    				self.timedout = 1;
    				if(isDefined(self.zbarrier.weapon_model))
    				{
    					self.zbarrier.weapon_model delete();
    				}
    				self.zbarrier notify( "weapon_grabbed" );
    				break;
    			}
    
    			// SHARING with V
    			if(user meleebuttonpressed() && isplayer( user ) && distance(self.origin, user.origin) <= 100)
    			{
    				level.magic_box_grab_by_anyone = 1;
    				level.shared_box = 1;
    				self.unitrigger_stub run_visibility_function_for_all_triggers();
    				for( a=i;a<105;a++ )
    				{
    					foreach(player in level.players)
    					{
    						if(player usebuttonpressed() && distance(self.origin, player.origin) <= 100 && isDefined( player.is_drinking ) && !player.is_drinking)
    						{
    							player thread treasure_chest_give_weapon( self.zbarrier.weapon_string );
    							a = 105;
    							break;
    						}
    					}
    					wait 0.1;
    				}
    				break;
    			}
    
    			// GRABBING with F
    			if(grabber usebuttonpressed() && isplayer( grabber ) && user == grabber && distance(self.origin, grabber.origin) <= 100 && isDefined( grabber.is_drinking ) && !grabber.is_drinking)
    			{
    				grabber thread treasure_chest_give_weapon( self.zbarrier.weapon_string );
    				break;
    			}
    			wait 0.1;
    		}
    		self.weapon_out = undefined;
    		self notify( "user_grabbed_weapon" );
    		user notify( "user_grabbed_weapon" );
    		self.grab_weapon_hint = 0;
    		self.zbarrier notify( "weapon_grabbed" );
    		if ( isDefined( self._box_opened_by_fire_sale ) && !self._box_opened_by_fire_sale )
    		{
    			level.chest_accessed += 1;
    		}
    		if ( level.chest_moves > 0 && isDefined( level.pulls_since_last_ray_gun ) )
    		{
    			level.pulls_since_last_ray_gun += 1;
    		}
    		thread maps/mp/zombies/_zm_unitrigger::unregister_unitrigger( self.unitrigger_stub );
    		if ( isDefined( self.chest_lid ) )
    		{
    			self.chest_lid thread treasure_chest_lid_close( self.timedout );
    		}
    		if ( isDefined( self.zbarrier ) )
    		{
    			self.zbarrier set_magic_box_zbarrier_state( "close" );
    			play_sound_at_pos( "close_chest", self.origin );
    			self.zbarrier waittill( "closed" );
    			wait 1;
    		}
    		else
    		{
    			wait 3;
    		}
    		if ( isDefined( level.zombie_vars[ "zombie_powerup_fire_sale_on" ] ) && level.zombie_vars[ "zombie_powerup_fire_sale_on" ] || self [[ level._zombiemode_check_firesale_loc_valid_func ]]() || self == level.chests[ level.chest_index ] )
    		{
    			thread maps/mp/zombies/_zm_unitrigger::register_static_unitrigger( self.unitrigger_stub, ::magicbox_unitrigger_think );
    		}
    	}
    	self._box_open = 0;
    	level.box_open = 0;
    	level.shared_box = 0;
    	level.magic_box_grab_by_anyone = 0;
    	self._box_opened_by_fire_sale = 0;
    	self.chest_user = undefined;
    	self notify( "chest_accessed" );
    	self thread custom_treasure_chest_think();
    }
    
    custom_watch_for_lock()
    {
        self endon( "user_grabbed_weapon" );
        self endon( "chest_accessed" );
        self waittill( "box_locked" );
        self notify( "kill_chest_think" );
        self.grab_weapon_hint = 0;
        wait 0.1;
        self thread maps/mp/zombies/_zm_unitrigger::register_static_unitrigger( self.unitrigger_stub, ::magicbox_unitrigger_think );
        self.unitrigger_stub run_visibility_function_for_all_triggers();
        self thread custom_treasure_chest_think();
    }
    
    

    [/code]

    🚀 Play smarter, share faster, and survive longer with the Shared Mystery Box Script!

    GhostRider0125undefined 1 Reply Last reply
    2
    • GhostRider0125undefined Offline
      GhostRider0125undefined Offline
      GhostRider0125
      wrote last edited by GhostRider0125
      #2

      Nice dude! Can please add to be able to get the rest of the perks from the box past the 4 limit so could have an other way to get the rest of the perks😅

      Somebody made it before but when you got the fourth perk it will not give anymore
      its in this little script pack if you're interested 😁
      https://forum.plutonium.pw/topic/38491/share-mystery-box-perks-in-bo3-aats-tranzit-fog-cw-trial-system-scripts

      AdrX003undefined 1 Reply Last reply
      0
      • GhostRider0125undefined GhostRider0125

        Nice dude! Can please add to be able to get the rest of the perks from the box past the 4 limit so could have an other way to get the rest of the perks😅

        Somebody made it before but when you got the fourth perk it will not give anymore
        its in this little script pack if you're interested 😁
        https://forum.plutonium.pw/topic/38491/share-mystery-box-perks-in-bo3-aats-tranzit-fog-cw-trial-system-scripts

        AdrX003undefined Offline
        AdrX003undefined Offline
        AdrX003
        wrote last edited by
        #3

        GhostRider0125 depending on what you want i thinkn (unsure if i got it) you could just merge the perk limit function on the same script or just add the thread from here https://forum.plutonium.pw/post/162265

        GhostRider0125undefined 1 Reply Last reply
        1
        • AdrX003undefined AdrX003

          GhostRider0125 depending on what you want i thinkn (unsure if i got it) you could just merge the perk limit function on the same script or just add the thread from here https://forum.plutonium.pw/post/162265

          GhostRider0125undefined Offline
          GhostRider0125undefined Offline
          GhostRider0125
          wrote last edited by
          #4

          AdrX003 yeah that works but i want it so the perk limit is still 4 when you buy from machines but if you buy from the box you can get the rest😅

          1 Reply Last reply
          0
          • kamuuiiundefined Offline
            kamuuiiundefined Offline
            kamuuii
            wrote last edited by
            #5

            need to be compiled to work

            AdrX003undefined 1 Reply Last reply
            1
            • kamuuiiundefined kamuuii

              need to be compiled to work

              AdrX003undefined Offline
              AdrX003undefined Offline
              AdrX003
              wrote last edited by AdrX003
              #6

              kamuuii nope, plutonium autocompiles/reads the open file normally, with any open source script in its folder before starting a match

              1 Reply Last reply
              0
              • DJseanyBundefined Offline
                DJseanyBundefined Offline
                DJseanyB
                wrote last edited by
                #7

                Always a good shout to give credit to person who wrote the script when reposting!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Donate