This article's documentation is for anything that uses the Source engine. Click here for more information.

Map edit: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎Introduction: moved the note about hammer_update_entity higher up)
No edit summary
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:map_edit}}
{{this is a|console command|name=map_edit}}
The <code>map_edit</code> and <code>hammer_update_entity</code> [[console]] commands can be used to update entity data while running a .[[BSP]], then sending the changes to [[Hammer]] to commit the changes to the .[[VMF]] file. The <code>map_edit</code> command is commonly used to change node positions or to update physics props after they have done their initial settling.


== Introduction ==
The <code>map_edit <mapname></code> command is used to load a .BSP for editing. This command creates a connection between the engine and the Hammer editor so that data can be transferred. Before using <code>map_edit</code>, you must compile the map with the current version of the associated .VMF, then load the map in Hammer. The map versions of the .BSP and the .VMF must match exactly. If they do not match, no editing is possible.
The <code>map_edit</code> and <code>wc_update_entity</code> (or <code>hammer_update_entity</code> for games running on post-[[Orange Box]] branches) [[console]] commands can be used to update entity data while running a map in the engine, then sending the changes to Hammer to commit the changes to the .VMF file. The <code>map_edit</code> command is commonly used to change node positions or to update physics props after they have done their initial settling.


The <code>map_edit <mapname></code> command is used to load a .[[BSP]] for editing. This command creates a connection between the engine and the Hammer editor so that data can be transferred. Before using <code>map_edit</code>, you must compile the map with the current version of the associated .VMF, then load the map in Hammer. The map versions of the .BSP and the .VMF must match exactly. If they do not match, no editing is possible.
{{note|{{hammerpp|2}} allows editing with mismatched map versions.}}


Once a map is loaded with <code>map_edit</code>, the <code>wc_update_entity <entity name></code> command is used to send the updated position and angles for the named entities back to the Hammer editor. When using <code>wc_update_entity</code> (or <code>hammer_update_entity</code>), you can use the targetname of a single entity to update, or use an entity classname (i.e. [[prop_physics]]) to update all entities in the map of that type. Every time <code>wc_update_entity</code> (or <code>hammer_update_entity</code>) is invoked, the position and angle of the entities is sent to the editor.
Once a map is loaded with <code>map_edit</code>, the <code>hammer_update_entity <entity name></code> command is used to send the updated position and angles for the named entities back to the Hammer editor. When using <code>hammer_update_entity</code>, you can use the targetname of a single entity to update, or use an entity [[classname]] (i.e. {{ent|prop_physics}}) to update all entities in the map of that type. Every time <code>hammer_update_entity</code> is invoked, the position and angle of the entities is sent to the editor.


{{note|Only the position and angle of [[Point entities]] can be updated in this way. [[Brush entities]] and other brushes cannot be modified using <code>wc_update_entity</code> (or <code>hammer_update_entity</code>). See [[Introduction to Editing]] for a description of entity types.}}
{{note|Only the position and angle of [[point entities]] can be updated in this way. [[Brush entities]] and other brushes cannot be modified using <code>hammer_update_entity</code>. See [[Introduction to Editing]] for a description of entity types.}}


{{note|In the Orange Box, <code>wc_update_entity</code> has been discontinued and replaced by <code>[[hammer_update_entity]]</code>, which seems to work in an identical fashion.}}
{{note|Prior to the [[Orange Box]] engine branch, <code>hammer_update_entity</code> was named <code>wc_update_entity</code>.}}


== Using map_edit to settle physics props ==
==Using map_edit to settle physics props==
You can use the <code>map_edit</code> command to update your .VMF with the positions of physics props after they've been settled into their final position by the game's physics system. This saves valuable CPU cycles at the start of the map, as well as preventing props from visually "dropping" into place when the map is loaded or a new round begins (in a multiplayer game).
You can use the <code>map_edit</code> command to update your .VMF with the positions of physics props after they've been settled into their final position by the game's physics system. This saves valuable CPU cycles at the start of the map, as well as preventing props from visually "dropping" into place when the map is loaded or a new round begins (in a multiplayer game).


