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; }
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; }
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; }
EnhanceItemStatus CItemEnhancement::Combine (const CItem &Item, CItemEnhancement Enhancement) // Combine // // Combine the current enhancement with the given one { DWORD dwNewMods = Enhancement.m_dwMods; // If we're losing the enhancement, then clear it if (dwNewMods == etLoseEnhancement) { if (IsEnhancement()) { *this = CItemEnhancement(); return eisEnhancementRemoved; } else return eisNoEffect; } // If the item is not currently enhanced, then we take the new enhancement else if (m_dwMods == etNone) { // For strength/hpBonus, use the following rules: // // etStrengthen 0 -> Min(10%, maxHPBonus) // etStrengthen {level} -> Min( {level} * 10, maxHPBonus ) if (Enhancement.GetType() == etStrengthen || Enhancement.GetType() == etHPBonus) { int iMaxBonus = Item.GetType()->GetMaxHPBonus(); int iNewBonus = Min((Enhancement.IsStacking() ? 10 : Enhancement.GetHPBonus()), iMaxBonus); if (iNewBonus > 0) { SetModBonus(iNewBonus); return eisOK; } else return eisNoEffect; } // For all others, take the enhancement else *this = Enhancement; return eisOK; } // If already enhanced else if (m_dwMods == dwNewMods) { if (IsDisadvantage()) return eisNoEffect; else return eisAlreadyEnhanced; } // We currently have a disadvantage else if (IsDisadvantage()) { // We have a disadvantage and the enhancement is another // disadvantage. if (Enhancement.IsDisadvantage()) { switch (Enhancement.GetType()) { // If we're making the disadvantage worse, then // continue; otherwise, no effect. case etRegenerate: case etResist: case etResistEnergy: case etResistMatter: case etPowerEfficiency: { if (Enhancement.GetType() == GetType() && Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisWorse; } else return eisNoEffect; } case etHPBonus: case etStrengthen: { if ((GetType() == etHPBonus || GetType() == etStrengthen) && Enhancement.GetHPBonus() < GetHPBonus()) { *this = Enhancement; return eisWorse; } else return eisNoEffect; } case etSpeed: case etSpeedOld: { if ((GetType() == etSpeed || GetType() == etSpeedOld) && Enhancement.GetActivateRateAdj() > GetActivateRateAdj()) { *this = Enhancement; return eisWorse; } else return eisNoEffect; } case etResistByLevel: case etResistByDamage: case etResistByDamage2: { if (Enhancement.GetType() == GetType() && Enhancement.GetDamageType() == GetDamageType() && Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisWorse; } else return eisNoEffect; } // Otherwise, a disadvantage does not affect a disadvantage default: return eisNoEffect; } } // We have a disadvantage and we use an enhancement. else { switch (Enhancement.GetType()) { // Regeneration enhancement always repairs a disadvantage case etRegenerate: { *this = CItemEnhancement(); return eisRepaired; } // If the enhancement is the opposite of the disadvantage // then the disadvantage is repaired. case etResist: case etResistEnergy: case etResistMatter: case etPowerEfficiency: case etResistByLevel: case etResistByDamage: case etResistByDamage2: case etReflect: { if (GetType() == Enhancement.GetType()) { *this = CItemEnhancement(); return eisRepaired; } else return eisNoEffect; } case etHPBonus: case etStrengthen: { if (GetType() == etHPBonus || GetType() == etStrengthen) { *this = CItemEnhancement(); return eisRepaired; } else return eisNoEffect; } case etSpeed: case etSpeedOld: { if (GetType() == etSpeed || GetType() == etSpeedOld) { *this = CItemEnhancement(); return eisRepaired; } else return eisNoEffect; } // Otherwise, no effect default: return eisNoEffect; } } } // We currently have an enhancement else { if (!Enhancement.IsDisadvantage()) { switch (Enhancement.GetType()) { case etHPBonus: case etStrengthen: { if (GetType() != etHPBonus && GetType() != etStrengthen) return eisNoEffect; // If improving... int iOldBonus = GetHPBonus(); int iMaxBonus = Item.GetType()->GetMaxHPBonus(); int iNewBonus = Min((Enhancement.IsStacking() ? iOldBonus + 10 : Enhancement.GetHPBonus()), iMaxBonus); if (iNewBonus > iOldBonus) { SetModBonus(iNewBonus); return eisBetter; } else return eisNoEffect; } // If this is the same type of enhancement and it is better, // then take it (otherwise, no effect) case etRegenerate: case etResist: case etResistEnergy: case etResistMatter: case etPowerEfficiency: { if (Enhancement.GetType() == GetType() && Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisBetter; } else return eisNoEffect; } case etSpeed: case etSpeedOld: { if (Enhancement.GetType() == GetType() && Enhancement.GetActivateRateAdj() < GetActivateRateAdj()) { *this = Enhancement; return eisBetter; } else return eisNoEffect; } case etResistByLevel: case etResistByDamage: case etResistByDamage2: { if (Enhancement.GetType() != GetType()) return eisNoEffect; else if (Enhancement.GetDamageType() != GetDamageType()) { *this = Enhancement; return eisEnhancementReplaced; } else if (Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisBetter; } else return eisNoEffect; } default: return eisNoEffect; } } else { // A disadvantage always destroys any enhancement *this = CItemEnhancement(); return eisEnhancementRemoved; } } }
EnhanceItemStatus CItemEnhancement::Combine (CItemEnhancement Enhancement) // Combine // // Combine the current enhancement with the given one { DWORD dwNewMods = Enhancement.m_dwMods; // If we're losing the enhancement, then clear it if (dwNewMods == etLoseEnhancement) { if (IsEnhancement()) { *this = CItemEnhancement(); return eisEnhancementRemoved; } else return eisNoEffect; } // If the item is not currently enhanced, then we take the new enhancement else if (m_dwMods == etNone) { // For stackable strengthening, start at 1 if (Enhancement.GetType() == etStrengthen && Enhancement.GetLevel() == 0 && Enhancement.GetEnhancementType() == GetEnhancementType()) m_dwMods = dwNewMods + 1; // For all others, take the enhancement else *this = Enhancement; return eisOK; } // If already enhanced else if (m_dwMods == dwNewMods) { if (IsDisadvantage()) return eisNoEffect; else return eisAlreadyEnhanced; } // We currently have a disadvantage else if (IsDisadvantage()) { // We have a disadvantage and the enhancement is another // disadvantage. if (Enhancement.IsDisadvantage()) { switch (Enhancement.GetType()) { // If we're making the disadvantage worse, then // continue; otherwise, no effect. case etStrengthen: case etRegenerate: case etResist: case etResistEnergy: case etResistMatter: case etPowerEfficiency: case etSpeed: { if (Enhancement.GetType() == GetType() && Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisWorse; } else return eisNoEffect; } case etResistByLevel: case etResistByDamage: case etResistByDamage2: { if (Enhancement.GetType() == GetType() && Enhancement.GetDamageType() == GetDamageType() && Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisWorse; } else return eisNoEffect; } // Otherwise, a disadvantage does not affect a disadvantage default: return eisNoEffect; } } // We have a disadvantage and we use an enhancement. else { switch (Enhancement.GetType()) { // Regeneration enhancement always repairs a disadvantage case etRegenerate: { *this = CItemEnhancement(); return eisRepaired; } // If the enhancement is the opposite of the disadvantage // then the disadvantage is repaired. case etStrengthen: case etResist: case etResistEnergy: case etResistMatter: case etPowerEfficiency: case etResistByLevel: case etResistByDamage: case etResistByDamage2: case etReflect: case etSpeed: { if (GetType() == Enhancement.GetType()) { *this = CItemEnhancement(); return eisRepaired; } else return eisNoEffect; } // Otherwise, no effect default: return eisNoEffect; } } } // We currently have an enhancement else { if (!Enhancement.IsDisadvantage()) { if (Enhancement.GetType() == GetType()) { switch (Enhancement.GetType()) { case etStrengthen: { // If stackable... if (Enhancement.GetLevel() == 0) { if (GetLevel() == 15) return eisNoEffect; else { m_dwMods++; return eisBetter; } } // If improving... else if (Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisBetter; } else return eisNoEffect; } // If this is the same type of enhancement and it is better, // then take it (otherwise, no effect) case etRegenerate: case etResist: case etResistEnergy: case etResistMatter: case etPowerEfficiency: case etSpeed: { if (Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisBetter; } else return eisNoEffect; } case etResistByLevel: case etResistByDamage: case etResistByDamage2: { if (Enhancement.GetDamageType() != GetDamageType()) { *this = Enhancement; return eisEnhancementReplaced; } else if (Enhancement.GetLevel() > GetLevel()) { *this = Enhancement; return eisBetter; } else return eisNoEffect; } default: return eisNoEffect; } } // No effect if we're already enhanced else { return eisNoEffect; } } else { // A disadvantage always destroys any enhancement *this = CItemEnhancement(); return eisEnhancementRemoved; } } }