diff --git a/data/_ui/tooltips.txt b/data/_ui/tooltips.txt index 9d404570c273..c2d8338423eb 100644 --- a/data/_ui/tooltips.txt +++ b/data/_ui/tooltips.txt @@ -774,6 +774,12 @@ tip "ammo usage:" tip "range:" `Total range of this weapon.` +tip "dropoff modifier:" + `The multiplier applied to the damage of this weapon once its projectile has reached the maximum dropoff range.` + +tip "dropoff range:" + `The starting and ending range between which the damage of this weapon ramps from 100% to the displayed dropoff modifier.` + tip "shield damage / second:" `Shield damage dealt per second.` diff --git a/source/OutfitInfoDisplay.cpp b/source/OutfitInfoDisplay.cpp index 86b3edd5c3bd..e3111f60de0c 100644 --- a/source/OutfitInfoDisplay.cpp +++ b/source/OutfitInfoDisplay.cpp @@ -474,6 +474,21 @@ void OutfitInfoDisplay::UpdateAttributes(const Outfit &outfit) attributeValues.emplace_back(Format::Number(outfit.Range())); attributesHeight += 20; + // Identify the dropoff at range and inform the player. + double fullDropoff = outfit.MaxDropoff(); + if(fullDropoff != 1.) + { + attributeLabels.emplace_back("dropoff modifier:"); + attributeValues.emplace_back(Format::Number(100. * fullDropoff) + "%"); + attributesHeight += 20; + // Identify the ranges between which the dropoff takes place. + attributeLabels.emplace_back("dropoff range:"); + const pair &ranges = outfit.DropoffRanges(); + attributeValues.emplace_back(Format::Number(ranges.first) + + " - " + Format::Number(ranges.second)); + attributesHeight += 20; + } + static const vector> VALUE_NAMES = { {"shield damage", ""}, {"hull damage", ""}, diff --git a/source/Weapon.cpp b/source/Weapon.cpp index d0304e4679d0..872dc080fc51 100644 --- a/source/Weapon.cpp +++ b/source/Weapon.cpp @@ -512,6 +512,22 @@ double Weapon::DamageDropoff(double distance) const +// Return the weapon's damage dropoff at maximum range. +double Weapon::MaxDropoff() const +{ + return damageDropoffModifier; +} + + + +// Return the ranges at which the weapon's damage dropoff begins and ends. +const pair &Weapon::DropoffRanges() const +{ + return damageDropoffRange; +} + + + // Legacy support: allow turret outfits with no turn rate to specify a // default turnrate. void Weapon::SetTurretTurn(double rate) diff --git a/source/Weapon.h b/source/Weapon.h index d4ef8f0347be..bc49e4f2fa57 100644 --- a/source/Weapon.h +++ b/source/Weapon.h @@ -192,6 +192,10 @@ class Weapon { // Calculate the percent damage that this weapon deals given the distance // that the projectile traveled if it has a damage dropoff range. double DamageDropoff(double distance) const; + // Return the weapon's damage dropoff at maximum range. + double MaxDropoff() const; + // Return the ranges at which the weapon's damage dropoff begins and ends. + const std::pair &DropoffRanges() const; protected: @@ -329,7 +333,7 @@ class Weapon { bool hasDamageDropoff = false; std::pair damageDropoffRange; - double damageDropoffModifier; + double damageDropoffModifier = 1.; // Cache the calculation of these values, for faster access. mutable bool calculatedDamage = true;