To use <code>map_edit</code> to update the position of [[prop_physics]] or [[prop_physics_multiplayer]] or entities:
To use <code>map_edit</code> to update the position of <code>prop_physics</code> or {{ent|prop_physics_multiplayer}} or entities:
#Load the map in Hammer.
#Compile the map to make sure the contents of the .BSP are identical to the current .VMF you have open. '''Do not''' make any changes or even save the map after compiling, or the edit will fail. Remember to turn off auto-saves in Hammer if you have them on.
#Start the game (windowed mode works best).
#At the console, type <code>map_edit <mapname></code> and the map will load (i.e. <code>map_edit de_inferno</code>).
#After the map loads, wait a few moments for the physics props to settle.
#Open the console and type <code>hammer_update_entity prop_physics</code> or <code>hammer_update_entity prop_physics_multiplayer</code>, depending on what type of props you are using.
#Switch back over to Hammer. The locations of the physics props should be updated. Save your changes to the map.
#Recompile the map, and the physics props will start in the "settled" positions.


# Load the map in Hammer.
You should now be able to safely mark many of the props with the ''Start Asleep'' flag. This will provide additional performance savings because no physics calculation will occur for the prop until it is acted upon by a physics force that would move it.
# Compile the map to make sure the contents of the .BSP are identical to the current .VMF you have open. '''Important:''' Do not make any changes or even save the map after compiling, or the edit will fail! Remember to turn off auto-saves in Hammer if you have them on!
# Minimize Hammer.
# Start the game (windowed mode works best).
# At the console, type <code>map_edit <mapname></code> and the map will load (i.e. <code>map_edit de_inferno</code>).
# After the map loads, wait a few moments for the physics props to settle.
# Open the console and type <code>wc_update_entity prop_physics</code> or <code>wc_update_entity prop_physics_multiplayer</code>, depending on what type of props you are using. (Here and below, replace <code>wc_update_entity </code> with <code>hammer_update_entity</code> if necessary.)
# Type <code>quit</code> to exit the game.
# Switch back over to Hammer. The locations of the physics props should be updated.
# Check the results, then save your changes to the map.
# Recompile the map, and the physics props will start in the "settled" positions.


You should now be able to safely mark many of the props with the <code>Start Asleep</code> flag. This will provide additional performance savings because no physics calculation will occur for the prop until it is acted upon by a physics force that would move it.
==Editing [[node graph]]s in-game==
[[File:map_edit_groundnode.jpg|thumb|300px|right|Editing ground nodes in the engine.]]


== Editing node graphs in-game ==
The <code>map_edit</code> command can also be used to edit various AI [[node]]s and node connections in the engine instead of Hammer. When using <code>map_edit</code> in this way, it is not necessary to use <code>hammer_update_entity</code> - any nodes changes are automatically sent to the Hammer editor as the changes are made in the engine.
''For more information, see the [[Nodegraph]] page.''
 
[[Image:map_edit_groundnode.jpg|thumb|300px|right|Editing ground nodes in the engine.]]
 
The <code>map_edit</code> command can also be used to edit various AI nodes and node connections in the engine instead of Hammer. When using <code>map_edit</code> in this way, it is not necessary to use <code>wc_update_entity</code> - any nodes changes are automatically sent to the Hammer editor as the changes are made in the engine.


The basic process is this:
The basic process is this:
#Load the map in Hammer.
#Compile the map to make sure the contents of the .BSP are identical to the current .VMF you have open. '''Do not''' make any changes or even save the map after compiling, or the edit will fail.
#Minimize Hammer.
#Start the game (windowed mode works best).
#At the console, type <code>map_edit <mapname></code> and the map will load (i.e. <code>map_edit sdk_d1_trainstation_01</code>).
#Use the node editing console commands (see below) to edit the nodes, primarily <code>wc_create</code> and <code>wc_destroy</code>. Many of these commands are bound to keys by default. See the section about key binding below.
#Type <code>quit</code> to exit the game.
#Switch back over to Hammer. Your changes to the nodes should be completed.
#Check the results, then save your changes to the map.
#Recompile the map with the nodes changes in place.


