Skip to content

Commit

Permalink
feat(mechanics): Separate delayed and non-delayed shield generation a…
Browse files Browse the repository at this point in the history
…nd hull repair attributes (endless-sky#9771)
  • Loading branch information
Quantumshark authored Mar 20, 2024
1 parent 93c36ce commit aac68a0
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 25 deletions.
32 changes: 28 additions & 4 deletions data/_ui/tooltips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,27 @@ tip "hull:"
tip "hull energy:"
`Energy consumed per second when repairing the hull.`

tip "delayed hull energy:"
`Additional energy consumed per second when repairing the hull after the repair delay period.`

tip "hull energy multiplier:"
`Modifies the energy consumed when repairing the hull by the given factor.`

tip "hull fuel:"
`Fuel consumed per second when repairing the hull.`

tip "delayed hull fuel:"
`Additional fuel consumed per second when repairing the hull after the repair delay period.`

tip "hull fuel multiplier:"
`Modifies the fuel consumed when repairing the hull by the given factor.`

tip "hull heat:"
`Heat produced per second when repairing the hull.`

tip "delayed hull heat:"
`Additional heat produced per second when repairing the hull after the repair delay period.`

tip "hull heat multiplier:"
`Modifies the heat produced when repairing the hull by the given factor.`

Expand All @@ -288,11 +297,14 @@ tip "hull multiplier:"
tip "hull repair rate:"
`Amount of hull strength that can be repaired per second. Repairs usually consume energy and may generate heat as well.`

tip "delayed hull repair rate:"
`Additional hull strength that can be repaired per second after the repair delay period.`

tip "repair delay:"
`The number of seconds it takes for hull repairs to begin after taking hull damage.`
`The number of seconds it takes for additional hull repairs to begin after taking hull damage.`

tip "disabled repair delay:"
`The number of seconds it takes for hull repairs to begin after being disabled.`
`The number of seconds it takes for additional hull repairs to begin after being disabled.`

tip "absolute threshold:"
`The remaining hull strength at which the ship becomes disabled. This attribute takes priority over other attributes that change the disabled threshold.`
Expand Down Expand Up @@ -519,24 +531,36 @@ tip "sells for:"
tip "shield energy:"
`Energy consumed per second when recharging shields.`

tip "delayed shield energy:"
`Additional energy consumed per second when recharging shields after the shield delay period.`

tip "shield energy multiplier:"
`Modifies the energy consumed when recharging shields by the given factor.`

tip "shield fuel:"
`Fuel consumed per second when recharging shields.`

tip "delayed shield fuel:"
`Additional fuel consumed per second when recharging shields after the shield delay period.`

tip "shield fuel multiplier:"
`Modifies the fuel consumed when recharging shields by the given factor.`

tip "shield heat:"
`Heat produced per second when recharging shields.`

tip "delayed shield heat:"
`Additional heat produced per second when recharging shields after the shield delay period.`

tip "shield heat multiplier:"
`Modifies the heat produced when recharging shields by the given factor.`

tip "shield generation:"
`Shield points recharged per second. Recharging shields usually consumes energy, and may also produce heat.`

tip "delayed shield generation:"
`Additional shield points recharged per second after the shield delay period.`

tip "shield generation multiplier:"
`Modifies the amount of shield points recharged per second by the given factor.`

Expand All @@ -556,10 +580,10 @@ tip "shield multiplier:"
`Modifies the ship's total shield strength by the given factor.`

tip "shield delay:"
`The number of seconds it takes for shield generation to begin after taking shield damage.`
`The number of seconds it takes for additional shield generation to begin after taking shield damage.`

tip "depleted shield delay:"
`The number of seconds it takes for shield generation to begin after your shields have been depleted.`
`The number of seconds it takes for additional shield generation to begin after your shields have been depleted.`

tip "shield protection:"
`Protection against shield damage. If you add more than one outfit with this attribute, each additional one is less effective: a total value of 1 results in a 1 percent reduction in shield damage, while a total value of 11 only results in a 10 percent reduction.`
Expand Down
2 changes: 1 addition & 1 deletion data/kahet/kahet outfits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ outfit "Ka'het Grand Restorer"
thumbnail "outfit/ka'het grand restorer"
"mass" 72
"outfit space" -86
"shield generation" 7.08
"delayed shield generation" 7.08
"energy consumption" 10.62
"depleted shield delay" 350
description "This shield generator is the apex of Ka'het shielding technology, a field that developed rapidly and out of necessity rather than gradually and perfected over long periods. Nevertheless, the Grand Restorer grants good protection for the largest Het ships, replacing the basic restorers used elsewhere."
Expand Down
8 changes: 8 additions & 0 deletions source/OutfitInfoDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ namespace {
{"hull energy", 0},
{"hull fuel", 0},
{"hull heat", 0},
{"delayed hull repair rate", 0},
{"delayed hull energy", 0},
{"delayed hull fuel", 0},
{"delayed hull heat", 0},
{"ion resistance energy", 0},
{"ion resistance fuel", 0},
{"ion resistance heat", 0},
Expand All @@ -97,6 +101,10 @@ namespace {
{"shield energy", 0},
{"shield fuel", 0},
{"shield heat", 0},
{"delayed shield generation", 0},
{"delayed shield energy", 0},
{"delayed shield fuel", 0},
{"delayed shield heat", 0},
{"slowing resistance energy", 0},
{"slowing resistance fuel", 0},
{"slowing resistance heat", 0},
Expand Down
34 changes: 20 additions & 14 deletions source/Ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3732,31 +3732,37 @@ void Ship::DoGeneration()
// 4. Shields of carried fighters
// 5. Transfer of excess energy and fuel to carried fighters.

const double hullAvailable = attributes.Get("hull repair rate")
const double hullAvailable = (attributes.Get("hull repair rate")
+ (hullDelay ? 0 : attributes.Get("delayed hull repair rate")))
* (1. + attributes.Get("hull repair multiplier"));
const double hullEnergy = (attributes.Get("hull energy")
* (1. + attributes.Get("hull energy multiplier"))) / hullAvailable;
+ (hullDelay ? 0 : attributes.Get("delayed hull energy")))
* (1. + attributes.Get("hull energy multiplier")) / hullAvailable;
const double hullFuel = (attributes.Get("hull fuel")
* (1. + attributes.Get("hull fuel multiplier"))) / hullAvailable;
+ (hullDelay ? 0 : attributes.Get("delayed hull fuel")))
* (1. + attributes.Get("hull fuel multiplier")) / hullAvailable;
const double hullHeat = (attributes.Get("hull heat")
* (1. + attributes.Get("hull heat multiplier"))) / hullAvailable;
+ (hullDelay ? 0 : attributes.Get("delayed hull heat")))
* (1. + attributes.Get("hull heat multiplier")) / hullAvailable;
double hullRemaining = hullAvailable;
if(!hullDelay)
DoRepair(hull, hullRemaining, MaxHull(),
energy, hullEnergy, fuel, hullFuel, heat, hullHeat);
DoRepair(hull, hullRemaining, MaxHull(),
energy, hullEnergy, fuel, hullFuel, heat, hullHeat);

