Exemple #1
0
void CBaseButton :: ButtonActivate( void )
{
	EMIT_SOUND( edict(), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM );
	
	if( IsLockedByMaster( ))
	{
		// button is locked, play locked sound
		PlayLockSounds( pev, &m_ls, TRUE, TRUE );
		return;
	}
	else
	{
		// button is unlocked, play unlocked sound
		PlayLockSounds( pev, &m_ls, FALSE, TRUE );
	}

	ASSERT( m_iState == STATE_OFF );
	m_iState = STATE_TURN_ON;
	
	if( pev->spawnflags & SF_BUTTON_DONTMOVE )
	{
		TriggerAndWait();
	}
	else
	{
		SetMoveDone( &CBaseButton::TriggerAndWait );

		if( !m_fRotating )
			LinearMove( m_vecPosition2, pev->speed );
		else AngularMove( m_vecAngle2, pev->speed );
	}
}
//
// Starts the button moving "in/up".
//
void CBaseButton::ButtonActivate()
{
	EMIT_SOUND(ENT(pev), CHAN_VOICE, (char *)STRING(pev->noise), 1, ATTN_NORM);

	if(!UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
	{
		// button is locked, play locked sound
		PlayLockSounds(pev, &m_ls, TRUE, TRUE);
		return;
	}
	else
	{
		// button is unlocked, play unlocked sound
		PlayLockSounds(pev, &m_ls, FALSE, TRUE);
	}

	ASSERT(m_toggle_state == TS_AT_BOTTOM);
	m_toggle_state = TS_GOING_UP;

	SetMoveDone(&CBaseButton::TriggerAndWait);
	if(!m_fRotating)
		LinearMove(m_vecPosition2, pev->speed);
	else
		AngularMove(m_vecAngle2, pev->speed);
}
//-----------------------------------------------------------------------------
// Purpose: Starts the door going to its "down" position (simply ToggleData->vecPosition1).
//-----------------------------------------------------------------------------
void CBaseDoor::DoorGoDown( void )
{
	if ( !HasSpawnFlags( SF_DOOR_SILENT ) )
	{
		// If we're not moving already, start the moving noise
		if ( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN )
		{
			StartMovingSound();
		}
	}
	
#ifdef DOOR_ASSERT
	ASSERT(m_toggle_state == TS_AT_TOP);
#endif // DOOR_ASSERT
	m_toggle_state = TS_GOING_DOWN;

	SetMoveDone( &CBaseDoor::DoorHitBottom );
	if ( IsRotatingDoor() )//rotating door
		AngularMove( m_vecAngle1, m_flSpeed);
	else
		LinearMove( m_vecPosition1, m_flSpeed);

	//Fire our closed output
	m_OnClose.FireOutput( this, this );
}
Exemple #4
0
/* <697ad> ../cstrike/dlls/doors.cpp:762 */
void CBaseDoor::DoorGoDown(void)
{
	bool isReversing = (m_toggle_state == TS_GOING_UP);

	if (!isReversing)
	{
		if (!(pev->spawnflags & SF_DOOR_SILENT))
		{
			if (m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN)
			{
				EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving), VOL_NORM, ATTN_NORM);
			}

			TheBots->OnEvent(EVENT_DOOR, m_hActivator);
		}
	}

#ifdef DOOR_ASSERT
	assert(m_toggle_state == TS_AT_TOP);
#endif // DOOR_ASSERT

	m_toggle_state = TS_GOING_DOWN;

	SetMoveDone(&CBaseDoor::DoorHitBottom);

	//rotating door
	if (FClassnameIs(pev, "func_door_rotating"))
	{
		AngularMove(m_vecAngle1, pev->speed);
	}
	else
		LinearMove(m_vecPosition1, pev->speed);
}
//
// Starts the door going to its "up" position (simply ToggleData->vecPosition2).
//
void CBaseDoor::DoorGoUp( void )
{
	entvars_t	*pevActivator;

	// It could be going-down, if blocked.
	ASSERT(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);

	// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
	// filter them out and leave a client stuck with looping door sounds!
	if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
		EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);

