Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turrets return fire at unseen ranged attackers #35784

Merged
merged 7 commits into from
Dec 9, 2019
Merged

Turrets return fire at unseen ranged attackers #35784

merged 7 commits into from
Dec 9, 2019

Conversation

Night-Pryanik
Copy link
Contributor

@Night-Pryanik Night-Pryanik commented Nov 30, 2019

Summary

SUMMARY: Features "Turrets return fire at unseen ranged attackers."

Purpose of change

Make turrets more dangerous and able to defend themselves even from unseen attackers.

Describe the solution

  • Turrets roughly estimate direction and distance to the attacker (2-tile radius around player);
  • Turrets warn player about engaging return fire mode;
  • Turrets fire through fake NPC, its weapon, skills and dexterity based on turret's in question properties.
  • Turrets react only on relatively loud sounds made by attacker (loudness 6 and more);
  • All turrets have this defense function.

Describe alternatives you've considered

None.

Testing

Got yourself Full Night Vision, spawned M240 turret at 6 tiles from the character, fired at the turret, got return fire.

Additional context

345

@Night-Pryanik Night-Pryanik added <Enhancement / Feature> New features, or enhancements on existing Monsters Monsters both friendly and unfriendly. labels Nov 30, 2019
Copy link
Member

@ymber ymber left a comment

Choose a reason for hiding this comment

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

This should detect your position based on where the noise from your shot came from. Currently it can work out where you are without being able to see or hear you and I think that needs reining in.

src/mondefense.cpp Outdated Show resolved Hide resolved
@Night-Pryanik
Copy link
Contributor Author

This should detect your position based on where the noise from your shot came from. Currently it can work out where you are without being able to see or hear you and I think that needs reining in.

If you have clear line of fire to it, then it has clean line of fire to you too. Using its detectors, turret fires in approximate direction of the sound.

@esotericist
Copy link
Contributor

I think you meant "return fire", not "backfire".

The first is the action of firing at an opponent who already fired on you.

The second is the action of a car who needs a mechanic.

@ymber
Copy link
Member

ymber commented Nov 30, 2019

The problem is that with this implementation it will fire in the direction of the player regardless of whether there is a sound to fire at. You could fire something completely silent at it and it would know where you were. fire_point should be targeting the location of a sound rather than the location of the player.

@OrenAudeles
Copy link
Contributor

"Backfire" evokes (at least for USA natives) the sound a vehicle makes when stuff is going weird with the engine. Secondending @esotericist on that suggestion.

Actual suggestion:
Is there any way to change Creature *source to a tripoint [&]source? If it isn't attached to a Creature / Player we can figure out how to use distraction mechanisms (tossing rocks / etc) to trigger the return fire mechanism and waste turret ammunition. Or allow it to target non-visible but triggering monsters (which it is incapable of doing currently, firing only at the Player).

@Night-Pryanik
Copy link
Contributor Author

The problem is that with this implementation it will fire in the direction of the player regardless of whether there is a sound to fire at. You could fire something completely silent at it and it would know where you were.

I'd say turrets are smart enough to understand that if something hit them with high velocity, then even if there was no sound at all, there is someone or something that tries to destroy it, and its next move should be suppressive fire in the direction from which projectile supposedly originated.

@Night-Pryanik Night-Pryanik changed the title Turrets backfire at unseen ranged attackers Turrets return fire at unseen ranged attackers Nov 30, 2019
@Night-Pryanik
Copy link
Contributor Author

Is there any way to change Creature *source to a tripoint [&]source?

For now turrets will return fire at position in player's vicinity, but fire_point could be changed to anything else, as it's a simple tripoint.

@thethunderhawk
Copy link

thethunderhawk commented Nov 30, 2019

I could imagine an acoustic thing that identifies the source of gunfire and targets it. I can’t see a system that detects the exact source of an impact however silent. How would that work on a man-portable turret?

@Night-Pryanik
Copy link
Contributor Author

How would that work on a man-portable turret?

Network of accelerometers all over the body of a turret?

@Night-Pryanik
Copy link
Contributor Author

use distraction mechanisms (tossing rocks / etc)

You will toss rocks from some position, right? Turret will return fire in that direction.
What other distraction mechanisms you have in mind?

allow it to target non-visible but triggering monsters (which it is incapable of doing currently, firing only at the Player).

