Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#7,953 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
game-dev

Direzione di ricerca

La larghezza della barra dell'Energia viene calcolata in hudtarget.cpp intorno alla riga 6043, dove fl2i tronca il rapporto prima della moltiplicazione; la ricerca dell'etichetta vicino alla riga 6030 usa un numero di banco dove serve una classe d'arma. Riproduci con -ballistic_gauge e un'arma primaria balistica, controllando la barra a energia parziale. Fatto quando la barra scala con l'energia, l'etichetta usa la classe d'arma corretta e i banchi vuoti (-1) vengono saltati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
C++
Stelle
488
Fork
184
Merge medio
2g 2h
PR unite (30g)
35

Preparare l'ambiente

Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di scp-fs2open/fs2open.github.com

Tutte le issue di scp-fs2open/fs2open.github.com

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.