Beispiel #1
0
void CHeavyWeapon::StartUse(EntityId userId)
{
    // holster user item here
    SetOwnerId(userId);

    CActor* pOwner = GetOwnerActor();
    if (!pOwner)
        return;

    HighlightWeapon(false);
    Physicalize(false, false);

    if(gEnv->bMultiplayer)
        {
            m_properties.usable &= strlen(g_pGameCVars->g_forceHeavyWeapon->GetString()) == 0;

            CHANGED_NETWORK_STATE(pOwner, CPlayer::ASPECT_CURRENT_ITEM);
        }

    if(IItem* pCurrentItem = pOwner->GetCurrentItem())
        {
            //Don't keep history if we're switching from Pick & Throw otherwsie we'll switch back to it when we're done with the heavy weapon
            static IEntityClass* pPickAndThrowWeaponClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("PickAndThrowWeapon");
            m_pItemSystem->SetActorItem(pOwner, GetEntityId(), pCurrentItem->GetEntity()->GetClass() != pPickAndThrowWeaponClass);
        }
    else
        {
            m_pItemSystem->SetActorItem(pOwner, GetEntityId(), true);
        }

    TriggerRespawn();

    EnableUpdate(true, eIUS_General);
    RequireUpdate(eIUS_General);

    RegisterAsUser();

    HandleHeavyWeaponPro(*pOwner);

    m_stats.brandnew = false;
    m_stats.used = true;
    m_stats.detached = false;

    if(IsClient() && gEnv->pGame->GetIGameFramework()->GetClientActorId()==userId)
        {
            if(IEntity* pEntity = GetEntity())
                {
                    const char* collectibleId = pEntity->GetClass()->GetName();
                    CPersistantStats* pStats = g_pGame->GetPersistantStats();
                    if(pStats && pStats->GetStat(collectibleId, EMPS_SPWeaponByName) == 0)
                        {
                            pStats->SetMapStat(EMPS_SPWeaponByName, collectibleId, eDatabaseStatValueFlag_Available);

                            if(!gEnv->bMultiplayer)
                                {
                                    // Show hud unlock msg
                                    SHUDEventWrapper::DisplayWeaponUnlockMsg(collectibleId);
                                }
                        }
                }
        }

    if (IsServer())
        {
            pOwner->GetGameObject()->InvokeRMIWithDependentObject(CActor::ClStartUse(), CActor::ItemIdParam(GetEntityId()), eRMI_ToAllClients|eRMI_NoLocalCalls, GetEntityId());
            g_pGame->GetGameRules()->AbortEntityRemoval(GetEntityId());
        }

    OnStartUsing();
}
Beispiel #2
0
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 &params = 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;
	}
}