示例#1
1
int SelectHeaviestSequence( CStudioHdr *pstudiohdr, int activity )
{
	if ( !pstudiohdr )
		return 0;

	VerifySequenceIndex( pstudiohdr );

	int maxweight = 0;
	int seq = ACTIVITY_NOT_AVAILABLE;
	int weight = 0;
	for (int i = 0; i < pstudiohdr->GetNumSeq(); i++)
	{
		int curActivity = GetSequenceActivity( pstudiohdr, i, &weight );
		if (curActivity == activity)
		{
			if ( iabs(weight) > maxweight )
			{
				maxweight = iabs(weight);
				seq = i;
			}
		}
	}

	return seq;
}
void CASW_Weapon_Minigun::UpdateSpinningBarrel()
{
	if (GetSequenceActivity(GetSequence()) != ACT_VM_PRIMARYATTACK)
	{
		SetActivity(ACT_VM_PRIMARYATTACK, 0);
	}
	m_flPlaybackRate = GetSpinRate();

	if ( GetSpinRate() > 0.0f )
	{
		if( !m_pBarrelSpinSound )
		{
			CPASAttenuationFilter filter( this );
			m_pBarrelSpinSound = CSoundEnvelopeController::GetController().SoundCreate( filter, entindex(), "ASW_Minigun.Spin" );
			CSoundEnvelopeController::GetController().Play( m_pBarrelSpinSound, 0.0, 100 );
		}
		CSoundEnvelopeController::GetController().SoundChangeVolume( m_pBarrelSpinSound, MIN( 1.0f, m_flPlaybackRate * 3.0f ), 0.0f );
		CSoundEnvelopeController::GetController().SoundChangePitch( m_pBarrelSpinSound, asw_minigun_pitch_min.GetFloat() + ( GetSpinRate() * ( asw_minigun_pitch_max.GetFloat() - asw_minigun_pitch_min.GetFloat() ) ), 0.0f );
	}
	else
	{
		if ( m_pBarrelSpinSound )
		{
			CSoundEnvelopeController::GetController().SoundDestroy( m_pBarrelSpinSound );
			m_pBarrelSpinSound = NULL;
		}
	}
}
示例#3
0
int SelectWeightedSequence( CStudioHdr *pstudiohdr, int activity, int curSequence )
{
	VPROF( "SelectWeightedSequence" );
#ifdef CLIENT_DLL
	VPROF_INCREMENT_COUNTER( "Client SelectWeightedSequence", 1 );
#else // ifdef GAME_DLL
	VPROF_INCREMENT_COUNTER( "Server SelectWeightedSequence", 1 );
#endif

	if (! pstudiohdr)
		return 0;

	if (!pstudiohdr->SequencesAvailable())
		return 0;

	VerifySequenceIndex( pstudiohdr );

	int numSeq = pstudiohdr->GetNumSeq();
	if ( numSeq == 1 )
	{
		return ( GetSequenceActivity( pstudiohdr, 0, NULL ) == activity ) ? 0 : ACTIVITY_NOT_AVAILABLE;
	}

	return pstudiohdr->SelectWeightedSequence( activity, curSequence );
}
示例#4
0
float CNPC_Infected::GetSequenceGroundSpeed( CStudioHdr *pStudioHdr, int iSequence )
{
	// Ensure navigator will move
	// TODO: Could limit it to move sequences only.
	float speed = BaseClass::GetSequenceGroundSpeed( pStudioHdr, iSequence );
	if( speed <= 0 /* */&& GetSequenceActivity( iSequence) == ACT_TERROR_RUN_INTENSE /* */ ) speed = 0.5f; //was 1.0f
	return speed;
}
void CASW_Weapon_Autogun::ReachedEndOfSequence()
{
	BaseClass::ReachedEndOfSequence();
	if (gpGlobals->curtime - m_flLastMuzzleFlashTime > 1.0)	// 0.3 is the real firing time, but spin for a bit longer
	{
		if (GetSequenceActivity(GetSequence()) != ACT_VM_IDLE)
		{
			SetActivity(ACT_VM_IDLE, 0);
		}
	}
}
void CASW_Weapon_Autogun::OnMuzzleFlashed()
{
	BaseClass::OnMuzzleFlashed();
	if (GetSequenceActivity(GetSequence()) != ACT_VM_PRIMARYATTACK)
	{
		SetActivity(ACT_VM_PRIMARYATTACK, 0);
	}
	m_flPlaybackRate = 1.0f;
	m_flLastMuzzleFlashTime = gpGlobals->curtime;
	
	int iAttachment = LookupAttachment( "eject1" );
	if( iAttachment != -1 )
	{
		EjectParticleBrass( "weapon_shell_casing_rifle", iAttachment );
	}
	if ( m_hGunSmoke.IsValid() )
	{
		m_hGunSmoke->OnFired();
	}
}
示例#7
-7
int SelectWeightedSequence( CStudioHdr *pstudiohdr, int activity, int curSequence )
{
	VPROF( "SelectWeightedSequence" );

	if (! pstudiohdr)
		return 0;

	if (!pstudiohdr->SequencesAvailable())
		return 0;

	VerifySequenceIndex( pstudiohdr );

#if STUDIO_SEQUENCE_ACTIVITY_LOOKUPS_ARE_SLOW
	int weighttotal = 0;
	int seq = ACTIVITY_NOT_AVAILABLE;
	int weight = 0;
	for (int i = 0; i < pstudiohdr->GetNumSeq(); i++)
	{
		int curActivity = GetSequenceActivity( pstudiohdr, i, &weight );
		if (curActivity == activity)
		{
			if ( curSequence == i && weight < 0 )
			{
				seq = i;
				break;
			}
			weighttotal += iabs(weight);
			
			int randomValue;

			if ( IsInPrediction() )
				randomValue = SharedRandomInt( "SelectWeightedSequence", 0, weighttotal - 1, i );
			else
				randomValue = RandomInt( 0, weighttotal - 1 );
			
			if (!weighttotal || randomValue < iabs(weight))
				seq = i;
		}
	}

	return seq;
#else
	return pstudiohdr->SelectWeightedSequence( activity, curSequence );
#endif
}