Пример #1
0
//
// SpinDown - decelerates a moving func_rotating to a standstill.
//
void CFuncRotating :: SpinDown( void )
{
	SetNextThink( 0.1 );

	m_fCurSpeed = m_fCurSpeed - ( pev->speed * m_flFanFriction );
	UTIL_SetAvelocity(this, pev->movedir * m_fCurSpeed);
	//pev->avelocity = pev->avelocity - ( pev->movedir * ( pev->speed * m_flFanFriction ) );//spin down slower than spinup

	// if we've met or exceeded target speed, set target speed and stop thinking
	if (m_fCurSpeed <= 0)
	{
		m_iState = STATE_OFF;
		m_fCurSpeed = 0;
		UTIL_SetAvelocity(this, g_vecZero);
		//pev->avelocity = g_vecZero;// set speed in case we overshot
		
		// stop sound, we're done
		EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning /* Stop */), 
				0, 0, SND_STOP, m_pitch);

		SetThink(&CFuncRotating :: Rotate );
		Rotate();
	} 
	else
	{
		RampPitchVol(FALSE);
	}
}
Пример #2
0
//
// SpinUp - accelerates a non-moving func_rotating up to it's speed
//
void CFuncRotating :: SpinUp( void )
{
	Vector	vecAVel;//rotational velocity

	pev->nextthink = pev->ltime + 0.1;
	pev->avelocity = pev->avelocity + ( pev->movedir * ( pev->speed * m_flFanFriction ) );

	vecAVel = pev->avelocity;// cache entity's rotational velocity

	// if we've met or exceeded target speed, set target speed and stop thinking
	if (	abs(vecAVel.x) >= abs(pev->movedir.x * pev->speed)	&&
			abs(vecAVel.y) >= abs(pev->movedir.y * pev->speed)	&&
			abs(vecAVel.z) >= abs(pev->movedir.z * pev->speed) )
	{
		pev->avelocity = pev->movedir * pev->speed;// set speed in case we overshot
		EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), 
			m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX);
		
		SetThink( Rotate );
		Rotate();
	} 
	else
	{
		RampPitchVol(TRUE);
	}
}
Пример #3
0
//
// SpinUp - accelerates a non-moving func_rotating up to it's speed
//
void CFuncRotating :: SpinUp( void )
{
	//Vector	vecAVel;//rotational velocity

	SetNextThink( 0.1 );
	m_fCurSpeed = m_fCurSpeed + ( pev->speed * m_flFanFriction );
	UTIL_SetAvelocity(this, pev->movedir * m_fCurSpeed);
	//pev->avelocity = pev->avelocity + ( pev->movedir * ( pev->speed * m_flFanFriction ) );

	//vecAVel = pev->avelocity;// cache entity's rotational velocity

	// if we've met or exceeded target speed, set target speed and stop thinking
	if ( m_fCurSpeed >= pev->speed )
	{
		m_iState = STATE_ON;
		m_fCurSpeed = pev->speed;
		UTIL_SetAvelocity(this, pev->movedir * pev->speed);
		//pev->avelocity = pev->movedir * pev->speed;// set speed in case we overshot
		EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), 
			m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX);
		
		SetThink(&CFuncRotating :: Rotate );
		Rotate();
	} 
	else
	{
		RampPitchVol(TRUE);
	}
}
Пример #4
0
void CFuncRotating :: RotateFriction( void )
{
	// angular impulse support
	if( GetLocalAvelocity() != g_vecZero )
	{
		m_iState = STATE_ON;
		SetMoveDoneTime( 0.1 );
		RampPitchVol();
	}
	else
	{
		STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noise3 ));
		SetMoveDoneTime( -1 );
		m_iState = STATE_OFF;
	}
}
Пример #5
0
/* <1e9c3> ../cstrike/dlls/bmodels.cpp:615 */
void CFuncRotating::SpinDown(void)
{
	//rotational velocity
	Vector vecAVel;
	vec_t vecdir;

	pev->nextthink = pev->ltime + 0.1;

	//spin down slower than spinup
	pev->avelocity = pev->avelocity - (pev->movedir * (pev->speed * m_flFanFriction));

	// cache entity's rotational velocity
	vecAVel = pev->avelocity;

	if (pev->movedir.x != 0)
		vecdir = pev->movedir.x;
	else if (pev->movedir.y != 0)
		vecdir = pev->movedir.y;
	else
		vecdir = pev->movedir.z;

	// if we've met or exceeded target speed, set target speed and stop thinking
	// (note: must check for movedir > 0 or < 0)
	if (((vecdir > 0) && (vecAVel.x <= 0 && vecAVel.y <= 0 && vecAVel.z <= 0))
		|| ((vecdir < 0) && (vecAVel.x >= 0 && vecAVel.y >= 0 && vecAVel.z >= 0)))
	{
		// set speed in case we overshot
		pev->avelocity = g_vecZero;

		// stop sound, we're done
		EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), 0, ATTN_NONE, SND_STOP, m_pitch);

		SetThink(&CFuncRotating::Rotate);
		Rotate();
	}
	else
	{
		RampPitchVol(FALSE);
	}
}
Пример #6
0
//-----------------------------------------------------------------------------
// Purpose: Sets the current speed to the given value and manages the sound effects.
// Input  : flNewSpeed - New speed in degrees per second.
//-----------------------------------------------------------------------------
void CFuncRotating::UpdateSpeed( float flNewSpeed )
{
	float flOldSpeed = m_flSpeed;
	m_flSpeed = clamp( flNewSpeed, -m_flMaxSpeed, m_flMaxSpeed );

	if ( m_bStopAtStartPos )
	{
		int checkAxis = 2;
		// See if we got close to the starting orientation
		if ( m_vecMoveAng[0] != 0 )
		{
			checkAxis = 0;
		}
		else if ( m_vecMoveAng[1] != 0 )
		{
			checkAxis = 1;
		}

		float angDelta = anglemod( GetLocalAngles()[ checkAxis ] - m_angStart[ checkAxis ] );
		if ( angDelta > 180.0f )
		{
			angDelta -= 360.0f;
		}

		if ( flNewSpeed < 100 )
		{
			if ( flNewSpeed <= 25 && fabs( angDelta ) < 1.0f )
			{
				m_flTargetSpeed = 0;
				m_bStopAtStartPos = false;
				m_flSpeed = 0.0f;

				SetLocalAngles( m_angStart );
			}
			else if ( fabs( angDelta ) > 90.0f )
			{
				// Keep rotating at same speed for now
				m_flSpeed = flOldSpeed;
			}
			else
			{
				float minSpeed =  fabs( angDelta );
				if ( minSpeed < 20 )
					minSpeed = 20;
	
				m_flSpeed = flOldSpeed > 0.0f ? minSpeed : -minSpeed;
			}
		}
	}


	if ( ( flOldSpeed == 0 ) && ( m_flSpeed != 0 ) )
	{
		// Starting to move - emit the sound.
		CPASAttenuationFilter filter( GetAbsOrigin(), m_flAttenuation );
		filter.MakeReliable();
	
		EmitSound_t ep;
		ep.m_nChannel = CHAN_STATIC;
		ep.m_pSoundName = STRING(m_NoiseRunning);
		ep.m_flVolume = 0.01;
		ep.m_SoundLevel = ATTN_TO_SNDLVL( m_flAttenuation );
		ep.m_nPitch = FANPITCHMIN;

		EmitSound( filter, entindex(), ep );
		RampPitchVol();
	}
	else if ( ( flOldSpeed != 0 ) && ( m_flSpeed == 0 ) )
	{
		// Stopping - stop the sound.
		StopSound( entindex(), CHAN_STATIC, STRING(m_NoiseRunning) );
		
	}
	else
	{
		// Changing speed - adjust the pitch and volume.
		RampPitchVol();
	}

	SetLocalAngularVelocity( m_vecMoveAng * m_flSpeed );
}
Пример #7
0
void CFuncRotating :: UpdateSpeed( float flNewSpeed )
{
	float flOldSpeed = pev->speed;
	pev->speed = bound( -m_flMaxSpeed, flNewSpeed, m_flMaxSpeed );

	if( m_bStopAtStartPos )
	{
		int checkAxis = 2;

		// see if we got close to the starting orientation
		if( pev->movedir[0] != 0 )
		{
			checkAxis = 0;
		}
		else if( pev->movedir[1] != 0 )
		{
			checkAxis = 1;
		}

		float angDelta = anglemod( GetLocalAngles()[checkAxis] - m_angStart[checkAxis] );

		if( angDelta > 180.0f )
			angDelta -= 360.0f;

		if( flNewSpeed < 100 )
		{
			if( flNewSpeed <= 25 && fabs( angDelta ) < 1.0f )
			{
				m_flTargetSpeed = 0;
				m_bStopAtStartPos = false;
				pev->speed = 0.0f;

				SetLocalAngles( m_angStart );
			}
			else if( fabs( angDelta ) > 90.0f )
			{
				// keep rotating at same speed for now
				pev->speed = flOldSpeed;
			}
			else
			{
				float minSpeed =  fabs( angDelta );
				if( minSpeed < 20 ) minSpeed = 20;
	
				pev->speed = flOldSpeed > 0.0f ? minSpeed : -minSpeed;
			}
		}
	}

	SetLocalAvelocity( pev->movedir * pev->speed );

	if(( flOldSpeed == 0 ) && ( pev->speed != 0 ))
	{
		// starting to move - emit the sound.
		EMIT_SOUND_DYN( edict(), CHAN_STATIC, STRING( pev->noise3 ), 0.01f, m_flAttenuation, 0, FANPITCHMIN );
		RampPitchVol();
	}
	else if(( flOldSpeed != 0 ) && ( pev->speed == 0 ))
	{
		// stopping - stop the sound.
		STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noise3 ));
		SetMoveDoneTime( -1 );
		m_iState = STATE_OFF;
	}
	else
	{
		// changing speed - adjust the pitch and volume.
		RampPitchVol();
	}
}