Fixed. Tested on mi-go scout. Turret correctly return fire to scout's ranged attack.

@thethunderhawk
Copy link

thethunderhawk commented Nov 30, 2019

I really don’t think such a system would be feasible IRL. Just knowing the impact force of a bullet can’t tell you where the bullet came from, ‘cause deflection and stuff makes the problem way too complicated. I’m pretty positive that doesn’t exist in any military capacity IRL.

@tenmillimaster
Copy link
Member

I agree with what @ymber is saying. Designers were going to assume attackers were using firearms of some sort, and would have used gunshot detection, not system diagnostics, to tell that they were being fired upon. A network of accelerometers would go crazy during a vehicle's ride.

I don't think there would have been any other "I'm being shot at" sensors other than an acoustical gunshot detector, since the human operators would recognize they're being shot at and take corrective actions.

Thus, I think it should only respond to gunfire.

@xrogaan
Copy link

xrogaan commented Nov 30, 2019

Dumb question: if the player makes a silent grazing hit on a turret, it means the impact would be on a side of the turret. How would the turret know where to return fire?

Also, assuming there are friendlies to the turret (because it wasn't made in a void), why would the turret takes the risk of firing blind if friendly forces might be engaged? This kind of automation, from the point of view of the operator, is bound to lead to accidents and friendly casualty.

@kevingranade
Copy link
Member

This needs to be audio based as people are suggesting, I'm not aware of a feasible way to trace the trajectory back to it's source based on accelerometer readings.

@FuelType-Memes
Copy link
Contributor

I suggest checking out this video about a gunshot detection system: https://www.youtube.com/watch?v=JJSNQoIvvkY

It uses multiple sensors to triangulate a shot, thus providing needed accuracy and also analyzes sound profile to determine if it's an actual gunshot. So throwing rocks to bait reaction fire wouldn't work, but that you should be able to stone a turret to death

Couple of more points:

  1. Turrets should give a lot more warnings and time. Such system doesn't understand if it's a friend or a foe, it only understands that there was a gunshot. I would say that a device that shoots randomly at gunshots without visual confirmation is... unsafe to its operators?
  2. What would it do if there was a friendly turret shooting nearby? Shoot it back, thus creating a react-shot loop? Can they communicate and understand that they're engaging a friendly?

@SirPendrak
Copy link
Contributor

How about some of the louder laser guns, or energy weapons in general? What about rail rifles, big louder variants of crossbows etc., will it detect them too?

@Kodiologist
Copy link
Contributor

Make turrets more dangerous

Because turrets aren't dangerous enough, said no one, ever.

@Night-Pryanik
Copy link
Contributor Author

Turrets should give a lot more warnings and time. Such system doesn't understand if it's a friend or a foe, it only understands that there was a gunshot. I would say that a device that shoots randomly at gunshots without visual confirmation is... unsafe to its operators?

I'd say if something hits you fast enough and hard enough to harm you, then it's obviously an enemy and should be fired back.

What would it do if there was a friendly turret shooting nearby? Shoot it back, thus creating a react-shot loop? Can they communicate and understand that they're engaging a friendly?

Turret's programming is limited to "Turret is being fired upon? Engage return fire mode.", no matter the source of firing. AFAIK there are no communication in-between turrets.

@Night-Pryanik
Copy link
Contributor Author

Because turrets aren't dangerous enough, said no one, ever.

My ultimate goal is to leave only three methods to cope with highly advanced armored military anti-personnel turrets: use anti-tank weaponry, use armored vehicles, or leave them for good and run away from them. Until this goal is completed, turrets can't be considered dangerous enough.
@kevingranade is this acceptable? Because if it isn't, I'll cease my efforts at balancing and tweaking turrets mechanics and behavior.

@Kodiologist
Copy link
Contributor

Kodiologist commented Dec 1, 2019

The thing is that these highly advanced armored military anti-personnel turrets are friggin' all over the place, and that in general you'll need to get past them to access anti-tank weaponry. So are you saying that you also intend to remove e.g. weapons that can shoot farther than them (generally the best method right now, but it depends on gun stores having a suitable gun), and the ability to stop them with control laptops (already barely viable because of the proximity and the very high computer skill that are required)?

@Night-Pryanik
Copy link
Contributor Author

So are you saying that you also intend to remove e.g. weapons that can shoot farther than them (generally the best method right now, but it depends on gun stores having a suitable gun), and the ability to stop them with control laptops (already barely viable because of the very computer high skill and proximity that are required)?

No, I'm not saying that. I meant that these three aforementioned methods are main, basic ones. If you're cunning enough to invent other working methods, that's good, but they are most probably occasional at best.

@thethunderhawk
Copy link

thethunderhawk commented Dec 1, 2019

@Night-Pryanik I think anti-tank weaponry is a bit much. It’d be really hard to armor a CROWS turret against a .50, and IMO a full burst of .308 should have a decent shot at destroying some important components. Unless you’re talking about up-armoring the shit out of these things, but in that case shouldn’t they be mounted on vehicles rather than stationary on the ground?

Look at this thing:
https://en.m.wikipedia.org/wiki/CROWS#/media/File%3AM240_CROWS.jpg

That’s already pretty big. Personally I always envisioned a man-portable tripod mounted thing, but that wouldn’t be the kind of threat you’re talking about I don’t think.

@Night-Pryanik
Copy link
Contributor Author

Well, maybe not anti-tank, but something with high range and power.

@thethunderhawk
Copy link

thethunderhawk commented Dec 1, 2019

Right now these turrets are seeming pretty substantial for a supposedly man-portable system. Ultimately the coolest way to make these things realistic would be to revamp the vehicle turret system so these can be removed in favor of small towed or stowed vehicles. That way they could run out of power, different types could be powered different ways, the player could turn them off if they get close enough with the right tools, they could be towed or pushed by an armored vehicle, they could have all the armor and sensors you want without sacrificing realism, etc.

@Night-Pryanik
Copy link
Contributor Author

I'm not aware of a feasible way to trace the trajectory back to it's source based on accelerometer readings.

Something like that? I know it's crude, but I hope the idea is understandable. It's three-component accelerometer (with 3 axes). If any of components has shifted its position after the hit, we can calculate the direction of its new position and, consequentially, the direction from which projectile has originated.

изображение

@esotericist
Copy link
Contributor

You seem to be assuming the shot hit dead center. The imparted impact could be a much much different angle

Also accelerometers are a terrible way to do this.

@tenmillimaster
Copy link
Member


There are too many irregular surfaces for this to really work out.

It's not a seamless pill shaped object.

@Night-Pryanik
Copy link
Contributor Author

Accelerometer could be installed in the base of the turret. Turret will move after the hit (even it's a slightest shift), highly sensitive sensor could measure this shift and calculate the direction. Something akin to optical image stabilization technologies.

@I-am-Erk
Copy link
Member

I-am-Erk commented Dec 1, 2019

These turrets are intentionally based on real turrets. Crows turrets aren't covered in accelerometers, even if such a thing could triangulate a shot origin in 3d, which they cannot.

The solution is to track the sound where the shot is thought to come from, as Kevin said. Without that this doesn't make sense, and isn't a reasonable mechanic since it can't be logically circumvented by the player taking reasonable precautions

Edit: I'm not even sure that's a good idea unless it's only for lab turrets maybe. On the street or in a combat zone it's very exploitable by the enemy or by accident.

@Night-Pryanik
Copy link
Contributor Author

On the street or in a combat zone it's very exploitable by the enemy or by accident.

How it is exploitable? Someone need to fire at turret to get return fire (for what?). This someone is in danger of being shot by this return fire. I doubt anyone will try to somehow exploit this feature instead of trying to simply destroying it.

@I-am-Erk
Copy link
Member

I-am-Erk commented Dec 1, 2019

Well, your accelerometer idea is exploitable simply by hitting a glancing shot. Any kind of banking shot would cause the turret to fire in an incorrect direction and could be used to hose the turret's allies very easily.

Shooting at the sound thought to be responsible for the turret taking damage is less easily exploitable, but all it takes a noisemaker and a silent attacker.

@Night-Pryanik
Copy link
Contributor Author

I think current implementation could suffice, no matter what internal explanation we're trying to come up with. It may be accelerometers, it may be acoustic detectors, it may be something else.
Code-wise turret return fire to Creature position, and at the moment AFAIK everything with ranged attack capabilities uses Creature class and its descendants (for example, NPCs, fake or real) to fire. So if something fires, this "something" is a Creature.
@kevingranade will this suffice?

@I-am-Erk
Copy link
Member

I-am-Erk commented Dec 1, 2019

Kevin already told you

This needs to be audio based as people are suggesting

Turrets being able to shoot at attackers they can't see with no way for the player to circumvent it is a terrible idea.

@tenmillimaster
Copy link
Member

tenmillimaster commented Dec 1, 2019

This should be your basis for implementation.
rws

Why not have a string match to the noise gunfire makes?

Eso tells me this is a terrible idea due to localization.

@Night-Pryanik
Copy link
Contributor Author

So... Turret now uses acoustic data (sorta). Game checks for loudness data of attacker's weapon. If it's low enough (like most low-end bows) or completely silent (thrown weapons), then it won't generate any sound on fire or throw and thus turrets won't be able to detect unseen attacker's position.

src/mondefense.cpp Outdated Show resolved Hide resolved
@FuelType-Memes
Copy link
Contributor

So correct me if I'm wrong:

  1. Using accelerometers turret checks whether it's hit by a projectile
  2. Using audio analysis turret understands location nearby gunshots
  3. If hit by a projectile, it uses audio data to roughly estimate the position of the shooter
  4. It issues a warning (one? two? does it wait for second shot?)
  5. It shoots

So, if it's hit by either the player or a stray turret/NPC/robot bullet it engages return fire

@Night-Pryanik
Copy link
Contributor Author

  1. Using accelerometers turret checks whether it's hit by a projectile
  2. Using audio analysis turret understands location nearby gunshots
  3. If hit by a projectile, it uses audio data to roughly estimate the position of the shooter

Yes.

  1. It issues a warning (one? two? does it wait for second shot?)
  2. It shoots

Formally it's not a warning, but rather an alert message for turret operators on duty. But since there are no more operators, players can use this message as a warning.
It's only one warning, and turret shoots immediately after it.

So, if it's hit by either the player or a stray turret/NPC/robot bullet it engages return fire

Yes. It doesn't matter for a turret who or what fires at it, it just returns fire.

@@ -41,6 +41,7 @@
"no_ammo_sound": "a chk!"
}
],
"special_when_hit": [ "RETURN_FIRE", 100 ],
Copy link
Member

