Skip to content

Commit

Permalink
Fix two issues with ftl_energy and damage
Browse files Browse the repository at this point in the history
ftl_energy wouldn't charge
Damage switch would fall-through
  • Loading branch information
royfalk committed Oct 3, 2024
1 parent 4be1d7f commit b1b8b2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions engine/src/cmd/energetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ float Energetic::totalShieldEnergyCapacitance() const {
// or better yet, write plugable consumption models.
//GAHHH reactor in units of 100MJ, shields in units of VSD=5.4MJ to make 1MJ of shield use 1/shieldenergycap MJ
void Energetic::ExpendEnergy(const bool player_ship) {
Unit *unit = vega_dynamic_cast_ptr<Unit>(this);

// TODO: if we run out of fuel or energy, we die from lack of air

MaintainShields();
ExpendEnergyToRechargeShields();
MaintainECM();
DecreaseWarpEnergyInWarp();

RechargeWarpCapacitors(player_ship);

ExpendFuel();
unit->reactor.Generate();
}

void Energetic::ExpendEnergy(float usage) {
Expand Down
18 changes: 11 additions & 7 deletions engine/src/cmd/unit_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,19 +1262,23 @@ void Unit::DamageRandSys(float dam, const Vector &vec, float randnum, float degr
return;
}
if (degrees >= 35 && degrees < 60) {
// This code potentially damages a whole bunch of components.
// We generate a random int (0-19). 0-8 damages something.
// 9-19 doesn't.
// This is really a stopgap code until we refactor this better.
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist20(0,19); // distribution in range [1, 6]

switch(dist20(rng)) {
case 0: fuel.Damage(); break; // Fuel
case 1: energy.Damage(); // Energy
case 2: ftl_energy.Damage();
case 3: ftl_drive.Damage();
case 4: jump_drive.Damage();
case 5: this->afterburnenergy += ((1 - dam) * reactor.Capacity());
case 6: CargoVolume *= dam;
case 7: UpgradeVolume *= dam;
case 1: energy.Damage(); break; // Energy
case 2: ftl_energy.Damage(); break;
case 3: ftl_drive.Damage(); break;
case 4: jump_drive.Damage(); break;
case 5: this->afterburnenergy += ((1 - dam) * reactor.Capacity()); break;
case 6: CargoVolume *= dam; break;
case 7: UpgradeVolume *= dam; break;
case 8:
//Do something NASTY to the cargo
if (cargo.size() > 0) {
Expand Down

0 comments on commit b1b8b2c

Please sign in to comment.