Skip to content

fix: track static weapon shots bypassing FiredMan (ACE CSW compat)#111

Open
fank wants to merge 2 commits intomainfrom
fix/ace-csw-static-weapon-tracking
Open

fix: track static weapon shots bypassing FiredMan (ACE CSW compat)#111
fank wants to merge 2 commits intomainfrom
fix/ace-csw-static-weapon-tracking

Conversation

@fank
Copy link
Member

@fank fank commented Mar 15, 2026

Summary

Fixes mortar rounds (and potentially other static weapon projectiles) not being tracked when ACE Crew Served Weapons (CSW) is active.

Root cause: ACE CSW fires static weapons via forceWeaponFire on the vehicle, which may not trigger the unit's FiredMan EH that OCAP relies on for shot tracking. Additionally, for mortars with allowFireOnLoad, ACE creates a temporary AI agent as gunner when the seat is empty (common solo mortar use) — this agent has no OCAP ID, so the shot is silently ignored.

Fix:

  • Add a StaticWeapon Fired class EH as fallback that catches vehicle-level firing events and forwards to existing tracking handlers
  • When the gunner is an ACE CSW agent (no OCAP ID), fall back to ace_csw_reloader to attribute the shot to the actual player who loaded the weapon
  • Add a dedup guard in eh_fired_client to prevent double-tracking when both FiredMan and the vehicle Fired EH fire for the same projectile

ACE3 source references:

Test plan

  • Place a mortar with ACE CSW enabled, fire rounds solo (exit seat to load) — verify rounds are tracked
  • Fire mortar with a dedicated gunner (one player aims, another loads) — verify rounds are tracked and attributed to the gunner
  • Fire a vanilla static weapon (no ACE CSW) — verify no double-tracking / regression
  • Fire AI-operated mortar with ACE loaded — verify still tracked as before
  • Verify kill attribution works correctly for CSW mortar kills

ACE Crew Served Weapons fires static weapons via forceWeaponFire on
the vehicle, which may not trigger the unit's FiredMan EH that OCAP
relies on. For mortars with allowFireOnLoad, ACE also creates a
temporary AI agent as gunner when the seat is empty (solo mortar use),
and this agent has no OCAP ID.

Add a StaticWeapon Fired class EH as fallback that catches
vehicle-level firing events, resolves the gunner, and forwards to the
existing tracking handlers. When the gunner is an ACE CSW agent (no
OCAP ID), falls back to ace_csw_reloader to attribute the shot to the
actual player who loaded the weapon.

A dedup guard in eh_fired_client prevents double-tracking when both
FiredMan and the vehicle Fired EH fire for the same projectile.
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where static weapon shots, particularly mortar rounds fired with ACE Crew Served Weapons (CSW) active, were not being tracked correctly. The fix introduces a new event handler for static weapons to capture firing events that bypass the standard FiredMan event handler, correctly attributes shots fired by temporary ACE CSW AI agents to the actual player, and includes a mechanism to prevent duplicate tracking of projectiles.

Highlights

  • Static Weapon Tracking: Implemented a StaticWeapon Fired class event handler as a fallback to catch vehicle-level firing events and forward them to existing tracking handlers, addressing cases where FiredMan is bypassed.
  • ACE CSW Attribution: Introduced logic to attribute shots to the ace_csw_reloader when the gunner is a temporary ACE CSW AI agent without an OCAP ID, ensuring correct player attribution for solo mortar use.
  • Double-Tracking Prevention: Added a deduplication guard in eh_fired_client to prevent projectiles from being tracked twice when both FiredMan and the new vehicle Fired event handler trigger for the same shot.
Changelog
  • addons/recorder/fnc_eh_fired_client.sqf
    • Added a deduplication guard to prevent double-tracking of projectiles.
  • addons/recorder/fnc_eh_fired_server.sqf
    • Implemented a new StaticWeapon Fired event handler to capture vehicle-level firing events.
    • Added logic within the new event handler to attribute shots from ACE CSW temporary AI agents to the ace_csw_reloader.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a fix for tracking shots from static weapons, particularly when used with the ACE Crew Served Weapons (CSW) mod, by adding a fallback Fired event handler on StaticWeapon. The approach is sound and addresses the root cause described. However, I've identified a critical issue in the implementation where a server-only function is called from code that can execute on a client, which would result in a script error. I've provided a detailed comment and a code suggestion to resolve this by using a CBA server event, which aligns with the existing patterns in the codebase.

Address code review: the previous Fired class EH only ran on the
server (CBA class EHs fire where registered), missing player-operated
weapons entirely.  Also dropped eh_firedMan call since it's
server-only and would error on clients.

Now follows the same Init + Local + remoteExec pattern used for
CAManBase FiredMan: add the Fired EH on the owning machine during
init, transfer it on locality changes.  Only calls eh_fired_client
(distributed to all clients) which already handles weapon attribution
via broadcast.  ACE CSW handles setShotParents for its own projectiles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant