Portal 2

Portal 2

Not enough ratings
p0rtalmaster's Hammer Guide Series Part 11/19
By The Sojourner
Hello and welcome to part 11/19 of my series of mini-guides, designed to help you learn perhaps what is the biggest part of the Portal 2 Authoring tools: Hammer.

For a super-quick version of this series, please check out my other guide, Hammer for the Flustered.
   
Award
Favorite
Favorited
Unfavorite
Intro
At this point, you know how to create a test chamber. Perhaps you're already drafting some puzzles in Hammer. There are some enhancements that can be made to any map, and this guide will tell you all about them.
Autosaves and Triggers
There are essentially two entities used for autosaving: logic_autosave (a point entity) and trigger_autosave (a brush entity). You may already know about the latter entity if you are a BEEMOD user. Now you have the advantage of resizing the trigger. The former entity is useful for whenever the player completes a portion of your puzzle and a trigger just won't cut it. You can link to a logic_autosave simply by sending an output from an activator (button, laser catcher/relay) and triggering its "Save" input. Make sure the "Fire Once Only" box is checked so that you don't save more than is necessary (remember, players can still use quicksave should they ever feel the need to).

Triggers are basically brush entities, and once you know merely how to create a brush entity, triggers are some of the most intuitive things to create: just create a trigger brush (textured with tools/toolstrigger) and turn it into a trigger_* entity ("Tie to Entity"). Some common trigger entities besides trigger_autosave and trigger_hurt:
  • trigger_once and trigger_multiple. You may already know about these if you are a BEEMOD user. Now you have the advantage of resizing the trigger to fit the needs of your map. The former entity only disappears once it's been triggered, unlike the latter entity which stays forever.
  • trigger_look: used in conjunction with an info_target to specify where to look. Special options include look time (how long should the player be staring at the target), field of view, and timeout (how long should the trigger be disabled before re-enabling itself after the player looks away from the target).
  • trigger_paint_cleanser: pretty self-explanatory; it's basically a fizzler for gels. You'll need to find your own texture for the fizzler though.
  • trigger_ping_detector: used in coop to detect player's pings. Outputs have filters for blue (ATLAS) and orange (P-body).
  • trigger_push: somewhat of an analog to trigger_catapult, but less precise. We'll be using it further down the road.
  • trigger_soundscape: sometimes useful for fine-tuning where a soundscape should play. Here you specify the name of your soundscape entity, not the name of the soundscape itself.
  • trigger_teleport: if an object enters this trigger, it will be teleported to a specified location.
For all triggers, under the "Flags" tab there are all sorts of filtering options, so that you don't need to use any additional filter entities. Common outputs for the triggers are OnStartTouch and OnEndTouchAll.
Portal Detectors and Placement Helpers
Portal detectors are like triggers, but the entity name doesn't begin with trigger_* (but it should still use the trigger texture). The entity to use here is func_portal_detector, and special outputs include:
  • OnStartTouchPortal: Fired when any portal touches the detector.
  • OnStartTouchPortal1: Fired when portal 1 (blue) is placed inside the portal detector.
  • OnStartTouchPortal2: Fired when portal 2 (orange) is placed inside the portal detector.
  • OnStartTouchLinkedPortal: Fired when an open portal is placed inside the portal detector, or when one opens while inside of it.
  • OnStartTouchBothLinkedPortals: Fired when both portals are placed inside the portal detector.
The OnEndTouch* outputs of the same name do essentially the same thing but in reverse.

Another special Portal 2 entity, func_portalled, was developed for detecting when an object passes through a portal. It has two additional outputs:
  • OnEntityPrePortalled: Fires when the entity is about to portal (i.e. enters the portal).
  • OnEntityPostPortalled: Fires when the entity is done portalling (i.e. exits the portal on the other side).
To help correct portal placement, there are a couple more brush entites: func_portal_bumper and func_portal_orientation. While the former is sometimes useful for ensuring that players never portal bump through glass barriers, both of these entites are obsolete as far as portal correction goes. Now we use a much more precise point entity called info_placement_helper. It is the magic behind BEEMOD's "Portal Magnet" puzzle element. It can be oriented in any which way, but here are some guidelines:
  • The big red arrow should always face outward from the surface.
  • The flat, blue arrow points to the top edge of the portal. Keep this in mind for when you want to rotate a portal at some angle.
  • It is recommended, but not required, that you set "Use helper's angles" to "Yes."
  • To make an info_placement_helper more fully effective, set "Force Placement" to "Yes."
  • You can also adjust the radius in which the "portal snapping" takes effect.
