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

Manual turret aiming #10575

Merged
merged 3 commits into from Dec 25, 2014

Conversation

Projects
None yet
4 participants
@Coolthulhu
Copy link
Contributor

commented Dec 21, 2014

A new option for turreted vehicles: aim a turret.
Forces a target for the turret rather than letting it pick one automatically.

Modifies and uses game::target, but in a way that doesn't affect existing uses. Makes game::target public.

Target is referred to by location. Uses the "std::pair<point,point> target" originally declared for jumper cables. Second point of the pair is original location of the turret - if it changes, the vehicles "sights" have moved and so will the target (not sure if it's possible for a vehicle to move between player's turn and turret handling).

Currently no support for burst fire/single fire selection - if the turret is configured for single fire, manual aiming will fire once. If not (off or burst) it will fire a burst. If it was off before manual aim, will turn it off after firing.

Will force turret_mode on if it wasn't.

Doesn't respect player's safety or warn about possible friendly fire.

Doesn't respect the hardcoded distance limit of 12 (or 5 in case of gasoline fuel) that automatic target acquirement has.

Checks for tag: "MANUAL". Turrets with this tag will not acquire targets by themselves and can't be configured.

@DragonLaggin

This comment has been minimized.

Copy link
Contributor

commented Dec 22, 2014

I had posted this as a suggestion about a year or a year and a half ago. Glad to see someone do this.

@KA101 KA101 self-assigned this Dec 23, 2014

@KA101

This comment has been minimized.

Copy link
Contributor

commented Dec 23, 2014

Good news: it works.

Bad news: the M2 Browning on my APC blew out my torso when on single-shot automatic acquisition, after I targeted a spitter that (with the fact I was in motion) moved into my line. Folks are not gonna be happy about that, ignoring IFF or no.

@KA101 KA101 removed their assignment Dec 23, 2014

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 23, 2014

How did it all look like before your M2 gunned you down? How close were you to it? Did it try to shoot through you or just included you in its cone of fire when it shouldn't?

I didn't change the automatic targeting code, so I don't see how could it happen. I can't reproduce it on my side either.

How fast were you going? Is it possible that it was just the recoil from a fast moving vehicle caused this? I'm pretty sure that (in mainline) low-accuracy turrets (tested with humvee GL) can friendly-fire when the player is close. Since recoil and dispersion are pretty much interchangeable here and moving vehicles have positive recoil, this could be just bad luck.
Chance of "bad luck" seems to be maximized around 2 tiles of distance, but can happen when adjacent if the weapon has bad accuracy or in a fact moving vehicle.

It should work like this: manual target acquisition costs some time. If you're fast, you can aim and then do something else. Turret will shoot as soon as vehicle gets processed (I think just after player's turn). The target is a point, so it doesn't track any possible moving entities. After it executes the shot, it goes back to automatic acquisition that doesn't differ from mainline.
If the turret is turned off at the time of manual aiming, it will burst. Burst CAN acquire a target behind the player, because it is handled by fire_gun, which doesn't care about allies (yet).

@KA101

This comment has been minimized.

Copy link
Contributor

commented Dec 23, 2014

APC-MG, I was facing roughly 45 degrees (so northeast) and aiming the turret via the gap that comes up at that point. Turret's located in the middle of the unit, practically adjacent to the controls, and, so far as I can tell, tried to shoot through me to hit the spitter I'd targeted.

Was traveling about 19 MPH or so, and am pretty confident the APC moved before the turret fired. Bad luck or no, players instakilling themselves this way is gonna get all sorts of clamor going on the forum, so it's gonna need fixed or worked around if this is to merge. ("No turret within two or three tiles of the controls on stock vehicles and a note in the help as to why" would be one, but I'm not sure if it's the most effective one.)

Basically, you shouldn't be able to kill yourself with your own turrets.

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 23, 2014

Would asking the player "this shot looks dangerous, do you still want to execute it?" be enough?
Possibly with a u.moves = 0 after aiming, to ensure the player doesn't move between aiming and shooting.

Then the only ways to kill self with turrets would be agreeing to be shot through, skidding just before shooting or standing in such a bad spot that the existing (mainlined) turret targeting would also kill the player.

If the turret moves after aiming, its line of fire doesn't rotate - it is the same exact line of fire except translated by the difference in car's position. So if a shot is not dangerous before vehicle movement, it will not become dangerous after it (barring collisions that cause skidding).