//	ALERT(at_debug, "%s go up (was %d)\n", STRING(pev->targetname), m_toggle_state);
	m_toggle_state = TS_GOING_UP;
	
	SetMoveDone(&CBaseDoor:: DoorHitTop );

	// LRC- if synched, we fire as soon as we start to go up
	if (m_iImmediateMode)
	{
		if (m_iOnOffMode)
			SUB_UseTargets( m_hActivator, USE_ON, 0 );
		else
			SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
	}

	if ( FClassnameIs(pev, "func_door_rotating"))		// !!! BUGBUG Triggered doors don't work with this yet
	{
		float	sign = 1.0;

		if ( m_hActivator != NULL )
		{
			pevActivator = m_hActivator->pev;
			
			if ( !FBitSet( pev->spawnflags, SF_DOOR_ONEWAY ) && pev->movedir.y ) 		// Y axis rotation, move away from the player
			{
				Vector vec = pevActivator->origin - pev->origin;
				Vector angles = pevActivator->angles;
				angles.x = 0;
				angles.z = 0;
				UTIL_MakeVectors (angles);
	//			Vector vnext = (pevToucher->origin + (pevToucher->velocity * 10)) - pev->origin;
				UTIL_MakeVectors ( pevActivator->angles );
				Vector vnext = (pevActivator->origin + (gpGlobals->v_forward * 10)) - pev->origin;
				if ( (vec.x*vnext.y - vec.y*vnext.x) < 0 )
					sign = -1.0;
			}
		}
		AngularMove(m_vecAngle2*sign, pev->speed);
	}
	else

		if(m_iSpeedMode==1){		//AJH modifed to allow two types of accelerating doors	
			LinearMove(m_vecPosition2, pev->speed);
		}else{
			LinearMove(m_vecPosition2, pev->speed, m_fAcceleration, m_fDeceleration); }
}
Exemple #6
0
void CBaseDoor::DoorGoUp( void )
{
	entvars_t	*pevActivator;

	// It could be going-down, if blocked.
	ASSERT( m_iState == STATE_OFF || m_iState == STATE_TURN_OFF );

	// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
	// filter them out and leave a client stuck with looping door sounds!
	if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ))
		EMIT_SOUND( edict(), CHAN_STATIC, STRING( pev->noise1 ), 1, ATTN_NORM );

	m_iState = STATE_TURN_ON;
	SetMoveDone( DoorHitTop );

	if( IsRotatingDoor( ))
	{
		float sign = 1.0;

		// !!! BUGBUG Triggered doors don't work with this yet
		if( m_hActivator != NULL && m_bDoorTouched )
		{
			pevActivator = m_hActivator->pev;

			// Y axis rotation, move away from the player			
			if( !FBitSet( pev->spawnflags, SF_DOOR_ONEWAY ) && pev->movedir.y )
			{
				// Positive is CCW, negative is CW, so make 'sign' 1 or -1 based on which way we want to open.
				// Important note:  All doors face East at all times, and twist their local angle to open.
				// So you can't look at the door's facing to determine which way to open.

				Vector nearestPoint;

				CalcNearestPoint( m_hActivator->GetAbsOrigin(), &nearestPoint );
				Vector activatorToNearestPoint = nearestPoint - m_hActivator->GetAbsOrigin();
				activatorToNearestPoint.z = 0;

				Vector activatorToOrigin = GetAbsOrigin() - m_hActivator->GetAbsOrigin();
				activatorToOrigin.z = 0;

				// Point right hand at door hinge, curl hand towards closest spot on door, if thumb
				// is up, open door CW. -- Department of Basic Cross Product Understanding for Noobs
				// g-cont. MWA-HA-HA!
				Vector cross = activatorToOrigin.Cross( activatorToNearestPoint );
				if( cross.z > 0.0f ) sign = -1.0f;	
			}
		}

		AngularMove( m_vecAngle2 * sign, pev->speed );
	}
	else
	{
		LinearMove( m_vecPosition2, pev->speed );
	}
}
//
// Starts the button moving "out/down".
//
void CBaseButton::ButtonReturn(void)
{
	ASSERT(m_toggle_state == TS_AT_TOP);
	m_toggle_state = TS_GOING_DOWN;

	SetMoveDone(&CBaseButton::ButtonBackHome);
	if(!m_fRotating)
		LinearMove(m_vecPosition1, pev->speed);
	else
		AngularMove(m_vecAngle1, pev->speed);

	pev->frame = 0; // use normal textures
}
Exemple #8
0
void CBaseDoor::DoorGoDown( void )
{
	if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ))
		EMIT_SOUND( edict(), CHAN_STATIC, STRING( pev->noise1 ), 1, ATTN_NORM );
	
	ASSERT( m_iState == STATE_ON || m_iState == STATE_TURN_ON );
	m_iState = STATE_TURN_OFF;

	SetMoveDone( DoorHitBottom );

	if( IsRotatingDoor( ))
		AngularMove( m_vecAngle1, pev->speed );
	else LinearMove( m_vecPosition1, pev->speed );
}
Exemple #9
0
//
// Starts the door going to its "down" position (simply ToggleData->vecPosition1).
//
void CBaseDoor::DoorGoDown( void )
{
	if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
		EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);
	
