Example #1
0
//------------------------------------------------------------------------
void CItem::UpdateDamageLevel()
{
    if (m_properties.hitpoints<=0 || m_damageLevels.empty())
        return;

    int slot=(m_stats.viewmode&eIVM_FirstPerson)?eIGS_FirstPerson:eIGS_ThirdPerson;

    int n=(int)m_damageLevels.size();
    int health=(int)((100.0f*MAX(0.0f, m_stats.health))/m_properties.hitpoints);
    for (int i=0; i<n; ++i)
    {
        SDamageLevel &level=m_damageLevels[i];
        if (level.min_health==0 && level.max_health==0)
            continue;

        if (level.min_health<=health && health<level.max_health)
        {
            if (level.effectId==-1)
                level.effectId=AttachEffect(slot, 0, true, level.effect.c_str(), level.helper.c_str(),
                                            Vec3Constants<float>::fVec3_Zero, Vec3Constants<float>::fVec3_OneZ, level.scale, true);
        }
        else if (level.effectId!=-1)
        {
            AttachEffect(0, level.effectId, false);
            level.effectId=-1;
        }
    }
}
Example #2
0
	KVOID BulletFactor::BindEffect( PropertySet kProp )
	{
		//////////////////////////////////////////////////////////////////////////
		// 加载特效
		KSTR sEffect;
		if (kProp.GetStrValue("$SpawnEffect",sEffect))
		{
			KFLOAT fTimes = -1.0f;
			kProp.GetFloatValue("$SpawnEffectTime",fTimes);

			EffectObject* pObj = AttachEffect(sEffect,fTimes);
			if (pObj)
			{	// 设置特效缩放
				KFLOAT fEfScale;
				if (kProp.GetFloatValue("$SpawnEffectScale",fEfScale))
				{
					pObj->SetScale(fEfScale);
				}
				pObj->SetUserData(1);
				pObj->SetCallbackObj(this);
			}
		}
		if (kProp.GetStrValue("$IdleEffect",sEffect))
		{
			KFLOAT fTimes = -1.0f;
			kProp.GetFloatValue("$IdleEffectTime",fTimes);

			EffectObject* pObj = AttachEffect(sEffect,fTimes);
			if (pObj)
			{	// 设置特效缩放
				KFLOAT fEfScale;
				if (kProp.GetFloatValue("$IdleEffectScale",fEfScale))
				{
					pObj->SetScale(fEfScale);
				}
				pObj->SetUserData(2);
				pObj->SetCallbackObj(this);
			}
		}
		if (kProp.GetStrValue("$DestroyEffect",sEffect))
		{
			KFLOAT fTimes = -1.0f;
			kProp.GetFloatValue("$DestroyEffectTime",fTimes);

			EffectObject* pObj = AttachEffect(sEffect,fTimes);
			if (pObj)
			{	// 设置特效缩放
				KFLOAT fEfScale;
				if (kProp.GetFloatValue("$DestroyEffectScale",fEfScale))
				{
					pObj->SetScale(fEfScale);
				}

				pObj->SetUserData(3);
				pObj->SetCallbackObj(this);
			}
		}
	}
Example #3
0
void CJaw::CreateSmokeEffect()
{
	const CFireMode* pFireMode = static_cast<CFireMode*>(m_fm);
	if (pFireMode)
	{
		const SFireModeParams* pFireModeParams = pFireMode->GetShared();
		AttachEffect(eIGS_ThirdPerson, pFireModeParams->muzzlesmoke.helperFromAccessory, pFireModeParams->muzzlesmoke.effect[1].c_str(), pFireModeParams->muzzlesmoke.helper[1].c_str());
	}
}
Example #4
0
//------------------------------------------------------------------------
void CProjectile::TrailEffect(bool enable, bool underWater /*=false*/)
{
	if(enable)
	{
		const STrailParams *pTrail = NULL;

		if(!underWater)
			pTrail = m_pAmmoParams->pTrail;
		else
			pTrail = m_pAmmoParams->pTrailUnderWater;

		if(!pTrail)
			return;

		bool fpOwner = false;

		if(CWeapon *pWep = GetWeapon())
			if(pWep->GetStats().fp)
				fpOwner = true;

		if(fpOwner && pTrail->effect_fp)
		{
			m_trailEffectId = AttachEffect(true, 0, pTrail->effect_fp, Vec3(0,0,0), Vec3(0,1,0), pTrail->scale, pTrail->prime);
		}
		else if(pTrail->effect)
		{
			if(!underWater)
				m_trailEffectId = AttachEffect(true, 0, pTrail->effect, Vec3(0,0,0), Vec3(0,1,0), pTrail->scale, pTrail->prime);
			else
				m_trailUnderWaterId = AttachEffect(true, 0, pTrail->effect, Vec3(0,0,0), Vec3(0,1,0), pTrail->scale, pTrail->prime);
		}

	}
	else if(m_trailEffectId>=0 && !underWater)
	{
		AttachEffect(false, m_trailEffectId);
		m_trailEffectId=-1;
	}
	else if(m_trailUnderWaterId>=0 && underWater)
	{
		AttachEffect(false, m_trailUnderWaterId);
		m_trailUnderWaterId=-1;
	}
}