//------------------------------------------------------------------------- bool CWeapon::OnActionModify(EntityId actorId, const ActionId& actionId, int activationMode, float value) { COffHand * offHandWeapon = NULL; bool isOffHandSelected = false; GetOffHandInfo(this,isOffHandSelected,&offHandWeapon); if (!IsBusy() && !isOffHandSelected) { if (m_fm) m_fm->StopFire(); if(m_zm && m_zm->IsZoomed()) m_zm->StopZoom(); if(m_weaponRaised) RaiseWeapon(false,true); if (m_modifying && !m_transitioning) { StopLayer(g_pItemStrings->modify_layer, eIPAF_Default, false); PlayAction(g_pItemStrings->leave_modify, 0); m_dofSpeed = -1.0f/((float)GetCurrentAnimationTime(eIGS_FirstPerson)/1000.0f); m_dofValue = 1.0f; m_focusValue = -1.0f; GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleLayer_Leave>::Create(this), false); m_transitioning = true; SAFE_HUD_FUNC(WeaponAccessoriesInterface(false)); m_modifying = false; GetGameObject()->InvokeRMI(CItem::SvRequestLeaveModify(), CItem::EmptyParams(), eRMI_ToServer); } else if (!m_modifying && !m_transitioning) { gEnv->p3DEngine->SetPostEffectParam("Dof_Active", 1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusRange", -1.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMin", 0.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusMax", 5.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_FocusLimit", 20.0f); gEnv->p3DEngine->SetPostEffectParam("Dof_UseMask", 0.0f); PlayAction(g_pItemStrings->enter_modify, 0, false, eIPAF_Default | eIPAF_RepeatLastFrame); m_dofSpeed = 1.0f/((float)GetCurrentAnimationTime(eIGS_FirstPerson)/1000.0f); m_dofValue = 0.0f; m_transitioning = true; GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<ScheduleLayer_Enter>::Create(this), false); m_modifying = true; GetGameObject()->InvokeRMI(CItem::SvRequestEnterModify(), CItem::EmptyParams(), eRMI_ToServer); } } return true; }
//------------------------------------------------------------------------ void CWeapon::RequestFireMode(int fmId) { if(fmId==GetCurrentFireMode()) return; CActor *pActor=GetOwnerActor(); if (gEnv->IsClient() && pActor && pActor->IsClient()) { float animationTime = GetCurrentAnimationTime(eIGS_Owner)/1000.0f; m_switchFireModeTimeStap = gEnv->pTimer->GetCurrTime() + animationTime; if(gEnv->bServer) { SetCurrentFireMode(fmId); } else { if(m_fm) { m_fm->Activate(false); } GetGameObject()->InvokeRMI(SvRequestFireMode(), SvRequestFireModeParams(fmId), eRMI_ToServer); } StartVerificationSample(gEnv->pTimer->GetAsyncCurTime()); SHUDEvent event(eHUDEvent_OnWeaponFireModeChanged); event.AddData(SHUDEventData(fmId)); CHUDEventDispatcher::CallEvent(event); } }
//================================================= void CRocketLauncher::AutoDrop() { if(m_zm && m_zm->IsZoomed()) { GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndZoomOutAction>::Create(EndZoomOutAction(this)), true); } else if(m_fm) { m_firedRockets--; CActor* pOwner = GetOwnerActor(); // no need to auto-drop for AI if(pOwner && !pOwner->IsPlayer()) return; if((GetAmmoCount(m_fm->GetAmmoType()) + GetInventoryAmmoCount(m_fm->GetAmmoType()) <= 0)&&(m_firedRockets<=0)) { PlayAction(g_pItemStrings->deselect); GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndDropAction>::Create(EndDropAction(this)), true); } } }
void CFists::RaiseWeapon(bool raise, bool faster /*= false*/) { //Only when colliding something while running if(raise && (GetCurrentAnimState()==eFAS_RUNNING || GetCurrentAnimState()==eFAS_JUMPING) && !IsWeaponRaised()) { if((m_fm && m_fm->IsFiring())||(m_melee && m_melee->IsFiring())) return; PlayAction(g_pItemStrings->raise); SetDefaultIdleAnimation( eIGS_FirstPerson,g_pItemStrings->idle_relaxed); SetWeaponRaised(true); //Also give the player some impulse into the opposite direction CActor *pPlayer = GetOwnerActor(); Vec3 pos; if(pPlayer) { IPhysicalEntity* playerPhysics = pPlayer->GetEntity()->GetPhysics(); if(playerPhysics) { IMovementController *pMC = pPlayer->GetMovementController(); if(pMC) { SMovementState state; pMC->GetMovementState(state); pe_action_impulse impulse; impulse.iApplyTime = 1; impulse.impulse = -state.eyeDirection*600.0f; playerPhysics->Action(&impulse); pos = state.eyePosition + state.eyeDirection*0.5f; } } } GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndRaiseWeaponAction>::Create(EndRaiseWeaponAction(this)), true); //Sound and FX feedback CollisionFeeback(pos,m_currentAnimState); } else if(!raise) SetWeaponRaised(false); }
//======================================== void CRocketLauncher::Drop(float impulseScale, bool selectNext, bool byDeath) { CActor* pOwner = GetOwnerActor(); //Don't let the player drop it if it has not been opened if(m_stats.first_selection && pOwner && pOwner->IsPlayer() && pOwner->GetHealth()>0 && !byDeath) return; if(pOwner && !pOwner->IsPlayer()) { //In this case goes to the clip, no the inventory for(TAmmoMap::const_iterator it = m_minDroppedAmmo.begin();it!=m_minDroppedAmmo.end();it++) m_ammo[it->first] = it->second; m_minDroppedAmmo.clear(); } PlayAction(g_pItemStrings->deselect); GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndDropAction>::Create(EndDropAction(this)), true); }
//------------------------------------------------------------------------ void CWeapon::OnStartReload(EntityId shooterId, IEntityClass* pAmmoType) { BROADCAST_WEAPON_EVENT(OnStartReload, (this, shooterId, pAmmoType)); if (CActor *pActor = GetOwnerActor()) { if (IAIObject *pAIObject=pActor->GetEntity()->GetAI()) if (gEnv->pAISystem) gEnv->pAISystem->SendSignal( SIGNALFILTER_SENDER, 1, "OnReload", pAIObject); if(pActor->IsClient()) { if (gEnv->bMultiplayer && pActor->IsCloaked()) { CPersistantStats::GetInstance()->IncrementClientStats(EIPS_CloakedReloads); } if(m_weaponsharedparams->bulletBeltParams.numBullets > 0) { const uint32 refillTime = (uint32)(GetCurrentAnimationTime(eIGS_Owner) * m_weaponsharedparams->bulletBeltParams.beltRefillReloadFraction); GetScheduler()->TimerAction(refillTime, CSchedulerAction<RefillBeltAction>::Create(RefillBeltAction(this)), false); } } } IFireMode *pFireMode = GetFireMode(GetCurrentFireMode()); if (pFireMode) { if(GetInventoryAmmoCount(pAmmoType) < pFireMode->GetClipSize()) { BATTLECHATTER(BC_LowAmmo, shooterId); } else { BATTLECHATTER(BC_Reloading, shooterId); } } }
//----------------------------------------------------------------------- bool CBinocular::OnActionZoom(EntityId actorId, const ActionId& actionId, int activationMode, float value) { if (activationMode == eAAM_OnPress) { if(m_bZoomed == false) { PlayAction(g_pItemStrings->raise); SetWeaponRaised(true); GetScheduler()->TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<EndRaiseWeaponAction>::Create(EndRaiseWeaponAction(this)), true); } else { if(m_zm && m_zm->IsZoomed()) { PlayAction(g_pItemStrings->lower); m_zm->ExitZoom(); } ResetState(); } } return true; }
void CItem::AttachAccessory(const ItemString &name, bool attach, bool noanim, bool force, bool initialSetup) { if(!force && IsBusy()) return; bool anim = !noanim && m_stats.fp; SAccessoryParams *params = GetAccessoryParams(name); if(!params) return; if(attach) { if(!IsAccessoryHelperFree(params->attach_helper)) return; if(CItem *pAccessory = AddAccessory(name)) { pAccessory->Physicalize(false, false); pAccessory->SetViewMode(m_stats.viewmode); if(!initialSetup) pAccessory->m_bonusAccessoryAmmo.clear(); SetCharacterAttachment(eIGS_FirstPerson, params->attach_helper, pAccessory->GetEntity(), eIGS_FirstPerson, 0); SetBusy(true); AttachAction action(pAccessory, params); if(anim) { PlayAction(params->attach_action, 0, false, eIPAF_Default|eIPAF_NoBlend); m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<AttachAction>::Create(action), false); } else action.execute(this); } } else { if(CItem *pAccessory = GetAccessory(name)) { DetachAction action(pAccessory, params); if(anim) { StopLayer(params->attach_layer, eIPAF_Default|eIPAF_NoBlend); PlayAction(params->detach_action, 0, false, eIPAF_Default|eIPAF_NoBlend); m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<DetachAction>::Create(action), false); SetBusy(true); } else { SetBusy(true); action.execute(this); } } } //Skip all this for the offhand if(GetEntity()->GetClass()!=CItem::sOffHandClass) FixAccessories(params, attach); //Attach silencer to 2nd SOCOM ///////////////////////////////////////////////////////////// bool isDualWield = IsDualWieldMaster(); CItem *dualWield = 0; if(isDualWield) { IItem *slave = GetDualWieldSlave(); if(slave && slave->GetIWeapon()) dualWield = static_cast<CItem *>(slave); else isDualWield = false; } if(isDualWield) dualWield->AttachAccessory(name,attach,noanim); ////////////////////////////////////////////////////////////// //Luciano - send game event g_pGame->GetIGameFramework()->GetIGameplayRecorder()->Event(GetOwner(), GameplayEvent(eGE_AttachedAccessory, name, (float)attach, (void *)GetEntityId())); }
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; } }