#ifdef DOOR_ASSERT
	ASSERT(m_toggle_state == TS_AT_TOP);
#endif // DOOR_ASSERT
	m_toggle_state = TS_GOING_DOWN;

	SetMoveDone( DoorHitBottom );
	if ( FClassnameIs(pev, "func_door_rotating"))//rotating door
		AngularMove( m_vecAngle1, pev->speed);
	else
		LinearMove( m_vecPosition1, pev->speed);
}
Exemple #10
0
//
// Starts the door going to its "up" position (simply ToggleData->vecPosition2).
//
void CBaseDoor::DoorGoUp( void )
{
	entvars_t	*pevActivator;

	// It could be going-down, if blocked.
	ASSERT(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);

	// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
	// filter them out and leave a client stuck with looping door sounds!
	if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
	{
		if ( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN )
			EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);
	}

	m_toggle_state = TS_GOING_UP;
	
	SetMoveDone( &CBaseDoor::DoorHitTop );
	if ( FClassnameIs(pev, "func_door_rotating"))		// !!! BUGBUG Triggered doors don't work with this yet
	{
		float	sign = 1.0;

		if ( m_hActivator != NULL )
		{
			pevActivator = m_hActivator->pev;
			
			if ( !FBitSet( pev->spawnflags, SF_DOOR_ONEWAY ) && pev->movedir.y ) 		// Y axis rotation, move away from the player
			{
				Vector vec = pevActivator->origin - pev->origin;
				Vector angles = pevActivator->angles;
				angles.x = 0;
				angles.z = 0;
				UTIL_MakeVectors (angles);
	//			Vector vnext = (pevToucher->origin + (pevToucher->velocity * 10)) - pev->origin;
				UTIL_MakeVectors ( pevActivator->angles );
				Vector vnext = (pevActivator->origin + (gpGlobals->v_forward * 10)) - pev->origin;
				if ( (vec.x*vnext.y - vec.y*vnext.x) < 0 )
					sign = -1.0;
			}
		}
		AngularMove(m_vecAngle2*sign, pev->speed);
	}
	else
		LinearMove(m_vecPosition2, pev->speed);
}
Exemple #11
0
// Starts the button moving "out/down".
void CBaseButton::ButtonReturn()
{
	//assert(m_toggle_state == TS_AT_TOP);
	m_toggle_state = TS_GOING_DOWN;

	SetMoveDone(&CBaseButton::ButtonBackHome);
	if (!m_fRotating)
	{
		LinearMove(m_vecPosition1, pev->speed);
	}
	else
	{
		AngularMove(m_vecAngle1, pev->speed);
	}

	// use normal textures
	pev->frame = 0;
}
Exemple #12
0
//
// Starts the door going to its "down" position (simply ToggleData->vecPosition1).
//
void CBaseDoor::DoorGoDown( void )
{
	if( !GetSpawnFlags().Any( SF_DOOR_SILENT ) )
	{
		if( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN )
			EMIT_SOUND( this, CHAN_STATIC, ( char* ) STRING( pev->noiseMoving ), 1, ATTN_NORM );
	}

#ifdef DOOR_ASSERT
	ASSERT( m_toggle_state == TS_AT_TOP );
#endif // DOOR_ASSERT
	m_toggle_state = TS_GOING_DOWN;

	SetMoveDone( &CBaseDoor::DoorHitBottom );
	if( ClassnameIs( "func_door_rotating" ) )//rotating door
		AngularMove( m_vecAngle1, GetSpeed() );
	else
		LinearMove( m_vecPosition1, GetSpeed() );
}
Exemple #13
0
void CBaseButton::ButtonReturn( void )
{
	ASSERT( m_iState == STATE_ON );
	m_iState = STATE_TURN_OFF;

	if( pev->spawnflags & SF_BUTTON_DONTMOVE )
	{
		ButtonBackHome();
	}
	else
	{
		SetMoveDone( &CBaseButton::ButtonBackHome );

		if( !m_fRotating )
			LinearMove( m_vecPosition1, pev->speed );
		else AngularMove( m_vecAngle1, pev->speed );
	}

	// use normal textures
	pev->frame = 0;
}
//
// Starts the door going to its "down" position (simply ToggleData->vecPosition1).
//
void CBaseDoor::DoorGoDown( void )
{
	if ( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) )
		EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMoving), 1, ATTN_NORM);
	
