Randomised Map Rotation In Custom Games
-
I want to run a custom games match, not a local server with bots and a randomised map rotation, not vote, randomised. How do I do this, or is it even possible. Thanks
-
Not sure if there is a pre-made solution but you can simply write that in GSC.
Set a map rotation on the client, split it up in your GSC script, choose a random map and switch to that map.
Should be a simple beginner project to start learning GSC. -
Xerxes moved this topic from BO2 Client Support
-
For anyone wondering, here was the code that ended up working in the end. To go in the scripts folder.
#include maps\mp_utility;
#include maps\mp\gametypes_hud_util;main()
{
level thread bot_lobby_monitor();
}bot_lobby_monitor()
{
level waittill("prematch_over");score_limit = getDvarInt("scr_war_scorelimit"); time_limit = getDvarInt("scr_war_timelimit"); if(score_limit <= 0) { score_limit = 75; } if(time_limit <= 0) { time_limit = 10; } time_limit_seconds = time_limit * 60; elapsed_seconds = 0; while(1) { // Check Score Conditions if (isDefined(game["teamScores"]["allies"]) && game["teamScores"]["allies"] >= score_limit) { wait 5; force_next_random_map(); break; } if (isDefined(game["teamScores"]["axis"]) && game["teamScores"]["axis"] >= score_limit) { wait 5; force_next_random_map(); break; } // Check Time Conditions if (elapsed_seconds >= time_limit_seconds) { wait 5; force_next_random_map(); break; } // Handle Natural or Manual Break Ends if(isDefined(level.gameEnded) && level.gameEnded) { if(isDefined(level.forcedEnd) && level.forcedEnd) { return; } wait 5; force_next_random_map(); break; } wait 0.5; elapsed_seconds += 0.5; }}
force_next_random_map()
{
// FIX: Manually starting the index at 0 so the array initializes perfectly
maps[0] = "mp_carrier";
maps[maps.size] = "mp_cargo";
maps[maps.size] = "mp_drone";
maps[maps.size] = "mp_express";
maps[maps.size] = "mp_hijacked";
maps[maps.size] = "mp_meltdown";
maps[maps.size] = "mp_nuketown_2020";
maps[maps.size] = "mp_overflow";
maps[maps.size] = "mp_plaza";
maps[maps.size] = "mp_raid";
maps[maps.size] = "mp_slums";
maps[maps.size] = "mp_standoff";
maps[maps.size] = "mp_turbine";
maps[maps.size] = "mp_yemen";// DLC 1 maps[maps.size] = "mp_downhill"; maps[maps.size] = "mp_mirage"; maps[maps.size] = "mp_hydro"; maps[maps.size] = "mp_skate"; // DLC 2 maps[maps.size] = "mp_concert"; maps[maps.size] = "mp_magma"; maps[maps.size] = "mp_studio"; maps[maps.size] = "mp_vertigo"; // DLC 3 maps[maps.size] = "mp_uplink"; maps[maps.size] = "mp_bridge"; maps[maps.size] = "mp_castaway"; maps[maps.size] = "mp_paintball"; // DLC 4 maps[maps.size] = "mp_dig"; maps[maps.size] = "mp_frostbite"; maps[maps.size] = "mp_pod"; maps[maps.size] = "mp_takeoff"; random_map = maps[ randomInt( maps.size ) ]; // Change the global rotation variable so the game picks it up when transitioning setDvar("g_gametype", "war"); setDvar("sv_mapRotation", "gametype war map " + random_map); setDvar("sv_mapRotationCurrent", "gametype war map " + random_map); // Override the UI lobby pointers directly setDvar("ui_mapname", random_map); setDvar("mapname", random_map); // Command the engine to progress immediately to the rotation we just established exitLevel( false );}
-
You can always take a mapvote script, such as mine, and make it rotate directly instead of displaying the vote by editing the code a little bit
I've edited mine for some people before for this use case and it's just a few lines, would gladly send it to you if you wish
-
Yes please, how would it improve it, would it be more efficient or consistent.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login