Exemplo n.º 1
0
void CHL2MPPlayerAnimState::ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr )
{
	//DHL - Skillet
	float flYaw = 0.0f;
	CDHL_Player* pDHLPlayer = ToDHLPlayer(GetBasePlayer());
	if ( pDHLPlayer->GetStuntState() == STUNT_PRONE
		&& pDHLPlayer->m_iStuntDir == STUNTDIR_FORWARDS 
		&& pDHLPlayer->GetAbsVelocity().Length() < 5.0f )
		flYaw = 0.0f;
	else
	{
		// Get the estimated movement yaw.
		EstimateYaw();

	#if 0 // 9way
		ConVarRef mp_slammoveyaw("mp_slammoveyaw");

		// Get the view yaw.
		float flAngle = AngleNormalize( m_flEyeYaw );

		// Calc side to side turning - the view vs. movement yaw.
		float flYaw = flAngle - m_PoseParameterData.m_flEstimateYaw;
		flYaw = AngleNormalize( -flYaw );

		// Get the current speed the character is running.
		bool bIsMoving;
		float flPlaybackRate = 	CalcMovementPlaybackRate( &bIsMoving );

		// Setup the 9-way blend parameters based on our speed and direction.
		Vector2D vecCurrentMoveYaw( 0.0f, 0.0f );
		if ( bIsMoving )
		{
			if ( mp_slammoveyaw.GetBool() )
				flYaw = SnapYawTo( flYaw );

			vecCurrentMoveYaw.x = cos( DEG2RAD( flYaw ) ) * flPlaybackRate;
			vecCurrentMoveYaw.y = -sin( DEG2RAD( flYaw ) ) * flPlaybackRate;
		}

		GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveX, vecCurrentMoveYaw.x );
		GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, vecCurrentMoveYaw.y );

		m_DebugAnimData.m_vecMoveYaw = vecCurrentMoveYaw;
	#else
		// view direction relative to movement
		//float flYaw;	 

		QAngle	angles = GetBasePlayer()->GetLocalAngles();
		float ang = angles[ YAW ];

		//DHL - Skillet - Local and Abs angles are 0,0,0 here for remote players on client
#ifdef CLIENT_DLL
		if ( !GetBasePlayer()->IsLocalPlayer() )
			ang = m_flEyeYaw;
#endif

		if ( ang > 180.0f )
		{
			ang -= 360.0f;
		}
		else if ( ang < -180.0f )
		{
			ang += 360.0f;
		}

		// calc side to side turning
		flYaw = ang - m_PoseParameterData.m_flEstimateYaw;
		// Invert for mapping into 8way blend
		flYaw = -flYaw;
		flYaw = flYaw - (int)(flYaw / 360) * 360;

		if (flYaw < -180)
		{
			flYaw = flYaw + 360;
		}
		else if (flYaw > 180)
		{
			flYaw = flYaw - 360;
		}
	} //DHL - Skillet endif

	//DHL - Skillet - HACK - Set stunt_yaw identically to move_yaw for non-forward prones
	int iStuntPose = GetBasePlayer()->LookupPoseParameter( pStudioHdr, "stunt_yaw" );
	if ( iStuntPose >= 0 )
	{
		if ( pDHLPlayer->GetStuntState() == STUNT_DIVE )
			GetBasePlayer()->SetPoseParameter( iStuntPose, flYaw );
		else if ( pDHLPlayer->GetStuntState() == STUNT_PRONE )
		{
			float flStuntYaw = 0.0f;
			//Hackish
			switch ( pDHLPlayer->m_iStuntDir )
			{
			case STUNTDIR_FORWARDS:
				flStuntYaw = 0.0f;
				break;
			case STUNTDIR_BACKWARDS:
				flStuntYaw = 180.0f;
				break;
			case STUNTDIR_LEFT:
				flStuntYaw = 90.0f;
				break;
			case STUNTDIR_RIGHT:
				flStuntYaw = -90.0f;
				break;
			}
			GetBasePlayer()->SetPoseParameter( iStuntPose, flStuntYaw );
		}
	}

	//Tony; the hl2mp player models have the pose parameter going the opposite direction, so we need to negate this here.
	GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, /*-*/flYaw ); //DHL - Skillet - no negation needed for our models

#endif
	
}
void CHL2MPPlayerAnimState::ComputePoseParam_MoveYaw( CStudioHdr *pStudioHdr )
{
	// Get the estimated movement yaw.
	EstimateYaw();

#if 0 // 9way
	ConVarRef mp_slammoveyaw("mp_slammoveyaw");

	// Get the view yaw.
	float flAngle = AngleNormalize( m_flEyeYaw );

	// Calc side to side turning - the view vs. movement yaw.
	float flYaw = flAngle - m_PoseParameterData.m_flEstimateYaw;
	flYaw = AngleNormalize( -flYaw );

	// Get the current speed the character is running.
	bool bIsMoving;
	float flPlaybackRate = 	CalcMovementPlaybackRate( &bIsMoving );

	// Setup the 9-way blend parameters based on our speed and direction.
	Vector2D vecCurrentMoveYaw( 0.0f, 0.0f );
	if ( bIsMoving )
	{
		if ( mp_slammoveyaw.GetBool() )
			flYaw = SnapYawTo( flYaw );

		vecCurrentMoveYaw.x = cos( DEG2RAD( flYaw ) ) * flPlaybackRate;
		vecCurrentMoveYaw.y = -sin( DEG2RAD( flYaw ) ) * flPlaybackRate;
	}

	GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveX, vecCurrentMoveYaw.x );
	GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, vecCurrentMoveYaw.y );

	m_DebugAnimData.m_vecMoveYaw = vecCurrentMoveYaw;
#else
	// view direction relative to movement
	float flYaw;	 

	QAngle	angles = GetBasePlayer()->GetLocalAngles();
	float ang = angles[ YAW ];
	if ( ang > 180.0f )
	{
		ang -= 360.0f;
	}
	else if ( ang < -180.0f )
	{
		ang += 360.0f;
	}

	// calc side to side turning
	flYaw = ang - m_PoseParameterData.m_flEstimateYaw;
	// Invert for mapping into 8way blend
	flYaw = -flYaw;
	flYaw = flYaw - (int)(flYaw / 360) * 360;

	if (flYaw < -180)
	{
		flYaw = flYaw + 360;
	}
	else if (flYaw > 180)
	{
		flYaw = flYaw - 360;
	}

	//Tony; the hl2mp player models have the pose parameter going the opposite direction, so we need to negate this here.
	GetBasePlayer()->SetPoseParameter( pStudioHdr, m_PoseParameterData.m_iMoveY, -flYaw );

#endif
	
}