Esempio n. 1
0
//------------------------------------------------------------------------
void CScan::Update(float frameTime, uint32 frameId)
{
	if (m_scanning && m_pWeapon->IsClient())
	{
		if (m_delayTimer>0.0f)
		{
			m_delayTimer -= frameTime;
			if (m_delayTimer>0.0f)
				return;

			m_delayTimer = 0.0f;

			int slot = m_pWeapon->GetStats().fp ?  eIGS_FirstPerson :  eIGS_ThirdPerson;
			int id = m_pWeapon->GetStats().fp ? 0 : 1;

			m_scanLoopId=m_pWeapon->PlayAction(m_scanactions.scan, 0, true, CItem::eIPAF_Default|CItem::eIPAF_CleanBlending);
			ISound *pSound = m_pWeapon->GetSoundProxy()->GetSound(m_scanLoopId);
			if (pSound)
				pSound->GetInterfaceDeprecated()->SetLoopMode(true);
		}

		if(m_delayTimer==0.0f)
		{
			if(m_tagEntitiesDelay>0.0f)
			{
				m_tagEntitiesDelay-=frameTime;
				if(m_tagEntitiesDelay<=0.0f)
				{
					m_tagEntitiesDelay = 0.0f;

					//Here is when entities are displayed on Radar
					if(gEnv->pGame->GetIGameFramework()->GetClientActor() == m_pWeapon->GetOwnerActor())
					{
						if(gEnv->bServer)
							NetShoot(ZERO, 0);
						else
							m_pWeapon->RequestShoot(0, ZERO, ZERO, ZERO, ZERO, 1.0f, 0, false);
					}
				}
			}

			if (m_durationTimer>0.0f)
			{
				m_durationTimer-=frameTime;
				if (m_durationTimer<=0.0f)
				{
					m_durationTimer=0.0f;	
					StopFire();
					//m_pWeapon->RequestShoot(0, ZERO, ZERO, ZERO, ZERO, 1.0f, 0, false);
				}
			}
		}

		m_pWeapon->RequireUpdate(eIUS_FireMode);
	}
}
//------------------------------------------------------------------------
IMPLEMENT_RMI(CWeapon, SvRequestShoot)
{
    CHECK_OWNER_REQUEST();

    bool ok=true;
    CActor *pActor=GetActorByNetChannel(pNetChannel);
    if (!pActor || pActor->IsDead())
        ok=false;

    if (ok)
    {
        m_fireCounter++;
        m_expended_ammo++;

        IActor *pLocalActor=m_pGameFramework->GetClientActor();
        bool isLocal = pLocalActor && (pLocalActor->GetChannelId() == pActor->GetChannelId());

#ifdef SERVER_CHECKS
        const float fCurrentTime = gEnv->pTimer->GetAsyncCurTime();
        const int kOldShotId = m_lastShotId;
        if(ShouldEndVerificationSample(fCurrentTime, params.shotId))
        {
            EndVerificationSample(pActor, kOldShotId);
            StartVerificationSample(fCurrentTime);
        }

        m_fLastSampleTakenTime = fCurrentTime;
        m_fSampleNumShots += 1.0f;

        CPlayer * pPlayer = static_cast<CPlayer*>(pActor);
        pPlayer->GetShotCounter()->RecordShot();
#endif

        if (!isLocal)
        {
            NetShoot(params.hit, 0, params.fireModeId);
        }

        CHANGED_NETWORK_STATE(this, ASPECT_STREAM);
    }

#ifdef SERVER_CHECKS
    CGameRules * pGameRules = static_cast<CGameRules*>(g_pGame->GetGameRules());
    if(pGameRules)	//really we should assert here. I struggle to think of a situation where someone is requesting a shot but there are no GameRules...
    {
        IGameRulesDamageHandlingModule * pDamageHandler = pGameRules->GetDamageHandlingModule();
        assert(pDamageHandler);
        pDamageHandler->RegisterShotIdentification(pActor->GetEntityId(), this, params.shotId);
    }
#endif

    return true;
}