示例#1
0
bool CPlayerRotation::ShouldProcessTargetAssistance() const
{
#if !defined(PS3) && !defined(XENON)
	if (gEnv->bMultiplayer)
	{
		return false;
	}
#endif

	if (!m_player.IsClient())
		return false;

	if (!g_pGameCVars->pl_aim_assistance_enabled)
		return false;

	if ((gEnv->bMultiplayer == false) && (g_pGameCVars->g_difficultyLevel >= g_pGameCVars->pl_aim_assistance_disabled_atDifficultyLevel))
		return false;

	IPlayerInput* pIPlayerInput = m_player.GetPlayerInput();
	if (pIPlayerInput && (pIPlayerInput->GetType() == IPlayerInput::PLAYER_INPUT))
	{
		return !(static_cast<CPlayerInput*>(pIPlayerInput)->IsAimingWithMouse());
	}

	return true;
}
void CCinematicInput::UpdateAdditiveCameraInput( IScriptSystem* pScriptSystem, float frameTime )
{
	CCinematicInput::SUpdateContext updateCtx;

	pScriptSystem->GetGlobalValue("Cinematic_CameraLookUp", updateCtx.m_lookUpLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookDown", updateCtx.m_lookDownLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookLeft", updateCtx.m_lookLeftLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookRight", updateCtx.m_lookRightLimit);
	float recenterCamera = 0.0f;
	pScriptSystem->GetGlobalValue("Cinematic_CameraDoNotCenter", recenterCamera);

	updateCtx.m_lookUpLimit = DEG2RAD(updateCtx.m_lookUpLimit);
	updateCtx.m_lookDownLimit = DEG2RAD(updateCtx.m_lookDownLimit);
	updateCtx.m_lookLeftLimit = DEG2RAD(updateCtx.m_lookLeftLimit);
	updateCtx.m_lookRightLimit = DEG2RAD(updateCtx.m_lookRightLimit);
	updateCtx.m_recenter = (recenterCamera < 0.01f);

	updateCtx.m_frameTime = frameTime;

	CActor* pClientActor = static_cast<CActor*>(g_pGame->GetIGameFramework()->GetClientActor());
	if (pClientActor)
	{
		CRY_ASSERT(pClientActor->GetActorClass() == CPlayer::GetActorClassType());
		CPlayer* pClientPlayer = static_cast<CPlayer*>(pClientActor);

		IPlayerInput* pIPlayerInput = pClientPlayer->GetPlayerInput();
		if(pIPlayerInput && pIPlayerInput->GetType() == IPlayerInput::PLAYER_INPUT)
		{
			CPlayerInput * pPlayerInput = static_cast<CPlayerInput*>(pIPlayerInput);

			Ang3 frameAccumulatedAngles(0.0f, 0.0f, 0.0f);

#if CINEMATIC_INPUT_PC_MOUSE
			const bool isAimingWithMouse = pPlayerInput->IsAimingWithMouse();

			RefreshInputMethod(isAimingWithMouse);

			if (isAimingWithMouse)
			{
				frameAccumulatedAngles = UpdateAdditiveCameraInputWithMouse(updateCtx, pPlayerInput->GetRawMouseInput());
			}
			else
			{
				frameAccumulatedAngles = UpdateAdditiveCameraInputWithController(updateCtx, pPlayerInput->GetRawControllerInput());
			}
#else
			frameAccumulatedAngles = UpdateAdditiveCameraInputWithController(updateCtx, pPlayerInput->GetRawControllerInput());
#endif

			IView* pActiveView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetActiveView();
			if (pActiveView)
			{
				pActiveView->SetFrameAdditiveCameraAngles(frameAccumulatedAngles);
			}
		}
	}
}
示例#3
0
void CCinematicInput::UpdateAdditiveCameraInput(IScriptSystem *pScriptSystem, float frameTime)
{
	float lookUpLimit = 0.0f, lookDownLimit = 0.0f;
	float lookLeftLimit = 0.0f, lookRightLimit = 0.0f;

	pScriptSystem->GetGlobalValue("Cinematic_CameraLookUp", lookUpLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookDown", lookDownLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookLeft", lookLeftLimit);
	pScriptSystem->GetGlobalValue("Cinematic_CameraLookRight", lookRightLimit);

	lookUpLimit = DEG2RAD(lookUpLimit);
	lookDownLimit = DEG2RAD(lookDownLimit);
	lookLeftLimit = DEG2RAD(lookLeftLimit);
	lookRightLimit = DEG2RAD(lookRightLimit);

	CActor *pClientActor = static_cast<CActor *>(g_pGame->GetIGameFramework()->GetClientActor());

	if(pClientActor)
	{
		CRY_ASSERT(pClientActor->GetActorClass() == CPlayer::GetActorClassType());
		CPlayer *pClientPlayer = static_cast<CPlayer *>(pClientActor);

		IPlayerInput *pIPlayerInput = pClientPlayer->GetPlayerInput();

		if(pIPlayerInput && pIPlayerInput->GetType() == IPlayerInput::PLAYER_INPUT)
		{
			CPlayerInput *pPlayerInput = static_cast<CPlayerInput *>(pIPlayerInput);

			Ang3 rawMouseInput = pPlayerInput->GetRawMouseInput() * 0.25f;
			rawMouseInput.z = - rawMouseInput.z;
			rawMouseInput.x *= (g_pGameCVars->cl_invertMouse == 0) ? 1.0f : -1.0f;

			Ang3 rawControllerInput = pPlayerInput->GetRawControllerInput() + rawMouseInput;
			//Yaw angle (Z axis)
			rawControllerInput.z = -clamp((float)__fsel(rawControllerInput.z, rawControllerInput.z * lookRightLimit, rawControllerInput.z * lookLeftLimit), -lookLeftLimit, lookRightLimit);
			//Pitch angle (X axis)
			rawControllerInput.x *= (g_pGameCVars->cl_invertController == 0) ? 1.0f : -1.0f;
			rawControllerInput.x = clamp((float)__fsel(rawControllerInput.x, rawControllerInput.x * lookUpLimit, rawControllerInput.x * lookDownLimit), -lookDownLimit, lookUpLimit);
			//No roll allowed
			rawControllerInput.y = 0.0f;

			Interpolate(m_currentRawInputAngles, rawControllerInput, 2.5f, frameTime);

			IView *pActiveView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetActiveView();

			if(pActiveView)
			{
				pActiveView->SetFrameAdditiveCameraAngles(m_currentRawInputAngles);
			}
		}
	}
}
示例#4
0
void CPlayerRotation::ProcessTargetAssistance( IItem* pCurrentPlayerItem )
{
	// aim assistance
	float targetAimAssistAngleFollowH;
	float targetAimAssistAngleFollowV;
	float targetAimAssistAngleScale;

	IPlayerInput * pIPlayerInput = m_player.GetPlayerInput();
	float absInput = 0.0f;

	float aimAssistPowerFactor = 1.0f;
	bool isUsingDedicatedInput = gEnv->IsDedicated();

#if (USE_DEDICATED_INPUT)
	isUsingDedicatedInput |= g_pGameCVars->g_playerUsesDedicatedInput ? true : false;
#endif

	if(pIPlayerInput && !isUsingDedicatedInput)
	{
		CRY_ASSERT(pIPlayerInput->GetType() == IPlayerInput::PLAYER_INPUT);
		CPlayerInput * pPlayerInput = static_cast<CPlayerInput*>(pIPlayerInput);

		const Ang3 rawDeltas = pPlayerInput->GetRawControllerInput();

		absInput = min((fabsf(rawDeltas.x) + fabsf(rawDeltas.z)) * 1.4f, 1.0f);

		aimAssistPowerFactor = 2.0f - absInput;
	}

	//Gather weapon info before processing target aim assistance
	bool playerWeaponIsRequestingSnap = false;
	CWeapon* pWeapon = GetCurrentWeapon( pCurrentPlayerItem );
	if (pWeapon)
	{
		playerWeaponIsRequestingSnap = pWeapon->ShouldSnapToTarget();
	}

	IMovementController* pMovementController = m_player.GetMovementController();
	CRY_ASSERT(pMovementController);
	SMovementState moveState;
	pMovementController->GetMovementState(moveState);

	Vec3 playerView[4] =
	{
		m_viewQuat.GetColumn0(), // Right
		m_viewQuat.GetColumn1(), // Forward
		m_viewQuat.GetColumn2(), // Up
		moveState.eyePosition    // Pos
	};

	IVehicle* pVehicle = m_player.GetLinkedVehicle();
	if (pVehicle)
	{
		Vec3 up(0.f,0.f,1.f);
		playerView[1] = moveState.eyeDirection;	// Forward
		playerView[0] = (playerView[1].cross(up)).GetNormalizedSafe(); // Right
		playerView[2] = playerView[0].cross(playerView[1]); // Up
	}

	float fZoomAmount = 0.0f;
	TargetAimAssistance(pWeapon, targetAimAssistAngleFollowH, targetAimAssistAngleFollowV, targetAimAssistAngleScale, fZoomAmount, playerView);

	targetAimAssistAngleScale = powf(targetAimAssistAngleScale, aimAssistPowerFactor);

	//TODO: Fix so it's not using auto aim unless selected

	float fFollowAssistScale = (absInput * (1.0f - fZoomAmount)) + min(absInput * fZoomAmount * __fres(g_pGameCVars->aim_assistInputForFullFollow_Ironsight), 1.0f);

	m_deltaAngles.z = (m_deltaAngles.z * targetAimAssistAngleScale) + (absInput * targetAimAssistAngleFollowH);
	m_deltaAngles.x = (m_deltaAngles.x * targetAimAssistAngleScale) + (absInput * targetAimAssistAngleFollowV);

	const bool snapToTarget = (!gEnv->bMultiplayer && playerWeaponIsRequestingSnap && !m_snap_target_dir.IsZero());
	const EntityId closeCombatSnapTargetId = g_pGame->GetAutoAimManager().GetCloseCombatSnapTarget();

	if (closeCombatSnapTargetId)
	{
		Vec3 snapDirection = GetCloseCombatSnapTargetDirection(closeCombatSnapTargetId);
		if (!snapDirection.IsZero())
		{
			const float blendSpeed = clamp_tpl( g_pGameCVars->pl_melee.melee_snap_blend_speed , 0.0f, 1.0f);
			m_deltaAngles.z = -asin_tpl(snapDirection * m_viewQuat.GetColumn0()) * blendSpeed;
			m_deltaAngles.x = asin_tpl(snapDirection * m_viewQuat.GetColumn2()) * blendSpeed;
		}
	}
	else if (snapToTarget)
	{
		const float zoomInTime = pWeapon->GetZoomInTime();
		const float blendFactor = clamp_tpl(pow_tpl((1.0f-zoomInTime),2.0f), 0.0f, 1.0f);
		m_deltaAngles.z = -asin_tpl(m_snap_target_dir * m_viewQuat.GetColumn0()) * blendFactor;
		m_deltaAngles.x = asin_tpl(m_snap_target_dir * m_viewQuat.GetColumn2()) * blendFactor;	
	}
	m_currently_snapping = playerWeaponIsRequestingSnap;

#if !defined(_RELEASE)
	if(g_pGameCVars->ctrlr_OUTPUTDEBUGINFO)
	{
		float white[] = {1,1,1,1};
		gEnv->pRenderer->Draw2dLabel( 20, 100, 1.4f, white, false, "Aim Acceleration & Assist\n  absInput: %.6f", absInput );
	}
#endif
}