예제 #1
0
int CArmorClass::GetMaxHP (CItemCtx &ItemCtx)

//	GetMaxHP
//
//	Returns the max HP for this kind of armor

	{
	//	Start with hit points defined by the class

	int iHP = m_iHitPoints;

	//	Fire event to compute HP, if necessary

	iHP = FireGetMaxHP(ItemCtx, iHP);

	//	Add mods

	const CItemEnhancement &Mods = ItemCtx.GetMods();
	if (Mods.IsNotEmpty())
		iHP = iHP * Mods.GetHPAdj() / 100;

	//	Add complete bonus

	CInstalledArmor *pSect = ItemCtx.GetArmor();
	if (pSect && pSect->IsComplete())
		iHP += m_iArmorCompleteBonus;

	//	Done

	return iHP;
	}
예제 #2
0
void CShieldClass::CalcMinMaxHP (CItemCtx &Ctx, int iCharges, int iArmorSegs, int iTotalHP, int *retiMin, int *retiMax) const

//	CalcMinMaxHP
//
//	Returns the min and max HP of this shield
//
//	iCharges = m_iMaxCharges or the current charges on item
//	iArmorSegs = count of armor segments on ship (or 0)
//	iTotalHP = current total HP of all armor segments (or 0)

	{
	int iMax = m_iHitPoints;
	int iMin = iMax;

	if (m_iExtraHPPerCharge)
		iMax = Max(0, iMax + (m_iExtraHPPerCharge * iCharges));

	if (m_iArmorShield)
		{
		iMin = m_iArmorShield;

		if (iArmorSegs > 0)
			iMax = Min(iMax, ((m_iArmorShield * iTotalHP / iArmorSegs) + 5) / 10);
		}

	//	If we're installed, fire the custom event to get max HPs

	if (Ctx.GetSource() && Ctx.GetDevice())
		{
		CItemEnhancementStack *pEnhancements = Ctx.GetDevice()->GetEnhancements();

		iMax = FireGetMaxHP(Ctx.GetDevice(), Ctx.GetSource(), iMax);

		//	Apply bonus from device (which includes mods)

		if (pEnhancements)
			iMax += (iMax * pEnhancements->GetBonus() / 100);
		}

	//	Otherwise, we just apply mods

	else
		{
		const CItemEnhancement &Mods = Ctx.GetMods();
		if (Mods.IsNotEmpty())
			iMax = iMax * Mods.GetHPAdj() / 100;
		}

	//	Done

	if (iMin > iMax)
		iMin = iMax;

	if (retiMin)
		*retiMin = iMin;

	if (retiMax)
		*retiMax = iMax;
	}
예제 #3
0
CString CShieldClass::GetReference (CItemCtx &Ctx, int iVariant, DWORD dwFlags)

//	GetReference
//
//	Returns a string that describes the basic attributes
//	of this shield
//
//	Example:
//
//		20 hp (average regen); 100MW

	{
	int i;

	CString sReference;
	CString sRegeneration;
	const CItemEnhancement &Mods = Ctx.GetMods();

	//	Compute the strength string

	int iMin, iMax;
	CalcMinMaxHP(Ctx, m_iMaxCharges, 0, 0, &iMin, &iMax);

	//	Compute the regeneration

	if (m_iRegenHP > 0)
		{
		int iRate = (int)((10.0 * g_TicksPerSecond * m_iRegenHP / m_iRegenRate) + 0.5);
		if (iRate == 0)
			sRegeneration = CONSTLIT("<0.1 hp/sec");
		else if ((iRate % 10) == 0)
			sRegeneration = strPatternSubst(CONSTLIT("%d hp/sec"), iRate / 10);
		else
			sRegeneration = strPatternSubst(CONSTLIT("%d.%d hp/sec"), iRate / 10, iRate % 10);
		}
	else
		sRegeneration = CONSTLIT("none");

	sReference = strPatternSubst("%s — regen @ %s", 
			GetReferencePower(Ctx),
			sRegeneration);

	//	Reflection

	for (i = 0; i < damageCount; i++)
		{
		if (m_Reflective.InSet((DamageTypes)i)
				|| (Mods.IsReflective() && Mods.GetDamageType() == i))
			sReference.Append(strPatternSubst(CONSTLIT(" — %s-reflecting"), GetDamageShortName((DamageTypes)i)));
		}

	return sReference;
	}
