Skip to content

Fix shield maintenance draining the capacitor at full shields and lasers getting ammo. - #1699

Open
evertvorster wants to merge 3 commits into
masterfrom
fix-shield-maintenance-drain
Open

Fix shield maintenance draining the capacitor at full shields and lasers getting ammo.#1699
evertvorster wants to merge 3 commits into
masterfrom
fix-shield-maintenance-drain

Conversation

@evertvorster

@evertvorster evertvorster commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request and becoming a contributor to the Vega Strike Core Engine.

Please answer the following:
The author of the changes should run the game and do the actions described below. Starting a new game, and completing these steps in this order should take around 10-15 minutes.

  • From the Main Menu, view the Introduction and the Credits, and verify the Vega Strike version number(s) displayed on each.
  • From the Main Menu, start a new Campaign.
  • Basic flight.
  • Docking to a planet.
  • On planet actions:
    • Save the game.
    • Read news.
    • Buy/Sell some goods.
    • Buy/Sell a ship upgrade.
    • Accept a mission from the bulletin board.
    • Talk to someone in the bar.
  • Primary and secondary weapon usage.
  • Fight (you can fight with Oswald).
  • SPEC flight.
  • A jump to a different system.
  • Docking to a non-planet location (mining base, etc).
  • Buy a ship. (If necessary, edit a save file to give yourself enough credits to do so.)
  • Save the game again.
  • Upgrade your new ship.
  • Save once more.
  • Purposely die, and then make sure you can respawn and continue playing without the game crashing or anything.
  • Quit Vega Strike. Make sure it doesn't segfault on exit.
  • Launch Vega Strike again. This time, from the Main Menu, choose Load, and load a previously saved game. Continue where you left off.

Code Changes:
Added in #1681
and
#1688
To ease play testing. Review those first and they'll disappear from the changes here, if approved.

  • This is a documentation change only

Issues:

Purpose:

  • What is this pull request trying to do?
  • Fix two simple bugs that affect game play. Full documentation on the bugs are linked above.
  • What release is this for?
  • 0.11
  • Is there a project or milestone we should apply this to?
  • 0.11

Regression from ca3df7f (Feb 2025, PR #1016): Shield::Regenerate charged
max_shield x maintenance_factor (5%/s) from the primary capacitor every atom,
even when shields were at full health. That made the capacitor unable to
refill after combat (stock Llama: 600x0.05=30/s maintenance == reactor 30/s,
so net 0; any ship with a big shield upgrade drains, e.g. Vendetta 4000 ->
200/s vs reactor 115/s).

Fix per Evert's principle: shields consume power only while building, and
the recharge rate is throttled by what the reactor can actually supply.

- Fully-charged gate moved to the top of Regenerate, before any consumption.
- Recharge cost now scales with the shield deficit being rebuilt
  ((max - current) x factor) instead of a flat always-on maintenance drain.
- Consume() returns the fraction of the cost the reactor supplied; regen runs
  at that fraction, so half the energy means half the recharge rate (twice
  as long to fill).
- The max_power throttle check runs before the full-shields gate so a
  throttled shield still decreases toward its power limit.
- Removed the unaffordable-maintenance Decrease() collapse (shields now slow
  their recharge instead of decaying when energy is short).

Fixes the reported 'capacitor never refills after firing' behavior.
See https://github.com/vegastrike/Vega-Strike-Engine-Source
@github-project-automation github-project-automation Bot moved this to Backlog in VS Engine Aug 5, 2026
@evertvorster
evertvorster marked this pull request as draft August 5, 2026 04:42
Regression from c3b14b9 (2026-01-05, 'Fix buying of missiles'): the buy
path set mounts[0].ammo = quantity unconditionally. quantity defaults to 1
for non-missile weapons, so bought lasers/plasma got ammo=1 instead of the
CSV default -1 (unlimited), burned to 0 on the first shot, and then locked
the weapon (Mount::Fire returns false when ammo == 0).

Fix: gate the ammo assignment on IsMissileMount(), matching how the rest of
the engine models energy weapons (ammo == -1 = unlimited in Mount::Fire,
AddAmmo, Deactivate). Missile buying is unaffected.
@evertvorster
evertvorster marked this pull request as ready for review August 5, 2026 13:23
@evertvorster evertvorster changed the title Fix shield maintenance draining the capacitor at full shields Fix shield maintenance draining the capacitor at full shields and lasers getting ammo. Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant