//ServerRandomizer v2.0 //Keeps server cycling random -- much more interesting! //by dun_Starscaper //Last modified 06/02/2005 //For use with MOTDGen (currently unreleased) $ServerRandomizer::Version = "2.0"; //Execute this file at the end of a dedicated server file to enable random //mission cycling. Do NOT execute more than once in the same server session. // //If you are running an auto-cycling server, such as most DM, CTF, WAR, C&D, //and CnH servers, this script will run as intended. If you have a gametype such //as Harvester or a multiplayer campaign, in which the mission is not ended by //a timer, you will have to define a variable called $ServerRandomizer::GameLength //that contains your estimate for how long a match will actually take. Otherwise, //the server will begin to cycle through a fixed pattern, although the mission //order within that pattern will still be random. function getNumMissions() { for(%count = 0; $MissionCycling::Stage[%count] != ""; %count++) %foo = 0; return %count; } function randomizeMissions() { %numMissions = getNumMissions(); if(%numMissions <= 0) { echo("********************************ERROR: No missions to randomize!"); return; } //The list is duplicated in order to prevent periodic behavior //To achieve this, maxGames must be greater than or equal to the //number of matches ran before the server reboots if($ServerRandomizer::GameLength == "") $ServerRandomizer::GameLength = $server::TimeLimit; %maxGames = 2 * 1440 / $ServerRandomizer::GameLength; //Assume 2-day server just to be safe for(%i = 0; %i < %maxGames; %i += %numMissions) scrambleMissions(%numMissions, %i); $server::Mission = $MissionCycling::Stage0; } function scrambleMissions(%numMissions, %base) { //Store into a temporary variable because don't always want to alter originals for(%i = 0; %i < %numMissions; %i++) %temp[%i] = $MissionCycling::Stage[%i]; for(%i = 0; %i < %numMissions - 1; %i++) { %j = randomInt(%i, %numMissions - 1); %temp = %temp[%j]; %temp[%j] = %temp[%i]; %temp[%i] = %temp; } for(%i = 0; %i < %numMissions; %i++) $MissionCycling::Stage[%base + %i] = %temp[%i]; } randomizeMissions();