Skip to content

Return Fire -> Defensive firestance - #8139

Merged
Ruwetuin merged 39 commits into
beyond-all-reason:masterfrom
SethDGamre:return-fire-rework-2
Jul 4, 2026
Merged

Return Fire -> Defensive firestance#8139
Ruwetuin merged 39 commits into
beyond-all-reason:masterfrom
SethDGamre:return-fire-rework-2

Conversation

@SethDGamre

@SethDGamre SethDGamre commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Enable in ModOptions Experimental tab "New Defend Firestate" to use
Is greatly aided by merging: #8159 as well to prevent falsely considering factories as threats.

Replace the mostly unused Return Fire with a new and more useful Defensive firestate. A defensive unit will shoot targets that are a threat to itself on a 1v1 basis.

What's a threat?

If the target run up and shoot you before you can kill it, it's a threat. This is done with prebaked math related to DPS, Distance, movement speed, and health.

What's this useful for?

  1. I don't want to shoot unarmed units. Useful during raids to take down defenders.
  2. I don't want to waste shots on trash until I really, really have to. Useful for starlights, banishers, etc.

Random notes.

  • units with >2000 range, Starburst Missiles, or are aircraft will shoot anything at max range regardless of threat. Because they can't hit moving things anyway or it's not relevant.
  • constructors that can reclaim are considered threats same as if they had a weapon
  • cloaked defensive units will not shoot until they're no longer cloaked.
  • kamikaze targets will always be shot
  • units with multiple weapons are biased to shoot things at farther distances just to be safe (more precision would be less performant in a stinky way)
  • to prevent taking hits from radar things over and over with no reaction, defensive units that take damage will aggro against radar dots regardless of source. Logic being, if there are things closeby they'll prefer them anyway. If there are only radar dots to shoot, they'll shoot. This resets upon changing
    firestate or after being healed.
  • under the hood, return fire is unchanged so ruins unaffected. Defensive is a virtual firestate that uses fire at will with AllowWeaponTarget filtering for its behavior.

I'm most active on discord, you can participate in the brunt of discussion here: https://discord.com/channels/549281623154229250/1520166826435280998/1520166826435280998

AI disclosure:
Used claude 4.8, gpt 5.5, and cursor's "auto mode" to conduct research, suggest and write some of the changes, and change the unitdefs. The shape of the functions, flow, and design and decisions for changes are strictly mine.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Integration Test Results

0 tests   - 14   0 ✅  - 6   0s ⏱️ -3s
0 suites  -  1   0 💤  - 8 
0 files    -  1   0 ❌ ±0 

Results for commit e929c9c. ± Comparison against base commit 5f16003.

♻️ This comment has been updated with latest results.

@SethDGamre
SethDGamre marked this pull request as ready for review July 3, 2026 02:48
@SethDGamre
SethDGamre marked this pull request as draft July 3, 2026 12:15
Ruwetuin pushed a commit that referenced this pull request Jul 3, 2026
Since they're builders and canReclaim is undefined, it seems the engine
considers them as able to reclaim things. This is impossible for them to
actually do as factories. This messes up the WIP FireState Defend I'm
working on.
#8139

Merge this with it.
@SethDGamre
SethDGamre marked this pull request as ready for review July 3, 2026 17:11
@Ruwetuin
Ruwetuin merged commit 72f3ecc into beyond-all-reason:master Jul 4, 2026
3 checks passed
local refCount = (weaponWatchRefCount[weaponDefID] or 0) + 1
weaponWatchRefCount[weaponDefID] = refCount
if refCount == 1 then
Script.SetWatchAllowTarget(weaponDefID, true)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See notes on AllowWeaponTarget in unit_aa_targeting_priority.lua.

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.

3 participants