Skip to content

Conversation

Keshash
Copy link
Contributor

@Keshash Keshash commented Aug 8, 2025

Additions

Describe new functionality added by your code, e.g.

  • Re-adds Karim's old code for AI switching to grenades/launchers, shooting once at the center of enemy swarm, then switching back to main gun
  • fixes a bug where AOE weapons that can't ignore blocked LoS (rpg, law) were unable to shoot at enemies behind cover. If pawn has such weapon, they will target the enemy pawn instead of ground between enemies.
  • fixes a NRE which presumably got this code commented out 1 year ago.
  • I've removed a significant chunk of checks and target calculations, making it instead simply target the current enemy with the grenade to improve performance.

References

Links to the associated issues or other related pull requests, e.g.

Reasoning

Why did you choose to implement things this way, e.g.

  • Enemies using grenades and launchers makes the game more interesting. We should give them more grenades in a future xml-only pr

Alternatives

Describe alternative implementations you have considered, e.g.

  • Rewrite the target selection logic in such a way that wouldn't harm performance as much.
  • Ideally, would also implement this for: underbarrels, emp usage, firefoam

Testing

Check tests you have performed:

  • Compiles without warnings
  • Game runs without errors
  • (For compatibility patches) ...with and without patched mod loaded
  • Playtested a colony
    tested devmode raids only so far

Copy link

github-actions bot commented Aug 8, 2025

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-16840123609.zip

@github-actions github-actions bot added the Download in Comments This PR has a zipfile download available. label Aug 8, 2025
Copy link

github-actions bot commented Aug 8, 2025

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-16840204395.zip

@Keshash Keshash marked this pull request as ready for review August 8, 2025 21:54
@Keshash Keshash requested review from a team as code owners August 8, 2025 21:54
@Keshash Keshash marked this pull request as draft August 9, 2025 10:07
Copy link

github-actions bot commented Aug 9, 2025

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-16851835218.zip

Copy link

github-actions bot commented Aug 9, 2025

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-16852300872.zip

@Keshash
Copy link
Contributor Author

Keshash commented Aug 31, 2025

I've tested it in more sterile conditions, 1 pawn attacking, measured at 10 calls. here's what I got on performance. Would like to know your opinions on if this is acceptable performance or should I ditch this endeavor of reviving weapon switching.
Average per call seems to yield unconsistent result, but max per frame was more or less consistent in all tests.

Without AoE switching:
0.126 ms max per frame, 231 average per call

With cut down AoE switching:
0.185 ms max per frame, 217 average per call

With original implementation of AoE switching:
0.238 ms max per frame, 249 average per call

Without:
изображение

With:
изображение

Old:
изображение

@Keshash Keshash marked this pull request as ready for review September 16, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Download in Comments This PR has a zipfile download available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant