Fix shield maintenance draining the capacitor at full shields and lasers getting ammo. - #1699
Open
evertvorster wants to merge 3 commits into
Open
Fix shield maintenance draining the capacitor at full shields and lasers getting ammo.#1699evertvorster wants to merge 3 commits into
evertvorster wants to merge 3 commits into
Conversation
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
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
marked this pull request as ready for review
August 5, 2026 13:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Code Changes:
Added in #1681
and
#1688
To ease play testing. Review those first and they'll disappear from the changes here, if approved.
Issues:
Purpose: