//--------------------------------------------------------------------------------- bool CWeapon::OnActionFiremode(EntityId actorId, const ActionId& actionId, int activationMode, float value) { CActor* pOwner = GetOwnerActor(); CPlayer* pPlayer = pOwner && pOwner->IsPlayer() ? static_cast<CPlayer*>(pOwner) : 0; if (pPlayer && (pPlayer->IsCinematicFlagActive(SPlayerStats::eCinematicFlag_LowerWeapon) || pPlayer->IsCinematicFlagActive(SPlayerStats::eCinematicFlag_LowerWeaponMP)) ) return true; bool incompatibleZommMode = (m_secondaryZmId != 0 && (IsZoomed() || IsZoomingInOrOut())); if (AreAnyItemFlagsSet(eIF_BlockActions) || incompatibleZommMode) { return true; } if (activationMode == eAAM_OnPress) { IFireMode* pNewFiremode = GetFireMode(GetNextFireMode(GetCurrentFireMode())); if (pNewFiremode == m_fm) { if(pPlayer && pPlayer->CanSwitchItems()) { pPlayer->SwitchToWeaponWithAccessoryFireMode(); } } else if (!IsReloading()) { StartChangeFireMode(); } } return true; }
FragmentID CHeavyWeapon::GetSelectAction() const { if (AreAnyItemFlagsSet(eIF_Unholstering)) return GetFragmentIds().unholster_select; else return GetFragmentIds().Select; }
//--------------------------------------------------------- bool CWeapon::OnActionReload(EntityId actorId, const ActionId& actionId, int activationMode, float value) { bool playerCanStartReload = false; if (activationMode == eAAM_OnPress && (CheckPickupInteraction(this) == false)) playerCanStartReload = true; // this condition results from the interaction between reload and item pickups. If on front on an item and press reload/pick button but not for long enought, // then the player should still reload the weapon instead of picking up the item. else if(activationMode == eAAM_OnRelease && CheckPickupInteraction(this) == true) playerCanStartReload = true; float currentTime = gEnv->pTimer->GetCurrTime(); if (!playerCanStartReload && activationMode == eAAM_OnPress) m_reloadButtonTimeStamp = currentTime; else if (activationMode == eAAM_OnRelease && playerCanStartReload && currentTime > m_reloadButtonTimeStamp+g_pGameCVars->pl_useItemHoldTime) playerCanStartReload = false; if (!playerCanStartReload) return true; if (!IsBusy() && !AreAnyItemFlagsSet(eIF_Modifying)) { ReloadWeapon(); } else if (!IsReloading() && activationMode == eAAM_OnPress) { SetInputFlag(eWeaponAction_Reload); } return true; }
//--------------------------------------------------------------------- bool CWeapon::OnActionSpecial(EntityId actorId, const ActionId& actionId, int activationMode, float value) { CPlayer* pOwnerPlayer = GetOwnerPlayer(); if (pOwnerPlayer && !pOwnerPlayer->CanMelee()) return true; if(gEnv->bMultiplayer && AreAnyItemFlagsSet(eIF_Transitioning)) //Ignore the transition from attachments menu and melee immediately { ClearItemFlags( eIF_Transitioning ); } if (gEnv->bMultiplayer && !g_pGameCVars->pl_boostedMelee_allowInMP) { if (activationMode == eAAM_OnPress) { if (CanMeleeAttack()) { if (PreMeleeAttack()) MeleeAttack(); } else { CCCPOINT(Melee_PressedButMeleeNotAllowed); } } } else { if (activationMode == eAAM_OnPress) { if(CanMeleeAttack()) { if (pOwnerPlayer) { if (PreMeleeAttack()) { BoostMelee(false); MeleeAttack(); } } } else { CCCPOINT(Melee_PressedButMeleeNotAllowed); } } } return true; }
//------------------------------------------------------------------------------ bool CWeapon::OnActionZoomXI(EntityId actorId, const ActionId& actionId, int activationMode, float value) { if (!AreAnyItemFlagsSet(eIF_Modifying)) { if (g_pGameCVars->hud_ctrlZoomMode) { if (activationMode == eAAM_OnPress) { if(m_fm && !m_fm->IsReloading()) { // The zoom code includes the aim assistance if (m_fm->AllowZoom()) { StartZoom(actorId,1); } else { m_fm->Cancel(); } } } else if (activationMode == eAAM_OnRelease) { if(m_fm && !m_fm->IsReloading()) { StopZoom(actorId); } } } else { if (activationMode == eAAM_OnPress && m_fm && !m_fm->IsReloading()) { if (m_fm->AllowZoom()) { StartZoom(actorId,1); } else { m_fm->Cancel(); } } } } return true; }
bool CHeavyWeapon::CanSelect() const { if (AreAnyItemFlagsSet(eIF_Unholstering)) return true; return BaseClass::CanSelect(); }
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; }
//------------------------------------------------------------------------- bool CWeapon::OnActionModify(EntityId actorId, const ActionId& actionId, int activationMode, float value) { if (IsZoomed() || IsZoomingInOrOut()) return false; if (CanModify() && ((!IsReloading() && !IsBusy()) || AreAnyItemFlagsSet(eIF_Modifying))) { if (m_fm) m_fm->StopFire(); if (AreAnyItemFlagsSet(eIF_Modifying)) { m_enterModifyAction = 0; PlayAction(GetFragmentIds().leave_modify, 0); s_dofSpeed = fres(-g_pGameCVars->i_weapon_customisation_transition_time); s_dofValue = 1.0f; s_focusValue = -1.0f; GetScheduler()->TimerAction(g_pGameCVars->i_weapon_customisation_transition_time, CSchedulerAction<ScheduleLayer_Leave>::Create(this), false); SetItemFlags( eIF_Transitioning ); ClearItemFlags( eIF_Modifying ); GetGameObject()->InvokeRMI(CItem::SvRequestLeaveModify(), CItem::EmptyParams(), eRMI_ToServer); } else { gEnv->p3DEngine->SetPostEffectParam("Dof_Active", 1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_UseMask", 0.f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusRange", -1.f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMin", 0.5f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMax", 1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusLimit", 1.5f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMinZ", 0.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMinZScale", 0.0f); m_itemLowerMode = eILM_Raised; TagState tagState = TAG_STATE_EMPTY; m_enterModifyAction = new CItemAction(PP_PlayerAction, GetFragmentIds().enter_modify, tagState); PlayFragment(m_enterModifyAction); s_dofSpeed = fres(g_pGameCVars->i_weapon_customisation_transition_time); s_dofValue = 0.0f; SetItemFlags(eIF_Transitioning); GetScheduler()->TimerAction(g_pGameCVars->i_weapon_customisation_transition_time, CSchedulerAction<ScheduleLayer_Enter>::Create(this), false); SetItemFlags(eIF_Modifying); CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor()); if (pPlayer) { SPlayerStats *pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats()); assert(pStats); pStats->bIgnoreSprinting = true; } GetGameObject()->InvokeRMI(CItem::SvRequestEnterModify(), CItem::EmptyParams(), eRMI_ToServer); } } return true; }