Call of Duty 4: Gametypes

From COD Modding & Mapping Wiki
Jump to navigation Jump to search

by Tally

Adding CTF/CTFB to your new map is easy. The only level requirement is that you must have SAB spawn points. (if you dont have SAB spawns, it can still be done)

Essentailly, I spawn a trigger_radius for each team's flag. I give each team's trigger_radius a targetname which the code in the CTF/CTFB gametypes looks for. It then dynamically spawns a flag model onto that trigger_radius.

All you have to do is copy the level GSC template below and use it for your own map:

  • Here is the level GSC from mp_backlot used in AWE4 for CTF and CTFB:
main()
{
	maps\mp\mp_backlot_fx::main();
	maps\createart\mp_backlot_art::main();
	maps\mp\_load::main();	
	
	maps\mp\_compass::setupMiniMap("compass_map_mp_backlot");

	//setExpFog(500, 2200, 0.81, 0.75, 0.63, 0);
	//VisionSetNaked( "mp_backlot" );
	ambientPlay("ambient_backlot_ext");

	game["allies"] = "marines";
	game["axis"] = "opfor";
	game["attackers"] = "axis";
	game["defenders"] = "allies";
	game["allies_soldiertype"] = "desert";
	game["axis_soldiertype"] = "desert";

	setdvar( "r_specularcolorscale", "1" );

	setdvar("r_glowbloomintensity0",".25");
	setdvar("r_glowbloomintensity1",".25");
	setdvar("r_glowskybleedintensity0",".3");
	setdvar("compassmaxrange","1800");

	// CTF/B code starts here
	if( getDvar("g_gametype") == "ctf")
	{
		addobj("allied_flag", (-486, 1998, 64), (0, 0, 0));
		addobj("axis_flag", (630, -2067, 64), (0, 0, 0));
	}

	if(getDvar("g_gametype") == "ctfb")
	{
		addobj("allied_flag", (-486, 1998, 64), (0, 0, 0));
		addobj("axis_flag", (630, -2067, 64), (0, 0, 0));
	}
}

addobj(name, origin, angles)
{
   ent = spawn("trigger_radius", origin, 0, 48, 148);
   ent.targetname = name;
   ent.angles = angles;
}
  • Use the code above for CTF and CTFB (not all of the level code, of course - just the relevant CTF, and CTFB bits. You dont want mp_backlot code in your map), and copy/paste it into your own map's GSC file.
  • Notice the coordinates such as (-486, 1998, 64)? You have to change them to suit your map. Here's how:
  • Go into your map, and go to the point that you think the allied flag should go.
  • Drop down console and type:
/viewpos
  • Close
  • Go to the next place, you think the axis flag should go, and do the same viewpos.
  • Come out of your map.
  • Look in the fs_game mod folder for the mp_console.log file, and open it.
  • Find the viewpos coordinates you just did, and copy/paste them into the relevant teams code.
  • Once in your map GSC file, subtract 60 from the 'z' corodinate ( they are listed like this - (x, y, z)). This is because viewpos is taken from the players eye level, and floor level is 60 units less than the eye level.
Make sure the right coordinates go with the right team - remember: allies have the "allied_flag" targetname; axis the "axis_flag" targetname.
  • You can now either compile your map's GSC file into your map's fast file, or simply include it in your map's IWD file.


CTF/CTFB is now included in most mods, such as AWE4, ACE and X4.