Skip to content

Commit

Permalink
feat(ui): Provide in-game display of damage dropoff on weapons (endle…
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumshark authored Nov 19, 2023
1 parent e4eb9e1 commit 9ae0182
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions data/_ui/tooltips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.`

Expand Down
15 changes: 15 additions & 0 deletions source/OutfitInfoDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double, double> &ranges = outfit.DropoffRanges();
attributeValues.emplace_back(Format::Number(ranges.first)
+ " - " + Format::Number(ranges.second));
attributesHeight += 20;
}

static const vector<pair<string, string>> VALUE_NAMES = {
{"shield damage", ""},
{"hull damage", ""},
Expand Down
16 changes: 16 additions & 0 deletions source/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double, double> &Weapon::DropoffRanges() const
{
return damageDropoffRange;
}



// Legacy support: allow turret outfits with no turn rate to specify a
// default turnrate.
void Weapon::SetTurretTurn(double rate)
Expand Down
6 changes: 5 additions & 1 deletion source/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double, double> &DropoffRanges() const;


protected:
Expand Down Expand Up @@ -329,7 +333,7 @@ class Weapon {

bool hasDamageDropoff = false;
std::pair<double, double> damageDropoffRange;
double damageDropoffModifier;
double damageDropoffModifier = 1.;

// Cache the calculation of these values, for faster access.
mutable bool calculatedDamage = true;
Expand Down

0 comments on commit 9ae0182

Please sign in to comment.