Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

P3: The ballistic ammo gauge shows weapon energy as empty unless it is completely full

Open Beginner friendly
#7,953 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
game-dev

Research direction

The Energy bar width is computed in hudtarget.cpp around line 6043, where fl2i truncates the ratio before the multiplication; the label lookup near line 6030 uses a bank number where a weapon class is needed. Reproduce with -ballistic_gauge and a ballistic primary, checking the bar at partial energy. Done when the bar scales with energy, the label uses the correct weapon class, and empty banks (-1) are skipped.

Written by the indexing model from the issue text.

Description

bug HUD LLM-suggested

Problem

When the ballistic ammo gauge is on (-ballistic_gauge, on a ship with a ballistic primary), its Energy bar is either completely full or completely empty. Any weapon energy below 100% draws as an empty bar, so the gauge tells the player they have no energy when they may have almost all of it.

The bar's width is max_w * fl2i(energy / max_reserve) (hudtarget.cpp:6043 on master). fl2i truncates the ratio first, so it is 1 only at full energy and 0 otherwise. Multiplying before truncating (fl2i(max_w * energy / max_reserve)) gives the right width.

Steps to reproduce

  1. Current master (I used 8afa31842, Debug build), MediaVPs 5.0.2, launched with -ballistic_gauge.
  2. Use a mod that gives the player's ship a ballistic primary. I made a small test mod: a weapons.tbm that adds the "ballistic" flag and $Rearm Rate: 100 to the Subach HL-7, and a ships.tbm that gives the GTF Ulysses $PBank Capacity: ( 1000, 1000 ).
  3. Start SM1-01 and drain some weapon energy.

I set the energy from Lua and paused before each screenshot: at 150/150 the Energy bar is full; at 148.5/150 and at 75/150 it is empty.

Expected vs. actual behavior

Expected: the bar is drawn in proportion to the weapon energy left.
Actual: it's full at 100% and empty at anything less.

Two more problems in the same gauge, found by reading the code and not run:

  • hudtarget.cpp:6030 looks up Weapon_info with current_primary_bank, a bank number rather than a weapon class, so the Energy label's brightness comes from the wrong weapon.
  • hudtarget.cpp:5997 and :6060 read Weapon_info[primary_bank_weapons[bx]] without checking for -1, which other HUD code guards against for an empty bank. I haven't confirmed an empty primary bank can reach this gauge.

Proposed fixes

  1. Do the multiplication before the truncation in the bar width, as above. One line.
  2. Fix the other two lookups in the same pass: use the weapon class in the current bank for the label, and skip banks set to -1.
  3. Compute the ratio as a float clamped to 0..1, then scale it to the bar width, so energy above the reserve can't overdraw either.
Dominant language
C++
Stars
488
Forks
184
Avg merge
1d 19h
Merged PRs (30d)
33

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scp-fs2open/fs2open.github.com

All issues in scp-fs2open/fs2open.github.com

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.