[1.1] Avoid Friendly Fire (stop shooting when friendlies are in the way)

Started by falconne, September 10, 2017, 06:16:37 AM

Previous topic - Next topic

falconne

This mod should hopefully alleviate some of the micromanagement needed to stop ranged colonists shooting friendlies, without changing the way friendly fire works in the game or reducing its potency.

Colonists who have the Avoid Friendly Fire option enabled will not take a shot if the projectile's path could hit a friendly or neutral pawn (taking into account miss radius). Drafted colonists will look for a target with a clean shot (or wait if there isn't one), while hunters will reposition themselves.

Usage
Any colonist with an appropriate weapon will show an "Avoid Friendly Fire" toggle button when they are selected (which is On by default; you can toggle it off for individual colonists). With this On their AI will automatically do the right thing.

If you manually try to force a drafted colonist who is set to avoid friendly fire to shoot an enemy with a friendly in the way, you will see a "Cannot hit target" message as you would if LoS was blocked.

Shooters who are being blocked by friendlies (but would otherwise have a target) will have their name on the map and in the Colonist Bar be written in cyan. Likewise, the first friendly blocking any shooter will show up in green.

There is a setting in the Mod Options screen to always enable 'Avoid FF' status on a pawn when it's undrafted. If you tend to disable the 'Avoid FF' setting on pawns during combat, using this option will ensure it is always turned back on again before the next combat. This option is off by default.



Shield Belts
Shooters will not worry about pawns wearing a shield belt with at least 10% power standing in the line of fire, so you can still use shielded infantry to attack while ranged troops continue to fire over them from behind. If the shield drops below 10% power while the pawn is still subject to friendly fire, then the shooters will stop. They will resume shooting after the shield gets above 10%.

Targeting Overlay
If you use the game's manual targeting button (the one with the B hotkey that then shows the weapons range), you will see a red overlay that appears from the shooter to where you point the mouse (see image). This overlay shows the potential "fire cone" from a standard ranged weapon in the game, from the shooter to a target under the mouse (miss radius depends on weapon and shooter skill). Any pawn within the red overlay could potentially be hit. This is purely a visual aid for planning and can be disabled from the Mod Settings menu if you don't like it. Note that pawns within 4 tiles of the shooter do not receive friendly fire, so the overlay does not mark them red and the mod takes this into account when deciding if a shooter should stop. In the example image the shooter on the top right will not shoot the pirate on the bottom left because the colonist "Flip" could potentially get hit.

Animals
By default the mod will also take into account animals with an assigned master and protect them from friendly fire, so you should be able to use and release trained animals without them getting shot. In the Mod Settings you can disable this, or expand it to include all tamed colony animals, such as livestock, but this is off by default as it could be annoying and cause performance issues on slower machines.

Downloads
Steam Workshop
Direct Download



Notes

This can be added to an existing save.

This mod is compatible with the Combat Extended mod, however the more complex fire trajectory in CE may mean this mod may not be 100% effective at very long ranges.

Current Limitations

  • Does not protect against friendly fire from explosive weapons such as grenades or rockets. They will be used as normal and you will need to micromanage them as before.
  • Will protect neutral pawns on your map, but not animals owned by them. E.g., if there are traders around during a raid, your colonists will avoid hitting them but not watch out for their animals. Should be fixed in the future.
  • Only affects the AI of your colonists. Does not prevent the computer controlled factions shooting their own troops; that's a hard problem.
  • Only affects the AI of shooters, who will stop shooting when someone gets in the way. Nothing is done to stop undrafted pawns from wandering into the middle of battle; again a harder problem to solve.

Translations:
* Japanese by @Proxyer
* Traditional Chinese by @FantasyMusic

Kori

Looks very useful, is it compatible with CE?


edit: Not sure if this is a mod conflict, but when starting a new colony with this mod enabled, you won't be able to see any UI info elements on the landing site selection screen and changing a once selected spot is not possible anymore.
This occurs only on the landing site screen, the world view of existing games works fine.