# Load the map in Hammer.
===Node display commands===
# Compile the map to make sure the contents of the .BSP are identical to the current .VMF you have open. '''Important:''' Do not make any changes or even save the map after compiling, or the edit will fail!
# Minimize Hammer.
# Start the game (windowed mode works best).
# At the console, type <code>map_edit &lt;mapname&gt;</code> and the map will load (i.e. <code>map_edit sdk_d1_trainstation_01</code>).
# Use the node editing console commands (see below) to edit the nodes, primarily <code>wc_create</code> and <code>wc_destroy</code>. Many of these commands are bound to keys by default. See the section about key binding below.
# Type <code>quit</code> to exit the game.
# Switch back over to Hammer. Your changes to the nodes should be completed.
# Check the results, then save your changes to the map.
# Recompile the map with the nodes changes in place.<br style="clear:both">
 
=== Node display commands ===
These are the basic commands for displaying various node data.
These are the basic commands for displaying various node data.


* <code>[[ai_show_connect]]</code>
*{{ent|ai_show_connect}}
** Toggle displaying ground node connections.
**Toggle displaying ground node connections.


* <code>ai_show_connect_jump</code>
*{{ent|ai_show_connect_jump}}
** Toggle display of jump connections between nodes.
**Toggle display of jump connections between nodes.


* <code>ai_show_connect_fly</code>
*{{ent|ai_show_connect_fly}}
** Toggle display of fly connections between nodes.
**Toggle display of fly connections between nodes.


* <code>ai_nodes</code>
*{{ent|ai_nodes}}
** Display all nodes. Useful for spotting nodes without any connections to them. Entering the command twice will also display the Hammer ID of the node.
**Display all nodes. Useful for spotting nodes without any connections to them. Entering the command twice will also display the Hammer ID of the node.


* <code>ai_show_hull</code>
*{{ent|ai_show_hull}}
** Displays the allowed hulls between each node for the currently selected hull type. Hulls are color code as follows:
**Displays the allowed hulls between each node for the currently selected hull type. Hulls colors are as follows:
*** Green - Ground movement connection. Only usable by NPCs that move on the ground.
***Green: Ground movement connection. Only usable by NPCs that move on the ground.
*** Blue - Jump movement connection. Only usable by NPCs that can jump.
***Blue: Jump movement connection. Only usable by NPCs that can jump.
*** Cyan - Fly movement connection. Only usable by NPCs that can fly.
***Cyan: Fly movement connection. Only usable by NPCs that can fly.
*** Magenta - Climbing movement.
***Magenta: Climbing movement.


* <code>ai_next_hull</code>
*{{ent|ai_next_hull}}
** Display the next [[NPC Hull]] size. Cycles through the various hull sizes. Currently selected hull size is written to the screen.  Controls which connections are shown when ai_show_hull or ai_show_connect commands are used.
**Display the next [[NPC Hull]] size. Cycles through the various hull sizes. Currently selected hull size is written to the screen.  Controls which connections are shown when <code>ai_show_hull</code> or <code>ai_show_connect</code> commands are used.


=== Node editing commands ===
===Node editing commands===
These are commands that are used to actually add and remove nodes.
These are commands that are used to actually add and remove nodes.


* <code>wc_create</code>
*<code>wc_create</code>
** Creates a node where the player is looking if a node is allowed at that location for the currently selected hull size (see [[NPC Hull]])
**Creates a node where the player is looking if a node is allowed at that location for the currently selected hull size (see [[NPC Hull]])


* <code>wc_destroy</code>
*<code>wc_destroy</code>
** Destroys the node that the player is nearest to looking at. The node will be highlighted by a red box.
**Destroys the node that the player is nearest to looking at. The node will be highlighted by a red box.


* <code>wc_destroy_undo</code>
*<code>wc_destroy_undo</code>
** Restores the last deleted node.
**Restores the last deleted node.


