Damaging Shield Boosters restores players energy

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
phkb
Commodore
Commodore
Posts: 2369
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Damaging Shield Boosters restores players energy

Post by phkb » Sun Jan 03, 2016 9:10 pm

I'm not sure if this is by-design, but when the Shield Boosters (EQ_SHIELD_BOOSTER) are damaged and the player's energy level is less than the maximum energy level (player.ship.energy < player.ship.maxEnergy), then their energy level is returns to the maximum amount.

I tested this with no OXP's installed (via the AddOns folder or via the in-built download manager) by hitting the ECM multiple times to reduce my energy level to about half. I then executed this snippet of code:

Code: Select all

player.ship.setEquipmentStatus("EQ_SHIELD_BOOSTER", "EQUIPMENT_DAMAGED");
My tests were all performed with EQ_NAVAL_SHIELD_BOOSTER, EQ_ENERGY_UNIT and EQ_NAVAL_ENERGY_UNIT installed as well. Not sure if those are related. I'll test without them later today.

So, not sure if this is a bug or not, but if someone else can test out the scenarios that would be helpful!

User avatar
CWolf
---- E L I T E ----
---- E L I T E ----
Posts: 317
Joined: Mon Jul 03, 2006 12:33 pm
Location: Currently floating round Eninre

Re: Damaging Shield Boosters restores players energy

Post by CWolf » Sun Jan 03, 2016 11:24 pm

It could be circuit feedback - the power is no longer going to the broken boosters so you get feedback from the dedicated capacitors back to the energy banks...
The act of talking b*ll*cks whilst waving one's arms about wildly is referred to as testiculation.

Image

User avatar
phkb
Commodore
Commodore
Posts: 2369
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: Damaging Shield Boosters restores players energy

Post by phkb » Mon Jan 04, 2016 1:55 am

More information: the scenario also applies to the Military Shield Enhancement (EQ_NAVAL_SHIELD_BOOSTER). If that item is damaged when your energy is down, you get a full energy recharge.

I have also tested with all shield and extra energy items removed and confirmed it still happens. So, if all you have is the shield booster, the scenario will kick in.

I have also confirmed that the scenario doesn't kick in when the extra energy unit or Naval energy unit are damaged.

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5394
Joined: Wed Feb 28, 2007 7:54 am

Re: Damaging Shield Boosters restores players energy

Post by another_commander » Mon Jan 04, 2016 7:13 am

It's a bug (well done spotting that, by the way). The problem is here in Resources/Scripts/oolite-equipment-control.js, this.$equipmentDisable["EQ_SHIELD_BOOSTER"] = this.$equipmentDisable["EQ_NAVAL_SHIELD_BOOSTER"] function:

Code: Select all

player.ship.maxForwardShield -= parseFloat(info.scriptInfo.oolite_shield_increase);
player.ship.maxAftShield -= parseFloat(info.scriptInfo.oolite_shield_increase);
When the boosters are damaged, the script will set the maximum shield levels to what they would have been without the boosters, but it forgets to check what the actual value of the shields is at the moment of disabling the equipment. So, for a split second, the ship finds itself having forward and/or aft shields higher than what the current post-damage maximum is. This leads to negative energy drain (i.e. energy gain) in the core code, which results in the energy banks instantly filling up. To fix:

Code: Select all

player.ship.maxForwardShield -= parseFloat(info.scriptInfo.oolite_shield_increase);
if (player.ship.forwardShield > player.ship.maxForwardShield)  player.ship.forwardShield = player.ship.maxForwardShield;
player.ship.maxAftShield -= parseFloat(info.scriptInfo.oolite_shield_increase);
if (player.ship.aftShield > player.ship.maxAftShield)  player.ship.aftShield = player.ship.maxAftShield;
The heart of the problem is in the core itself, which allows for negative enrergy drains to occur. However, since the behaviour is easily fixable in the script and there could be OXPs that rely on negative energy drain behaviour in the future, for now I think I'll leave the core alone and just ensure that the maximum shield values are not exceeded via the boosters script.

User avatar
CWolf
---- E L I T E ----
---- E L I T E ----
Posts: 317
Joined: Mon Jul 03, 2006 12:33 pm
Location: Currently floating round Eninre

Re: Damaging Shield Boosters restores players energy

Post by CWolf » Mon Jan 04, 2016 7:27 am

another_commander wrote:It's a bug.
Keep it in!
Seeing as it only does it with shield boosters I think my explanation fits nicely within the Ooniverse.
The act of talking b*ll*cks whilst waving one's arms about wildly is referred to as testiculation.

Image

another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 5394
Joined: Wed Feb 28, 2007 7:54 am

Re: Damaging Shield Boosters restores players energy

Post by another_commander » Mon Jan 04, 2016 8:02 am

The core is unchanged, but the fix in the script has already gone in (commit 623f9ef). If you prefer the way it was before, you can just remove the two check lines added in oolite-equipment-control.js and Shift-restart the game.

Post Reply