PF2/Adding items without recompiling: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
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 (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 31: | Line 30: | ||
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 54: | Line 58: | ||
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.jpg|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" | ||
{ | { |
Latest revision as of 08:51, 31 March 2025
When an existing map made for Team Fortress 2 has no grenades or armor,
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.

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 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.
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.
If it looks out of place you can change the coordinates around, save the file, and 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.