[[Image:map_edit_nodelink1.jpg|thumb|300px|right|Using wc_link_edit mode to change links between nodes.]]
[[File:map_edit_nodelink1.jpg|thumb|300px|right|Using <code>wc_link_edit</code> mode to change links between nodes.]]


* <code>wc_link_edit</code>
*<code>wc_link_edit</code>
** Toggles link editing mode, which allows forced disconnection of nodes that are linked.
**Toggles link editing mode, which allows forced disconnection of nodes that are linked.
*** A red box highlights node links that can be removed. Use <code>wc_destroy</code> to remove a highlighted link.
***A red box highlights node links that can be removed. Use <code>wc_destroy</code> to remove a highlighted link.
*** A green box highlights node links that have been previously removed. Use <code>wc_create</code> to restore a highlighted link.
***A green box highlights node links that have been previously removed. Use <code>wc_create</code> to restore a highlighted link.
*** Enter the <code>wc_link_edit</code> command again to disable link editing mode.
***Enter the <code>wc_link_edit</code> command again to disable link editing mode.


* <code>wc_air_node_edit</code>
*<code>wc_air_node_edit</code>
** Toggles air node editing mode, which allows add and removed air nodes. Use <code>wc_create</code> and <code>wc_destroy</code> to add and remove nodes.
**Toggles air node editing mode, which allows add and removed air nodes. Use <code>wc_create</code> and <code>wc_destroy</code> to add and remove nodes.


* <code>wc_air_edit_further</code>
*<code>wc_air_edit_further</code>
** Moves position of air node crosshair and placement location further away from player.
**Moves position of air node crosshair and placement location further away from player.


* <code>wc_air_edit_nearer</code>
*<code>wc_air_edit_nearer</code>
** Moves position of air node crosshair and placement location nearer to from player.<br style="clear:both">
**Moves position of air node crosshair and placement location nearer to from player.


=== Other useful commands ===
===Other useful commands===
* <code>ai_show_grid</code>
*<code>ai_show_grid</code>
** Draw a grid on the floor where you are currently looking.
**Draw a grid on the floor where you are currently looking.


* <code>[[ai_disable]]</code>
*{{ent|ai_disable}}
** Toggles the enabled/disabled state of the AI.
**Toggles the enabled/disabled state of the AI.


* <code>notarget</code>
*{{ent|notarget}}
** Disables AI ability to see the player. Stops enemy NPCs from shooting you while you're editing.
**Disables AI ability to see the player. Stops enemy NPCs from shooting you while you're editing.


* <code>god</code>
*{{ent|god}}
** Makes you invulnerable while you're editing.
**Makes you invulnerable while you're editing.


=== Default key bindings ===
===Default key bindings===
Here is the contents of the configuration file that contains the key bindings for these commands. The configuration file is found in the <code>source engine.gcf</code> under <code>half-life 2/hl2/cfg/map_edit.cfg</code>). This configuration file is automatically executed when you enter map_edit mode.
Here is the contents of the configuration file that contains the key bindings for these commands. The configuration file is found in the <code>source engine.gcf</code> under <code>half-life 2/hl2/cfg/map_edit.cfg</code>). This configuration file is automatically executed when you enter <code>map_edit</code> mode.


<pre>
<pre>
Line 146: Line 139:
</pre>
</pre>


You can override these settings (or add your own key bindings) by placing your own configuration file at <code>half-life 2/hl2/cfg/map_edit.cfg</code>.
You can override these settings (or add your own key bindings) by placing your own configuration file at <code>[mod folder]/cfg/map_edit.cfg</code>.
 
== Other uses of map_edit ==
* For Half-Life 2 or Half-Life 2: Deathmatch maps, <code>map_edit</code> can be used to place [[prop_physics]] debris models easily. Simply pick up the physics prop in-game with the +use key or the gravity gun, then drop it where you wish to place the object in the map. When you're done placing props, use <code>wc_update_entity</code> to send the changes to the map in Hammer.
 
* Follow the same process to update other entity types than move after the map is spawned. Simply use the syntax <code>wc_update_entity <entity name></code> for each entity you wish to update in the map. Only the position and angle of point entities can be updated.


