[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

Quote from: Maeyanie on September 17, 2017, 11:36:23 PM
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.

Interesting. In my testing I found that the pawns already do regular rechecks during their warmup to check if they can still see the target. Are you sure the other colonist actually walked into a danger tile? If they were within 4 tiles of the shooter they are not subject to friendly fire.

falconne

Have just posted an update. Latest version now also protects against friendly fire from miniguns and other weapons with a forced miss radius.

Maeyanie

Quote from: falconne on September 17, 2017, 11:56:34 PM
Interesting. In my testing I found that the pawns already do regular rechecks during their warmup to check if they can still see the target. Are you sure the other colonist actually walked into a danger tile? If they were within 4 tiles of the shooter they are not subject to friendly fire.

It happened when my long-range shooters were taking shots at an enemy while some swordsmen ran up, and one of them almost got shot in the back as she swung at the same target which was getting shot. Was at fairly long range, so definitely not that.

It's possible there was some other factor I didn't notice, though. Maybe she wasn't quite in the line of fire yet and I just misinterpreted what happened, or something. I'll keep an eye out for if I see it happen again.

Edit: The CE version actually seems to not fire even if people are within the 4 tiles. Though, I think it's possible to accidentally shoot someone right in front of you with CE, so that's probably a good thing.

falconne

Quote from: Maeyanie on September 20, 2017, 11:24:06 AM
It happened when my long-range shooters were taking shots at an enemy while some swordsmen ran up, and one of them almost got shot in the back as she swung at the same target which was getting shot. Was at fairly long range, so definitely not that.

It's possible there was some other factor I didn't notice, though. Maybe she wasn't quite in the line of fire yet and I just misinterpreted what happened, or something. I'll keep an eye out for if I see it happen again.

Edit: The CE version actually seems to not fire even if people are within the 4 tiles. Though, I think it's possible to accidentally shoot someone right in front of you with CE, so that's probably a good thing.

For the long range it's possible at the time the decision to fire the bullet was made the swordsman wasn't quite in the line of fire yet. Keep an eye out anyway and let me know if it happens to be more obvious. Currently vanilla has its own "recheck LoS during warmup" functionality which I've let take care of this. I could add extra checks if necessary but that all adds performance hits so I want to be sure it's necessary.

As for the CE issue, I can't reproduce that. Can you send me a save if you can? Do they take the shot when you disable their FF option?

Maeyanie

Quote from: falconne on September 20, 2017, 04:44:49 PM
For the long range it's possible at the time the decision to fire the bullet was made the swordsman wasn't quite in the line of fire yet. Keep an eye out anyway and let me know if it happens to be more obvious. Currently vanilla has its own "recheck LoS during warmup" functionality which I've let take care of this. I could add extra checks if necessary but that all adds performance hits so I want to be sure it's necessary.
That is definitely possible. I didn't get a good look at exactly what happened, just saw a shot very nearly hit someone in the back, saw the person stop shooting afterwards, and jumped to conclusions.

Quote from: falconne on September 20, 2017, 04:44:49 PM
As for the CE issue, I can't reproduce that. Can you send me a save if you can? Do they take the shot when you disable their FF option?
At the time I noticed that behaviour, I disabled the FF option and they took the shot... right into the back of a friendly 2 tiles away. I think the friendly they hit was an animal, though, not a person, so maybe they're handled differently by CE. I do have the "avoid shooting animals" option enabled.

It's also possible there was a friendly 4 tiles away who was off to the side or something which I missed, and it's actually working as intended. In the future I'll make a point of taking screenshots to re-analyze stuff later, make sure I'm not wasting your time reporting nonsense.

Edit:
That didn't take as long as I'd hoped, but as promised, this time I come armed with screenshots.
One of my colonists, taking cover behind a rock wall, shot a front-line person in the back. Everyone was stationary, so shouldn't have been any oddness there. The two who were not in cover realized someone was in the way and held fire.
Layout: https://www.dropbox.com/s/14i93clb0hnu5rv/20170923054245_1.jpg
Manual shot from the "in cover" position shows no risk of hitting anything: https://www.dropbox.com/s/un5elpa8qzkjt9g/20170923054326_1.jpg
Manual shot from the "pop out to shoot" position shows what it should: https://www.dropbox.com/s/9wan08ca88ch3si/20170923054330_1.jpg

falconne

Great, thanks for the detailed analysis. I should be able be able to set this up in dev mode to investigate. Yes, it looks like the calculation of the fire cone is disrupted by the cover which I hadn't thought about.

falconne


falconne

I introduced a bug in yesterday's update and have just done another update to fix that. Please download again if you are doing so manually. Sorry about that.

AngleWyrm

My 5-point rating system: Yay, Kay, Meh, Erm, Bleh


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

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

falconne

I've just updated with a feature to make the mod more flexible when it comes to 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%.

warcin

I think there might be some issue with hunting and friendly fire. I don't use CE.  :'(
https://i.imgur.com/SpLWy40.jpg

Edit: I can reproduce this situation, seems that hunter will reposition himself only if someone is in "red danger zone" while starting to shoot. It would be nice if hunter would check for friendly fire after warming up, just before shooting up projectile.

falconne

Quote from: warcin on November 24, 2017, 11:30:08 AM
Edit: I can reproduce this situation, seems that hunter will reposition himself only if someone is in "red danger zone" while starting to shoot. It would be nice if hunter would check for friendly fire after warming up, just before shooting up projectile.

Do you have a save from just before you can reproduce it? The game does recheck the target during warmup every tick, including on the last tick before warmup completes. Someone did report this happening before but I could only assume it was an edge case where the other pawn walked into the fire zone after the warmup phase completed and the launch phase had begun, where it can't be stopped. I'll have another go at reproducing the behaviour, but I've tried to previously and not got it so a save where you know it happens would be good.