Beispiel #1
0
int CItemEnhancement::GetDamageAdj (const DamageDesc &Damage) const

//	GetDamageAdj
//
//	Returns the damage adjustment confered by this mod

{
    switch (GetType())
    {
    case etResist:
        return Level2DamageAdj(GetLevel(), IsDisadvantage());

    case etResistEnergy:
        return (Damage.IsEnergyDamage() ? Level2DamageAdj(GetLevel(), IsDisadvantage()) : 100);

    case etResistMatter:
        return (Damage.IsMatterDamage() ? Level2DamageAdj(GetLevel(), IsDisadvantage()) : 100);

    case etResistByLevel:
    {
        if (Damage.GetDamageType() == GetDamageType()
                || Damage.GetDamageType() == GetDamageType() + 1)
            return Level2DamageAdj(GetLevel(), IsDisadvantage());
        else
            return 100;
    }

    case etResistByDamage:
        return (Damage.GetDamageType() == GetDamageType() ? Level2DamageAdj(GetLevel(), IsDisadvantage()) : 100);

    case etResistByDamage2:
    {
        if (Damage.GetDamageType() == GetDamageType())
            //	0 = 100			100
            //	1 = 90			111
            //	2 = 80			125
            //	3 = 70			143
            return Level2DamageAdj(GetLevel(), IsDisadvantage());
        else if (Damage.GetDamageType() == GetDamageType() + 2)
            //	0 = 100			100
            //	1 = 95			105
            //	2 = 90			112
            //	3 = 85			121
            return 100 + ((Level2DamageAdj(GetLevel(), IsDisadvantage()) - 100) / 2);
        else
            return 100;
    }

    default:
        return 100;
    }
}
bool CParticleEffect::CanBeHitBy (const DamageDesc &Damage)

//	CanBeHitBy
//
//	Returns TRUE if the given type of damage can hit this object

	{
	//	Only massless particles can hit a particle field

	return (Damage.GetDamageType() == damageLaser 
			|| Damage.GetDamageType() == damageParticle
			|| Damage.GetDamageType() == damageIonRadiation
			|| Damage.GetDamageType() == damagePositron);
	}
Beispiel #3
0
int CShieldClass::GetDamageAdj (CItemEnhancement Mods, const DamageDesc &Damage) const

//	GetDamageAdj
//
//	Damage adjustment

	{
	//	The adjustment varies by shield class

	int iAdj = m_DamageAdj.GetAdj(Damage.GetDamageType());

	//	Adjust based on difference in level (negative numbers means the shield
	//	is lower than the damage level):
	//
	//	...
	//	-3	=	4.5x damage
	//	-2	=	4x damage
	//	-1	=	3.5x damage
	//	0	=	3x damage
	//	1	=	2.5x damage
	//	2	=	2x damage
	//	3	=	1.5x damage
	//	>3	=	1x damage

	if (Damage.GetShieldDamageLevel())
		iAdj = iAdj * Max(100, 300 + (50 * (Damage.GetShieldDamageLevel() - GetLevel()))) / 100;

	//	Adjust based on enhancements

	if (Mods.IsNotEmpty())
		iAdj = iAdj * Mods.GetDamageAdj(Damage) / 100;

	return iAdj;
	}
Beispiel #4
0
bool CItemEnhancement::IsReflective (const DamageDesc &Damage, int *retiReflectChance) const

//	IsReflective
//
//	Returns TRUE if we reflect the given damage

{
    switch (GetType())
    {
    case etReflect:
    {
        if (!IsDisadvantage() && Damage.GetDamageType() == GetDamageType())
        {
            if (retiReflectChance)
                *retiReflectChance = 50 + (GetLevel() * 5);

            return true;
        }
        else
            return false;
    }

    default:
        return false;
    }
}
Beispiel #5
0
int CArmorClass::GetDamageAdj (CItemEnhancement Mods, const DamageDesc &Damage)

//	GetDamageAdj
//
//	Returns the damage adjustment for the given damage type

	{
	int iDamageAdj = GetDamageAdj(Damage.GetDamageType());

	if (Mods.IsNotEmpty())
		return iDamageAdj * Mods.GetDamageAdj(Damage) / 100;
	else
		return iDamageAdj;
	}
Beispiel #6
0
int CShieldClass::GetDamageAdj (CItemEnhancement Mods, const DamageDesc &Damage) const

//	GetDamageAdj
//
//	Damage adjustment

	{
	//	The adjustment varies by shield class

	int iAdj = (Damage.GetDamageType() == damageGeneric ? 100 : m_iDamageAdj[Damage.GetDamageType()]);

	//	Adjust based on the type of damage

	if (Damage.GetShieldDamage())
		iAdj = iAdj * Max(100, 300 + (50 * (Damage.GetShieldDamageLevel() - GetLevel()))) / 100;

	//	Adjust based on enhancements

	if (Mods.IsNotEmpty())
		iAdj = iAdj * Mods.GetDamageAdj(Damage) / 100;

	return iAdj;
	}
Beispiel #7
0
int CItemEnhancement::GetAbsorbAdj (const DamageDesc &Damage) const

//	GetAbsorbAdj
//
//	Returns damage absorbed

{
    switch (GetType())
    {
    case etReflect:
    {
        if (IsDisadvantage() && Damage.GetDamageType() == GetDamageType())
            return Level2DamageAdj(GetLevel());
        else
            return 100;
    }

    default:
        return 100;
    }
}
Beispiel #8
0
bool CArmorClass::IsReflective (CItemCtx &ItemCtx, const DamageDesc &Damage)

//	IsReflective
//
//	Returns TRUE if the armor reflects this damage

	{
	const CItemEnhancement &Mods = ItemCtx.GetMods();

	int iReflectChance = 0;

	//	Base armor chance

	if (m_Reflective.InSet(Damage.GetDamageType()))
		iReflectChance = MAX_REFLECTION_CHANCE;

	//	Mods

	int iModReflect;
	if (Mods.IsNotEmpty() && Mods.IsReflective(Damage, &iModReflect))
		iReflectChance = Max(iReflectChance, iModReflect);

	//	Done

	if (iReflectChance)
		{
		CInstalledArmor *pSect = ItemCtx.GetArmor();

		int iMaxHP = GetMaxHP(ItemCtx);
		int iHP = (pSect ? pSect->GetHitPoints() : iMaxHP);

		//	Adjust based on how damaged the armor is

		iReflectChance = (iMaxHP > 0 ? iHP * iReflectChance / iMaxHP : iReflectChance);

		return (mathRandom(1, 100) <= iReflectChance);
		}
	else
		return false;
	}