fix: track static weapon shots bypassing FiredMan (ACE CSW compat)#111
fix: track static weapon shots bypassing FiredMan (ACE CSW compat)#111
Conversation
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.
Summary of ChangesHello, 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
Changelog
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
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
forceWeaponFireon the vehicle, which may not trigger the unit'sFiredManEH that OCAP relies on for shot tracking. Additionally, for mortars withallowFireOnLoad, 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:
StaticWeaponFiredclass EH as fallback that catches vehicle-level firing events and forwards to existing tracking handlersace_csw_reloaderto attribute the shot to the actual player who loaded the weaponeh_fired_clientto prevent double-tracking when bothFiredManand the vehicleFiredEH fire for the same projectileACE3 source references:
fnc_autofire_fire.sqf— uses_gunner forceWeaponFirefnc_autofire_onReload.sqf— creates temporary AI agent when gunner seat is emptyfnc_reload_loadMagazine.sqf— setsace_csw_reloaderon the vehicleTest plan