Skip to content

[Tutorial] Starting a Server Side Mod Adding a Mutator

kitsune94 edited this page Jan 12, 2013 · 1 revision

In this tutorial we’re going to add a simple mutator to the list. Before we begin, I’d like to acknowledge that the game scripts are written in Torque Script, however, anyone could easily learn it just by studying the scripts in ROTC without any real coding knowledge. It is recommended to use a text editor with syntax highlighting such as Notepad++ or Geany.

Before we start adding in code to perform a new task or change a variable, there are 2 places we have to define stuff in for our mod to become listed in the mutator list. First open up game/arenas/rotc-ethernet/common.cs It will look like this:

$MissionInfo::Type = "\cp\c0ROTC:ETH\c2" SPC $GameVersionString @ "\co";
$MissionInfo::TypeDesc = "Capture all the opposing team's zones to win.";
$MissionInfo::InitScript = "game/server/missions/rotc-eth.cs";
$MissionInfo::MutatorDesc = ""
	@ "temptag\tPlayers are tagged from when they take damage until they're out of enemy LOS\n"
	@ "nevertag\tPlayers are never tagged\n"
	@ "noshield\tDeactivate CAT shields\n"
	@ "lowhealth\tCATs have 50 instead of 75 health\n"
	@ "slowpoke\tMakes the game slow\n"
	@ "superblaster\tReplaces normal blaster with high-powered hitscan version\n"
	@ "QUICKDEATH\tCombo: noshield/lowhealth\n"
	@ "";

This file is the actual list of mutators, how they are read in the game’s ui and by the server itself. To add a mutator to the list, follow the format of ‘@ “(name)\t(description)\n”‘ We’ll add our mod like this right below quick death.

	@ "QUICKDEATH\tCombo: noshield/lowhealth\n"
	@ "ourmod\tDoes something neat\n"

Now that our mutator is defined, lets open up game/server/missions/rotc-eth.cs This is where we make our mutator work when selected. Scroll down till we see this block:

function initMission()
{
   	if(isObject($Server::Game))
		$Server::Game.delete();
	$Server::Game = new ScriptObject();
	$Server::Game.mutators = "";
	$Server::Game.alwaystag = -1;
	$Server::Game.nevertag  = 0;
	$Server::Game.temptag   = 1;
	$Server::Game.tagMode = $Server::Game.alwaystag;
   	$Server::Game.slowpokemod = 1.0;
	%recognized = "";
	for(%i = 0; %i < getWordCount($Pref::Server::Mutators); %i++)
	{
   		%mutator = getWord($Pref::Server::Mutators, %i);
		if(%mutator $= "temptag")
		{
		 %recognized = %mutator SPC %recognized;
			$Server::Game.tagMode = $Server::Game.temptag;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "nevertag")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.tagMode = $Server::Game.nevertag;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "noshield")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.noshield = true;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "lowhealth")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.lowhealth = true;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "slowpoke")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.slowpoke = true;
			$Server::Game.slowpokemod = 0.5;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "superblaster")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.superblaster = true;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "QUICKDEATH")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.noshield = true;
			$Server::Game.lowhealth = true;
			$Server::Game.mutators = $Server::Game.mutators SPC
				"noshield" SPC "lowhealth";
		}
	}

For this tutorial we are going to add two things. A global variable and a global boolean. First add our variable underneath ‘$Server::Game.slowpokemod = 1.0;’ following its syntax. Like this:

	$Server::Game.slowpokemod = 1.0;
	// We added this variable
	$Server::Game.ourVar = 1.0;
	%recognized = "";

Now scroll down and copy the quickdeath mutator underneath itself and change it to be like this:

		else if(%mutator $= "ourmod")
		{
			$Server::Game.ourmod = true;
			$Server::Game.ourVar = 5.0;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}

Our block should now look like this:

function initMission()
{
	if(isObject($Server::Game))
		$Server::Game.delete();
	$Server::Game = new ScriptObject();
	$Server::Game.mutators = "";
	$Server::Game.alwaystag = -1;
	$Server::Game.nevertag  = 0;
	$Server::Game.temptag   = 1;
	$Server::Game.tagMode = $Server::Game.alwaystag;
	$Server::Game.slowpokemod = 1.0;
	// We added this variable
	$Server::Game.ourVar = 1.0;
	%recognized = "";
	for(%i = 0; %i < getWordCount($Pref::Server::Mutators); %i++)
	{
		%mutator = getWord($Pref::Server::Mutators, %i);
		if(%mutator $= "temptag")
		{
		 %recognized = %mutator SPC %recognized;
			$Server::Game.tagMode = $Server::Game.temptag;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "nevertag")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.tagMode = $Server::Game.nevertag;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "noshield")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.noshield = true;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "lowhealth")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.lowhealth = true;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "slowpoke")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.slowpoke = true;
			$Server::Game.slowpokemod = 0.5;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;    
		}
   		else if(%mutator $= "superblaster")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.superblaster = true;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
		else if(%mutator $= "QUICKDEATH")
		{
		%recognized = %mutator SPC %recognized;
			$Server::Game.noshield = true;
			$Server::Game.lowhealth = true;
			$Server::Game.mutators = $Server::Game.mutators SPC
				"noshield" SPC "lowhealth";
		}
		// We Added This
		else if(%mutator $= "ourmod")
		{
			$Server::Game.ourmod = true;
			$Server::Game.ourVar = 5.0;
			$Server::Game.mutators = %mutator SPC $Server::Game.mutators;
		}
	}

Our mutator will now work, however it does nothing. Lets open up game/server/base/cats/standard/standard.cs and scroll down to “datablock PlayerData(RedStandardCat)” and find “maxEnergy = 100″ Change it to look like this:

	// maxEnergy = 100;
 	maxEnergy = 100 * $Server::Game.ourVar;

Now underneath the datablock portion we should see:

if($Server::Game.noshield)
	RedStandardCat.damageBuffer = 0;
 
if($Server::Game.lowhealth)
	RedStandardCat.maxDamage = 50;

Right beneath this add:

if($Server::Game.ourmod)
	RedStandardCat.maxDamage = 200;

You should now be able to start the game, select your mutator and see that we now have 200 health and 500 energy. Congratulations, you’ve successfully added your first mutator. Coming soon will be adding a game type such as instagib.

Clone this wiki locally