75 ratings
Contagion SDK Tutorial - The Hunt
By | 非現実的な | DeRaNgEr | and 1 collaborators
In this tutorial I will go over all the basics that are required to create a full fledged map for "The Hunt" Game mode.
Hi my name is Joure and I’m the lead level designer on Contagion. I’ll be guiding you through
a series of tutorials to help you understand the inner workings of the Contagion SDK. I intend to cover as many aspects per tutorial so that beginners will be able to pick it up easily with a basic knowledge of Hammer (You should be able to create a simple map at least before trying to add gameplay). I hope these tutorials will inspire you to go out there and create some awesome new content.
The Hunt (ch_) In a nutshell
The Hunt is a PVP Game mode with zombies tossed into the mix. It's a Free For All game mode where the last man standing wins the round. This is the easiest game mode to implement which is a solid basis to start getting used to Contagion SDK's custom entities.
Here's a brief overview of what entities are needed for this game mode. We'll go over how to properly implement them in the next section.

  • info_survivor_position: In the Hunt you don't really need these but add them in anyway. It's Contagion's version of the "player_start" entity from Half Life 2.

  • trigger_zombie_spawns: This is a brush based entity class which triggers what area zombies can spawn in. The brush is covered with the "tools/toolszombiespawn" material. You need to create a script file in order to spawn zombies into the map.

  • logic_script: You'll need these to define which script is being referenced in your map. We'll cover implementing these into your map in the next section.

  • info_random_weapon: This entity is used to spawn random weapons in designated areas. You'll need script file in order to determine which weapon is spawned and how many.

  • info_random_ammo: This entity is used to spawn random Ammunition in designated areas. You'll need a script file in order to determine which ammunition is spawned and how many. It uses the same script as the "info_random_weapon" script. More information on this entity in the next section.
Setting up the entities
Example map: ch_tutorial.vmf
You;ll have to download the files [] and put the "ch_tutorial" folder here: "contagion\addons\"
Note: The example map covered in this tutorial is not built for actual gameplay but for a functional game mode only.

Map Prefix
Each game mode comes with a prefix before the map name itself. This is to determine what game mode is associated with your map. So if you name your map "deadcell" or something and it's a hunted map, the full name of your map should be "ch_deadcell". This is all determined in the game's code, so there's no way around it.

Navigational Meshes
Before anything the first thing you should do when you get to playtest your map is to create a navmesh. Without it players will spawn at 0.0.0. coordinates even if you've added a "info_survivor_position". To do this just load up your map in-game and turn on cheats in the console. Then type in "nav_edit 1. If you're stuck then noclip your way to one of the playable areas and make sure you're facing towards the ground.

Now you have to create a point of reference for the navmesh generator. Simply type "nav_mark_walkable" into the console while facing the ground and hit enter. You should see a marker on the floor like this one:

You're almost there, next you type "nav_generate" into the console and the game will run through a series of processes to generate the navmesh. After that you're set, well, at least for now. Navmeshes need a lot of cleanup. You can find out more here. You should be able to start the map and have no issues spawning into the map anymore.

Zombie Spawns
Now that we've got all that out of the way let's start with actually implementing our entities. We'll start with making zombies appear in our map. Go to your "SteamApps\common\Contagion\bin" folder (or "SteamApps\common\ContagionBeta\bin" if you have the game installed since Early Access) and double click "ContagionSDK.exe" This will start up the Contagion SDK where you'll find all the tools you need like hammer for instance.

Open your map and determine which area(s) you want to spawn your zombies. Then, simply create a brush covering the desired area and cover the brush with the tools/toolszombiespawn texture as shown in the image below.

Once you created your brush you hit Ctrl+T to create a brush entity. By default this should be a "func_detail". Once you created the brush entity seach for and select the "trigger_zombie_spawns" under the class tab.

Now that you've created the zombie trigger you have to name it. As a rule of thumb during game creation you have to stick to solid and logical naming conventions that make sense and are coherent so that when you make a new map your basis is already laid out. In this case we go for "zspawn_start". The name of the zombie trigger will be directly referenced in the VScript itself but we'll get there shortly.
Note: Zombie triggers use the navmesh to determine if and where zombies can spawn.
Note: Be aware that zombie spawns use player visibility so that no zombies will spawn inside any players line of sight.

Next you want to add a "logic_script" and give it a name: script_zombiespawns is a good naming convention. Now you'll need a an actual VScript associated with your map. For this tutorial I created a script called "ch_tutorial_zombiespawns.nut" which should be located in "contagion\addons\ch_tutorial\scripts\vscripts"(see the download link on top of this section). Use this script name for the VScripts without the extension. (See image below)