const double shieldsAvailable = attributes.Get("shield generation")
const double shieldsAvailable = (attributes.Get("shield generation")
+ (shieldDelay ? 0 : attributes.Get("delayed shield generation")))
* (1. + attributes.Get("shield generation multiplier"));
const double shieldsEnergy = (attributes.Get("shield energy")
* (1. + attributes.Get("shield energy multiplier"))) / shieldsAvailable;
+ (shieldDelay ? 0 : attributes.Get("delayed shield energy")))
* (1. + attributes.Get("shield energy multiplier")) / shieldsAvailable;
const double shieldsFuel = (attributes.Get("shield fuel")
* (1. + attributes.Get("shield fuel multiplier"))) / shieldsAvailable;
+ (shieldDelay ? 0 : attributes.Get("delayed shield fuel")))
* (1. + attributes.Get("shield fuel multiplier")) / shieldsAvailable;
const double shieldsHeat = (attributes.Get("shield heat")
* (1. + attributes.Get("shield heat multiplier"))) / shieldsAvailable;
+ (shieldDelay ? 0 : attributes.Get("delayed shield heat")))
* (1. + attributes.Get("shield heat multiplier")) / shieldsAvailable;
double shieldsRemaining = shieldsAvailable;
if(!shieldDelay)
DoRepair(shields, shieldsRemaining, MaxShields(),
energy, shieldsEnergy, fuel, shieldsFuel, heat, shieldsHeat);
DoRepair(shields, shieldsRemaining, MaxShields(),
energy, shieldsEnergy, fuel, shieldsFuel, heat, shieldsHeat);

