Jump to content

Shot Miss Scattering


Recommended Posts

A long rifle is about a meter. That leaves about the length of my arm from the muzzle to the alien's chest. A heavier and longer barrier takes longer to bring up, and that's it. If I can accurately shoot someone from 25 meters firing from the shoulder, you better bet I can do it from 2. Heck, even if you're lazy and have bad training and don't have the stock in your shoulder, you could still accurately hit something at that range.

Ask someone with a hunting rifle to take you shooting. Stand 5 feet away from the target, bring the rifle up, and shoot it. You'll notice that it takes a long time to swing the barrel up, but you'll also notice that hitting the target is effortless.

I surrender! (please don't shoot me)

Link to comment
Share on other sites

if((soldPosX == (targetPosX + 1)) ||  (soldPosY == (targetPosY + 1)) ||  (soldPosX == (targetPosX - 1)) ||  (soldPosY == (targetPosY - 1)))           hitChance = 99;else if((soldPosX == (targetPosX + 1) && soldPosY == (targetPosY +1)) ||       (soldPosX == (targetPosX - 1) && soldPosY == (targetPosY + 1)) ||       (soldPosX == (targetPosX + 1) && soldPosY == (targetPosY - 1)) ||       (soldPosX == (targetPosX -1) && (soldPosY == (targetPosY + 1)))           hitChance = MAX(soldierAcc, weaponAcc);else           hitChance = (whatever fabulous formula the coders have come up with);

SoldPos = 9, 200

TargetPos = 8, 5

first if breaks with true -> hitchance = 99

Right way will be fabulous formula only. Correct function with the hit curve closing to the 100% with the distance reduction, depending on two coefficients (human accuracy and weapon accuracy)

Bézier curves is the first thing that come in my mind. It will look like this:

Untitled-1.jpg

And it can be tuned pretty good, for example, you will have control over the distance on which rookie with sniper rifle will became more accurate than the veteran with pistol, maximal hit percent, minimal hit percent, etc.

Untitled-1.jpg

Untitled-1.jpg.97f1045052b94449a5ed20963

Link to comment
Share on other sites

SoldPos = 9, 200

TargetPos = 8, 5

first if breaks with true -> hitchance = 99

Right way will be fabulous formula only. Correct function with the hit curve closing to the 100% with the distance reduction, depending on two coefficients (human accuracy and weapon accuracy)

Bézier curves is the first thing that come in my mind. It will look like this:

[ATTACH=CONFIG]2012[/ATTACH]

And it can be tuned pretty good, for example, you will have control over the distance on which rookie with sniper rifle will became more accurate than the veteran with pistol, maximal hit percent, minimal hit percent, etc.

I think I had it right and then changed it because I'm an idiot.

Link to comment
Share on other sites

I don't understand why you would concentrate on a system that could make it significantly harder to hit someone 3 metres away than it is to hit someone 1.6 metres away.

Surely it makes more sense to just fix the system so that short range shots are sufficiently accurate to allow you to hit the enemy with reasonable reliability at all ranges?

Link to comment
Share on other sites

I don't understand why you would concentrate on a system that could make it significantly harder to hit someone 3 metres away than it is to hit someone 1.6 metres away.

Surely it makes more sense to just fix the system so that short range shots are sufficiently accurate to allow you to hit the enemy with reasonable reliability at all ranges?

Because I'm not the world's greatest programmer and am just thinking of brute-force methods before refinement. I think that a333's curve would probably work better than what I wrote, but what I wrote is, as I said, incredibly brute-force. It works, but it ain't pretty.

Link to comment
Share on other sites

You just have to use an exponent based formula to get the proper results. I'm not going to work one out, but I've done it before. Basically, all weapons have an effective range. The curve basically drops slowly as range increases then past the effective it becomes much steeper.

..............

.............

................

......

.....

...

..

.

Link to comment
Share on other sites

What's the formula for your curve graph? I just want to know how much of a pain in the neck it would be to code (likely a giant pain because complicated formulae are a giant pain to write properly).

As i said, it's Bezier curve. Wiki page has great explanations and build animation. For a code implementation, look for de Casteljau's algorithm, like here.

How it works with the given parameters:

First point (starter point) would define a max hit percent, second reflects human accuracy skill. It has significant impact in the low-to mid distance, but lower when the target is far away. Third point represents weapon accuracy, and it's more important on the far away, which is logical. You can't sharpshoot from the pistol. This point also depends of second point coordinates to avoid situation when your accuracy drops and then suddenly rises again. It's better think of it as of "accuracy reduction". It also can work in conjunction with the final point which defines minimal hit percent over the longest possibly distance.

But after doing a research myself, i'm not so sure it would be practical. Curve is defined parametrically, so returning y for given x would be harder than it looks. Therefore simple exponential function as the StellarRat says can be more suitable.

Link to comment
Share on other sites

I've got a fancy idea:

func.JPG

it's basically y= AccW*cos(AccA*x) +1 +(1-AccW)

Where

AccW - Weapon accuracy, from 1 to 0.1, more = better;

AccW - Actor accuracy, from 1 to 1.9, more = worse.

+1 is to set graph in positives only,

+(1-AccW) is to hold graph up to the 100% accuracy when distance = 0.

The only thing left to add is if (x>Pi) x= Pi; to get rid of graph' rising after minimum.

Now translate 0..2 to 0..100% on y, 0..Pi to 0..whatever distance you want to be maximal on x. You're done.

func.JPG

func.JPG.87d4f9d25ae39e8d5464edae8b52ba6

Link to comment
Share on other sites

From your explanation that varies with weapon accuracy and soldier accuracy but where does the optimal range of the weapon come into it?

As a variable shouldn't it be represented in the formula rather than by altering the labelling of the axis or am I misunderstanding you (maths is not my strongest field :P).

Link to comment
Share on other sites

Weapon optimal range is reduced to a weapon maximum effective range here, and defined by AccW. This number defines how strong accuracy will drop over the distance. For pistols it's a huge drop almost to 0 (blue and cyan lines), for sniper rifles it isn't so bad (orange and red lines).

You will always get a max possible hit percent in point-blank for every weapon. Of course you can set this on 98-99 (by altering axis to accuracy diapason translation), for a rare chance of missing upclose. But this number will be constant for everything. As crusherven said, if you can hit the target two meters away with the pistol, it's unbelievable to miss with sniper rifle from the same distance.

Obviously, sniper rifle should be balanced to be unwieldy from upclose, but you can do it by other means, like TU's cost.

IMHO «optimal range» should be related to something like not shooting with the rocket launcher under your own feet, but that's another question.

Link to comment
Share on other sites

Ok so you are combining the current optimum range and accuracy modifier settings under one statistic?

So if the system locks in the starting point at 100% accuracy (or 95% as per the current cap) and has a set reduction based on the weapon how would the actual accuracy of the soldier affect the accuracy at range?

Or did you mean that the accuracy is locked at 100% of the soldiers accuracy?

I am unclear on how this is much different from the current system.

At the moment if you were to give all weapons a 100% accuracy modifier then wouldn't they work in roughly the same way as your suggestion?

Maximum accuracy at zero tiles then falling off to the weapons set maximum range.

The shotgun with 7 tile range has the accuracy fall off sharply while the precision rifle with 26 tile range falls of slowly.

Link to comment
Share on other sites

So if the system locks in the starting point at 100% accuracy (or 95% as per the current cap) and has a set reduction based on the weapon how would the actual accuracy of the soldier affect the accuracy at range?

AccA

Look at the graph, it has 4 lines, for each of the situation. High soldier (or alien) accuracy represented by the dark blue and dark red lines. Low soldier accuracy - light blue and red lines. Accuracy falling starts earlier.

And while i was writing this i've realised that i should modify formula so the accuracy of the rookies will drop lower over the distance. And also clean the graph.

So:

func.JPG

Legend:

x - percentage. from 0% to, say, 99%;

y - distance. Scale is irrelevant as for now. Let's think from 0 to the medium map size;

— Veteran with pistol;

— Veteran with sniper rifle;

— Rookie with pistol;

— Rookie with sniper rifle.

func.JPG

func.JPG.f94812665604e1eb51cd5e4b8b80304

Link to comment
Share on other sites

And here I thought they would just use something like

Code:

toHit = shotType * (wAcc * sAcc) * (weaponRangeMax / distToTarget);

I guess that's a bit too simple, though?

I have problems with simplicity =) We just don't see each other frequently.

Link to comment
Share on other sites

But with modification to account for cover, that'd work, right? Right?

Technically this will reduce to y=k/x, which can represent lowering accuracy over the distance. So, yes, this will work.

I just don't like this kind of quickdrop, and poor control of dropping in general.

edit: You can use y = kx+b, it's even simpler and will work too =)

Edited by a333
Link to comment
Share on other sites

Suggested:

toHit = shotType * (wAcc * sAcc) * (weaponRangeMax / distToTarget)

Current formula (link):

Unmodified Accuracy = Shooter Accuracy (sAcc) * Accuracy Modifier (wAcc) * (Range to Target / Weapon Operational Range)

Given that the shot type is the same thing as weapon accuracy (so would be redundant) that looks the same to me *edit* apart form the reversed range calculation which I think is an error.

There is additional information taken into account obviously like intervening obstacles and so on.

*edit* adding a few numbers into that still gives a 66% accuracy soldier with a 75% accuracy weapon around a 49% chance to hit an enemy at 1 tile range unless the modifier doesn't work in the way I expect it to.

Edited by Gauddlike
Link to comment
Share on other sites

Given that the shot type is the same thing as weapon accuracy (so would be redundant) that looks the same to me.

Though it's not the same. This one is straight line (k*x), Assoonasitis' one is hyperbolic curve (k/x). Strightly speaking...^W^W

This thread have too much of the math spilled around, so i'll stop here.

Link to comment
Share on other sites

Suggested:

toHit = shotType * (wAcc * sAcc) * (weaponRangeMax / distToTarget)

Current formula (link):

Unmodified Accuracy = Shooter Accuracy (sAcc) * Accuracy Modifier (wAcc) * (Range to Target / Weapon Operational Range)

Given that the shot type is the same thing as weapon accuracy (so would be redundant) that looks the same to me *edit* apart form the reversed range calculation which I think is an error.

There is additional information taken into account obviously like intervening obstacles and so on.

*edit* adding a few numbers into that still gives a 66% accuracy soldier with a 75% accuracy weapon around a 49% chance to hit an enemy at 1 tile range unless the modifier doesn't work in the way I expect it to.

I was unsure of what should come first in the division part, so I'm not surprised I got it wrong. But if that's the case, then my old, really ugly calculation for accuracy at 1 or 1.5 tiles (the diagonals) would be a really good way for accuracy to be great near the target.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...