For the final part to make the zombies spawn you'll need to call a script command. We'll need a "logic_auto" for that. So go ahead and create one. Then give it the following outputs:

I'll go over the VScript itself very briefly.
As you can see you're able to control how many zombies spawn for each difficulty and depending on the size of your map you should set it to an acceptable number. This will require playtesting to make sure each game mode is properly set up.
Note: The number of zombies in this game mode are constant. If one dies another one will pop up. This is to keep the pressure on the survivors so they won't be able to stay in one place for too long.

Now take a look at line #8 and #9, it reads the following:
// Enable the spawns for the zombies.
DoEntFire( "zspawn_start", "enable", "", 0, 0, 0 );

You should notice the zombie trigger name "zspawn_start" so it means that the "logic_auto" will run the "DoEntFire" command which points to the "zspawn_start" brush. Now save your map, compile and test it out. Again, make sure you created a navmesh for your map otherwise, nothing will happen.

info_random_weapon & info_random_ammo
What are zombies in your game without additional firearms and melee weapons, right? So let's fix that.

We've already created a "logic_script" inside the map for our zombie spawns, now we need to create another one for our weapon and ammunition spawns. Create one and once again use a good naming convention. I went with "script_weapons". I also created a VScript for this tutorial called "ch_tutorial_weapons.nut" also located inside the "contagion\addons\ch_tutorial\scripts\vscripts" folder. So choose that script name in the "logic_script" properties to reference the correct script. Then open up the "logic_auto" again and set it up like so:

Now browse though the available list of entities and search for "info_random_weapon" and start placing them in logical places around the map. Don't try to hide them too much and make sure that most of them are easily found. You can hide some of them a bit more cleverly as to (potentionally) reward exploring players.

After that you can search for the "info_random_ammo" entity and also start adding these to the map. You should end up with a lot more of these, since ammunition is more common then actual weaponry.

Once that is done the script should be set up and you have actual spawn positions for all your weapons and ammo. Compile your map again and go test it out. Make sure you think about weapon and ammo balance so that there is no abundance or lack of the amount of weapons players will find.

On some of our maps we've sectioned off entire areas that have weapon and ammo spawns. Our system is incredibly random but will never spawn weapons in one place only. So just make sure it's all evened out and it should be fine.
I hope this tutorial is clear enough and will have you be making Hunted maps in no time. I'll update this tutorial if needed because I haven't written any tutorials before. If you have any questions just post them here and I will try to get back to you as soon as possible. Thank you for reading and good luck !!!
< >
Slick Mar 10 @ 10:09am 
Did the game change too much since this tutorial's release? Zombies don't spawn when I run this map.
Anonymous Jan 19 @ 5:24am 
how do you make custom flashlighs, if you can link me to a good tutorial that would be great, thx :)
johnebchief Jan 15 @ 6:10am Will this tutorial help set up? Anything additional we need?
| 非現実的な | DeRaNgEr |  [author] Sep 7, 2014 @ 1:22pm 
@ Tabajara: Double, tripple check everything that links to the script file. Script name, entity names. Rule of thumb is to copy and paste the names from hammer to vscript, or vice versa, so you can rule out spelling errors that way. Scripts can get very tedious and the slightest mistake can stop a script from running.

@ Woodstock: Open the "ContagionSDK.exe" which can be found in the same bin folder.

@ Tabajara: Make sure to put player clips in the areas you don't want players to spawn. In hunted the navmesh is being used to spawn survivors at random, clipping off these areas will prevent this from happening. :)

@:TF: Tony Neechmo Wrong section but we are still working on getting voting options sorted in Contagion.
:TF: Madkatmk11 Aug 30, 2014 @ 9:35pm 
can anyone tell me how to get map voting working on my server i tried sev things and can't fig it out
Tabajara Aug 3, 2014 @ 8:10pm 
Question: Why survivors are spawning on zombie spawn trigger, since i already added the survivor spawn entitie?
\/\/oodstock Aug 3, 2014 @ 7:20pm 
i am opening editor in contagion bin folder
\/\/oodstock Aug 3, 2014 @ 7:17pm 
when i open the hammer editor it has a bunch of errors, something about missing half life 2 textures, my game folder doesnt exist amongst other things, and u please write a small tutorial on configuring settings
Tabajara Aug 3, 2014 @ 3:55pm 
I can't make my scropt for weapons work following this tutorial. Did something change? Zombie spawns works, but the random weapons don't spawn.
the-videogame Jul 24, 2014 @ 2:29am 
Could you kindly please give some hints on how to change the background of the cell phone?