//------------------------------------------------------------------------
void CRapid::StopFire()
{
	bool acceleratingOrDecelerating = (m_rapidFlags & (eRapidFlag_accelerating|eRapidFlag_decelerating)) != 0;
	if (!m_firing && (m_reloading || !acceleratingOrDecelerating))
		return;

	m_firing = false;
	m_rapidFlags &= ~(eRapidFlag_startedFiring|eRapidFlag_rapidFiring);

  if(m_acceleration >= 0.0f)
  {
	  Accelerate(m_fireParams->rapidparams.deceleration);

    if (m_pWeapon->IsDestroyed())
      FinishDeceleration();
  }

  SpinUpEffect(false);
	SmokeEffect();
	
	const bool shouldTriggerStopFiringAnim =
		m_fireParams->rapidparams.min_firingTimeToStop==0.0f ||
		((gEnv->pTimer->GetAsyncTime().GetSeconds() - m_startFiringTime.GetSeconds()) > m_fireParams->rapidparams.min_firingTimeToStop);
	if (shouldTriggerStopFiringAnim)
	{
		m_queueRapidFireAction = true;
	}

	m_startFiringTime.SetSeconds(0.0f);

	m_muzzleEffect.StopFire(this);

	m_pWeapon->RequestStopFire();
}
//------------------------------------------------------------------------
void CAutomatic::StopFire()
{
	if(m_firing)
		SmokeEffect();

	m_firing = false;

	m_pWeapon->RequestStopFire();

	BaseClass::StopFire();
}
Example #3
0
//------------------------------------------------------------------------
void CRapid::NetStopFire()
{
	if(m_acceleration >= 0.0f)
	{
		Accelerate(m_pShared->rapidparams.deceleration);

	  if (m_pWeapon->IsDestroyed())
		  FinishDeceleration();
	}
	
	SpinUpEffect(false);

	if(m_firing)
		SmokeEffect();
}
//------------------------------------------------------------------------
void CRapid::StopFire()
{
	m_startedToFire = false;

	if (m_pWeapon->IsBusy() && !m_pWeapon->IsZoomingInOrOut())
	{
		return;
	}

	if (m_zoomtimeout > 0.0f)
	{
		CActor *pActor = m_pWeapon->GetOwnerActor();
		CScreenEffects *pSE = pActor ? pActor->GetScreenEffects() : NULL;

		if (pSE)
		{
			float speed = 1.0f / .1f;
			pSE->ResetBlendGroup(CScreenEffects::eSFX_GID_ZoomIn);
			pSE->ResetBlendGroup(CScreenEffects::eSFX_GID_ZoomOut);
			IBlendedEffect *fov	= CBlendedEffect<CFOVEffect>::Create(CFOVEffect(pActor->GetEntityId(), 1.0f));
			IBlendType *blend		= CBlendType<CLinearBlend>::Create(CLinearBlend(1.0f));
			pSE->StartBlend(fov, blend, speed, CScreenEffects::eSFX_GID_ZoomOut);
		}

		m_zoomtimeout = 0.0f;
	}

	if(m_acceleration >= 0.0f)
	{
		Accelerate(m_pShared->rapidparams.deceleration);

		if (m_pWeapon->IsDestroyed())
		{
			FinishDeceleration();
		}
	}

	SpinUpEffect(false);

	if(m_firing)
	{
		SmokeEffect();
	}

	m_pWeapon->RequestStopFire();
}
//------------------------------------------------------------------------
void CRapid::NetStopFire()
{
	if(m_acceleration >= 0.0f)
	{
		Accelerate(m_fireParams->rapidparams.deceleration);

	  if (m_pWeapon->IsDestroyed())
		  FinishDeceleration();
	}
	
	SpinUpEffect(false);

	if(m_firing)
		SmokeEffect();

	m_firing = false;
	m_rapidFlags &= ~(eRapidFlag_startedFiring|eRapidFlag_rapidFiring|eRapidFlag_netShooting);

	m_queueRapidFireAction = true;
	m_startFiringTime.SetSeconds(0.0f);
}
Example #6
0
//------------------------------------------------------------------------
void CAutomatic::StopFire()
{
	if(m_zoomtimeout > 0.0f)
	{
		CActor *pActor = m_pWeapon->GetOwnerActor();
		CScreenEffects *pSE = pActor?pActor->GetScreenEffects():NULL;

		if(pSE)
		{
			pSE->ResetBlendGroup(CScreenEffects::eSFX_GID_ZoomIn);

			// this is so we will zoom out always at the right speed
			//float speed = (1.0f/.1f) * (1.0f - pActor->GetScreenEffects()->GetCurrentFOV())/(1.0f - .75f);
			//speed = fabs(speed);
			float speed = 1.0f/.1f;
			//if (pActor->GetScreenEffects()->HasJobs(pActor->m_autoZoomOutID))
			//	speed = pActor->GetScreenEffects()->GetAdjustedSpeed(pActor->m_autoZoomOutID);

			pSE->ResetBlendGroup(CScreenEffects::eSFX_GID_ZoomOut);

			IBlendedEffect *fov	= CBlendedEffect<CFOVEffect>::Create(CFOVEffect(pActor->GetEntityId(),1.0f));
			IBlendType *blend		= CBlendType<CLinearBlend>::Create(CLinearBlend(1.0f));
			pSE->StartBlend(fov, blend, speed, CScreenEffects::eSFX_GID_ZoomOut);
		}

		m_zoomtimeout = 0.0f;
	}

	if(m_firing)
		SmokeEffect();

	m_firing = false;

	if(m_soundId)
	{
		m_pWeapon->StopSound(m_soundId);
		m_soundId = INVALID_SOUNDID;
	}
}
Example #7
0
//------------------------------------------------------------------------
void CBurst::Update(float frameTime, uint32 frameId)
{
	BaseClass::Update(frameTime, frameId);

	if (m_bursting)
	{
		if (m_next_shot <= 0.0f)
		{
			float saved_next_burst=m_next_burst;
			m_next_burst=0.0f;

			m_burst_shot = m_burst_shot+1;
			Shoot(true, m_fireParams->fireparams.autoReload);

			if (!m_firing || (m_burst_shot >= m_fireParams->burstparams.nshots-1))
			{
				EndBurst();
				m_firing = false;
				m_bursting = false;
				m_burst_shot = 0;
				SmokeEffect();
				m_pWeapon->PlayAction(GetFragmentIds().spin_down_tail);
				m_pWeapon->SetItemFlag(CItem::eIF_BlockActions, false);
			}

			m_next_burst=saved_next_burst;
		}
	}

	if (m_fireTriggerDown || m_bursting)
		m_pWeapon->RequireUpdate(eIUS_FireMode);

	m_next_burst -= frameTime;
	if (m_next_burst <= 0.0f)
		m_next_burst = 0.0f;
}
Example #8
0
//------------------------------------------------------------------------
void CBurst::StopFire()
{
	if(m_firing)
		SmokeEffect();
}
Example #9
0
//------------------------------------------------------------------------
void CRapid::Update(float frameTime, uint32 frameId)
{
  FUNCTION_PROFILER( GetISystem(), PROFILE_GAME );

  CSingle::Update(frameTime, frameId);

	if (m_speed <= 0.0f && m_acceleration < 0.0001f)
	{
		FinishDeceleration();
		return;
	}

	m_pWeapon->RequireUpdate(eIUS_FireMode);

	m_speed = m_speed + m_acceleration*frameTime;

	if (m_speed > m_pShared->rapidparams.max_speed)
	{
		m_speed = m_pShared->rapidparams.max_speed;
		m_accelerating = false;
	}

	if ((m_speed >= m_pShared->rapidparams.min_speed) && (!m_decelerating))
	{
		float dt = 1.0f;
		if (cry_fabsf(m_speed)>0.001f && cry_fabsf(m_pShared->rapidparams.max_speed>0.001f))
			dt=m_speed/m_pShared->rapidparams.max_speed;
		m_next_shot_dt = 60.0f/(m_pShared->fireparams.rate*dt);

		bool canShoot = CanFire(false);

		if (canShoot)
		{
			if (!OutOfAmmo())
			{
				if (m_netshooting)
					Firing(true);
				else
					Firing(Shoot(true, false));

				if (m_firing && !(m_pShared->rapidparams.camshake_rotate.IsZero() && m_pShared->rapidparams.camshake_shift.IsZero()))
				{
					CActor *act = m_pWeapon->GetOwnerActor();
					if (act && act->IsClient())
					{
						IView *pView = g_pGame->GetIGameFramework()->GetIViewSystem()->GetActiveView();
						if (pView)            
							pView->SetViewShake(Ang3(m_pShared->rapidparams.camshake_rotate), m_pShared->rapidparams.camshake_shift, m_next_shot_dt/m_pShared->rapidparams.camshake_perShot, m_next_shot_dt/m_pShared->rapidparams.camshake_perShot, 0, 1);            
					}
				}
			}
			else
			{
				Firing(false);
				Accelerate(m_pShared->rapidparams.deceleration);
				if (m_pWeapon->GetOwnerActor() && m_pWeapon->GetOwnerActor()->IsPlayer())
				{
					SmokeEffect();
					m_pWeapon->Reload();
				}
			}
		}
	}
	else if (m_firing)
	{
		Firing(false);
		if (OutOfAmmo() && m_pWeapon->GetOwnerActor() && m_pWeapon->GetOwnerActor()->IsPlayer())
		{
			SmokeEffect();
			m_pWeapon->Reload();
		}
	}

	if ((m_speed < m_pShared->rapidparams.min_speed) && (m_acceleration < 0.0f) && (!m_decelerating))
		Accelerate(m_pShared->rapidparams.deceleration);

	UpdateRotation(frameTime);
	UpdateSound(frameTime);
}