falconne

Quote from: Kori on September 11, 2017, 12:45:33 AM
Not sure if this is a mod conflict, but when starting a new colony with this mod enabled, you won't be able to see any UI info elements on the landing site selection screen and changing a once selected spot is not possible anymore.
This occurs only on the landing site screen, the world view of existing games works fine.

Thanks, I will look into that now.

falconne

I've fixed the bug on the landing site selection screen and the download link has been updated to the new version.

I'm not sure if this would be compatible with Combat Extended. This mod assumes all regular ranged weapons use a one tile miss radius. I will have to see if CE make that larger or variable for each weapon. Other than that there should be no reason for incompatibility, so long as CE uses Harmony patching and does not overwrite vanilla code this mod depends on.

Kori

Quote from: falconne on September 11, 2017, 03:56:41 AM
I've fixed the bug on the landing site selection screen and the download link has been updated to the new version.

I'm not sure if this would be compatible with Combat Extended. This mod assumes all regular ranged weapons use a one tile miss radius. I will have to see if CE make that larger or variable for each weapon. Other than that there should be no reason for incompatibility, so long as CE uses Harmony patching and does not overwrite vanilla code this mod depends on.

Thanks for the quick fix, I hope both mods will be compatible. :)

falconne


falconne

Just published a new version that fixes a bug where the FF toggle button for a selected pawn does not go away when an Architecture toolbox is opened. Please update if you have manually downloaded the mod.

Crow_T

Can't wait to try this out, thanks for making this! I noticed on the Reddit thread earlier that some people wanted exceptions, eg bloodlust trait will ignore this and fire away as usual. Making trigger happy ignore this would make some sense as well if you decide to go that route. Either way making pawns smarter is always good :)
(regarding dead man's apparel)
"I think, at the very least, the buff should go away for jackets so long as you're wearing the former owner's skin as a shirt."
-Condaddy20

SpaceDorf

Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

Maeyanie

Quote from: falconne on September 11, 2017, 03:56:41 AM
I'm not sure if this would be compatible with Combat Extended. This mod assumes all regular ranged weapons use a one tile miss radius. I will have to see if CE make that larger or variable for each weapon. Other than that there should be no reason for incompatibility, so long as CE uses Harmony patching and does not overwrite vanilla code this mod depends on.

I tried it with CE, figuring if the 1-tile miss radius assumption wasn't ideal, it would still help with the worst cases. Unfortunately it didn't seem to work at all, the FF button didn't even show up on CE-enabled weapons.

falconne

Quote from: Maeyanie on September 14, 2017, 09:22:20 PM
I tried it with CE, figuring if the 1-tile miss radius assumption wasn't ideal, it would still help with the worst cases. Unfortunately it didn't seem to work at all, the FF button didn't even show up on CE-enabled weapons.

Yes based on the reply they posted they've done a change to vanilla that at the moment makes it impossible fo rmy mod to work with it. I have to post a follow up question with a possible workaround.

falconne

Latest version should now be compatible with Combat Extended. If you are trying this mod with that one, please observe the colonists during a raid and let me know if they aren't behaving right.

falconne

Just fixed a bug where colonists were not putting out fires when friendlies are standing next to them (it seems putting out fires is considered an attack).

Please update if you are using the manual download.

Maeyanie

Quote from: falconne on September 16, 2017, 06:36:07 AM
Latest version should now be compatible with Combat Extended. If you are trying this mod with that one, please observe the colonists during a raid and let me know if they aren't behaving right.

Seems to work. Only minor problem I noticed in testing was if a colonist is already aiming for a shot, they won't cancel it if someone moves in the way by the time they fire.

Not sure if it's possible to do a second check before firing, but even if not, it's way better than vanilla behaviour.

Kori

Quote from: falconne on September 16, 2017, 06:36:07 AM
Latest version should now be compatible with Combat Extended. If you are trying this mod with that one, please observe the colonists during a raid and let me know if they aren't behaving right.

Thank you!