예제 #4
0
int CShieldClass::GetPowerRating (CItemCtx &Ctx)

//	GetPowerRating
//
//	Returns the power rating of the item

	{
	int iPower = m_iPowerUse;

	const CItemEnhancement &Mods = Ctx.GetMods();
	if (Mods.IsNotEmpty())
		iPower = iPower * Mods.GetPowerAdj() / 100;

	return iPower;
	}
예제 #5
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;
	}
예제 #6
0
CString CShieldClass::GetReference (CItemCtx &Ctx, int iVariant, DWORD dwFlags)

//	GetReference
//
//	Returns a string that describes the basic attributes
//	of this shield
//
//	Example:
//
//		20 hp (average regen); 100MW

	{
	int i;

	CString sReference;
	const CItemEnhancement &Mods = Ctx.GetMods();

	//	Compute the strength string

	int iMin, iMax;
	CalcMinMaxHP(Ctx, m_iMaxCharges, 0, 0, &iMin, &iMax);

	//	Compute the regeneration

	sReference = strPatternSubst("%s — regen @ %s", 
			GetReferencePower(Ctx),
			m_Regen.GetReferenceRate(CONSTLIT("hp/sec")));

	//	Reflection

	for (i = 0; i < damageCount; i++)
		{
		if (m_Reflective.InSet((DamageTypes)i)
				|| (Mods.IsReflective() && Mods.GetDamageType() == i))
			sReference.Append(strPatternSubst(CONSTLIT(" — %s-reflecting"), GetDamageShortName((DamageTypes)i)));
		}

	return sReference;
	}
예제 #7
0
CString CArmorClass::GetReference (CItemCtx &Ctx, int iVariant)
	