How To Do Multiple Inputs for a Door/Laser/Hard Light Bridge/etc.
The key entity for this is math_counter. It's a surprisingly versatile point entity, and can function as any logic gate by setting its outputs correctly. To use:

1) Create a math_counter and name it. Set its maximum to however many activators you want to activate your door/laser/hard light bridge/etc.

2) For a traditional AND gate, use the outputs OnHitMax and OnChangedFromMax for enable/disable, respectively.

3) For an OR gate, use the outputs OnChangedFromMin and OnHitMin for enable/disable, respectively.

4) For a simple XOR gate, use the outputs OnChangedFromMin and OnHitMin for enable/disable, respectively as before, but also use the outputs OnChangedFromMax and OnHitMax for enable/disable, respectively.

To do a negation of any of these, simply swap the enable/disable outputs.
Some Useful Console Commands for Developers
Many other guides cover some of these, but here is perhaps a more complete listing for mappers:
  • r_flashlightbrightness <number>: used to tweak the env_projectedtexture entity to make it work.
  • ent_bbox trigger_catapult: used to debug trigger_catapult trajectories by visualizing their paths.
  • buildcubemaps: Does what it says if your map is placed in the portal2_dlc2 directory. Crashes the game otherwise.
  • mat_hdr_level <0/1/2>: 0 is LDR, 2 is HDR. Used when building cubemaps. Not sure about 1...
  • mat_leafvis <0/1/2/3>: 0 is off, 1 shows current visleaf, and 3 shows all visleafs. Not sure about 2...
  • r_drawclipbrushes <0/1>: 0 is off, 1 is on. Displays a wireframe of all clipping brushes.
  • showtriggers_toggle: Shows or hides all trigger brushes. You may need to use the showtriggers command to get this one to work.
  • playsoundscape <soundscape name>: plays a soundscape, overriding the current one.
  • playgamesound <game sound name>: plays a game sound.
  • play <raw sound name>: plays a sound file directly. There is no pre-listing with this command.
  • *noclip <0/1>: you can fly through anything and everything, unaffected by gravity. Need I say more?
  • *notarget <0/1>: turrets will not shoot at you, nor will cameras stare at you. Useful for taking screenshots.
  • crosshair <0/1>: toggles your crosshair. Useful for taking screenshots.
  • r_drawviewmodel <0/1>: toggles your portalgun viewmodel (in the corner of your screen). Useful for taking screenshots.
  • ent_create <entity name>: useful for spawning certain entities on the fly. There are several specialized versions of this command for creating cubes and gel bombs.
  • ent_fire <entity name in map> <output>: make something in your map do something. For instance, you can make a cube disappear by using the kill output.
  • crash: yes, VALVe really did include this command and leave it for us :P
  • exit: a milder version of the above.
  • restart: pretty self-explanatory
  • r_inforceuser: use this command to switch between ATLAS and P-body when playing coop alone.
  • map <mapname>: loads a map on your computer.
  • ss_map <mapname>: loads a coop map in offline split-screen mode. Make sure the mapname starts with mp_coop_.
  • bind <key> <command>: once this command is executed, the specified command will be available at the press of a key.
  • BindToggle <key> <command>: some commands can be toggled. This is an alternative to the "bind" command.

*(singleplayer) cheat command: you must have sv_cheats set to 1 in order to use.
NB you can execute multiple commands at once by separating them with a semicolon (;).

Many movement-related commands begin with "+" and "-".
Mistakes to Avoid & More Information

  • Not using (enough) autosaves. trigger_autosave and logic_autosave will help immensely. Remember them. But please, DON'T JUST ASK US TO "F6" OR "QUICKSAVE"!! You're not using the in-game editor anymore!
  • Not using info_placement_helpers to ease pain for players. Don't forget that this entity can place sideways portals on walls!
  • Not much to say here other than abusing the console for...well... things that the console was made to be abused for :P

More information from the VDC Wiki:...and additional information about all sorts of logic entities. These are your best friends:
Master Guide List
Please note that there are still some works in progress. This section will be updated as I finish more guides for you!

You are currently viewing part 11/19 in the series.

| 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |19 |

Previous Guide (about fizzlers, laserfields and other "moat" areas)
Next Guide (optimizing a map)

Please feel free to leave a well-reasoned question or comment below. Either I or a qualified Test Chamber Associate (you'll know because they make all the good maps on the workshop) will respond. If your question or comment is not well-reasoned, I recommend reading over my guides again until you understand them 100%. No further information is required here or will be provided, and you will become an excellent Test Chamber Designer — using Hammer!

1 Comments
󠀡 Jun 23, 2021 @ 1:43pm 
r_inforceuser doesn't work right now