void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; if( !FStringNull( m_iChainTarget )) ChainUse( useType, value ); m_bDoorTouched = false; if( IsLockedByMaster( )) { PlayLockSounds( pev, &m_ls, TRUE, FALSE ); return; } if( FBitSet( pev->spawnflags, SF_DOOR_ONOFF_MODE )) { if( useType == USE_ON ) { if( m_iState == STATE_OFF ) { // door should open if( m_hActivator != NULL && m_hActivator->IsPlayer( )) m_hActivator->TakeHealth( m_bHealthValue, DMG_GENERIC ); PlayLockSounds( pev, &m_ls, FALSE, FALSE ); DoorGoUp(); } return; } else if( useType == USE_OFF ) { if( m_iState == STATE_ON ) { DoorGoDown(); } return; } else if( useType == USE_SET ) { // change texture pev->frame = !pev->frame; return; } } // if not ready to be used, ignore "use" command. if( m_iState == STATE_OFF || FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) && m_iState == STATE_ON ) DoorActivate(); }
//----------------------------------------------------------------------------- // Purpose: Called when the player uses the door. // Input : pActivator - // pCaller - // useType - // value - //----------------------------------------------------------------------------- void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; if( m_ChainTarget != NULL_STRING ) ChainUse(); // We can't +use this if it can't be +used if ( m_hActivator != NULL && m_hActivator->IsPlayer() && HasSpawnFlags( SF_DOOR_PUSE ) == false ) { PlayLockSounds( this, &m_ls, TRUE, FALSE ); return; } bool bAllowUse = false; // if not ready to be used, ignore "use" command. if( HasSpawnFlags(SF_DOOR_NEW_USE_RULES) ) { //New behavior: // If not ready to be used, ignore "use" command. // Allow use in these cases: // - when the door is closed/closing // - when the door is open/opening and can be manually closed if ( ( m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN ) || ( HasSpawnFlags(SF_DOOR_NO_AUTO_RETURN) && ( m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP ) ) ) bAllowUse = true; } else { // Legacy behavior: if (m_toggle_state == TS_AT_BOTTOM || (HasSpawnFlags(SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP) ) bAllowUse = true; } if( bAllowUse ) { if (m_bLocked) { m_OnLockedUse.FireOutput( pActivator, pCaller ); PlayLockSounds(this, &m_ls, TRUE, FALSE); } else { DoorActivate(); } } }