//	GetReference
//
//	Returns a string that describes the basic attributes
//	of this armor.
//
//	Example:
//
//		30 hp; laser-resistant; impact-resistant

	{
	int i;
	CString sReference;

	//	Get modifications

	int iLevel = m_pItemType->GetLevel();
	const CItemEnhancement &Mods = Ctx.GetMods();

	//	Radiation 

	if (m_fRadiationImmune || Mods.IsRadiationImmune())
		{
		if (iLevel < RADIATION_IMMUNE_LEVEL)
			AppendReferenceString(&sReference, CONSTLIT("radiation-immune"));
		}
	else if (iLevel >= RADIATION_IMMUNE_LEVEL)
		AppendReferenceString(&sReference, CONSTLIT("radiation-vulnerable"));

	//	If we're immune to blinding/EMP/device damage, then collapse
	//	it all under a single entry

	bool bCheckedBlind = false;
	bool bCheckedEMP = false;
	bool bCheckedDevice = false;

	if ((m_iBlindingDamageAdj == 0 || Mods.IsBlindingImmune())
			&& (m_iEMPDamageAdj == 0 || Mods.IsEMPImmune())
			&& (m_iDeviceDamageAdj < 100 || Mods.IsDeviceDamageImmune()))
		{
		if (iLevel < DEVICE_DAMAGE_IMMUNE_LEVEL)
			AppendReferenceString(&sReference, CONSTLIT("ion effect-immune"));

		bCheckedBlind = true;
		bCheckedEMP = true;
		bCheckedDevice = true;
		}

	//	Collapse blind and EMP resistance

	else if ((m_iBlindingDamageAdj == 0 || Mods.IsBlindingImmune())
			&& (m_iEMPDamageAdj == 0 || Mods.IsEMPImmune()))
		{
		if (iLevel < EMP_IMMUNE_LEVEL)
			AppendReferenceString(&sReference, CONSTLIT("blind-, EMP-immune"));

		bCheckedBlind = true;
		bCheckedEMP = true;
		}
	else if ((m_iBlindingDamageAdj < 100) && (iLevel < BLIND_IMMUNE_LEVEL)
			&& (m_iEMPDamageAdj < 100))
		{
		AppendReferenceString(&sReference, CONSTLIT("blind-, EMP-resistant"));

		bCheckedBlind = true;
		bCheckedEMP = true;
		}

	//	Otherwise, treat each separate
	//
	//	Blindness

	if (!bCheckedBlind)
		{
		if (m_iBlindingDamageAdj == 0 || Mods.IsBlindingImmune())
			{
			if (iLevel < BLIND_IMMUNE_LEVEL)
				AppendReferenceString(&sReference, CONSTLIT("blind-immune"));
			}
		else if (m_iBlindingDamageAdj < 100)
			{
			if (iLevel < BLIND_IMMUNE_LEVEL)
				AppendReferenceString(&sReference, CONSTLIT("blind-resistant"));
			else
				AppendReferenceString(&sReference, CONSTLIT("blind-vulnerable"));
			}
		else if (iLevel >= BLIND_IMMUNE_LEVEL)
			AppendReferenceString(&sReference, CONSTLIT("blind-vulnerable"));
		}

	//	EMP

	if (!bCheckedEMP)
		{
		if (m_iEMPDamageAdj == 0 || Mods.IsEMPImmune())
			{
			if (iLevel < EMP_IMMUNE_LEVEL)
				AppendReferenceString(&sReference, CONSTLIT("EMP-immune"));
			}
		else if (m_iEMPDamageAdj < 100)
			{
			if (iLevel < EMP_IMMUNE_LEVEL)
				AppendReferenceString(&sReference, CONSTLIT("EMP-resistant"));
			else
				AppendReferenceString(&sReference, CONSTLIT("EMP-vulnerable"));
			}
		else if (iLevel >= EMP_IMMUNE_LEVEL)
			AppendReferenceString(&sReference, CONSTLIT("EMP-vulnerable"));
		}

	//	Device damage

	if (!bCheckedDevice)
		{
		if (m_iDeviceDamageAdj < 100 || Mods.IsDeviceDamageImmune())
			{
			if (iLevel < DEVICE_DAMAGE_IMMUNE_LEVEL)
				AppendReferenceString(&sReference, CONSTLIT("device-protect"));
			}
		else if (iLevel >= DEVICE_DAMAGE_IMMUNE_LEVEL)
			AppendReferenceString(&sReference, CONSTLIT("device-vulnerable"));
		}

	//	Disintegration

	if (m_fDisintegrationImmune || Mods.IsDisintegrationImmune())
		AppendReferenceString(&sReference, CONSTLIT("disintegrate-immune"));

	//	Shatter

	if (IsShatterImmune(Ctx))
		AppendReferenceString(&sReference, CONSTLIT("shatter-immune"));

	//	Shield interference

	if (m_fShieldInterference || Mods.IsShieldInterfering())
		AppendReferenceString(&sReference, CONSTLIT("no-shields"));

	//	Photo repair

	if (m_fPhotoRepair || Mods.IsPhotoRegenerating())
		AppendReferenceString(&sReference, CONSTLIT("photo-repair"));

	//	Solar power

	if (m_fPhotoRecharge || Mods.IsPhotoRecharge())
		AppendReferenceString(&sReference, CONSTLIT("solar"));

	//	Regeneration

	if ((!m_Regen.IsEmpty() && !m_fPhotoRepair) || Mods.IsRegenerating())
		AppendReferenceString(&sReference, CONSTLIT("regenerate"));

	//	Decay

	if (!m_Decay.IsEmpty() || Mods.IsDecaying())
		AppendReferenceString(&sReference, CONSTLIT("decay"));

	//	Reflection

	for (i = 0; i < damageCount; i++)
		{
		if (m_Reflective.InSet((DamageTypes)i)
				|| (Mods.IsReflective() && Mods.GetDamageType() == i))
			AppendReferenceString(&sReference, strPatternSubst(CONSTLIT("%s-reflecting"), GetDamageShortName((DamageTypes)i)));
		}

	//	Done

	return sReference;
	}