//	ALERT(at_debug, "%s go down (was %d)\n", STRING(pev->targetname), m_toggle_state);

//FYI: not defined, so this doesn't happen. --LRC
#ifdef DOOR_ASSERT
	ASSERT(m_toggle_state == TS_AT_TOP);
#endif // DOOR_ASSERT
	m_toggle_state = TS_GOING_DOWN;

	SetMoveDone(&CBaseDoor:: DoorHitBottom );
	if ( FClassnameIs(pev, "func_door_rotating"))//rotating door
	{
		// LRC- if synched, we fire as soon as we start to go down
		if (m_iImmediateMode)
		{
			if (m_iOnOffMode)
				SUB_UseTargets( m_hActivator, USE_OFF, 0 );
			else
				SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 );
		}
		AngularMove( m_vecAngle1, pev->speed);
	}
	else
	{
		// LRC- if synched, we fire as soon as we start to go down
		if (m_iImmediateMode)
		{
			SUB_UseTargets( m_hActivator, USE_OFF, 0 );
		}

		if(m_iSpeedMode==1){		//AJH modifed to allow two types of accelerating doors	
			LinearMove(m_vecPosition1, pev->speed);
		}else{
			LinearMove(m_vecPosition1, pev->speed, m_fAcceleration, m_fDeceleration); }
	}
}
Exemple #15
0
//-----------------------------------------------------------------------------
// Purpose: Starts the button moving "in/up".
// Input  : *pOther - 
//-----------------------------------------------------------------------------
void CBaseButton::ButtonActivate( void )
{
	if ( m_sNoise != NULL_STRING )
	{
		CPASAttenuationFilter filter( this );

		EmitSound_t ep;
		ep.m_nChannel = CHAN_VOICE;
		ep.m_pSoundName = (char*)STRING(m_sNoise);
		ep.m_flVolume = 1;
		ep.m_SoundLevel = SNDLVL_NORM;

		EmitSound( filter, entindex(), ep );
	}
	
	if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator) || m_bLocked)
	{
		// button is locked, play locked sound
		PlayLockSounds(this, &m_ls, TRUE, TRUE);
		return;
	}
	else
	{
		// button is unlocked, play unlocked sound
		PlayLockSounds(this, &m_ls, FALSE, TRUE);
	}

	ASSERT(m_toggle_state == TS_AT_BOTTOM);
	m_toggle_state = TS_GOING_UP;
	
	SetMoveDone( &CBaseButton::TriggerAndWait );
	if (!m_fRotating)
		LinearMove( m_vecPosition2, m_flSpeed);
	else
		AngularMove( m_vecAngle2, m_flSpeed);
}
//-----------------------------------------------------------------------------
// Purpose: Starts the door going to its "up" position (simply ToggleData->vecPosition2).
//-----------------------------------------------------------------------------
void CBaseDoor::DoorGoUp( void )
{
	edict_t	*pevActivator;

	UpdateAreaPortals( true );
	// It could be going-down, if blocked.
	ASSERT(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);

	// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
	// filter them out and leave a client stuck with looping door sounds!
	if ( !HasSpawnFlags(SF_DOOR_SILENT ) )
	{
		// If we're not moving already, start the moving noise
		if ( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN )
		{
			StartMovingSound();
		}
	}

	m_toggle_state = TS_GOING_UP;
	
	SetMoveDone( &CBaseDoor::DoorHitTop );
	if ( IsRotatingDoor() )		// !!! BUGBUG Triggered doors don't work with this yet
	{
		float	sign = 1.0;

		if ( m_hActivator != NULL )
		{
			pevActivator = m_hActivator->edict();
			
			if ( !HasSpawnFlags( SF_DOOR_ONEWAY ) && m_vecMoveAng.y ) 		// Y axis rotation, move away from the player
			{
				// Positive is CCW, negative is CW, so make 'sign' 1 or -1 based on which way we want to open.
				// Important note:  All doors face East at all times, and twist their local angle to open.
				//					So you can't look at the door's facing to determine which way to open.

				Vector nearestPoint;
				CollisionProp()->CalcNearestPoint( m_hActivator->GetAbsOrigin(), &nearestPoint );
				Vector activatorToNearestPoint = nearestPoint - m_hActivator->GetAbsOrigin();
				activatorToNearestPoint.z = 0;

				Vector activatorToOrigin = GetAbsOrigin() - m_hActivator->GetAbsOrigin();
				activatorToOrigin.z = 0;

				// Point right hand at door hinge, curl hand towards closest spot on door, if thumb
				// is up, open door CW.  -- Department of Basic Cross Product Understanding for Noobs
				Vector cross = activatorToOrigin.Cross( activatorToNearestPoint );

				if( cross.z > 0.0f )
				{
					sign = -1.0f;	
				}
			}
		}
		AngularMove(m_vecAngle2*sign, m_flSpeed);
	}
	else
	{
		LinearMove(m_vecPosition2, m_flSpeed);
	}

	//Fire our open ouput
	m_OnOpen.FireOutput( this, this );
}
Exemple #17
0
/* <6a125> ../cstrike/dlls/doors.cpp:588 */
void CBaseDoor::DoorGoUp(void)
{
	entvars_t *pevActivator;
	bool isReversing = (m_toggle_state == TS_GOING_DOWN);

	// It could be going-down, if blocked.
	assert(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN);

	// emit door moving and stop sounds on CHAN_STATIC so that the multicast doesn't
	// filter them out and leave a client stuck with looping door sounds!
	if (!isReversing)
	{
		if (!(pev->spawnflags & SF_DOOR_SILENT))
		{
			if (m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN)
			{
				EMIT_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseMoving), VOL_NORM, ATTN_NORM);
			}

			TheBots->OnEvent(EVENT_DOOR, m_hActivator);
		}
	}

	m_toggle_state = TS_GOING_UP;

	SetMoveDone(&CBaseDoor::DoorHitTop);

	// !!! BUGBUG Triggered doors don't work with this yet
	if (FClassnameIs(pev, "func_door_rotating"))
	{
		float sign = 1.0;

		if (m_hActivator != NULL)
		{
			pevActivator = m_hActivator->pev;

			// Y axis rotation, move away from the player
			if (!(pev->spawnflags & SF_DOOR_ONEWAY) && pev->movedir.y)
			{
				Vector2D toActivator = pevActivator->origin.Make2D();

				float loX = pev->mins.x + pev->origin.x;
				float loY = pev->mins.y + pev->origin.y;

				float hiX = pev->maxs.x + pev->origin.x;
				float hiY = pev->maxs.y + pev->origin.y;

				float momentArmX = toActivator.x - pev->origin.x;
				float momentArmY = toActivator.y - pev->origin.y;

				if (loX > toActivator.x)
				{
					if (toActivator.y < loY)
					{
						if (abs((int)momentArmY) > abs((int)momentArmX))
							sign = (momentArmY < 0) ? 1 : -1;
						else
							sign = (momentArmX > 0) ? 1 : -1;
					}
					else if (toActivator.y > hiY)
					{
						if (abs((int)momentArmY) > abs((int)momentArmX))
							sign = (momentArmY < 0) ? 1 : -1;
						else
							sign = (momentArmX < 0) ? 1 : -1;
					}
					else
						sign = (momentArmY < 0) ? 1 : -1;
				}
				else
				{
					if (toActivator.x <= hiX)
					{
						if (toActivator.y > loY)
							sign = (momentArmX > 0) ? 1 : -1;
						else if (toActivator.y > hiY)
							sign = (momentArmX < 0) ? 1 : -1;
					}
					else if (toActivator.y < loY)
					{
						if (abs((int)momentArmY) > abs((int)momentArmX))
							sign = (momentArmY > 0) ? 1 : -1;
						else
							sign = (momentArmX > 0) ? 1 : -1;
					}
					else if (toActivator.y > hiY)
					{
						if (abs((int)momentArmY) > abs((int)momentArmX))
							sign = (momentArmY > 0) ? 1 : -1;
						else
							sign = (momentArmX < 0) ? 1 : -1;
					}
					else
						sign = (momentArmY > 0) ? 1 : -1;
				}

				if (isReversing)
				{
					sign = -sign;
				}
			}
		}

		AngularMove(m_vecAngle2 * sign, pev->speed);
	}
	else
		LinearMove(m_vecPosition2, pev->speed);
}