Use
All entities have a Use input, though many do nothing in response to it. Use input only calls the entity's Use function. Any entity can have custom use function assigned (see Programming ↓) and if it doesn't have one the default behavior is forwarding the use to the entity's parent. Typically, it performs the action players most expect when interacting with the entity (e.g., opening/closing a door, picking up a physics object). There are several methods to invoke it:
- A player looking at the entity and using the
+use
console command (commonly bound to the E key). - An entity output that specifies the
Use
input, or not specifying any input. - Directly calling the C++ function.
- The firetarget cheat command. (directly calls Use function with type USE_TOGGLE)
Programming
Although there is always a Use
input and Use method as those are parts of CBaseEntity the actual Use
function of an entity starts null. The Use function in this context refers to the function that m_pfnUse
field was set as which can be assigned at any time with SetUse( void *SomeFunc(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) )
. The Use function also must be defined in the given entity using DEFINE_FUNCTION( our_func )
. (see func_button code for an example)
The CBaseEntity::Use
method simply checks if a Use function was set (i.e. m_pfnUse
is not empty) and if it was set then it's called otherwise if we have a parent then the Use method of the parent is called. Many entities usually override the Use method instead of setting a Use function. Benefit of setting a Use function instead of overriding the Use method is the ability to dynamically change it to a different one for example as response to inputs.
Use type in I/O
It is not possible to specify USE_TYPE
or value
through the I/O system when mapping.
Use input uses the outputID property to specify USE_TYPE. Which means specifying Use input's USE_TYPE via I/O system can be done only in code by specifying the outputID parameter of AcceptInput or AddEvent functions as the desired USE_TYPE. It is set that way for players performing use action [1]
OutputID parameter being used as USE_TYPE also results in following behavior:
- ent_fire sets outputID to 0 which means use fired through it is always of type USE_OFF
- use input fired from the first loaded output in the given game (which has outputID 1) session will USE_ON, from the 2nd USE_SET, 3rd USE_TOGGLE and the rest bogus valus that are usually interpreted as USE_TOGGLE
- firetarget calls Use function directly with use type USE_TOGGLE

Create a map with only npc_grenade_frag which has 4 outputs |