Esempio n. 1
0
//----------------------------------------------------------
bool CWeapon::OnActionZoom(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	COffHand * offHandWeapon = NULL;
	bool isOffHandSelected = false;
	GetOffHandInfo(this,isOffHandSelected,&offHandWeapon);

	if (!m_modifying && (!isOffHandSelected || (offHandWeapon->GetOffHandState()&eOHS_TRANSITIONING)))
	{
		if (activationMode == eAAM_OnPress && m_useViewMode)
		{
			IncrementViewmode();
		}
		else
		{
			bool isDualWield = false;
			CWeapon *dualWield = NULL;
			GetDualWieldInfo(this,isDualWield,&dualWield);

			if (!isDualWield)
			{
				if (m_fm && !m_fm->IsReloading())
				{
					if (activationMode == eAAM_OnPress)
					{
						if(!m_fm->AllowZoom())
						{
							if(!IsTargetOn()) //Allow zoom-in, when using aiming helper
								return false;
						}

						if(m_weaponRaised)
						{
							return false;
						}

						//Use mouse wheel for scopes with several steps/stages
						if (m_zm && m_zm->IsZoomed() && m_zm->GetMaxZoomSteps()>1)
							m_zm->StopZoom();
						else
							StartZoom(actorId,1);
					}
					else if (activationMode == eAAM_OnRelease)
					{
						if(m_zm && !m_zm->IsToggle())
							m_zm->StopZoom();
					}
				}
			}
		}
	}

	return true;
}
Esempio n. 2
0
//------------------------------------------------------
void CWeapon::ForcePendingActions()
{
	CItem::ForcePendingActions();

	CActor* pOwner = GetOwnerActor();
	if(!pOwner || !pOwner->IsClient())
		return;

	//Force start firing, if needed and possible
	/*if(m_requestedFire)
	{
		if(!IsDualWield() && !IsWeaponRaised())
		{
			m_requestedFire = false;
			if(IsTargetOn() || (m_fm && !m_fm->AllowZoom()))
				return;
			
			OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
		}
		else if(IsDualWield() && IsDualWieldMaster())
		{
			IItem *slave = GetDualWieldSlave();
			if(!IsWeaponRaised())
			{
				m_requestedFire = false;
				OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
			}
			else if(slave && slave->GetIWeapon())
			{
				CWeapon* dualwield = static_cast<CWeapon*>(slave);
				if(!dualwield->IsWeaponRaised())
				{
					m_requestedFire = false;
					OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
				}
			}
		}
	}*/

	// EXP 1: Rewritten dual wield handling
	if(m_requestedFire && !IsWeaponRaised())
	{
		m_requestedFire = false;
		if(IsTargetOn() || (m_fm && !m_fm->AllowZoom()))
			return;
		
		if (!IsDualWield() || IsDualWieldSlave())
			OnAction(GetOwnerId(),"attack1",eAAM_OnPress,0.0f);
		else
			OnAction(GetOwnerId(),"attack2",eAAM_OnPress,0.0f);
	}
}
Esempio n. 3
0
//------------------------------------------------------
void CWeapon::ForcePendingActions(uint8 blockedActions)
{
	CItem::ForcePendingActions(blockedActions);

	CActor* pOwner = GetOwnerActor();
	if(!pOwner || !pOwner->IsClient() || s_lockActionRequests)
		return;

	//--- Lock action requests to ensure that we don't recurse back into this function but also
	//--- block any recursive action requests to ensure we don't repeat the actions next frame
	s_lockActionRequests = true;

	//Force start firing, if needed and possible
	if(IsInputFlagSet(eWeaponAction_Fire) && !(blockedActions&eWeaponAction_Fire))
	{
		ClearInputFlag(eWeaponAction_Fire);
		if(IsTargetOn() || (m_fm && !m_fm->AllowZoom()))
		{
			s_lockActionRequests = false;
			return;
		}
			
		OnAction(GetOwnerId(),CCryName("attack1"),eAAM_OnHold,0.0f);
	}

	//Force zoom in if needed
	if(IsInputFlagSet(eWeaponAction_Zoom) && !(blockedActions&eWeaponAction_Zoom))
	{
		if(!IsZoomed() && !IsZoomingInOrOut())
			OnActionZoom(GetOwnerId(), CCryName("zoom"), eAAM_OnPress, 0.0f);

		ClearInputFlag(eWeaponAction_Zoom);
	}

	if(IsInputFlagSet(eWeaponAction_Reload) && !(blockedActions&eWeaponAction_Reload))
	{
		if (!IsBusy())
			ReloadWeapon();
		ClearInputFlag(eWeaponAction_Reload);
	}

	s_lockActionRequests = false;
}
Esempio n. 4
0
bool CWeapon::OnActionZoom(EntityId actorId, const ActionId& actionId, int activationMode, float value)
{
	if (IsModifying())
	{
		return false;
	}

	const bool zoomingIn = IsZoomingIn();
	const bool zoomed = IsZoomed();

	const bool toggleMode = (g_pGameCVars->cl_zoomToggle > 0);
	const bool toggleZoomOn = !(zoomingIn || zoomed);

	const bool buttonPressed = (activationMode == eAAM_OnPress);

	if (!toggleMode)
	{
		// Toggle mode is off, i.e. You have to hold to stay zoomed.
		if(buttonPressed || activationMode == eAAM_OnHold)
		{
			SetInputFlag(eWeaponAction_Zoom);
		}
		else
		{
			ClearInputFlag(eWeaponAction_Zoom);
		}
	}
	else
	{
		// Toggle mode is on.
		if(buttonPressed)
		{
			if (toggleZoomOn)
			{
				SetInputFlag(eWeaponAction_Zoom);
			}
			else
			{
				ClearInputFlag(eWeaponAction_Zoom);
			}
		}
	}
	
	//can ironsight while super jumping in MP
	const bool trumpZoom = !CanZoomInState();

	if (!AreAnyItemFlagsSet(eIF_Modifying) && !trumpZoom)	
	{
		if (!m_fm || !m_fm->IsReloading())
		{
			if (buttonPressed && (!toggleMode || toggleZoomOn))
			{
				if(m_fm && !m_fm->AllowZoom())
				{
					if(IsTargetOn())
					{
						m_fm->Cancel();
					}
					else
					{
						return false;
					}
				}
			}
			else if ((!toggleMode && activationMode == eAAM_OnRelease) || // Not toggle mode and button is released
							 (toggleMode && !toggleZoomOn && buttonPressed)) // Toggle mode, zoom is to be toggled off and button is pressed
			{
				StopZoom(actorId);
			}

			const bool shouldStartZoom = (!toggleMode && (buttonPressed || activationMode == eAAM_OnHold)) ||
																	 (toggleMode && toggleZoomOn && buttonPressed);
			if (m_zm && shouldStartZoom)
			{
				const bool zoomingOut = m_zm->IsZoomingInOrOut() && !zoomingIn;
				if ((!zoomed && !zoomingIn) || zoomingOut)
				{
					StartZoom(actorId,1);
				}
				if (buttonPressed)
				{
					m_snapToTargetTimer = 0.5f;
				}
			}
		}
		else if( (!toggleMode && activationMode == eAAM_OnRelease) || (toggleMode && !toggleZoomOn && buttonPressed) )
		{
			StopZoom(actorId);
		}
	}
	else if (trumpZoom)
	{
		StopZoom(actorId);
	}

	return true;
}