Choose a reason for hiding this comment

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

Based on the slide I posted, this should be a 'counter sniper' function co-opted to blindfire at heard targets.
It shouldn't need to have been hit to attempt this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Detecting "firing in your direction" mechanics could be an upgrade to current state, but as it requires much more coding, I think it could be done in subsequent PRs.

@I-am-Erk
Copy link
Member

I-am-Erk commented Dec 3, 2019

I'm glad to see it moving to attacking noise instead, but I think tenmillimaster is right - having it identify and shoot at loud bangs rather than know when it's been damaged is a better system, because it allows it to be spoofed by clever player tricks.

@Night-Pryanik
Copy link
Contributor Author

I spent 2+ full days doing nothing except for trying only to make the system work based on sound location. Despite my efforts, I failed at that. Current implementation is the best I've managed to do on this matter. I'm sure we need someone much more qualified to implement the system you're suggesting.

@thethunderhawk
Copy link

thethunderhawk commented Dec 3, 2019

Thanks for trying @Night-Pryanik. Personally I think the current implementation (sound based, but the turret needs to take a hit first right?) is still an enhancement and might as well be merged. It does the job of making turrets less cheese-able, and while it might make turrets a lot more deadly, it at least helps deal with the “loot piñata” situation. The full on “counter-sniper” implementation could happen in later PRs IMO.

I do think the new capabilities should be mentioned in the monster description, and even an audio message from the turret saying something like “unseen attacker detected, returning fire”, just so the player has a little warning that the old tactics won’t work anymore. Just a thought though I don’t think that’s critically important.

@tenmillimaster
Copy link
Member

@Night-Pryanik
No one in the repo intends to disparage your efforts, and I am thankful for them; We only wish to maintain and adhere to a consistent vision for the game. There are so many contributors and it can be difficult to do so.

I believe that this is a sufficient enough improvement over current CROWS behavior that it should be merged, with the understanding that it should be expanded to all firearm noises when possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Enhancement / Feature> New features, or enhancements on existing Monsters Monsters both friendly and unfriendly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.