Exemple #1
0
//------------------------------------------------------------------------
void CFireModePlugin_Overheat::Activate(bool activate)
{
	CWeapon* pWeapon = m_pOwnerFiremode->GetWeapon();
		
	CRY_ASSERT(pWeapon);

	if(activate)
	{
		m_heat = 0.f;
		m_overheat = 0.f;

		if(m_nextHeatTime > 0.0f)
		{
			CTimeValue time = gEnv->pTimer->GetFrameStartTime();
			float dt = m_nextHeatTime - time.GetSeconds();
			if(dt > 0.0f)
			{
				m_heat = min(dt,1.0f);
			}
			if(dt > 1.0f)
			{
				m_overheat = dt - 1.0f;
			}
			m_nextHeatTime = 0.0f;
		}
	}
	else
	{
		if(m_heatEffectId)
		{
			pWeapon->DetachEffect(m_heatEffectId);
			m_heatEffectId = 0;
		}

		m_nextHeatTime = 0.0f;
		if(m_heat>0.0f)
		{
			CTimeValue time = gEnv->pTimer->GetFrameStartTime();
			m_nextHeatTime = time.GetSeconds() + m_heat + m_overheat;
		}

		m_heat = 0.f;
		m_overheat = 0.f;
	}

	m_firedThisFrame = false;
}
Exemple #2
0
//------------------------------------------------------------------------
bool CFireModePlugin_Overheat::Update(float frameTime, uint32 frameId)
{
	CWeapon* pWeapon = m_pOwnerFiremode->GetWeapon();

	CRY_ASSERT(pWeapon);

	CActor *pActor = pWeapon->GetOwnerActor();
	bool isOwnerAIControlled = pActor ? !pActor->IsPlayer() : false;

	if(isOwnerAIControlled)
		return false;

	float oldheat = m_heat;

	if (m_overheat > 0.0f)
	{
		m_overheat -= frameTime;
		if (m_overheat <= 0.0f)
		{
			m_overheat = 0.0f;
			FragmentID fragment = pWeapon->GetFragmentID(m_pParams->cooldown.c_str());
			pWeapon->PlayAction(fragment);				
		}
	}
	else
	{
		float add=0.0f;
		float sub=0.0f;

		if (m_firedThisFrame)
		{
			add = m_pParams->attack;

			if(pActor && pActor->GetLinkedVehicle())
			{
				const static float k_VehicleCombatMode_ScaleOverheat = 0.5f;
				add = m_pParams->attack * k_VehicleCombatMode_ScaleOverheat;	
			}

		}
		else if (m_pOwnerFiremode->GetNextShotTime()<=0.0001f && !m_pOwnerFiremode->IsFiring())
		{
			sub=frameTime / m_pParams->decay;
		}

		m_heat = clamp_tpl(m_heat + (add-sub), 0.0f, 1.0f);

		if (m_heat >= 0.999f && oldheat<0.999f)
		{
			m_overheat = m_pParams->duration;
			m_isCoolingDown = true;

			m_pOwnerFiremode->StopFire();
			FragmentID fragment = pWeapon->GetFragmentID(m_pParams->overheating.c_str());
			pWeapon->PlayAction(fragment);

			int slot = pWeapon->GetStats().fp ? eIGS_FirstPerson : eIGS_ThirdPerson;
			if (!m_pParams->effect[slot].empty())
			{
				if (m_heatEffectId)
				{
					pWeapon->DetachEffect(m_heatEffectId);
					m_heatEffectId = 0;
				}

				m_heatEffectId = pWeapon->AttachEffect(slot, false, m_pParams->effect[slot].c_str(), m_pParams->helper[slot].c_str());
			}
		}
		else if(m_heat <= m_pParams->refire_heat)
		{
			m_isCoolingDown = false;
		}
	}

	m_firedThisFrame = false;

	return (m_heat > 0.0001f);
}
void CFlashLight::EnableLight(bool enable)
{
	CWeapon* pWeapon = GetWeapon();

	if (!pWeapon || !m_sharedparams->pFlashLightParams || (m_lightEnabled && enable) || (!m_lightEnabled && !enable))
	{
		return;
	}

	CActor* pOwner = pWeapon->GetOwnerActor();
	bool ownerIsFP = pWeapon->IsOwnerFP();
	int slot = ownerIsFP ? eIGS_FirstPerson : eIGS_ThirdPerson;

	if (enable)
	{
		const char* attachHelper = "light_term";
		const Vec3 direction = Vec3(-1.0f, 0.0f, 0.0f);

		IRenderNode* pCasterException = NULL;

		if (pOwner)
		{
			IComponentRender* pRenderProxy = static_cast<IComponentRender*>(pOwner->GetEntity()->GetComponent<IComponentRender>().get());

			if (pRenderProxy)
			{
				pCasterException = pRenderProxy->GetRenderNode();
			}
		}

		EntityEffects::SLightAttachParams lightParams;

		lightParams.pCasterException = pCasterException;
		lightParams.color = m_sharedparams->pFlashLightParams->color * m_sharedparams->pFlashLightParams->diffuseMult;
		lightParams.direction = direction;
		lightParams.radius = m_sharedparams->pFlashLightParams->distance;
		lightParams.specularMultiplier = m_sharedparams->pFlashLightParams->specularMult;
		lightParams.projectFov = m_sharedparams->pFlashLightParams->fov;
		lightParams.hdrDynamic = m_sharedparams->pFlashLightParams->HDRDynamic;
		lightParams.projectTexture = m_sharedparams->pFlashLightParams->lightCookie.c_str();
		lightParams.style = m_sharedparams->pFlashLightParams->style;
		lightParams.animSpeed = m_sharedparams->pFlashLightParams->animSpeed;
		lightParams.castShadows = g_pGameCVars->i_flashlight_has_shadows != 0;
		lightParams.firstSafeSlot = eIGS_Last;

		m_lightId = pWeapon->AttachLight(slot, attachHelper, lightParams);

		EnableFogVolume(pWeapon, slot, true);
	}
	else
	{
		if (m_lightId)
		{
			pWeapon->DetachEffect(m_lightId);
		}

		m_lightId = 0;
		EnableFogVolume(pWeapon, slot, false);
	}

	m_lightEnabled = enable;
}