aliens

Author Topic: Experimenting with firing mechanics  (Read 6283 times)

Offline zugz

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Experimenting with firing mechanics
« on: June 20, 2014, 05:10:53 am »
One thing I always felt could be improved in the original xcom is the basic
mechanics of firing. The approach of vanilla (open)xcom is based on a
pencil&paper style to-hit system, mixed in with a little simulationism.

I'll sketch the openxcom mechanics, which seem to be a faithful replication of
the original mechanics. See Projectile::applyAccuracy in
src/BattleScape/Projectile.cpp for details.

When you fire a shot at an enemy, a d100 is rolled; if it comes up less than
your accuracy score, which is a function only of the stats of the shooter and
of the weapon, then you "hit", otherwise you "miss". If you "hit", then the
shot is fired almost directly at the target - with a little random error if
your dice roll was only just low enough to "hit" - while if you "miss" it's
fired with quite a bit of random error, the exact amount of which again
depending on how bad your roll was.

We know how this feels in play - if you shoot (or are shot at) all the way
across the map with 50% accuracy (the number shown when you choose to make a
shot), about half your shots will be way off while most of the other half will
be unnervingly deadly accurate, with also a few near-misses.

This system is fine and neat in many ways, but it has a couple of downsides.

The first is that range is mostly ignored. If you get a decent roll, you're
guaranteed to hit whatever the distance. Distance still has some small effect,
because with a closer target more of the "misses" will actually randomly hit
anyway, but the effect is quite subtle (c.f.
https://www.ufopaedia.org/index.php?title=Firing_Accuracy_Testing).

UFOExtender's "range-based accuracy", an option included in openxcom, deals
with this in an artificial way by directly changing the accuracy score
according to range. It doesn't affect aimed shots, though.

The second problem is that cover isn't nearly as effective as you'd expect,
for exactly the same reasons as with distance. A decent roll means the shot
will hit, ignoring both cover and distance. Again, cover has some small effect
anyway, but not nearly as much as you might think.

All this makes the game less tactically interesting than it could be.

So, this has been bugging me for the last decade or so. Now, finally, with
openxcom we have the opportunity to fix it!

So I suggest we add a new option (off by default, of course) to replace the
vanilla mechanics with something new.

WarBoy says
(https://github.com/SupSuper/OpenXcom/pull/860#issuecomment-46503455)
that he'll consider this *if* there's some consensus on exactly what the
optional replacement should be; so I'm starting this thread in the hopes of
getting such a consensus.

My suggestion would be to throw away the d100, and *just* add some random
error to each shot, with the amount of noise determined by the accuracy and
nothing else. Then range and cover will have their natural effects - getting a
shot dead-on is very unlikely, so the closer and more exposed the target, the
greater your chance of hitting. Just like in real life. (Disclaimer: I do not
advocate shooting aliens (or anything else) in real life).

I think it's nice to still have the accuracy score mean something concrete, so
I suggest the noise be set such that the chances of hitting a tile at 20
tiles' distance is given by the accuracy. (More concretely, that the error in
horizontal angle be normally distributed with a standard deviation set such
that this holds, with then a separate error in the vertical direction.)

I've implemented this
https://github.com/SupSuper/OpenXcom/pull/860
and have been playing with it; to me, it seems to work rather well. It changes
the game quite a bit, and I think it makes it more interesting.

The only problems I see are firstly that getting a strong unit to throw a
grenade is often more effective at longish ranges than sniping, because
throwing accuracy is always high and missing a bit doesn't matter so much, and
secondly that the increased effectiveness of cover sometimes makes it annoying
that it can be difficult to tell what cover there is along a firepath.

So... any thoughts on this, whether on the specifics of the model I
implemented, or on entirely alternative models, or on why I'm utterly wrong
and the vanilla model is entirely unimprovable?

Offline wsmithjr

  • Colonel
  • ****
  • Posts: 149
    • View Profile
Re: Experimenting with firing mechanics
« Reply #1 on: June 20, 2014, 02:17:33 pm »
Sounds interesting, though to be honest I haven't fully understood the principle behind it yet.  I'm just posting because I'm annoyed by how cover seems to be completely useless for my troops.  I hide behind trees or airplane struts or whatever else I can find and it seems as helpful as standing in the open.  So, a system which takes this into account and makes cover more useful sounds good to me.

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Experimenting with firing mechanics
« Reply #2 on: June 20, 2014, 03:27:49 pm »
Sorry I'm not sure I understand your mechanic. Could you explain it a bit more, maybe using some concrete examples?



Offline zugz

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: Experimenting with firing mechanics
« Reply #3 on: June 20, 2014, 07:37:16 pm »
OK, here's a quick concrete example.

To make things simpler, let's only consider horizontal aim.

Suppose there's a one-tile gap in a wall 20 tiles east of me, and 20 tiles
east of that there's a muton. I shoot at the muton, with whatever fire mode,
and the accuracy the game shows me is 50%.

Under vanilla: 40% of my shots will be dead-on. Another 10% will be
near-dead-on - all those will go through the hole in the wall, and many will
hit the muton. The remaining 50% will be way off, although a few might
randomly happen to go through the hole or even hit the muton. Overall,
something like 43% will go through the hole, and 41% will hit the muton.

With the system I'm proposing, and pretending for simplicity that all shots
have correct vertical aim: exactly 50% will go through the hole in the wall,
since the system is set up such that this is what the accuracy figure means -
chance of getting through a one-tile width 20 tiles away. The shots will be
distributed with a normal distribution (aka bell curve), so most of the other
50% will hit quite close to the hole. Of the 50% which do make it through,
about half will hit the muton - the exact calculation requires a bit of maths,
it comes out as 26% of all shots hitting the muton.

As I say, actually the situation is a bit more complicated than what I just
described, because you can miss vertically too. With the way I'm handling
vertical aiming, it comes out as an overall chance to hit the muton of 25%, if
I'm right in thinking that a muton fills up the whole 16x16x24 block it's in
(if not, adjust appropriately; actually that's another advantage of this
system: it should make crouching or being a sectoid more valuable, because
chance to hit is basically proportional to the area of the target).

Of those which hit the muton, only a few will hit it dead on centre, so if
there were some cover in the middle, it would block many of the shots.
Roughly, if half the muton is covered, then half the shots will hit the cover
rather than the muton.

Clear?
« Last Edit: June 20, 2014, 07:42:38 pm by zugz »

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Experimenting with firing mechanics
« Reply #4 on: June 20, 2014, 09:53:45 pm »
like this:



?

Offline zugz

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: Experimenting with firing mechanics
« Reply #5 on: June 20, 2014, 10:03:40 pm »
Nice!

Although actually I made vertical error half that of the horizontal (the
vanilla code does this too), so actually "on-target" is 16 wide and only 8
high.

Also, there isn't actually a limit to the spread, so putting a 100% mark on
your lines is a bit misleading. It would be technically possible, even with
99% accuracy, to miss so badly that you shoot directly backwards - although
this is vanishingly unlikely.
« Last Edit: June 20, 2014, 10:06:41 pm by zugz »

Offline sender

  • Sergeant
  • **
  • Posts: 16
    • View Profile
Re: Experimenting with firing mechanics
« Reply #6 on: June 21, 2014, 08:30:35 pm »
I agree this is an annoyance with the current accuracy system.

If I could make a different, possibly simpler suggestion: Change absolutely nothing from the current system except the attempted aiming point.

Currently the shooter always aims dead-center (I think, correctly me if I'm wrong). Instead, have the aim be at a random point inside the enemy's hit area. If said area is blocked by cover, you'll hit cover on a "good" shot.
« Last Edit: June 21, 2014, 08:36:37 pm by sender »

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: Experimenting with firing mechanics
« Reply #7 on: June 21, 2014, 08:54:59 pm »
Personally, I'd like to try a system where every weapon (and shooting type) has a top "precision" which can't be overcome by shooter's skill: A successful pistol shot would have a horizontal variation of 1 tile at 10 tile distance, while a successful rifle shot would have a variation of 1 tile at 20 tile distance.

Offline zugz

  • Squaddie
  • *
  • Posts: 4
    • View Profile
Re: Experimenting with firing mechanics
« Reply #8 on: June 29, 2014, 07:33:24 pm »
I agree this is an annoyance with the current accuracy system.

If I could make a different, possibly simpler suggestion: Change absolutely nothing from the current system except the attempted aiming point.

Currently the shooter always aims dead-center (I think, correctly me if I'm wrong). Instead, have the aim be at a random point inside the enemy's hit area. If said area is blocked by cover, you'll hit cover on a "good" shot.

Right, this would deal with cover, though not range. It would leave out other
subtleties, though; for example, if there's another unit right by your target,
with the current system your chances of hitting that unit instead of the one
you aimed at it are artificially low, and this tweak wouldn't change that. The
game is tactically richer when you really have to take these things into
account.

I'm not sure I'd call this tweaked model 'simpler', either. It's a simpler
change from the current model, but the resulting model as a whole would be
rather complicated: first roll to pick a precise target point, then roll to
see if you "hit", then roll again to see how much you miss. It has no obvious
relation to reality, so it's counterintuitive and hence hard to discover,
without reading the source.

The model I'm suggesting - you aim for the centre of the target, but you're
going to miss by some random amount - is the simplest I can think of.

Quote from: yrizoud
Personally, I'd like to try a system where every weapon (and shooting type)
has a top "precision" which can't be overcome by shooter's skill: A successful
pistol shot would have a horizontal variation of 1 tile at 10 tile distance,
while a successful rifle shot would have a variation of 1 tile at 20 tile
distance.

You could just have a per-weapon cap to accuracy. But I think the weapon
accuracy stats are enough on their own, really.