Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1331 lines
34 KiB

9 years ago
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
/*
===== buttons.cpp ========================================================
button-related code
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "saverestore.h"
#include "doors.h"
#define SF_BUTTON_DONTMOVE 1
9 years ago
#define SF_ROTBUTTON_NOTSOLID 1
9 years ago
#define SF_BUTTON_TOGGLE 32 // button stays pushed until reactivated
9 years ago
#define SF_BUTTON_SPARK_IF_OFF 64 // button sparks in OFF state
#define SF_BUTTON_TOUCH_ONLY 256 // button only fires as a result of USE key.
9 years ago
#define SF_GLOBAL_SET 1 // Set global state to initial state on spawn
class CEnvGlobal : public CPointEntity
{
public:
9 years ago
void Spawn( void );
void KeyValue( KeyValueData *pkvd );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
9 years ago
9 years ago
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
9 years ago
9 years ago
string_t m_globalstate;
int m_triggermode;
int m_initialstate;
9 years ago
};
TYPEDESCRIPTION CEnvGlobal::m_SaveData[] =
{
DEFINE_FIELD( CEnvGlobal, m_globalstate, FIELD_STRING ),
DEFINE_FIELD( CEnvGlobal, m_triggermode, FIELD_INTEGER ),
DEFINE_FIELD( CEnvGlobal, m_initialstate, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CEnvGlobal, CBaseEntity )
9 years ago
LINK_ENTITY_TO_CLASS( env_global, CEnvGlobal )
9 years ago
void CEnvGlobal::KeyValue( KeyValueData *pkvd )
{
pkvd->fHandled = TRUE;
9 years ago
if( FStrEq( pkvd->szKeyName, "globalstate" ) ) // State name
9 years ago
m_globalstate = ALLOC_STRING( pkvd->szValue );
9 years ago
else if( FStrEq( pkvd->szKeyName, "triggermode" ) )
9 years ago
m_triggermode = atoi( pkvd->szValue );
9 years ago
else if( FStrEq( pkvd->szKeyName, "initialstate" ) )
9 years ago
m_initialstate = atoi( pkvd->szValue );
9 years ago
else
9 years ago
CPointEntity::KeyValue( pkvd );
}
void CEnvGlobal::Spawn( void )
{
9 years ago
if( !m_globalstate )
9 years ago
{
9 years ago
REMOVE_ENTITY( ENT( pev ) );
9 years ago
return;
}
9 years ago
if( FBitSet( pev->spawnflags, SF_GLOBAL_SET ) )
9 years ago
{
9 years ago
if( !gGlobalState.EntityInTable( m_globalstate ) )
9 years ago
gGlobalState.EntityAdd( m_globalstate, gpGlobals->mapname, (GLOBALESTATE)m_initialstate );
}
}
void CEnvGlobal::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
GLOBALESTATE oldState = gGlobalState.EntityGetState( m_globalstate );
GLOBALESTATE newState;
switch( m_triggermode )
{
case 0:
newState = GLOBAL_OFF;
break;
case 1:
newState = GLOBAL_ON;
break;
case 2:
newState = GLOBAL_DEAD;
break;
default:
case 3:
9 years ago
if( oldState == GLOBAL_ON )
9 years ago
newState = GLOBAL_OFF;
9 years ago
else if( oldState == GLOBAL_OFF )
9 years ago
newState = GLOBAL_ON;
else
newState = oldState;
}
9 years ago
if( gGlobalState.EntityInTable( m_globalstate ) )
9 years ago
gGlobalState.EntitySetState( m_globalstate, newState );
else
gGlobalState.EntityAdd( m_globalstate, gpGlobals->mapname, newState );
}
TYPEDESCRIPTION CMultiSource::m_SaveData[] =
{
//!!!BUGBUG FIX
DEFINE_ARRAY( CMultiSource, m_rgEntities, FIELD_EHANDLE, MS_MAX_TARGETS ),
DEFINE_ARRAY( CMultiSource, m_rgTriggered, FIELD_INTEGER, MS_MAX_TARGETS ),
DEFINE_FIELD( CMultiSource, m_iTotal, FIELD_INTEGER ),
DEFINE_FIELD( CMultiSource, m_globalstate, FIELD_STRING ),
};
IMPLEMENT_SAVERESTORE( CMultiSource, CBaseEntity )
LINK_ENTITY_TO_CLASS( multisource, CMultiSource )
9 years ago
//
// Cache user-entity-field values until spawn is called.
//
void CMultiSource::KeyValue( KeyValueData *pkvd )
{
9 years ago
if( FStrEq( pkvd->szKeyName, "style" ) ||
FStrEq( pkvd->szKeyName, "height" ) ||
FStrEq( pkvd->szKeyName, "killtarget" ) ||
FStrEq( pkvd->szKeyName, "value1" ) ||
FStrEq( pkvd->szKeyName, "value2" ) ||
FStrEq( pkvd->szKeyName, "value3" ) )
9 years ago
pkvd->fHandled = TRUE;
9 years ago
else if( FStrEq( pkvd->szKeyName, "globalstate" ) )
9 years ago
{
m_globalstate = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
9 years ago
else
9 years ago
CPointEntity::KeyValue( pkvd );
}
#define SF_MULTI_INIT 1
void CMultiSource::Spawn()
{
// set up think for later registration
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NONE;
pev->nextthink = gpGlobals->time + 0.1f;
9 years ago
pev->spawnflags |= SF_MULTI_INIT; // Until it's initialized
9 years ago
SetThink( &CMultiSource::Register );
9 years ago
}
void CMultiSource::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
int i = 0;
// Find the entity in our list
9 years ago
while( i < m_iTotal )
if( m_rgEntities[i++] == pCaller )
9 years ago
break;
// if we didn't find it, report error and leave
9 years ago
if( i > m_iTotal )
9 years ago
{
9 years ago
ALERT( at_console, "MultiSrc:Used by non member %s.\n", STRING( pCaller->pev->classname ) );
9 years ago
return;
}
// CONSIDER: a Use input to the multisource always toggles. Could check useType for ON/OFF/TOGGLE
9 years ago
m_rgTriggered[i - 1] ^= 1;
9 years ago
//
9 years ago
if( IsTriggered( pActivator ) )
9 years ago
{
9 years ago
ALERT( at_aiconsole, "Multisource %s enabled (%d inputs)\n", STRING( pev->targetname ), m_iTotal );
9 years ago
useType = USE_TOGGLE;
9 years ago
if( m_globalstate )
9 years ago
useType = USE_ON;
SUB_UseTargets( NULL, useType, 0 );
}
}
BOOL CMultiSource::IsTriggered( CBaseEntity * )
{
// Is everything triggered?
int i = 0;
// Still initializing?
9 years ago
if( pev->spawnflags & SF_MULTI_INIT )
9 years ago
return 0;
9 years ago
while( i < m_iTotal )
9 years ago
{
9 years ago
if( m_rgTriggered[i] == 0 )
9 years ago
break;
i++;
}
9 years ago
if( i == m_iTotal )
9 years ago
{
9 years ago
if( !m_globalstate || gGlobalState.EntityGetState( m_globalstate ) == GLOBAL_ON )
9 years ago
return 1;
}
9 years ago
9 years ago
return 0;
}
9 years ago
void CMultiSource::Register( void )
9 years ago
{
9 years ago
edict_t *pentTarget = NULL;
9 years ago
m_iTotal = 0;
memset( m_rgEntities, 0, MS_MAX_TARGETS * sizeof(EHANDLE) );
9 years ago
SetThink( &CBaseEntity::SUB_DoNothing );
9 years ago
// search for all entities which target this multisource (pev->targetname)
9 years ago
pentTarget = FIND_ENTITY_BY_STRING( NULL, "target", STRING( pev->targetname ) );
9 years ago
9 years ago
while( !FNullEnt( pentTarget ) && ( m_iTotal < MS_MAX_TARGETS ) )
9 years ago
{
9 years ago
CBaseEntity *pTarget = CBaseEntity::Instance( pentTarget );
if( pTarget )
9 years ago
m_rgEntities[m_iTotal++] = pTarget;
9 years ago
pentTarget = FIND_ENTITY_BY_STRING( pentTarget, "target", STRING( pev->targetname ) );
9 years ago
}
9 years ago
pentTarget = FIND_ENTITY_BY_STRING( NULL, "classname", "multi_manager" );
while( !FNullEnt( pentTarget ) && ( m_iTotal < MS_MAX_TARGETS ) )
9 years ago
{
9 years ago
CBaseEntity *pTarget = CBaseEntity::Instance( pentTarget );
if( pTarget && pTarget->HasTarget( pev->targetname ) )
9 years ago
m_rgEntities[m_iTotal++] = pTarget;
pentTarget = FIND_ENTITY_BY_STRING( pentTarget, "classname", "multi_manager" );
}
pev->spawnflags &= ~SF_MULTI_INIT;
}
// CBaseButton
TYPEDESCRIPTION CBaseButton::m_SaveData[] =
{
DEFINE_FIELD( CBaseButton, m_fStayPushed, FIELD_BOOLEAN ),
DEFINE_FIELD( CBaseButton, m_fRotating, FIELD_BOOLEAN ),
DEFINE_FIELD( CBaseButton, m_sounds, FIELD_INTEGER ),
DEFINE_FIELD( CBaseButton, m_bLockedSound, FIELD_CHARACTER ),
DEFINE_FIELD( CBaseButton, m_bLockedSentence, FIELD_CHARACTER ),
DEFINE_FIELD( CBaseButton, m_bUnlockedSound, FIELD_CHARACTER ),
DEFINE_FIELD( CBaseButton, m_bUnlockedSentence, FIELD_CHARACTER ),
DEFINE_FIELD( CBaseButton, m_strChangeTarget, FIELD_STRING ),
9 years ago
//DEFINE_FIELD( CBaseButton, m_ls, FIELD_??? ), // This is restored in Precache()
9 years ago
};
IMPLEMENT_SAVERESTORE( CBaseButton, CBaseToggle )
9 years ago
void CBaseButton::Precache( void )
{
const char *pszSound;
9 years ago
9 years ago
if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state
9 years ago
{
9 years ago
PRECACHE_SOUND( "buttons/spark1.wav" );
PRECACHE_SOUND( "buttons/spark2.wav" );
PRECACHE_SOUND( "buttons/spark3.wav" );
PRECACHE_SOUND( "buttons/spark4.wav" );
PRECACHE_SOUND( "buttons/spark5.wav" );
PRECACHE_SOUND( "buttons/spark6.wav" );
9 years ago
}
// get door button sounds, for doors which require buttons to open
9 years ago
if( m_bLockedSound )
9 years ago
{
pszSound = ButtonSound( (int)m_bLockedSound );
9 years ago
PRECACHE_SOUND( pszSound );
m_ls.sLockedSound = MAKE_STRING( pszSound );
9 years ago
}
9 years ago
if( m_bUnlockedSound )
9 years ago
{
pszSound = ButtonSound( (int)m_bUnlockedSound );
9 years ago
PRECACHE_SOUND( pszSound );
m_ls.sUnlockedSound = MAKE_STRING( pszSound );
9 years ago
}
// get sentence group names, for doors which are directly 'touched' to open
9 years ago
switch( m_bLockedSentence )
9 years ago
{
9 years ago
case 1: // access denied
m_ls.sLockedSentence = MAKE_STRING( "NA" );
break;
case 2: // security lockout
m_ls.sLockedSentence = MAKE_STRING( "ND" );
break;
case 3: // blast door
m_ls.sLockedSentence = MAKE_STRING( "NF" );
break;
case 4: // fire door
m_ls.sLockedSentence = MAKE_STRING( "NFIRE" );
break;
case 5: // chemical door
m_ls.sLockedSentence = MAKE_STRING( "NCHEM" );
break;
case 6: // radiation door
m_ls.sLockedSentence = MAKE_STRING( "NRAD" );
break;
case 7: // gen containment
m_ls.sLockedSentence = MAKE_STRING( "NCON" );
break;
case 8: // maintenance door
m_ls.sLockedSentence = MAKE_STRING( "NH" );
break;
case 9: // broken door
m_ls.sLockedSentence = MAKE_STRING( "NG" );
break;
default:
m_ls.sLockedSentence = 0;
break;
9 years ago
}
9 years ago
switch( m_bUnlockedSentence )
9 years ago
{
9 years ago
case 1: // access granted
m_ls.sUnlockedSentence = MAKE_STRING( "EA" );
break;
case 2: // security door
m_ls.sUnlockedSentence = MAKE_STRING( "ED" );
9 years ago
break;
case 3: // blast door
m_ls.sUnlockedSentence = MAKE_STRING( "EF" );
9 years ago
break;
case 4: // fire door
m_ls.sUnlockedSentence = MAKE_STRING( "EFIRE" );
9 years ago
break;
case 5: // chemical door
m_ls.sUnlockedSentence = MAKE_STRING( "ECHEM" );
9 years ago
break;
case 6: // radiation door
m_ls.sUnlockedSentence = MAKE_STRING( "ERAD" );
9 years ago
break;
case 7: // gen containment
m_ls.sUnlockedSentence = MAKE_STRING( "ECON" );
9 years ago
break;
case 8: // maintenance door
m_ls.sUnlockedSentence = MAKE_STRING( "EH" );
9 years ago
break;
default:
m_ls.sUnlockedSentence = 0;
break;
9 years ago
}
}
//
// Cache user-entity-field values until spawn is called.
//
void CBaseButton::KeyValue( KeyValueData *pkvd )
{
9 years ago
if( FStrEq( pkvd->szKeyName, "changetarget" ) )
9 years ago
{
9 years ago
m_strChangeTarget = ALLOC_STRING( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
9 years ago
else if( FStrEq( pkvd->szKeyName, "locked_sound" ) )
9 years ago
{
m_bLockedSound = atoi( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
9 years ago
else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) )
9 years ago
{
m_bLockedSentence = atoi( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
9 years ago
else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) )
9 years ago
{
m_bUnlockedSound = atoi( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
9 years ago
else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) )
9 years ago
{
m_bUnlockedSentence = atoi( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
9 years ago
else if( FStrEq( pkvd->szKeyName, "sounds" ) )
9 years ago
{
9 years ago
m_sounds = atoi( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
else
CBaseToggle::KeyValue( pkvd );
}
//
// ButtonShot
//
9 years ago
int CBaseButton::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
9 years ago
{
BUTTON_CODE code = ButtonResponseToTouch();
9 years ago
if( code == BUTTON_NOTHING )
9 years ago
return 0;
// Temporarily disable the touch function, until movement is finished.
SetTouch( NULL );
m_hActivator = CBaseEntity::Instance( pevAttacker );
if( m_hActivator == 0 )
9 years ago
return 0;
9 years ago
if( code == BUTTON_RETURN )
9 years ago
{
EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM );
9 years ago
// Toggle buttons fire when they get back to their "home" position
9 years ago
if( !( pev->spawnflags & SF_BUTTON_TOGGLE ) )
9 years ago
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
ButtonReturn();
}
else // code == BUTTON_ACTIVATE
9 years ago
ButtonActivate();
9 years ago
return 0;
}
/*QUAKED func_button (0 .5 .8) ?
When a button is touched, it moves some distance in the direction of it's angle,
triggers all of it's targets, waits some time, then returns to it's original position
where it can be triggered again.
"angle" determines the opening direction
"target" all entities with a matching targetname will be used
"speed" override the default 40 speed
"wait" override the default 1 second wait (-1 = never return)
"lip" override the default 4 pixel lip remaining at end of move
"health" if set, the button must be killed instead of touched
"sounds"
0) steam metal
1) wooden clunk
2) metallic click
3) in-out
*/
LINK_ENTITY_TO_CLASS( func_button, CBaseButton )
9 years ago
9 years ago
void CBaseButton::Spawn()
9 years ago
{
const char *pszSound;
9 years ago
//----------------------------------------------------
//determine sounds for buttons
//a sound of 0 should not make a sound
//----------------------------------------------------
pszSound = ButtonSound( m_sounds );
9 years ago
PRECACHE_SOUND( pszSound );
pev->noise = MAKE_STRING( pszSound );
9 years ago
Precache();
9 years ago
if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state
9 years ago
{
SetThink( &CBaseButton::ButtonSpark );
pev->nextthink = gpGlobals->time + 0.5f;// no hurry, make sure everything else spawns
9 years ago
}
9 years ago
SetMovedir( pev );
9 years ago
9 years ago
pev->movetype = MOVETYPE_PUSH;
pev->solid = SOLID_BSP;
SET_MODEL( ENT( pev ), STRING( pev->model ) );
9 years ago
if( pev->speed == 0.0f )
pev->speed = 40.0f;
9 years ago
9 years ago
if( pev->health > 0 )
9 years ago
{
pev->takedamage = DAMAGE_YES;
}
if( m_flWait == 0.0f )
m_flWait = 1.0f;
if( m_flLip == 0.0f )
m_flLip = 4.0f;
9 years ago
m_toggle_state = TS_AT_BOTTOM;
m_vecPosition1 = pev->origin;
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
m_vecPosition2 = m_vecPosition1 + ( pev->movedir * ( fabs( pev->movedir.x * ( pev->size.x - 2.0f ) ) + fabs( pev->movedir.y * ( pev->size.y - 2.0f ) ) + fabs( pev->movedir.z * ( pev->size.z - 2.0f ) ) - m_flLip ) );
9 years ago
// Is this a non-moving button?
if( ( ( m_vecPosition2 - m_vecPosition1 ).Length() < 1.0f ) || ( pev->spawnflags & SF_BUTTON_DONTMOVE ) )
9 years ago
m_vecPosition2 = m_vecPosition1;
m_fStayPushed = m_flWait == -1.0f ? TRUE : FALSE;
9 years ago
m_fRotating = FALSE;
// if the button is flagged for USE button activation only, take away it's touch function and add a use function
9 years ago
if( FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // touchable button
9 years ago
{
SetTouch( &CBaseButton::ButtonTouch );
}
else
{
SetTouch( NULL );
SetUse( &CBaseButton::ButtonUse );
}
}
// Button sound table.
// Also used by CBaseDoor to get 'touched' door lock/unlock sounds
8 years ago
const char *ButtonSound( int sound )
9 years ago
{
const char *pszSound;
9 years ago
9 years ago
switch( sound )
9 years ago
{
9 years ago
case 0:
pszSound = "common/null.wav";
break;
case 1:
pszSound = "buttons/button1.wav";
break;
case 2:
pszSound = "buttons/button2.wav";
break;
case 3:
pszSound = "buttons/button3.wav";
break;
case 4:
pszSound = "buttons/button4.wav";
break;
case 5:
pszSound = "buttons/button5.wav";
break;
case 6:
pszSound = "buttons/button6.wav";
break;
case 7:
pszSound = "buttons/button7.wav";
break;
case 8:
pszSound = "buttons/button8.wav";
break;
case 9:
pszSound = "buttons/button9.wav";
break;
case 10:
pszSound = "buttons/button10.wav";
break;
case 11:
pszSound = "buttons/button11.wav";
break;
case 12:
pszSound = "buttons/latchlocked1.wav";
break;
case 13:
pszSound = "buttons/latchunlocked1.wav";
break;
case 14:
pszSound = "buttons/lightswitch2.wav";
break;
9 years ago
// next 6 slots reserved for any additional sliding button sounds we may add
9 years ago
case 21:
pszSound = "buttons/lever1.wav";
break;
case 22:
pszSound = "buttons/lever2.wav";
break;
case 23:
pszSound = "buttons/lever3.wav";
break;
case 24:
pszSound = "buttons/lever4.wav";
break;
case 25:
pszSound = "buttons/lever5.wav";
break;
default:
pszSound = "buttons/button9.wav";
break;
9 years ago
}
return pszSound;
}
//
// Makes flagged buttons spark when turned off
//
9 years ago
void DoSpark( entvars_t *pev, const Vector &location )
9 years ago
{
Vector tmp = location + pev->size * 0.5f;
9 years ago
UTIL_Sparks( tmp );
float flVolume = RANDOM_FLOAT( 0.25f, 0.75f ) * 0.4f;//random volume range
switch( (int)( RANDOM_FLOAT( 0.0f, 1.0f ) * 6.0f ) )
9 years ago
{
9 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark1.wav", flVolume, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark2.wav", flVolume, ATTN_NORM );
break;
case 2:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark3.wav", flVolume, ATTN_NORM );
break;
case 3:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark4.wav", flVolume, ATTN_NORM );
break;
case 4:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM );
break;
case 5:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM );
break;
9 years ago
}
}
9 years ago
void CBaseButton::ButtonSpark( void )
9 years ago
{
SetThink( &CBaseButton::ButtonSpark );
pev->nextthink = gpGlobals->time + 0.1f + RANDOM_FLOAT( 0.0f, 1.5f );// spark again at random interval
9 years ago
DoSpark( pev, pev->mins );
}
//
// Button's Use function
//
9 years ago
void CBaseButton::ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
9 years ago
{
// Ignore touches if button is moving, or pushed-in and waiting to auto-come-out.
// UNDONE: Should this use ButtonResponseToTouch() too?
9 years ago
if( m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN )
return;
9 years ago
m_hActivator = pActivator;
9 years ago
if( m_toggle_state == TS_AT_TOP )
9 years ago
{
9 years ago
if( !m_fStayPushed && FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) )
9 years ago
{
EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1.0f, ATTN_NORM );
9 years ago
9 years ago
//SUB_UseTargets( m_eoActivator );
ButtonReturn();
}
}
else
9 years ago
ButtonActivate();
9 years ago
}
CBaseButton::BUTTON_CODE CBaseButton::ButtonResponseToTouch( void )
{
// Ignore touches if button is moving, or pushed-in and waiting to auto-come-out.
9 years ago
if( m_toggle_state == TS_GOING_UP ||
9 years ago
m_toggle_state == TS_GOING_DOWN ||
9 years ago
( m_toggle_state == TS_AT_TOP && !m_fStayPushed && !FBitSet(pev->spawnflags, SF_BUTTON_TOGGLE ) ) )
9 years ago
return BUTTON_NOTHING;
9 years ago
if( m_toggle_state == TS_AT_TOP )
9 years ago
{
9 years ago
if( ( FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) && !m_fStayPushed )
9 years ago
{
return BUTTON_RETURN;
}
}
else
return BUTTON_ACTIVATE;
return BUTTON_NOTHING;
}
//
// Touching a button simply "activates" it.
//
9 years ago
void CBaseButton::ButtonTouch( CBaseEntity *pOther )
9 years ago
{
// Ignore touches by anything but players
if( !pOther->IsPlayer() )
9 years ago
return;
m_hActivator = pOther;
BUTTON_CODE code = ButtonResponseToTouch();
9 years ago
if( code == BUTTON_NOTHING )
9 years ago
return;
9 years ago
if( !UTIL_IsMasterTriggered( m_sMaster, pOther ) )
9 years ago
{
// play button locked sound
9 years ago
PlayLockSounds( pev, &m_ls, TRUE, TRUE );
9 years ago
return;
}
// Temporarily disable the touch function, until movement is finished.
SetTouch( NULL );
9 years ago
if( code == BUTTON_RETURN )
9 years ago
{
EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM );
9 years ago
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
ButtonReturn();
}
else // code == BUTTON_ACTIVATE
9 years ago
ButtonActivate();
9 years ago
}
//
// Starts the button moving "in/up".
//
9 years ago
void CBaseButton::ButtonActivate()
9 years ago
{
EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM );
9 years ago
if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) )
9 years ago
{
// button is locked, play locked sound
9 years ago
PlayLockSounds( pev, &m_ls, TRUE, TRUE );
9 years ago
return;
}
else
{
// button is unlocked, play unlocked sound
9 years ago
PlayLockSounds( pev, &m_ls, FALSE, TRUE );
9 years ago
}
9 years ago
ASSERT( m_toggle_state == TS_AT_BOTTOM );
9 years ago
m_toggle_state = TS_GOING_UP;
SetMoveDone( &CBaseButton::TriggerAndWait );
9 years ago
if( !m_fRotating )
LinearMove( m_vecPosition2, pev->speed );
9 years ago
else
9 years ago
AngularMove( m_vecAngle2, pev->speed );
9 years ago
}
//
// Button has reached the "in/up" position. Activate its "targets", and pause before "popping out".
//
void CBaseButton::TriggerAndWait( void )
{
9 years ago
ASSERT( m_toggle_state == TS_GOING_UP );
9 years ago
9 years ago
if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) )
9 years ago
return;
m_toggle_state = TS_AT_TOP;
9 years ago
9 years ago
// If button automatically comes back out, start it moving out.
// Else re-instate touch method
9 years ago
if( m_fStayPushed || FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) )
9 years ago
{
9 years ago
if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // this button only works if USED, not touched!
9 years ago
{
// ALL buttons are now use only
SetTouch( NULL );
}
else
SetTouch( &CBaseButton::ButtonTouch );
}
else
{
pev->nextthink = pev->ltime + m_flWait;
SetThink( &CBaseButton::ButtonReturn );
}
9 years ago
pev->frame = 1; // use alternate textures
9 years ago
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
}
//
// Starts the button moving "out/down".
//
void CBaseButton::ButtonReturn( void )
{
9 years ago
ASSERT( m_toggle_state == TS_AT_TOP );
9 years ago
m_toggle_state = TS_GOING_DOWN;
9 years ago
SetMoveDone( &CBaseButton::ButtonBackHome );
9 years ago
if( !m_fRotating )
LinearMove( m_vecPosition1, pev->speed );
9 years ago
else
9 years ago
AngularMove( m_vecAngle1, pev->speed );
9 years ago
pev->frame = 0; // use normal textures
}
//
// Button has returned to start state. Quiesce it.
//
void CBaseButton::ButtonBackHome( void )
{
9 years ago
ASSERT( m_toggle_state == TS_GOING_DOWN );
9 years ago
m_toggle_state = TS_AT_BOTTOM;
9 years ago
if( FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) )
9 years ago
{
//EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM );
9 years ago
SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
}
9 years ago
if( !FStringNull( pev->target ) )
9 years ago
{
9 years ago
edict_t *pentTarget = NULL;
for( ;; )
9 years ago
{
9 years ago
pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->target ) );
9 years ago
9 years ago
if( FNullEnt( pentTarget ) )
9 years ago
break;
9 years ago
if( !FClassnameIs( pentTarget, "multisource" ) )
9 years ago
continue;
CBaseEntity *pTarget = CBaseEntity::Instance( pentTarget );
9 years ago
if( pTarget )
9 years ago
pTarget->Use( m_hActivator, this, USE_TOGGLE, 0 );
}
}
// Re-instate touch method, movement cycle is complete.
9 years ago
if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) ) // this button only works if USED, not touched!
9 years ago
{
// All buttons are now use only
9 years ago
SetTouch( NULL );
}
else
SetTouch( &CBaseButton::ButtonTouch );
// reset think for a sparking button
9 years ago
if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )
9 years ago
{
SetThink( &CBaseButton::ButtonSpark );
pev->nextthink = gpGlobals->time + 0.5f;// no hurry.
9 years ago
}
}
//
// Rotating button (aka "lever")
//
class CRotButton : public CBaseButton
{
public:
void Spawn( void );
};
LINK_ENTITY_TO_CLASS( func_rot_button, CRotButton )
9 years ago
void CRotButton::Spawn( void )
{
const char *pszSound;
9 years ago
//----------------------------------------------------
//determine sounds for buttons
//a sound of 0 should not make a sound
//----------------------------------------------------
pszSound = ButtonSound( m_sounds );
9 years ago
PRECACHE_SOUND( pszSound );
pev->noise = MAKE_STRING( pszSound );
9 years ago
// set the axis of rotation
CBaseToggle::AxisDir( pev );
// check for clockwise rotation
9 years ago
if( FBitSet( pev->spawnflags, SF_DOOR_ROTATE_BACKWARDS ) )
pev->movedir = pev->movedir * -1.0f;
9 years ago
9 years ago
pev->movetype = MOVETYPE_PUSH;
9 years ago
9 years ago
if( pev->spawnflags & SF_ROTBUTTON_NOTSOLID )
pev->solid = SOLID_NOT;
9 years ago
else
9 years ago
pev->solid = SOLID_BSP;
9 years ago
9 years ago
SET_MODEL( ENT( pev ), STRING( pev->model ) );
9 years ago
if( pev->speed == 0.0f )
pev->speed = 40.0f;
9 years ago
9 years ago
if( m_flWait == 0 )
9 years ago
m_flWait = 1;
9 years ago
if( pev->health > 0 )
9 years ago
{
pev->takedamage = DAMAGE_YES;
}
m_toggle_state = TS_AT_BOTTOM;
9 years ago
m_vecAngle1 = pev->angles;
m_vecAngle2 = pev->angles + pev->movedir * m_flMoveDistance;
ASSERTSZ( m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal" );
9 years ago
m_fStayPushed = m_flWait == -1.0f ? TRUE : FALSE;
9 years ago
m_fRotating = TRUE;
// if the button is flagged for USE button activation only, take away it's touch function and add a use function
9 years ago
if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ) )
9 years ago
{
SetTouch( NULL );
SetUse( &CBaseButton::ButtonUse );
}
else // touchable button
SetTouch( &CBaseButton::ButtonTouch );
//SetTouch( &ButtonTouch );
}
// Make this button behave like a door (HACKHACK)
// This will disable use and make the button solid
// rotating buttons were made SOLID_NOT by default since their were some
// collision problems with them...
#define SF_MOMENTARY_DOOR 0x0001
class CMomentaryRotButton : public CBaseToggle
{
public:
9 years ago
void Spawn( void );
void KeyValue( KeyValueData *pkvd );
virtual int ObjectCaps( void )
9 years ago
{
9 years ago
int flags = CBaseToggle::ObjectCaps() & ( ~FCAP_ACROSS_TRANSITION );
if( pev->spawnflags & SF_MOMENTARY_DOOR )
9 years ago
return flags;
return flags | FCAP_CONTINUOUS_USE;
}
9 years ago
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void EXPORT Off( void );
void EXPORT Return( void );
void UpdateSelf( float value );
void UpdateSelfReturn( float value );
void UpdateAllButtons( float value, int start );
void PlaySound( void );
void UpdateTarget( float value );
static CMomentaryRotButton *Instance( edict_t *pent ) { return (CMomentaryRotButton *)GET_PRIVATE( pent ); };
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
int m_lastUsed;
int m_direction;
float m_returnSpeed;
vec3_t m_start;
vec3_t m_end;
int m_sounds;
9 years ago
};
9 years ago
TYPEDESCRIPTION CMomentaryRotButton::m_SaveData[] =
{
DEFINE_FIELD( CMomentaryRotButton, m_lastUsed, FIELD_INTEGER ),
DEFINE_FIELD( CMomentaryRotButton, m_direction, FIELD_INTEGER ),
DEFINE_FIELD( CMomentaryRotButton, m_returnSpeed, FIELD_FLOAT ),
DEFINE_FIELD( CMomentaryRotButton, m_start, FIELD_VECTOR ),
DEFINE_FIELD( CMomentaryRotButton, m_end, FIELD_VECTOR ),
DEFINE_FIELD( CMomentaryRotButton, m_sounds, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CMomentaryRotButton, CBaseToggle )
9 years ago
LINK_ENTITY_TO_CLASS( momentary_rot_button, CMomentaryRotButton )
9 years ago
void CMomentaryRotButton::Spawn( void )
{
CBaseToggle::AxisDir( pev );
if( pev->speed == 0.0f )
pev->speed = 100.0f;
9 years ago
if( m_flMoveDistance < 0.0f )
9 years ago
{
m_start = pev->angles + pev->movedir * m_flMoveDistance;
m_end = pev->angles;
m_direction = 1; // This will toggle to -1 on the first use()
m_flMoveDistance = -m_flMoveDistance;
}
else
{
m_start = pev->angles;
m_end = pev->angles + pev->movedir * m_flMoveDistance;
m_direction = -1; // This will toggle to +1 on the first use()
}
9 years ago
if( pev->spawnflags & SF_MOMENTARY_DOOR )
pev->solid = SOLID_BSP;
9 years ago
else
9 years ago
pev->solid = SOLID_NOT;
9 years ago
9 years ago
pev->movetype = MOVETYPE_PUSH;
UTIL_SetOrigin( pev, pev->origin );
SET_MODEL( ENT( pev ), STRING( pev->model ) );
9 years ago
const char *pszSound = ButtonSound( m_sounds );
9 years ago
PRECACHE_SOUND( pszSound );
pev->noise = MAKE_STRING( pszSound );
9 years ago
m_lastUsed = 0;
}
void CMomentaryRotButton::KeyValue( KeyValueData *pkvd )
{
9 years ago
if( FStrEq( pkvd->szKeyName, "returnspeed" ) )
9 years ago
{
9 years ago
m_returnSpeed = atof( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
9 years ago
else if( FStrEq( pkvd->szKeyName, "sounds" ) )
9 years ago
{
9 years ago
m_sounds = atoi( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
else
CBaseToggle::KeyValue( pkvd );
}
void CMomentaryRotButton::PlaySound( void )
{
EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM );
9 years ago
}
// BUGBUG: This design causes a latentcy. When the button is retriggered, the first impulse
// will send the target in the wrong direction because the parameter is calculated based on the
// current, not future position.
void CMomentaryRotButton::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
pev->ideal_yaw = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance;
UpdateAllButtons( pev->ideal_yaw, 1 );
// Calculate destination angle and use it to predict value, this prevents sending target in wrong direction on retriggering
Vector dest = pev->angles + pev->avelocity * ( pev->nextthink - pev->ltime );
float value1 = CBaseToggle::AxisDelta( pev->spawnflags, dest, m_start ) / m_flMoveDistance;
UpdateTarget( value1 );
9 years ago
}
void CMomentaryRotButton::UpdateAllButtons( float value, int start )
{
// Update all rot buttons attached to the same target
edict_t *pentTarget = NULL;
9 years ago
for( ; ; )
9 years ago
{
9 years ago
pentTarget = FIND_ENTITY_BY_STRING( pentTarget, "target", STRING( pev->target ) );
if( FNullEnt( pentTarget ) )
9 years ago
break;
9 years ago
if( FClassnameIs( VARS( pentTarget ), "momentary_rot_button" ) )
9 years ago
{
9 years ago
CMomentaryRotButton *pEntity = CMomentaryRotButton::Instance( pentTarget );
if( pEntity )
9 years ago
{
9 years ago
if( start )
9 years ago
pEntity->UpdateSelf( value );
else
pEntity->UpdateSelfReturn( value );
}
}
}
}
void CMomentaryRotButton::UpdateSelf( float value )
{
BOOL fplaysound = FALSE;
9 years ago
if( !m_lastUsed )
9 years ago
{
fplaysound = TRUE;
m_direction = -m_direction;
}
m_lastUsed = 1;
pev->nextthink = pev->ltime + 0.1f;
if( m_direction > 0 && value >= 1.0f )
9 years ago
{
pev->avelocity = g_vecZero;
pev->angles = m_end;
return;
}
else if( m_direction < 0 && value <= 0.0f )
9 years ago
{
pev->avelocity = g_vecZero;
pev->angles = m_start;
return;
}
9 years ago
if( fplaysound )
9 years ago
PlaySound();
// HACKHACK -- If we're going slow, we'll get multiple player packets per frame, bump nexthink on each one to avoid stalling
9 years ago
if( pev->nextthink < pev->ltime )
pev->nextthink = pev->ltime + 0.1f;
9 years ago
else
pev->nextthink += 0.1f;
9 years ago
9 years ago
pev->avelocity = m_direction * pev->speed * pev->movedir;
9 years ago
SetThink( &CMomentaryRotButton::Off );
}
void CMomentaryRotButton::UpdateTarget( float value )
{
9 years ago
if( !FStringNull( pev->target ) )
9 years ago
{
9 years ago
edict_t *pentTarget= NULL;
for( ; ; )
9 years ago
{
9 years ago
pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->target ) );
if( FNullEnt( pentTarget ) )
9 years ago
break;
9 years ago
CBaseEntity *pEntity = CBaseEntity::Instance( pentTarget );
if( pEntity )
9 years ago
{
pEntity->Use( this, this, USE_SET, value );
}
}
}
}
void CMomentaryRotButton::Off( void )
{
pev->avelocity = g_vecZero;
m_lastUsed = 0;
9 years ago
if( FBitSet( pev->spawnflags, SF_PENDULUM_AUTO_RETURN ) && m_returnSpeed > 0 )
9 years ago
{
SetThink( &CMomentaryRotButton::Return );
pev->nextthink = pev->ltime + 0.1f;
9 years ago
m_direction = -1;
}
else
SetThink( NULL );
}
void CMomentaryRotButton::Return( void )
{
float value = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance;
UpdateAllButtons( value, 0 ); // This will end up calling UpdateSelfReturn() n times, but it still works right
if( value > 0.0f )
9 years ago
UpdateTarget( value );
}
void CMomentaryRotButton::UpdateSelfReturn( float value )
{
if( value <= 0.0f )
9 years ago
{
pev->avelocity = g_vecZero;
pev->angles = m_start;
pev->nextthink = -1.0f;
9 years ago
SetThink( NULL );
}
else
{
pev->avelocity = -m_returnSpeed * pev->movedir;
pev->nextthink = pev->ltime + 0.1f;
9 years ago
}
}
//----------------------------------------------------------------
// Spark
//----------------------------------------------------------------
class CEnvSpark : public CBaseEntity
{
public:
9 years ago
void Spawn( void );
void Precache( void );
void EXPORT SparkThink( void );
void EXPORT SparkStart( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void EXPORT SparkStop( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void KeyValue( KeyValueData *pkvd );
9 years ago
9 years ago
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
9 years ago
9 years ago
float m_flDelay;
9 years ago
};
TYPEDESCRIPTION CEnvSpark::m_SaveData[] =
{
DEFINE_FIELD( CEnvSpark, m_flDelay, FIELD_FLOAT),
};
IMPLEMENT_SAVERESTORE( CEnvSpark, CBaseEntity )
9 years ago
LINK_ENTITY_TO_CLASS( env_spark, CEnvSpark )
LINK_ENTITY_TO_CLASS( env_debris, CEnvSpark )
9 years ago
9 years ago
void CEnvSpark::Spawn( void )
9 years ago
{
SetThink( NULL );
SetUse( NULL );
9 years ago
if( FBitSet( pev->spawnflags, 32 ) ) // Use for on/off
9 years ago
{
9 years ago
if( FBitSet( pev->spawnflags, 64 ) ) // Start on
9 years ago
{
9 years ago
SetThink( &CEnvSpark::SparkThink ); // start sparking
SetUse( &CEnvSpark::SparkStop ); // set up +USE to stop sparking
9 years ago
}
else
9 years ago
SetUse( &CEnvSpark::SparkStart );
9 years ago
}
else
9 years ago
SetThink( &CEnvSpark::SparkThink );
9 years ago
pev->nextthink = gpGlobals->time + 0.1f + RANDOM_FLOAT( 0.0f, 1.5f );
9 years ago
if( m_flDelay <= 0.0f )
m_flDelay = 1.5f;
9 years ago
9 years ago
Precache();
9 years ago
}
9 years ago
void CEnvSpark::Precache( void )
9 years ago
{
PRECACHE_SOUND( "buttons/spark1.wav" );
PRECACHE_SOUND( "buttons/spark2.wav" );
PRECACHE_SOUND( "buttons/spark3.wav" );
PRECACHE_SOUND( "buttons/spark4.wav" );
PRECACHE_SOUND( "buttons/spark5.wav" );
PRECACHE_SOUND( "buttons/spark6.wav" );
}
void CEnvSpark::KeyValue( KeyValueData *pkvd )
{
9 years ago
if( FStrEq( pkvd->szKeyName, "MaxDelay" ) )
9 years ago
{
9 years ago
m_flDelay = atof( pkvd->szValue );
9 years ago
pkvd->fHandled = TRUE;
}
9 years ago
else if( FStrEq( pkvd->szKeyName, "style" ) ||
FStrEq( pkvd->szKeyName, "height" ) ||
FStrEq( pkvd->szKeyName, "killtarget" ) ||
FStrEq( pkvd->szKeyName, "value1" ) ||
FStrEq( pkvd->szKeyName, "value2" ) ||
FStrEq( pkvd->szKeyName, "value3" ) )
9 years ago
pkvd->fHandled = TRUE;
else
CBaseEntity::KeyValue( pkvd );
}
9 years ago
void EXPORT CEnvSpark::SparkThink( void )
9 years ago
{
pev->nextthink = gpGlobals->time + 0.1f + RANDOM_FLOAT( 0.0f, m_flDelay );
9 years ago
DoSpark( pev, pev->origin );
}
9 years ago
void EXPORT CEnvSpark::SparkStart( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
9 years ago
{
9 years ago
SetUse( &CEnvSpark::SparkStop );
SetThink( &CEnvSpark::SparkThink );
pev->nextthink = gpGlobals->time + 0.1f + RANDOM_FLOAT( 0.0f, m_flDelay );
9 years ago
}
9 years ago
void EXPORT CEnvSpark::SparkStop( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
9 years ago
{
SetUse( &CEnvSpark::SparkStart);
SetThink( NULL );
}
#define SF_BTARGET_USE 0x0001
#define SF_BTARGET_ON 0x0002
class CButtonTarget : public CBaseEntity
{
public:
void Spawn( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
9 years ago
int ObjectCaps( void );
9 years ago
};
LINK_ENTITY_TO_CLASS( button_target, CButtonTarget )
9 years ago
void CButtonTarget::Spawn( void )
{
9 years ago
pev->movetype = MOVETYPE_PUSH;
pev->solid = SOLID_BSP;
SET_MODEL( ENT( pev ), STRING( pev->model ) );
9 years ago
pev->takedamage = DAMAGE_YES;
9 years ago
if( FBitSet( pev->spawnflags, SF_BTARGET_ON ) )
9 years ago
pev->frame = 1;
}
void CButtonTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
9 years ago
if( !ShouldToggle( useType, (int)pev->frame ) )
9 years ago
return;
pev->frame = 1 - pev->frame;
9 years ago
if( pev->frame )
9 years ago
SUB_UseTargets( pActivator, USE_ON, 0 );
else
SUB_UseTargets( pActivator, USE_OFF, 0 );
}
9 years ago
int CButtonTarget::ObjectCaps( void )
9 years ago
{
int caps = CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION;
9 years ago
if( FBitSet( pev->spawnflags, SF_BTARGET_USE ) )
9 years ago
return caps | FCAP_IMPULSE_USE;
else
return caps;
}
9 years ago
int CButtonTarget::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
9 years ago
{
9 years ago
Use( Instance( pevAttacker ), this, USE_TOGGLE, 0 );
9 years ago
return 1;
}