The other solution I see would be making turrets more realistic: forbid them from shooting and damaging anything standing on vehicle parts that are inside (turrets are on the roof) or even just a any part of the vehicle. Defenses for the inside of the vehicle could be added later.
This sounds cool, I think I'll try to implement this.

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 24, 2014

OK, so now the turret can't hit the player inside the same vehicle the turret is a part of.
The turret is on the roof, so it shouldn't be capable of shooting anything under that roof (at least without punching through first). It will still IFF as before (ie. avoids player who sits under the roof).

It will not damage the player who is a part of the vehicle, even if there is no roof above them. This is more for convenience, but also because it should only happen to players who specifically aim the turret (and thus avoid aiming at self) or stand at the very edge of IFF range, where things get iffy due to number rounding. Also, the survivor in a vehicle is probably not standing straight, but hunched over or even sitting, making stray shots hitting them make even less sense.

Targeting will now avoid monsters who are standing on the vehicle. Those under the roof wouldn't be damaged anyway (and realistically seen by the turret), those on unroofed areas get it for free (and because turrets can't damage own vehicle).

@KA101 KA101 self-assigned this Dec 24, 2014

@KA101

This comment has been minimized.

Copy link
Contributor

commented Dec 24, 2014

Looks like a git-side issue, so I'll take a look.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Dec 24, 2014

Compiles fine, but now the M2 Browning won't shoot at a bio-op directly in front of the APC. (By "directly" I mean anywhere from 12 tiles directly in front of the weapon, to right up on the APC's bumper.) Goes for manual and auto targeting.

:-(

@KA101 KA101 removed their assignment Dec 24, 2014

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 24, 2014

Was it with the newest commit? I did some really stupid mistakes in the ones just before it (comparing vehicle to null rather than to other vehicle).
I can't reproduce - spawned some bio-ops, 2 died before they could reach the car, the one that got on the bumper got ignored, but still could be shot off manually.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Dec 24, 2014

Yep, I manually targeted the op and it kept saying the M2 couldn't shoot it. What vehicle were you using to test? I'm wondering if turrets "inside" the vehicle (as in, not on the immediate outside edge) are getting blocked by their own vehicle.

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 24, 2014

Kept saying it couldn't shoot?
I scanned the code and I think it should only pop when you fail to load it with ammo/supply energy. Or when the jsons are bad. Did you make sure you loaded it?

I'll change the description and try to prevent ammo-less turrets from being aimed.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Dec 24, 2014

Last time I checked APC turrets (at least when debug-spawned) came loaded. It had no problem shooting when it one-shot my test char earlier. ;-)

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 24, 2014

Well, not all do. Apparently it's random. You mean the APC named "Armored Personnel Carrier" with id "apc" under number 4 in debug spawn menu? I spawned 10. 2 of them had no ammo.

I mean, I seriously can't find any other explanation. The "failed to shoot" message can only happen when it's a non-turret firing, a turret with non-gun weapon item, a turret firing non-ammo, a turret with no ammo or a turret trying to fire ammo with negative charges or 0 charges.

@KA101 KA101 self-assigned this Dec 24, 2014

@KA101 KA101 merged commit 438a403 into CleverRaven:master Dec 25, 2014

1 check passed

default
Details
@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 25, 2014

Thanks Santa!

@KA101

This comment has been minimized.

Copy link
Contributor

commented Dec 26, 2014

FYI: this seems to break down at nighttime and/or underground: M249s (test-mounted on a quad or RV, or preinstalled on an armored car) all have max range 0 in such circumstances. M2s on the APC retain range 45.

The faux-ammo thing is the likely culprit but that wouldn't explain the daylight-only aspect, I'd think. :-/

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 26, 2014

Nice catch, though the explanation is much simpler: I didn't include ammo range in calculation. It only uses gun range, which in M2 is 45 and in M249 is 0.

@KA101

This comment has been minimized.

Copy link
Contributor

commented Dec 26, 2014

Bloody hell. >_<

KA101 has been on this for a While now

@Coolthulhu

This comment has been minimized.

Copy link
Contributor Author

commented Dec 26, 2014

I'll PR a fix in few minutes. Got normal turrets covered, but CHARGE ones need a tiny bit of extra care.

EDIT: #10641

@Coolthulhu Coolthulhu deleted the cataclysmbnteam:manual-fire-turret branch Dec 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.