PF2/Adding items without recompiling

From Valve Developer Community
Jump to navigation Jump to search

When an existing map made for Team Fortress 2 Team Fortress 2 has no grenades or armor, Pre-Fortress 2 Pre-Fortress 2 will make all health kits and large ammo packs give armor and grenades. You can leave them as-is, but this solution is imperfect and many maps do not have any large ammo packs at all. Armor and grenade packs can be added in Hammer like normal, but this can become tedious for maps without VMFs available, or community server hosts with enormous map pools and no Hammer experience.

Instead, items can be added to maps without Hammer and only a simple text file.

Tip.pngTip:If you are playtesting a work-in-progress map, you can also spawn all items this way to quickly iterate item placements without making players download new versions every time.

Creating _map_ents.txt

First, create a file in the same folder as yourmap.bsp titled yourmap_map_ents.txt. In this demonstration we are adding items to a regular Team Fortress 2 TF2 map, cp_gorge.bsp, as an example: cp_gorge_map_ents.txt

map_ents
{
	cp_gorge
	{
		"item_armor"
		{
			"origin"	"0 0 0"

			"angles"	"0 0 0"
		}
	}
}

At runtime, this will spawn a single armor item at the origin of the world. To change the location, you will need coordinates.

Stand where you would like to place an item like so, and then type getpos 2 into console.

It will be placed at your feet.

This will give you a big string of text that looks something like this:

setpos_exact -5934.707031 3561.709717 32.031250;setang_exact 89.000000 -90.229599 0.000000

For this we only care about the first 3 numbers:

-5934.707031 3561.709717 32.031250

And let's round them to fit nicely on the map's grid:

-5935 3562 32

Now you can change "origin" like so:

map_ents
{
	cp_gorge
	{
		"item_armor"
		{
			"origin"	"-5935 3562 32"

			"angles"	"0 0 0"
		}
	}
}

And when you reload the map, your item will have been placed where you were standing.

A new item has appeared.

If it looks out of place you can change the coordinates around, save the file, and reload the map.

Tip.pngTip:You don't need to restart the game for changes to apply, just reload the map.

Here the item looks out of place on the floor next to items that are floating, so let's bump up the third number (Z) by 16 units, to 48.

And let's add a grenade pack too, in the exact same way but with the name changed to "item_grenadepack":

map_ents
{
	cp_gorge
	{
		"item_armor"
		{
 			"origin"	"-5935 3562 48"

			"angles"	"0 0 0"
		}

		"item_grenadepack"
		{
			"origin"	"-6096 3562 48"

			"angles"	"0 0 0"
		}
	}
}

Now we have successfully added two items to a map without having to edit it in any way. Repeat as many times as you'd like.

Icon-Important.pngImportant:Placing at least one grenade pack or armor in a map will disable receiving any armor or grenades from all health kits and ammo packs, so make sure to place several to account for this.
Items usually float 16 units off the ground.