{{note|If you are going to move props around with the gravity gun in map_edit mode, you '''must''' first disable or modify the default key bindings in map_edit.cfg (discussed above). Otherwise, the gravity gun will be completely useless and clicking the left or right mouse button will place or destroy nodes instead of activating the gun's expected functions.}}
{{note|map_edit.cfg re{{ent|bind}}s <code>MOUSE1</code> and <code>MOUSE2</code>. This means that all weapons will be disabled by default. To use them while in the edit mode, change the keys that <code>wc_create</code> and <code>wc_destroy</code> get bound to or remove the lines entirely.}}


== See also ==
==See also==
* [[:Category:Hammer|Hammer Editor Documentation]]
*[[:Category:Hammer|Hammer Editor Documentation]]
* [[ai_show_connect]]
* [[hammer_update_entity]]


[[Category:Level Design]]
[[Category:Level Design]]
[[Category:AI_Commands]]
[[Category:Debugging]]
[[Category:Debugging]]

Latest revision as of 16:10, 2 July 2024

map_edit is a console command available in all Source Source games. The map_edit and hammer_update_entity console commands can be used to update entity data while running a .BSP, then sending the changes to Hammer to commit the changes to the .VMF file. The map_edit command is commonly used to change node positions or to update physics props after they have done their initial settling.

The map_edit <mapname> command is used to load a .BSP for editing. This command creates a connection between the engine and the Hammer editor so that data can be transferred. Before using map_edit, you must compile the map with the current version of the associated .VMF, then load the map in Hammer. The map versions of the .BSP and the .VMF must match exactly. If they do not match, no editing is possible.

Note.pngNote:Hammer++ Hammer++ allows editing with mismatched map versions.

Once a map is loaded with map_edit, the hammer_update_entity <entity name> command is used to send the updated position and angles for the named entities back to the Hammer editor. When using hammer_update_entity, you can use the targetname of a single entity to update, or use an entity classname (i.e. prop_physics) to update all entities in the map of that type. Every time hammer_update_entity is invoked, the position and angle of the entities is sent to the editor.

Note.pngNote:Only the position and angle of point entities can be updated in this way. Brush entities and other brushes cannot be modified using hammer_update_entity. See Introduction to Editing for a description of entity types.
Note.pngNote:Prior to the Orange Box engine branch, hammer_update_entity was named wc_update_entity.

Using map_edit to settle physics props

You can use the map_edit command to update your .VMF with the positions of physics props after they've been settled into their final position by the game's physics system. This saves valuable CPU cycles at the start of the map, as well as preventing props from visually "dropping" into place when the map is loaded or a new round begins (in a multiplayer game).

To use map_edit to update the position of prop_physics or prop_physics_multiplayer or entities:

  1. Load the map in Hammer.
  2. Compile the map to make sure the contents of the .BSP are identical to the current .VMF you have open. Do not make any changes or even save the map after compiling, or the edit will fail. Remember to turn off auto-saves in Hammer if you have them on.
  3. Start the game (windowed mode works best).
  4. At the console, type map_edit <mapname> and the map will load (i.e. map_edit de_inferno).
  5. After the map loads, wait a few moments for the physics props to settle.
  6. Open the console and type hammer_update_entity prop_physics or hammer_update_entity prop_physics_multiplayer, depending on what type of props you are using.
  7. Switch back over to Hammer. The locations of the physics props should be updated. Save your changes to the map.
  8. Recompile the map, and the physics props will start in the "settled" positions.

You should now be able to safely mark many of the props with the Start Asleep flag. This will provide additional performance savings because no physics calculation will occur for the prop until it is acted upon by a physics force that would move it.

Editing node graphs in-game

Editing ground nodes in the engine.

The map_edit command can also be used to edit various AI nodes and node connections in the engine instead of Hammer. When using map_edit in this way, it is not necessary to use hammer_update_entity - any nodes changes are automatically sent to the Hammer editor as the changes are made in the engine.

The basic process is this:

  1. Load the map in Hammer.
  2. Compile the map to make sure the contents of the .BSP are identical to the current .VMF you have open. Do not make any changes or even save the map after compiling, or the edit will fail.
  3. Minimize Hammer.
  4. Start the game (windowed mode works best).
  5. At the console, type map_edit <mapname> and the map will load (i.e. map_edit sdk_d1_trainstation_01).
  6. Use the node editing console commands (see below) to edit the nodes, primarily wc_create and wc_destroy. Many of these commands are bound to keys by default. See the section about key binding below.
  7. Type quit to exit the game.
  8. Switch back over to Hammer. Your changes to the nodes should be completed.
  9. Check the results, then save your changes to the map.
  10. Recompile the map with the nodes changes in place.

Node display commands

These are the basic commands for displaying various node data.

  • ai_nodes
    • Display all nodes. Useful for spotting nodes without any connections to them. Entering the command twice will also display the Hammer ID of the node.
  • ai_show_hull
    • Displays the allowed hulls between each node for the currently selected hull type. Hulls colors are as follows:
      • Green: Ground movement connection. Only usable by NPCs that move on the ground.
      • Blue: Jump movement connection. Only usable by NPCs that can jump.
      • Cyan: Fly movement connection. Only usable by NPCs that can fly.
      • Magenta: Climbing movement.
  • ai_next_hull
    • Display the next NPC Hull size. Cycles through the various hull sizes. Currently selected hull size is written to the screen. Controls which connections are shown when ai_show_hull or ai_show_connect commands are used.

Node editing commands

These are commands that are used to actually add and remove nodes.

  • wc_create
    • Creates a node where the player is looking if a node is allowed at that location for the currently selected hull size (see NPC Hull)
  • wc_destroy
    • Destroys the node that the player is nearest to looking at. The node will be highlighted by a red box.
  • wc_destroy_undo
    • Restores the last deleted node.
Using wc_link_edit mode to change links between nodes.
  • wc_link_edit
    • Toggles link editing mode, which allows forced disconnection of nodes that are linked.
      • A red box highlights node links that can be removed. Use wc_destroy to remove a highlighted link.
      • A green box highlights node links that have been previously removed. Use wc_create to restore a highlighted link.
      • Enter the wc_link_edit command again to disable link editing mode.
  • wc_air_node_edit
    • Toggles air node editing mode, which allows add and removed air nodes. Use wc_create and wc_destroy to add and remove nodes.
  • wc_air_edit_further
    • Moves position of air node crosshair and placement location further away from player.
  • wc_air_edit_nearer
    • Moves position of air node crosshair and placement location nearer to from player.

Other useful commands

  • ai_show_grid
    • Draw a grid on the floor where you are currently looking.
  • ai_disable
    • Toggles the enabled/disabled state of the AI.
  • notarget
    • Disables AI ability to see the player. Stops enemy NPCs from shooting you while you're editing.
  • god
    • Makes you invulnerable while you're editing.

Default key bindings

Here is the contents of the configuration file that contains the key bindings for these commands. The configuration file is found in the source engine.gcf under half-life 2/hl2/cfg/map_edit.cfg). This configuration file is automatically executed when you enter map_edit mode.

// Key bindings
bind z ai_nodes
bind f ai_next_hull
bind h ai_show_hull
bind j ai_show_connect

bind "MOUSE1" wc_create
bind "MOUSE2" wc_destroy
bind "MWHEELUP" wc_air_edit_further
bind "MWHEELDOWN" wc_air_edit_nearer
bind l wc_link_edit
bind m wc_air_node_edit
bind - wc_air_edit_further
bind = wc_air_edit_nearer
bind * ai_show_grid

// These commands are run automatically
ai_disable
ai_nodes
ai_show_connect
notarget
god

You can override these settings (or add your own key bindings) by placing your own configuration file at [mod folder]/cfg/map_edit.cfg.

Note.pngNote:map_edit.cfg rebinds MOUSE1 and MOUSE2. This means that all weapons will be disabled by default. To use them while in the edit mode, change the keys that wc_create and wc_destroy get bound to or remove the lines entirely.

See also