//------------------------------------------------------ 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; }
bool CHeavyMountedWeapon::OnActionRipOff(EntityId actorId, const ActionId& actionId, int activationMode, float value) { //TODO: This has to be synchronized for MP if((activationMode == eAAM_OnPress) && !m_rippedOff && !m_rippingOff) { if(CanRipOff()) { TryRipOffGun(); ClearInputFlag(eWeaponAction_Fire); } return true; } return false; }
//-------------------------------------------------------------------- bool CWeapon::PreActionAttack(bool startFire) { if(startFire) { SetInputFlag(eWeaponAction_Fire); } else if(!startFire) { ClearInputFlag(eWeaponAction_Fire); } if(IsModifying()) return true; if(startFire) { return CheckSprint(); } return false; }
void CHeavyMountedWeapon::PerformRipOff(CActor* pOwner) { ExitZoom(true); UnlinkMountedGun(); SetUnMountedConfiguration(); // This needs to come after the call to UnlinkMountedGun otherwise killcam doesn't work properly AttachToHand(true); StopFire(); Physicalize(false, false); if (pOwner) { HandleHeavyWeaponPro(*pOwner); float speedOverride = 1.0f; if(pOwner->IsPlayer()) { CPlayer* pOwnerPlayer = static_cast<CPlayer*>(pOwner); speedOverride = pOwnerPlayer->GetModifiableValues().GetValue(kPMV_HeavyWeaponRipOffSpeedOverride); } PlayAction(GetFragmentIds().rip_off, 0, false, eIPAF_Default, speedOverride); m_rippingOff = true; m_stats.dropped = false; DoRipOffPrompt(GetOwnerId(), false); int timeDelay = GetCurrentAnimationTime(eIGS_Owner); timeDelay = (timeDelay > 0) ? timeDelay : 2000; int removeViewLimitDelay = int(timeDelay * 0.65f); GetScheduler()->TimerAction(timeDelay, CSchedulerAction<EndRippingOff>::Create(EndRippingOff(this)), false); GetScheduler()->TimerAction(removeViewLimitDelay, CSchedulerAction<RemoveViewLimitsAction>::Create(RemoveViewLimitsAction(this)), false); if(!pOwner->IsThirdPerson() && !(m_stats.viewmode&eIVM_FirstPerson)) { SetViewMode(eIVM_FirstPerson); } //Lock view in place during rip off SActorParams ¶ms = pOwner->GetActorParams(); Vec3 limitDir(ZERO); bool bUseMovementState = true; if (pOwner->IsClient() && (g_pGame->GetHostMigrationState() != CGame::eHMS_NotMigrating)) { // If this happens during a host migration, our aim direction may not have made it into the movement // controller yet, get it from the saved migration params instead const CGameRules::SHostMigrationClientControlledParams *pHostMigrationParams = g_pGame->GetGameRules()->GetHostMigrationClientParams(); if (pHostMigrationParams) { limitDir = pHostMigrationParams->m_aimDirection; bUseMovementState = false; } } if (bUseMovementState) { IMovementController *pMovementController = pOwner->GetMovementController(); SMovementState state; pMovementController->GetMovementState(state); limitDir = state.aimDirection; } params.viewLimits.SetViewLimit(limitDir, 0.01f, 0.01f, 0.01f, 0.01f, SViewLimitParams::eVLS_Item); pOwner->SetSpeedMultipler(SActorParams::eSMR_Item, 0.0f); if(!gEnv->bMultiplayer) pOwner->LockInteractor(GetEntityId(), false); } TriggerRespawn(); if (pOwner) { if (CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem()) { pRecordingSystem->OnWeaponRippedOff(this); } BATTLECHATTER(BC_Ripoff, GetOwnerId()); if(pOwner->IsClient()) { g_pGame->GetPersistantStats()->IncrementClientStats(EIPS_RipOffMountedWeapon); ClearInputFlag(eWeaponAction_Zoom); } } else { //--- If ripped off without an actor we should finish instantly m_rippingOff = false; m_rippedOff = true; } }
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; }