void CBaseDoor::DoorTouch( CBaseEntity *pOther ) { if( !FStringNull( m_iChainTarget )) ChainTouch( pOther ); m_bDoorTouched = true; // ignore touches by anything but players and pushables if( !pOther->IsPlayer() && !pOther->IsPushable()) return; m_hActivator = pOther; // remember who activated the door // If door has master, and it's not ready to trigger, // play 'locked' sound if( IsLockedByMaster( )) PlayLockSounds( pev, &m_ls, TRUE, FALSE ); // If door is somebody's target, then touching does nothing. // You have to activate the owner (e.g. button). // g-cont. but allow touch for chain doors if( !FStringNull( pev->targetname ) && FStringNull( m_iChainTarget )) { // play locked sound PlayLockSounds( pev, &m_ls, TRUE, FALSE ); return; } if( DoorActivate( )) { // temporarily disable the touch function, until movement is finished. SetTouch( NULL ); } }
// // Doors not tied to anything (e.g. button, another door) can be touched, to make them activate. // void CBaseDoor::DoorTouch( CBaseEntity *pOther ) { entvars_t* pevToucher = pOther->pev; // Ignore touches by anything but players if (!FClassnameIs(pevToucher, "player")) return; // If door has master, and it's not ready to trigger, // play 'locked' sound if (m_sMaster && !UTIL_IsMasterTriggered(m_sMaster, pOther)) PlayLockSounds(pev, &m_ls, TRUE, FALSE); // If door is somebody's target, then touching does nothing. // You have to activate the owner (e.g. button). if (!FStringNull(pev->targetname)) { // play locked sound PlayLockSounds(pev, &m_ls, TRUE, FALSE); return; } m_hActivator = pOther;// remember who activated the door if (DoorActivate( )) SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished. }
// // Used by SUB_UseTargets, when a door is the target of a button. // void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; // if not ready to be used, ignore "use" command. if (m_toggle_state == TS_AT_BOTTOM || FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP) DoorActivate(); }
// // Doors not tied to anything (e.g. button, another door) can be touched, to make them activate. // void CBaseDoor::DoorTouch( CBaseEntity *pOther ) { // Ignore touches by anything but players if( !pOther->IsPlayer() ) return; // If door has master, and it's not ready to trigger, // play 'locked' sound if( m_sMaster && !UTIL_IsMasterTriggered( m_sMaster, pOther ) ) PlayLockSounds( this, &m_ls, true, false ); // If door is somebody's target, then touching does nothing. // You have to activate the owner (e.g. button). if( HasTargetname() ) { // play locked sound PlayLockSounds( this, &m_ls, true, false ); return; } m_hActivator = pOther;// remember who activated the door if( DoorActivate() ) SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished. }
// // Used by SUB_UseTargets, when a door is the target of a button. // void CBaseDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; if (!UTIL_IsMasterTriggered(m_sMaster, pActivator)) return; if (m_iSpeedMode==1){ //AJH for changing door speeds pev->speed+=m_fAcceleration; DoorActivate(); ALERT(at_debug, "speed increased by %f and is now %f\n", m_fAcceleration,pev->speed); } else{ if (m_iOnOffMode) { if (useType == USE_ON) { if (m_toggle_state == TS_AT_BOTTOM) { PlayLockSounds(pev, &m_ls, FALSE, FALSE); DoorGoUp(); } return; } else if (useType == USE_OFF) { if (m_toggle_state == TS_AT_TOP) { DoorGoDown(); } return; } } // if not ready to be used, ignore "use" command. if (m_toggle_state == TS_AT_TOP) { if (!FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN)) return; } else if (m_toggle_state != TS_AT_BOTTOM) return; DoorActivate(); } }
//----------------------------------------------------------------------------- // Purpose: Doors not tied to anything (e.g. button, another door) can be touched, // to make them activate. // Input : *pOther - //----------------------------------------------------------------------------- void CBaseDoor::DoorTouch( CBaseEntity *pOther ) { if( m_ChainTarget != NULL_STRING ) ChainTouch( pOther ); // Ignore touches by anything but players. if ( !pOther->IsPlayer() ) { #ifdef HL1_DLL if( PassesBlockTouchFilter( pOther ) && m_toggle_state == TS_GOING_DOWN ) { DoorGoUp(); } #endif return; } // If door is not opened by touch, do nothing. if ( !HasSpawnFlags(SF_DOOR_PTOUCH) ) { #ifdef HL1_DLL if( m_toggle_state == TS_AT_BOTTOM ) { PlayLockSounds(this, &m_ls, TRUE, FALSE); } #endif//HL1_DLL return; } // If door has master, and it's not ready to trigger, // play 'locked' sound. if (m_sMaster != NULL_STRING && !UTIL_IsMasterTriggered(m_sMaster, pOther)) { PlayLockSounds(this, &m_ls, TRUE, FALSE); } if (m_bLocked) { m_OnLockedUse.FireOutput( pOther, pOther ); PlayLockSounds(this, &m_ls, TRUE, FALSE); return; } // Remember who activated the door. m_hActivator = pOther; if (DoorActivate( )) { // Temporarily disable the touch function, until movement is finished. SetTouch( NULL ); } }
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(); } } }
// // Doors not tied to anything (e.g. button, another door) can be touched, to make them activate. // void CBaseDoor::DoorTouch( CBaseEntity *pOther ) { entvars_t* pevToucher = pOther->pev; //EDIT: si estamos tocando la puerta, mandar mensaje y terminar funcion /* if ( FBitSet ( pev->spawnflags, SF_DOOR_USE_ONLY ) )//si tiene flag "solo uso" { if ( pOther->IsPlayer())//si el que la toca es un jugador { if (FStringNull(pev->targetname))//si tiene vacio el campo de "nombre" { ClientPrint(pOther->pev, HUD_PRINTCENTER, "#PressUseForOpen"); //digamos al cliente que presione E SERVER_COMMAND("neardoor 1\n"); return;//terminar } } } */ // Ignore touches by anything but players if (!FClassnameIs(pevToucher, "player")) return; // If door has master, and it's not ready to trigger, // play 'locked' sound if (m_sMaster && !UTIL_IsMasterTriggered(m_sMaster, pOther)) PlayLockSounds(pev, &m_ls, TRUE, FALSE); // If door is somebody's target, then touching does nothing. // You have to activate the owner (e.g. button). if (!FStringNull(pev->targetname)) { // play locked sound PlayLockSounds(pev, &m_ls, TRUE, FALSE); return; } m_hActivator = pOther;// remember who activated the door if (DoorActivate( )) SetTouch( NULL ); // Temporarily disable the touch function, until movement is finished. }