item_key

From Valve Developer Community
Jump to navigation Jump to search

item_key is a model entity available in Cry of Fear Cry of Fear.

A variant of item_security that supports displaying a custom model. When a player collects it, it can trigger another entity (like a door) or fire targets with a specified delay.

Keyvalues

Name (targetname) <string>
The targetname that other entities refer to this entity by, usually via the target, killtarget, and TriggerTarget KVs.
Target (target) <targetname>
The targetname of an entity this entity will trigger when activated.
Delay before trigger (delay) <integer>
Delay in seconds before firing the targeted entity.
Killtarget (killtarget) <targetname>
Entity to remove when activated.
Note.pngNote: Targets are fired when the key is picked up.
Name of .txt for the key (message) <file path>
The name of the text file associated with the key (e.g., inventoryitems/basementkey.txt). Used for displaying a notification with the key's name at the bottom of the screen.
Model (model) <model path>
Model to display (MDL, BSP, or SPR). Relative to mod folder.
Colormap (colormap) <integer>
Works like the deathmatch recolor system, wherein this KV equals (bottomcolor * 256) + topcolor. This value can be calculated using Half-Life Asset Manager.

How to use

To set up a global puzzle logic where a door requires a key and tracking via a global variable:

  1. Place the item_key entity somewhere on your map where the player can collect it. Set its target value to match your env_global name (e.g., key_global_trigger).
  2. Place the entity that you want to open, such as a func_door. In its Master field, type the targetname of your multisource (e.g., my_multisource).
  3. Place a multisource entity anywhere on the map. Set its targetname to my_multisource.
  4. Place an env_global entity on your map.
  5. Configure the env_global parameters using the following settings:
Keyvalue SmartEdit Name Value Description
targetname Name key_global_trigger The name that matches the key's target.
globalstate Global State To Set my_key_picked_up A unique name for your custom global state.
triggermode Trigger To Send 1: On Turns the global state ON when triggered by the key.
initialstate Initial State 0: Off The state is disabled by default until the player finds the key.
  1. Go back to your multisource entity and in its Global State Master field, type the exact name of the global state you defined in the env_global (e.g., my_key_picked_up).

When the player picks up the key, it will trigger the env_global, changing the global state to ON. The multisource detects this global state change and unlocks the master controlled func_door.

Creating Custom Notifications

You can create your own custom notification file by simply copying basementkey.txt from the mod files and modifying its content to suit your needs.