bool CShieldClass::GetReferenceDamageAdj (const CItem *pItem, CSpaceObject *pInstalled, int *retiHP, int *retArray) const // GetReferenceDamageAdj // // Returns an array of damage adj values { CItemCtx Ctx(pItem, pInstalled); int i; const CItemEnhancement &Mods = Ctx.GetMods(); int iMinHP, iMaxHP; CalcMinMaxHP(Ctx, m_iMaxCharges, 0, 0, &iMinHP, &iMaxHP); if (retiHP) *retiHP = iMaxHP; if (retArray) { for (i = 0; i < damageCount; i++) { DamageDesc Damage((DamageTypes)i, DiceRange(0, 0, 0)); int iAdj = GetDamageAdj(Mods, Damage); if (iAdj == 0) retArray[i] = -1; else retArray[i] = (int)((iMaxHP * 100.0 / iAdj) + 0.5); } } return true; }
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; }
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; }
int CShieldClass::CalcBalance (void) // CalcBalance // // Computes the relative balance of this shield relative to it level { int i; int iBalance = 0; SStdStats *pStd = GetStdStats(GetLevel()); if (pStd == NULL) return 0; // Calc HPs. +1 for each 1% above standard HP // If hp is below the standard, then invert the ratio // (i.e., 50% below is 1/0.5 or half strength, which // counts as -100). int iMaxHP; CalcMinMaxHP(CItemCtx(), m_iMaxCharges, 0, 0, NULL, &iMaxHP); int iDiff = (iMaxHP - pStd->iHP); if (iDiff > 0) iBalance += iDiff * 100 / pStd->iHP; else if (iMaxHP > 0) iBalance -= (pStd->iHP * 100 / iMaxHP) - 100; else iBalance -= 200; // Compute the regen HP for each 180 ticks // +1 for each 1% above standard rate int iRegen = (int)m_Regen.GetHPPer180(); iDiff = (iRegen - pStd->iRegen); if (iDiff > 0) iBalance += iDiff * 100 / pStd->iHP; else if (iRegen > 0) iBalance -= (pStd->iRegen * 100 / iRegen) - 100; else iBalance -= 200; // Account for damage adjustments int iBalanceAdj = 0; for (i = 0; i < damageCount; i++) { int iStdAdj; int iDamageAdj; m_DamageAdj.GetAdjAndDefault((DamageTypes)i, &iDamageAdj, &iStdAdj); if (iStdAdj != iDamageAdj) { if (iDamageAdj > 0) { int iBonus = (int)((100.0 * (iStdAdj - iDamageAdj) / iDamageAdj) + 0.5); if (iBonus > 0) iBalanceAdj += iBonus / 4; else iBalanceAdj -= ((int)((100.0 * iDamageAdj / iStdAdj) + 0.5) - 100) / 4; } else if (iStdAdj > 0) { iBalanceAdj += iStdAdj; } } } iBalance += Max(Min(iBalanceAdj, 100), -100); // Done return iBalance; }