Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#7,953 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
game-dev

Hướng nghiên cứu

Độ rộng thanh Energy được tính trong hudtarget.cpp quanh dòng 6043, nơi fl2i cắt cụt tỷ lệ trước phép nhân; việc tra cứu nhãn gần dòng 6030 dùng số bank trong khi cần lớp vũ khí. Tái hiện với -ballistic_gauge và một vũ khí chính đạn đạo, kiểm tra thanh ở mức năng lượng một phần. Hoàn tất khi thanh co giãn theo năng lượng, nhãn dùng đúng lớp vũ khí và các bank rỗng (-1) bị bỏ qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
C++
Star
488
Fork
184
Merge trung bình
2 ngày 2 giờ
Pull request đã merge (30 ngày)
35

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của scp-fs2open/fs2open.github.com

Tất cả issue của scp-fs2open/fs2open.github.com

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.