Skip to content

Commit

Permalink
feat(mechanics): Account for all combat damage types in the raid dete…
Browse files Browse the repository at this point in the history
…rrence of a weapon (endless-sky#8827)
  • Loading branch information
Hurleveur authored Oct 29, 2023
1 parent 8e49750 commit c3d0d2e
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions source/Ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4621,9 +4621,43 @@ double Ship::CalculateDeterrence() const
if(hardpoint.GetOutfit())
{
const Outfit *weapon = hardpoint.GetOutfit();
double strength = weapon->ShieldDamage() + weapon->HullDamage()
+ (weapon->RelativeShieldDamage() * MaxShields())
+ (weapon->RelativeHullDamage() * MaxHull());
// 1 DoT damage of type X = 100 damage of type X over an extended period of time
// (~95 damage after 5 seconds, ~99 damage after 8 seconds). Therefore, multiply
// DoT damage types by 100. Disruption, scrambling, and slowing don't have an
// analogous instantaneous damage type, but still just multiply them by 100 to
// stay consistent.

// Compare the relative damage types to the strength of the firing ship, since we
// have nothing else to reasonably compare against.

// Shield and hull damage are the primary damage types that dictate combat, so
// consider the full damage dealt by these types for the strength of a weapon.
double shieldFactor = weapon->ShieldDamage()
+ weapon->RelativeShieldDamage() * MaxShields()
+ weapon->DischargeDamage() * 100.;
double hullFactor = weapon->HullDamage()
+ weapon->RelativeHullDamage() * MaxHull()
+ weapon->CorrosionDamage() * 100.;

// Other damage types don't outright destroy ships, so they aren't considered
// as heavily in the strength of a weapon.
double energyFactor = weapon->EnergyDamage()
+ weapon->RelativeEnergyDamage() * attributes.Get("energy capacity")
+ weapon->IonDamage() * 100.;
double heatFactor = weapon->HeatDamage()
+ weapon->RelativeHeatDamage() * MaximumHeat()
+ weapon->BurnDamage() * 100.;
double fuelFactor = weapon->FuelDamage()
+ weapon->RelativeFuelDamage() * attributes.Get("fuel capacity")
+ weapon->LeakDamage() * 100.;
double scramblingFactor = weapon->ScramblingDamage() * 100.;
double slowingFactor = weapon->SlowingDamage() * 100.;
double disruptionFactor = weapon->DisruptionDamage() * 100.;

// Disabled and asteroid damage are ignored because they don't matter in combat.

double strength = shieldFactor + hullFactor + 0.2 * (energyFactor + heatFactor + fuelFactor
+ scramblingFactor + slowingFactor + disruptionFactor);
tempDeterrence += .12 * strength / weapon->Reload();
}
return tempDeterrence;
Expand Down

0 comments on commit c3d0d2e

Please sign in to comment.