bugfix(weapon): fix patriot assist system extended range bug #1886
+28
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follows SkyAero's comments on the original issue. Fixes an issue where patriot systems (especially laser patriots) would shoot at units outside their normal range. This occurred due to two bugs in the assist targeting system:
Fix 1: Prevent Self-Targeting
When a patriot requests assistance, it could ask itself to assist if it was also the target, causing the patriot to switch to its extended-range secondary weapon and attempt to fire at itself. This fix adds a check to prevent a patriot from assisting when it is the target. "Stop hitting yourself, why are you hitting yourself?" - Patriot's older brother.
Fix 2: Release Weapon Lock on Target Destruction
When a patriot enters assist mode, it temporarily locks its secondary weapon (extended range) until the clip is empty or the attack completes. If the target was destroyed before the clip finished, the weapon lock was not released, causing the patriot to continue using the extended-range weapon. This fix releases the temporary weapon lock when the victim is null or destroyed in both
privateAttackObject()andprivateForceAttackObject()functions.Both fixes are behind
!RETAIL_COMPATIBLE_CRCTesting
Test Case 1: Extended Range After Target Destruction
Test Case 2: Self targeting
Follow steps from above, force fire one of the patriots at another one after step 4.