if(!bays.empty())
{
Expand Down
18 changes: 12 additions & 6 deletions source/ShipInfoDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ void ShipInfoDisplay::UpdateAttributes(const Ship &ship, const PlayerInfo &playe
attributeLabels.push_back(string());
attributeValues.push_back(string());
attributesHeight += 10;
double shieldRegen = attributes.Get("shield generation")
double shieldRegen = (attributes.Get("shield generation")
+ attributes.Get("delayed shield generation"))
* (1. + attributes.Get("shield generation multiplier"));
bool hasShieldRegen = shieldRegen > 0.;
if(hasShieldRegen)
Expand All @@ -208,7 +209,8 @@ void ShipInfoDisplay::UpdateAttributes(const Ship &ship, const PlayerInfo &playe
attributeValues.push_back(Format::Number(ship.MaxShields()));
}
attributesHeight += 20;
double hullRepair = attributes.Get("hull repair rate")
double hullRepair = (attributes.Get("hull repair rate")
+ attributes.Get("delayed hull repair rate"))
* (1. + attributes.Get("hull repair multiplier"));
bool hasHullRepair = hullRepair > 0.;
if(hasHullRepair)
Expand Down Expand Up @@ -375,16 +377,20 @@ void ShipInfoDisplay::UpdateAttributes(const Ship &ship, const PlayerInfo &playe

// Add energy and heat when doing shield and hull repair to the table.
attributesHeight += 20;
double shieldEnergy = (hasShieldRegen) ? attributes.Get("shield energy")
double shieldEnergy = (hasShieldRegen) ? (attributes.Get("shield energy")
+ attributes.Get("delayed shield energy"))
* (1. + attributes.Get("shield energy multiplier")) : 0.;
double hullEnergy = (hasHullRepair) ? attributes.Get("hull energy")
double hullEnergy = (hasHullRepair) ? (attributes.Get("hull energy")
+ attributes.Get("delayed hull energy"))
* (1. + attributes.Get("hull energy multiplier")) : 0.;
tableLabels.push_back((shieldEnergy && hullEnergy) ? "shields / hull:" :
hullEnergy ? "repairing hull:" : "charging shields:");
energyTable.push_back(Format::Number(-60. * (shieldEnergy + hullEnergy)));
double shieldHeat = (hasShieldRegen) ? attributes.Get("shield heat")
double shieldHeat = (hasShieldRegen) ? (attributes.Get("shield heat")
+ attributes.Get("delayed shield heat"))
* (1. + attributes.Get("shield heat multiplier")) : 0.;
double hullHeat = (hasHullRepair) ? attributes.Get("hull heat")
double hullHeat = (hasHullRepair) ? (attributes.Get("hull heat")
+ attributes.Get("delayed hull heat"))
* (1. + attributes.Get("hull heat multiplier")) : 0.;
heatTable.push_back(Format::Number(60. * (shieldHeat + hullHeat)));

Expand Down

0 comments on commit aac68a0

Please sign in to comment.