PF2/Adding items without recompiling: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "== Overview == When an existing map made for {{tf2|4}} has no grenades or armor, {{pf2|4}} 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. item_armor (Pre-Fortress 2) and item_grenadepack (Pre-Fortress 2) can be added in Hammer like normal, but thi...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Overview ==
When an existing map made for {{tf2|4}} has no grenades or armor, {{pf2|4}} will make all [[item_healthkit_medium|health kits]] and [[item_ammopack_medium|large ammo packs]] give armor and grenades.
When an existing map made for {{tf2|4}} has no grenades or armor, {{pf2|4}} will make all [[item_healthkit_medium|health kits]] and [[item_ammopack_medium|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.
You can leave them as-is, but this solution is imperfect and many maps do not have any large ammo packs at all.
[[item_armor|item_armor (Pre-Fortress 2)]] and [[item_grenadepack|item_grenadepack (Pre-Fortress 2)]] can be added in [[Hammer]] like normal, but this can become tedious for maps without [[VMF]]s available, or community server hosts with enormous map pools and no Hammer experience.
[[item_armor (Pre-Fortress 2)|Armor]] and [[item_grenadepack (Pre-Fortress 2)|grenade packs]] can be added in [[Hammer]] like normal, but this can become tedious for maps without [[VMF]]s 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.
Instead, items can be added to maps without Hammer and only a simple text file.
Line 28: Line 27:


Stand where you would like to place an item like so, and then type <code>getpos 2</code> into console.
Stand where you would like to place an item like so, and then type <code>getpos 2</code> into console.
[[File:pf2_gorge_standing|thumb|It will be placed at your feet.]]
[[File:pf2_gorge_standing.jpg|thumb|It will be placed at your feet.]]


This will give you a big string of text that looks something like this:
This will give you a big string of text that looks something like this:
<code>setpos_exact -5934.707031 3561.709717 32.031250;setang_exact 89.000000 -90.229599 0.000000</code>
<code>setpos_exact -5934.707031 3561.709717 32.031250;setang_exact 89.000000 -90.229599 0.000000</code>
For this we only care about the first 3 numbers:
For this we only care about the first 3 numbers:
<code>-5934.707031 3561.709717 32.031250</code>
<code>-5934.707031 3561.709717 32.031250</code>
And let's round them to fit nicely on the map's grid:
And let's round them to fit nicely on the map's grid:
<code>-5935 3562 32</code>
<code>-5935 3562 32</code>


Line 53: Line 57:


And when you reload the map, your item will have been placed where you were standing.
And when you reload the map, your item will have been placed where you were standing.
[[File:pf2_gorge_newitem|thumb|A new item has appeared.]]
[[File:pf2_gorge_newitem.jpg|thumb|A new item has appeared.]]
 
If it looks out of place you can change the coordinates around, save the file, and reload the map.
If it looks out of place you can change the coordinates around, save the file, and reload the map.
{{Tip|You don't need to restart the game for changes to apply, just reload the map.}}
{{Tip|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.
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]]":
 
And let's add a grenade pack too, in the exact same way but with the name changed to "[[item_grenadepack (Pre-Fortress 2)|item_grenadepack]]":


  map_ents
  map_ents
Line 70: Line 76:
  "angles" "0 0 0"
  "angles" "0 0 0"
  }
  }
 
  "item_grenadepack"
  "item_grenadepack"
  {
  {
Line 82: Line 88:
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.
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.
{{Important|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.}}
{{Important|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.}}
[[File:pf2_gorge_grenade|thumb|Items usually float 16 units off the ground.]]
[[File:pf2_gorge_grenade.jpg|thumb|Items usually float 16 units off the ground.]]

Latest revision as of 08:51, 31 March 2025

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.