OpenXcom Forum

Contributions => Programming => Topic started by: KingMob4313 on July 11, 2014, 02:53:50 am

Title: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 02:53:50 am
I'm about 25% the way into making changes to the code I pulled down to utilize a new field under weapons called 'recoil'.  This would be the penalty (or bonus for negative values) that each further shot in an auto-fire string takes.

I was figuring on making it account for strength, using the following equation: Recoil Adjustment = (sqr(Str * 1.5)) - (5 + Weapon Recoil Stat) with minimum of 1. This would be deducted on every shot past the first. So soldier with a 35% chance to hit with a burst will have 35 for the first shot, then 35 - Recoil Adjustment, then 35 - (2* Recoil Adjustment) and so on.

NEW FORMULA: Recoil Adjustment = Recoil - ((sqr(Str * 1.5)) - 5)

Depending on logistics, I could also see about having it show the 'average' hit rate for the burst, instead of the first shot's percentage.

This would be a further option with default values of zero and only be exposed for modders and have no effect if the option is turned off, like the range based accuracy.
Title: Re: Option for autofire recoil
Post by: Sturm on July 11, 2014, 03:13:52 am
Yes.
Title: Re: Option for autofire recoil
Post by: Solarius Scorch on July 11, 2014, 06:31:49 am
In order to have an opinion, I would have to test this against the UFO Extender Accuracy, which I'm currently using with good results. I don't know how exactly UFO EA works, so your formula tells me nothing. Besides, I can never derive much from formulas when it's a matter of a gameplay - it's all in the practice.

Having said that, I hope you'll finish your code, the idea is interesting.
Title: Re: Option for autofire recoil
Post by: Gifty on July 11, 2014, 07:08:29 am
The difference is that UFO Extender accuracy just applies a "flat-rate" accuracy to all auto shots, making every shot the same within that burst. This new method would alter the accuracy dynamically after each shot, so the first shots in a burst have a higher chance than the final shots, simulating weapon recoil. It would add a whole new angle to weapon stats and give modders one more way to make weapons distinct from one another.
Title: Re: Option for autofire recoil
Post by: Falko on July 11, 2014, 11:21:49 am
so you give a weapon a adjustment of 6
now compare a strength 45 (20-70 average) with a strength 70 (cap) guy
math.sqrt(45*1.5)-(5+6)=-2.7841616374225087
math.sqrt(70*1.5)-(5+6)=-0.753049234040402
so each shot gets more accurate but if you are stronger its accuracy gain is less?
ok perhaps the arbitrary chosen number 6 is way of lets try 2
math.sqrt(45*1.5)-(5+2)=1.2158383625774913
math.sqrt(70*1.5)-(5+2)=3.246950765959598
so here the accuracy decrease with each shot but more strength also means less accuracy
so where is now the position where the bonus turns negative into a for a weapon
ok so lets take a look using value 2 with increasing strength
strength20=>-1.5227744249483388
strength30=>-0.2917960675006306
strength40=>0.745966692414834
strength50=>1.6602540378443873
strength60=>2.486832980505138
strength70=>3.246950765959598
but using value 4 with increasing strength
strength20=>-3.522774424948339
strength30=>-2.2917960675006306
strength40=>-1.254033307585166
strength50=>-0.3397459621556127
strength60=>0.4868329805051381
strength70=>1.246950765959598
your turning point moves

in my opinion there are some flaws in the formula
better strength decreases accuracy
it is not obvious what that recoil parameter does/what is a useful value
the result can switch between positive and negative value - thats not a problem - but there is no clear border/turning point and the resulting behaviour a bit unpredictable
higher values make less recoil ?
Title: Re: Option for autofire recoil
Post by: Muukalainen on July 11, 2014, 02:58:48 pm
Interesting.

You could make it in a way that with laser weapons the accuracy slightly increases the longer you fire.

We used to play paintball, and they have so big "bullets" that you can see them when they fly. And you can have like 200 of them in your clip / loader. When you keep shooting fast enough it looks almost like a laser. And you can aim by just looking where that "laser beam" goes, if you just keep shooting :)
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 03:49:14 pm
so you give a weapon a adjustment of 6
now compare a strength 45 (20-70 average) with a strength 70 (cap) guy
math.sqrt(45*1.5)-(5+6)=-2.7841616374225087
math.sqrt(70*1.5)-(5+6)=-0.753049234040402

Whoops, screwed it up writing it down.

Try this:

Recoil - ((math.sqrt(STR*1.5)-(5))
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 03:50:47 pm
The difference is that UFO Extender accuracy just applies a "flat-rate" accuracy to all auto shots, making every shot the same within that burst. This new method would alter the accuracy dynamically after each shot, so the first shots in a burst have a higher chance than the final shots, simulating weapon recoil. It would add a whole new angle to weapon stats and give modders one more way to make weapons distinct from one another.

That's exactly the point.  It opens up so much more differentiation between the weapons.  Suddenly weapons that have a ton of autoshots per autofire action have some disadvantages.
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 03:52:19 pm
Interesting.

You could make it in a way that with laser weapons the accuracy slightly increases the longer you fire.

We used to play paintball, and they have so big "bullets" that you can see them when they fly. And you can have like 200 of them in your clip / loader. When you keep shooting fast enough it looks almost like a laser. And you can aim by just looking where that "laser beam" goes, if you just keep shooting :)

That could be the flipside of laser weapons. With laser weapons, you won't see the shot fly.  It'll just be 'there' just like how lights there on the wall when you turn on the flashlight.

I'd more see it with lower ROF plasma weapons, that would be a lot like paintball.
Title: Re: Option for autofire recoil
Post by: Muukalainen on July 11, 2014, 04:01:10 pm
That could be the flipside of laser weapons. With laser weapons, you won't see the shot fly.  It'll just be 'there' just like how lights there on the wall when you turn on the flashlight.

I'd more see it with lower ROF plasma weapons, that would be a lot like paintball.

Yes. Ofcourse it depends on the laser. At least I can see very well the laser beams that X-Com use :)

But that was just an idea, so if you change the code, you could make it in a way so modders have this option too.
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 04:19:22 pm
Yes. Ofcourse it depends on the laser. At least I can see very well the laser beams that X-Com use :)

But that was just an idea, so if you change the code, you could make it in a way so modders have this option too.

Absolutely, that's the idea of this. If you want shots past the first one to get more accurate, you enter a negative recoil value.
Title: Re: Option for autofire recoil
Post by: Falko on July 11, 2014, 04:32:07 pm
Recoil - ((math.sqrt(STR*1.5)-(5))
ah that makes more sense now more strength=more accuracy and higher number=higher accuracy loss
for x in itertools.product(range(1,7),range(20,71,10)): print (x,x[0]-(math.sqrt(x[1]*1.5)-5))
(1, 20) 0.5227744249483388
(1, 30) -0.7082039324993694
(1, 40) -1.745966692414834
(1, 50) -2.6602540378443873
(1, 60) -3.486832980505138
(1, 70) -4.246950765959598
(2, 20) 1.5227744249483388
(2, 30) 0.2917960675006306
(2, 40) -0.745966692414834
(2, 50) -1.6602540378443873
(2, 60) -2.486832980505138
(2, 70) -3.246950765959598
(3, 20) 2.522774424948339
(3, 30) 1.2917960675006306
(3, 40) 0.25403330758516596
(3, 50) -0.6602540378443873
(3, 60) -1.4868329805051381
(3, 70) -2.246950765959598
(4, 20) 3.522774424948339
(4, 30) 2.2917960675006306
(4, 40) 1.254033307585166
(4, 50) 0.3397459621556127
(4, 60) -0.4868329805051381
(4, 70) -1.246950765959598
(5, 20) 4.522774424948339
(5, 30) 3.2917960675006306
(5, 40) 2.254033307585166
(5, 50) 1.3397459621556127
(5, 60) 0.5131670194948619
(5, 70) -0.24695076595959797
(6, 20) 5.522774424948339
(6, 30) 4.291796067500631
(6, 40) 3.254033307585166
(6, 50) 2.3397459621556127
(6, 60) 1.5131670194948619
(6, 70) 0.753049234040402
in my opinion the points: "it is not obvious what is a useful value"/"behaviour a bit unpredictable" are still valid
to be clear i dont want to discourage here i just see it from a modder perspective who wants to use this value and give it a useful meaning .. 
perhaps a wiki page that sums up a list like above would be enough to explain
and to go one step further i had an idea about an alternative base for strength
one could go and use "free" strength points (strenght-weight?) so you can increse the reliability in using a heavy recoil weapon with a 30 strength guy if you get rid of all his other items medipacks,grenades, second ammoclip,... like: (Recoil - ((math.sqrt(max(0,(STR-WeightOfAllItems)*1.5))-5))
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 05:20:25 pm
ah that makes more sense now more strength=more accuracy and higher number=higher accuracy loss
for x in itertools.product(range(1,7),range(20,71,10)): print (x,x[0]-(math.sqrt(x[1]*1.5)-5))
(1, 20) 0.5227744249483388
(1, 30) -0.7082039324993694
(1, 40) -1.745966692414834
(1, 50) -2.6602540378443873
(1, 60) -3.486832980505138
(1, 70) -4.246950765959598
(2, 20) 1.5227744249483388
(2, 30) 0.2917960675006306
(2, 40) -0.745966692414834
(2, 50) -1.6602540378443873
(2, 60) -2.486832980505138
(2, 70) -3.246950765959598
(3, 20) 2.522774424948339
(3, 30) 1.2917960675006306
(3, 40) 0.25403330758516596
(3, 50) -0.6602540378443873
(3, 60) -1.4868329805051381
(3, 70) -2.246950765959598
(4, 20) 3.522774424948339
(4, 30) 2.2917960675006306
(4, 40) 1.254033307585166
(4, 50) 0.3397459621556127
(4, 60) -0.4868329805051381
(4, 70) -1.246950765959598
(5, 20) 4.522774424948339
(5, 30) 3.2917960675006306
(5, 40) 2.254033307585166
(5, 50) 1.3397459621556127
(5, 60) 0.5131670194948619
(5, 70) -0.24695076595959797
(6, 20) 5.522774424948339
(6, 30) 4.291796067500631
(6, 40) 3.254033307585166
(6, 50) 2.3397459621556127
(6, 60) 1.5131670194948619
(6, 70) 0.753049234040402
in my opinion the points: "it is not obvious what is a useful value"/"behaviour a bit unpredictable" are still valid
to be clear i dont want to discourage here i just see it from a modder perspective who wants to use this value and give it a useful meaning .. 
perhaps a wiki page that sums up a list like above would be enough to explain
and to go one step further i had an idea about an alternative base for strength
one could go and use "free" strength points (strenght-weight?) so you can increse the reliability in using a heavy recoil weapon with a 30 strength guy if you get rid of all his other items medipacks,grenades, second ammoclip,... like: (Recoil - ((math.sqrt(max(0,(STR-WeightOfAllItems)*1.5))-5))

Well, once the value reaches less than zero, it flatlines at 0 or 1. Otherwise, yes, at high strengths and lower recoil values, high strength squadies would see their accuracy increase per shot.  That's not intended.  Generally a higher strength always lets you have better control of the weapon with this equation.

Title: Re: Option for autofire recoil
Post by: Falko on July 11, 2014, 05:49:17 pm
hm so how about two numbers?
recoilstep and recoilstrength
recoilstep is the base decrease in accuracy for each shot
recoilstrength is a value that is substracted from the recoil for every 10 strengthpoints
now:
recoilstep=0 => no recoil
recoilstep>0 => weapon has recoil that decrease accuracy
recoilstep<0 => weapon aims with more shots (laser)
recoilstrength=0 means strenght has no influence
e.g. recoilstep=4, recoilstrength=0.3 , strength=40 is easy to calculate each shot you get 4-(40/10)*0.3 = 2.8 accuracy loss
a laser weapon would be like: recoilstep=-3, recoilstrength=0 # no strength benefit but increasing accuracy by 3 per shot

the formula allows for recoilstep=0 and recoilstrength>0 so real recoil but strenght gives accuracy - could be an option for very heavy weapons with autofire?

for x in itertools.product([-5,0,5,10],[-0.5,0,0.5,1],range(20,71,25)): print (x,x[0]-(math.ceil(x[2]/10)*x[1]))

(-5, -0.5, 20) -4.0
(-5, -0.5, 45) -2.5
(-5, -0.5, 70) -1.5
(-5, 0, 20) -5
(-5, 0, 45) -5
(-5, 0, 70) -5
(-5, 0.5, 20) -6.0
(-5, 0.5, 45) -7.5
(-5, 0.5, 70) -8.5
(-5, 1, 20) -7
(-5, 1, 45) -10
(-5, 1, 70) -12
(0, -0.5, 20) 1.0
(0, -0.5, 45) 2.5
(0, -0.5, 70) 3.5
(0, 0, 20) 0
(0, 0, 45) 0
(0, 0, 70) 0
(0, 0.5, 20) -1.0
(0, 0.5, 45) -2.5
(0, 0.5, 70) -3.5
(0, 1, 20) -2
(0, 1, 45) -5
(0, 1, 70) -7
(5, -0.5, 20) 6.0
(5, -0.5, 45) 7.5
(5, -0.5, 70) 8.5
(5, 0, 20) 5
(5, 0, 45) 5
(5, 0, 70) 5
(5, 0.5, 20) 4.0
(5, 0.5, 45) 2.5
(5, 0.5, 70) 1.5
(5, 1, 20) 3
(5, 1, 45) 0
(5, 1, 70) -2
(10, -0.5, 20) 11.0
(10, -0.5, 45) 12.5
(10, -0.5, 70) 13.5
(10, 0, 20) 10
(10, 0, 45) 10
(10, 0, 70) 10
(10, 0.5, 20) 9.0
(10, 0.5, 45) 7.5
(10, 0.5, 70) 6.5
(10, 1, 20) 8
(10, 1, 45) 5
(10, 1, 70) 3
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 08:10:17 pm
Here's a link to what I currently have: https://docs.google.com/spreadsheets/d/1stJwQFVcpN6S6AaULgckqQSA4oVlEz0G8yPWf6_auxY/pubhtml

I'm still playing with the numbers.

Current formula is: B$2-(SQRT($A3*$B$1)-$C$1)
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 08:31:26 pm
hm so how about two numbers?
recoilstep and recoilstrength
recoilstep is the base decrease in accuracy for each shot
recoilstrength is a value that is substracted from the recoil for every 10 strengthpoints
now:
recoilstep=0 => no recoil
recoilstep>0 => weapon has recoil that decrease accuracy
recoilstep<0 => weapon aims with more shots (laser)
recoilstrength=0 means strenght has no influence
e.g. recoilstep=4, recoilstrength=0.3 , strength=40 is easy to calculate each shot you get 4-(40/10)*0.3 = 2.8 accuracy loss
a laser weapon would be like: recoilstep=-3, recoilstrength=0 # no strength benefit but increasing accuracy by 3 per shot

the formula allows for recoilstep=0 and recoilstrength>0 so real recoil but strenght gives accuracy - could be an option for very heavy weapons with autofire?

for x in itertools.product([-5,0,5,10],[-0.5,0,0.5,1],range(20,71,25)): print (x,x[0]-(math.ceil(x[2]/10)*x[1]))

(-5, -0.5, 20) -4.0
(-5, -0.5, 45) -2.5
(-5, -0.5, 70) -1.5
(-5, 0, 20) -5
(-5, 0, 45) -5
(-5, 0, 70) -5
(-5, 0.5, 20) -6.0
(-5, 0.5, 45) -7.5
(-5, 0.5, 70) -8.5
(-5, 1, 20) -7
(-5, 1, 45) -10
(-5, 1, 70) -12
(0, -0.5, 20) 1.0
(0, -0.5, 45) 2.5
(0, -0.5, 70) 3.5
(0, 0, 20) 0
(0, 0, 45) 0
(0, 0, 70) 0
(0, 0.5, 20) -1.0
(0, 0.5, 45) -2.5
(0, 0.5, 70) -3.5
(0, 1, 20) -2
(0, 1, 45) -5
(0, 1, 70) -7
(5, -0.5, 20) 6.0
(5, -0.5, 45) 7.5
(5, -0.5, 70) 8.5
(5, 0, 20) 5
(5, 0, 45) 5
(5, 0, 70) 5
(5, 0.5, 20) 4.0
(5, 0.5, 45) 2.5
(5, 0.5, 70) 1.5
(5, 1, 20) 3
(5, 1, 45) 0
(5, 1, 70) -2
(10, -0.5, 20) 11.0
(10, -0.5, 45) 12.5
(10, -0.5, 70) 13.5
(10, 0, 20) 10
(10, 0, 45) 10
(10, 0, 70) 10
(10, 0.5, 20) 9.0
(10, 0.5, 45) 7.5
(10, 0.5, 70) 6.5
(10, 1, 20) 8
(10, 1, 45) 5
(10, 1, 70) 3

I do appreciate the work, but I do better with seeing things in a matrix, can you do a spreadsheet up in google drive and let me see it? Just a run of STRs from 30-70.  I'm still playing with the equation still.
Title: Re: Option for autofire recoil
Post by: Falko on July 11, 2014, 09:04:25 pm
here as matrix (i do not have google account)
Code: [Select]
+------------+----------------+----------+--------+
| recoilstep | recoilstrength | strength | result |
+------------+----------------+----------+--------+
| -5         | -0.5           | 20       | -4.0   |
+------------+----------------+----------+--------+
| -5         | -0.5           | 30       | -3.5   |
+------------+----------------+----------+--------+
| -5         | -0.5           | 40       | -3.0   |
+------------+----------------+----------+--------+
| -5         | -0.5           | 50       | -2.5   |
+------------+----------------+----------+--------+
| -5         | -0.5           | 60       | -2.0   |
+------------+----------------+----------+--------+
| -5         | -0.5           | 70       | -1.5   |
+------------+----------------+----------+--------+
| -5         | 0              | 20       | -5     |
+------------+----------------+----------+--------+
| -5         | 0              | 30       | -5     |
+------------+----------------+----------+--------+
| -5         | 0              | 40       | -5     |
+------------+----------------+----------+--------+
| -5         | 0              | 50       | -5     |
+------------+----------------+----------+--------+
| -5         | 0              | 60       | -5     |
+------------+----------------+----------+--------+
| -5         | 0              | 70       | -5     |
+------------+----------------+----------+--------+
| -5         | 0.5            | 20       | -6.0   |
+------------+----------------+----------+--------+
| -5         | 0.5            | 30       | -6.5   |
+------------+----------------+----------+--------+
| -5         | 0.5            | 40       | -7.0   |
+------------+----------------+----------+--------+
| -5         | 0.5            | 50       | -7.5   |
+------------+----------------+----------+--------+
| -5         | 0.5            | 60       | -8.0   |
+------------+----------------+----------+--------+
| -5         | 0.5            | 70       | -8.5   |
+------------+----------------+----------+--------+
| -5         | 1              | 20       | -7     |
+------------+----------------+----------+--------+
| -5         | 1              | 30       | -8     |
+------------+----------------+----------+--------+
| -5         | 1              | 40       | -9     |
+------------+----------------+----------+--------+
| -5         | 1              | 50       | -10    |
+------------+----------------+----------+--------+
| -5         | 1              | 60       | -11    |
+------------+----------------+----------+--------+
| -5         | 1              | 70       | -12    |
+------------+----------------+----------+--------+
| 0          | -0.5           | 20       | 1.0    |
+------------+----------------+----------+--------+
| 0          | -0.5           | 30       | 1.5    |
+------------+----------------+----------+--------+
| 0          | -0.5           | 40       | 2.0    |
+------------+----------------+----------+--------+
| 0          | -0.5           | 50       | 2.5    |
+------------+----------------+----------+--------+
| 0          | -0.5           | 60       | 3.0    |
+------------+----------------+----------+--------+
| 0          | -0.5           | 70       | 3.5    |
+------------+----------------+----------+--------+
| 0          | 0              | 20       | 0      |
+------------+----------------+----------+--------+
| 0          | 0              | 30       | 0      |
+------------+----------------+----------+--------+
| 0          | 0              | 40       | 0      |
+------------+----------------+----------+--------+
| 0          | 0              | 50       | 0      |
+------------+----------------+----------+--------+
| 0          | 0              | 60       | 0      |
+------------+----------------+----------+--------+
| 0          | 0              | 70       | 0      |
+------------+----------------+----------+--------+
| 0          | 0.5            | 20       | -1.0   |
+------------+----------------+----------+--------+
| 0          | 0.5            | 30       | -1.5   |
+------------+----------------+----------+--------+
| 0          | 0.5            | 40       | -2.0   |
+------------+----------------+----------+--------+
| 0          | 0.5            | 50       | -2.5   |
+------------+----------------+----------+--------+
| 0          | 0.5            | 60       | -3.0   |
+------------+----------------+----------+--------+
| 0          | 0.5            | 70       | -3.5   |
+------------+----------------+----------+--------+
| 0          | 1              | 20       | -2     |
+------------+----------------+----------+--------+
| 0          | 1              | 30       | -3     |
+------------+----------------+----------+--------+
| 0          | 1              | 40       | -4     |
+------------+----------------+----------+--------+
| 0          | 1              | 50       | -5     |
+------------+----------------+----------+--------+
| 0          | 1              | 60       | -6     |
+------------+----------------+----------+--------+
| 0          | 1              | 70       | -7     |
+------------+----------------+----------+--------+
| 5          | -0.5           | 20       | 6.0    |
+------------+----------------+----------+--------+
| 5          | -0.5           | 30       | 6.5    |
+------------+----------------+----------+--------+
| 5          | -0.5           | 40       | 7.0    |
+------------+----------------+----------+--------+
| 5          | -0.5           | 50       | 7.5    |
+------------+----------------+----------+--------+
| 5          | -0.5           | 60       | 8.0    |
+------------+----------------+----------+--------+
| 5          | -0.5           | 70       | 8.5    |
+------------+----------------+----------+--------+
| 5          | 0              | 20       | 5      |
+------------+----------------+----------+--------+
| 5          | 0              | 30       | 5      |
+------------+----------------+----------+--------+
| 5          | 0              | 40       | 5      |
+------------+----------------+----------+--------+
| 5          | 0              | 50       | 5      |
+------------+----------------+----------+--------+
| 5          | 0              | 60       | 5      |
+------------+----------------+----------+--------+
| 5          | 0              | 70       | 5      |
+------------+----------------+----------+--------+
| 5          | 0.5            | 20       | 4.0    |
+------------+----------------+----------+--------+
| 5          | 0.5            | 30       | 3.5    |
+------------+----------------+----------+--------+
| 5          | 0.5            | 40       | 3.0    |
+------------+----------------+----------+--------+
| 5          | 0.5            | 50       | 2.5    |
+------------+----------------+----------+--------+
| 5          | 0.5            | 60       | 2.0    |
+------------+----------------+----------+--------+
| 5          | 0.5            | 70       | 1.5    |
+------------+----------------+----------+--------+
| 5          | 1              | 20       | 3      |
+------------+----------------+----------+--------+
| 5          | 1              | 30       | 2      |
+------------+----------------+----------+--------+
| 5          | 1              | 40       | 1      |
+------------+----------------+----------+--------+
| 5          | 1              | 50       | 0      |
+------------+----------------+----------+--------+
| 5          | 1              | 60       | -1     |
+------------+----------------+----------+--------+
| 5          | 1              | 70       | -2     |
+------------+----------------+----------+--------+
| 10         | -0.5           | 20       | 11.0   |
+------------+----------------+----------+--------+
| 10         | -0.5           | 30       | 11.5   |
+------------+----------------+----------+--------+
| 10         | -0.5           | 40       | 12.0   |
+------------+----------------+----------+--------+
| 10         | -0.5           | 50       | 12.5   |
+------------+----------------+----------+--------+
| 10         | -0.5           | 60       | 13.0   |
+------------+----------------+----------+--------+
| 10         | -0.5           | 70       | 13.5   |
+------------+----------------+----------+--------+
| 10         | 0              | 20       | 10     |
+------------+----------------+----------+--------+
| 10         | 0              | 30       | 10     |
+------------+----------------+----------+--------+
| 10         | 0              | 40       | 10     |
+------------+----------------+----------+--------+
| 10         | 0              | 50       | 10     |
+------------+----------------+----------+--------+
| 10         | 0              | 60       | 10     |
+------------+----------------+----------+--------+
| 10         | 0              | 70       | 10     |
+------------+----------------+----------+--------+
| 10         | 0.5            | 20       | 9.0    |
+------------+----------------+----------+--------+
| 10         | 0.5            | 30       | 8.5    |
+------------+----------------+----------+--------+
| 10         | 0.5            | 40       | 8.0    |
+------------+----------------+----------+--------+
| 10         | 0.5            | 50       | 7.5    |
+------------+----------------+----------+--------+
| 10         | 0.5            | 60       | 7.0    |
+------------+----------------+----------+--------+
| 10         | 0.5            | 70       | 6.5    |
+------------+----------------+----------+--------+
| 10         | 1              | 20       | 8      |
+------------+----------------+----------+--------+
| 10         | 1              | 30       | 7      |
+------------+----------------+----------+--------+
| 10         | 1              | 40       | 6      |
+------------+----------------+----------+--------+
| 10         | 1              | 50       | 5      |
+------------+----------------+----------+--------+
| 10         | 1              | 60       | 4      |
+------------+----------------+----------+--------+
| 10         | 1              | 70       | 3      |
+------------+----------------+----------+--------+
Title: Re: Option for autofire recoil
Post by: Dioxine on July 11, 2014, 09:19:04 pm
IMHO the idea, while interesting mathematically, is subject to Occham's Razor - adding a lot complexity for inconsequential in-game effect. Why?

1. The current autoshot accuracy averages the recoil in already, that's why it's lower than snap shot accuracy. Game-wise it doesn't make any difference if the separate bullets have varied or constant hit chances, as long as the average accuracy holds.
2. As Falko mentioned, the formula has problem with weapons where recoil is small or unknown - like lasers and plasmas. Maybe they work in reverse, shot tracing overwhelming the recoil effect and improving accuracy with every extra shot?
3. It is debatable what effect soldier's Strength, as in XCom Strength, can have on autofire accuracy. The Firing Accuracy parameter already covers how steady are shooter's hands.
4.Weapon's weight and construction has far more impact on recoil than soldier's (real-life) strenght. Human muscle system is nowhere as rigid as a metal tripod, it cushions a force, then counteracts (with delay).
5.Real life shows that proper weapon bracing has far more impact on accuracy than brute strength (again, Firing Accuracy stat in XCom, which already influences autofire accuracy).
6.The formula ignores the number of projectiles fired, thus dramatically reducing the accuracy of the final shots in a long burst, skewing the statistics.

But, to play devil's advocate...
A. A soldier in power armor should be able to brace the weapon much more effectively, thus measurably reducing recoil.
B. If we agree that Strength indeed has any measurable effect on accuracy, there is no need to calculate hit chances for every bullet, as (see 1.) the results are averaged anyway. Plus, if every bullet has different accuracy, the player is given false information about hit chances.
C. If a weapon had freely adjustable burst length - like in JA2 - a recoil formula would be needed, but again, a formula modyfying averaged accuracy would suffice.

Therefore, I'd vote for a much simpler solution:
a) Optional recoil parameter for a weapon. It is equal to required Strength to use the weapon efficiently. A soldier suffers [-2%?] autofire hit chance for every Strength point lower.
b) Optionally, they also suffer [half of that value?] when firing snap/aimed shots.
c) When kneeling, the Recoil parameter of any weapon is treated as [15?] points lower.
d) An armor can have Anti-Recoil parameter, which again, lowers the recoil of a weapon.
e) So, no need for complex calculations or gutting the mechanics, just a modifier to current Auto accuracy.
Title: Re: Option for autofire recoil
Post by: Yankes on July 11, 2014, 09:31:57 pm
Quote
d) An armor can have Anti-Recoil parameter, which again, lowers the recoil of a weapon.
this is equal to str bonus form armor.

Overall I think simplified version will be better, you will always know what accuracy will third shot have.
Without you will require changes in UI to show this info to user.
Title: Re: Option for autofire recoil
Post by: Falko on July 11, 2014, 09:49:29 pm
1. agree (but this changes  basicaly accuracy into accuracy =  Firing Accuracy*X + Strength*Y )
2. i like playing with mechanics :) - reverse recoil could make sense for lasers
3. no idea of the real effect of strength .. recoil is a modparameter that perhaps should only be applied to very heavy weapons?
4. the heavier a weapon is the higher their recoil value
5. bracing is part if the Firing Accuracy-skillset  ?
6. the formula is per bullet so: bullet number X fired a factor of (X-1)*formula(....) is subtracted from accuracy

A: so give the armor a +strength bonus
B: agree on mileading display
C: autoShots nr of shots is changable using a per bullet type of calcualtion can be more easy to understand

a) -2% per missing strength point so an already low auto accuracy is further lowered into extrem 30% accuracy -(40 defaultstrength-25strength of soldier)=>0%accuracy?
b) snap/aim shot is one bullet they are aimed again so recoil should not have an effect
c) kneeling already has a bonus
d) +strength
e) there is nothing complex going on here just a discussion what an understandable formula could be if a modder uses too high/too low values and creates ridiculous results its not the problem of the basic idea/implementation

"Without you will require changes in UI to show this info to user."
you need this regardless there has to be some change
from
accuracytext=fireing accuracy*weapon accuracy
to
accuracytext=fireing accuracy*weapon accuracy-(someformula(strength,some recoilvalue(s))*(autoShots-1)/2)
this calclulates the number of shots into the average
Title: Re: Option for autofire recoil
Post by: moriarty on July 11, 2014, 10:02:07 pm
2. i like playing with mechanics :) - reverse recoil could make sense for lasers

if you spin this a little further, shouldn't soldiers with a lot of experience with heavy weapons actually have a problem using laser weapons at first, because they are intuitively over-compensating for the non-existent recoil? of course, that would mean we need "skills" or "abilities", making the whole system very RPG-y...

:)

I like RPG-y, but it's probably taking it too far. for the vanilla game, that is. I could see the engine working brilliantly for a RPG. :D
Title: Re: Option for autofire recoil
Post by: Falko on July 11, 2014, 10:10:07 pm
if someone later makes weapon specific stats that add/subtract to the accuracy and can convince warboy to include it it in the main source :) that would complement a recoil mechanic but its IMHO independent of it
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 11, 2014, 11:35:07 pm
Actually, Recoil is generally less for heavier weapons.  If you fire a massive, powerful round, from a light weapon, the recoil is incredible. You can mitigate that recoil through a number of ways, but generally, a heavier weapon reduces recoil.

Also, the faster a weapon fires (more shots per tu in auto) the worse the recoil is.

here's an example of a very fast firing weapon, firing a powerful round: https://youtu.be/6glb6_e2HjQ

There would be just a singular 'recoil' stat for the weapons, and then a method that uses the soldier's STR stat to see how much that recoil affects each shot in an auto 'string'
Title: Re: Option for autofire recoil
Post by: 54x on July 19, 2014, 03:17:47 pm
IMHO the idea, while interesting mathematically, is subject to Occham's Razor - adding a lot complexity for inconsequential in-game effect. Why?

1. The current autoshot accuracy averages the recoil in already, that's why it's lower than snap shot accuracy. Game-wise it doesn't make any difference if the separate bullets have varied or constant hit chances, as long as the average accuracy holds.
2. As Falko mentioned, the formula has problem with weapons where recoil is small or unknown - like lasers and plasmas. Maybe they work in reverse, shot tracing overwhelming the recoil effect and improving accuracy with every extra shot?
3. It is debatable what effect soldier's Strength, as in XCom Strength, can have on autofire accuracy. The Firing Accuracy parameter already covers how steady are shooter's hands.
4.Weapon's weight and construction has far more impact on recoil than soldier's (real-life) strenght. Human muscle system is nowhere as rigid as a metal tripod, it cushions a force, then counteracts (with delay).
5.Real life shows that proper weapon bracing has far more impact on accuracy than brute strength (again, Firing Accuracy stat in XCom, which already influences autofire accuracy).
6.The formula ignores the number of projectiles fired, thus dramatically reducing the accuracy of the final shots in a long burst, skewing the statistics.

But, to play devil's advocate...
A. A soldier in power armor should be able to brace the weapon much more effectively, thus measurably reducing recoil.
B. If we agree that Strength indeed has any measurable effect on accuracy, there is no need to calculate hit chances for every bullet, as (see 1.) the results are averaged anyway. Plus, if every bullet has different accuracy, the player is given false information about hit chances.
C. If a weapon had freely adjustable burst length - like in JA2 - a recoil formula would be needed, but again, a formula modyfying averaged accuracy would suffice.

Therefore, I'd vote for a much simpler solution:
a) Optional recoil parameter for a weapon. It is equal to required Strength to use the weapon efficiently. A soldier suffers [-2%?] autofire hit chance for every Strength point lower.
b) Optionally, they also suffer [half of that value?] when firing snap/aimed shots.
c) When kneeling, the Recoil parameter of any weapon is treated as [15?] points lower.
d) An armor can have Anti-Recoil parameter, which again, lowers the recoil of a weapon.
e) So, no need for complex calculations or gutting the mechanics, just a modifier to current Auto accuracy.

Actually I feel you're mis-applying Occam's razor in this case. Even the initial proposal has a distinct effect from rolling lower accuracy into auto shot, as it effects the likelihood the shot will hit 2 or 3 times. With a flat accuracy, the shot can potential hit 3 times rather often. If the second and third shots have lower accuracy however, then auto might become a bit less incentivised against high-health aliens. Also, even if it didn't have a gameplay effect, to be honest, it's a cool flavour option.

The point of simulating recoil is not to drop accuracy. You can have any degree of accuracy you want with or without simulating recoil. The point of simulating recoil is essentially that the faster you take shots, the more likely your aim is to be effected by the "kick" of your weapon. (basically, it gives a larger incentive to strategic positioning and aimed shots than currently exists, as opposed to a "bullet spray" strategy) Ideally, simulating recoil should actually make your initial shot in a turn more likely to hit, given the penalty.

Ideally, if you're adding recoil, it should apply to every subsequent shot on the same turn for the same soldier, not just to the second and third shots in an auto burst. Then it becomes a real tactical consequence, and having a soldier rush forward to act as a turret in subsequent turns doesn't work so well.

Thoughts:

Strength differential between the required strength and actual strength should ideally effect the recoil step rather than applying a flat bonus or penalty. Higher-strength soldiers will be able to bullet-spray more effectively that way. This should reinforce existing playstyles- in the early game you're trying to snipe off any aliens you can, in the late game you can sometimes go toe-to-toe with the weaker ones.

Walking shots with lasers resulting in a negative recoil makes sense realistically, but could have funky gameplay results. Worth trying it out.
Title: Re: Option for autofire recoil
Post by: KingMob4313 on July 21, 2014, 06:20:16 am
Actually I feel you're mis-applying Occam's razor in this case. Even the initial proposal has a distinct effect from rolling lower accuracy into auto shot, as it effects the likelihood the shot will hit 2 or 3 times. With a flat accuracy, the shot can potential hit 3 times rather often. If the second and third shots have lower accuracy however, then auto might become a bit less incentivised against high-health aliens. Also, even if it didn't have a gameplay effect, to be honest, it's a cool flavour option.

The point of simulating recoil is not to drop accuracy. You can have any degree of accuracy you want with or without simulating recoil. The point of simulating recoil is essentially that the faster you take shots, the more likely your aim is to be effected by the "kick" of your weapon. (basically, it gives a larger incentive to strategic positioning and aimed shots than currently exists, as opposed to a "bullet spray" strategy) Ideally, simulating recoil should actually make your initial shot in a turn more likely to hit, given the penalty.

Ideally, if you're adding recoil, it should apply to every subsequent shot on the same turn for the same soldier, not just to the second and third shots in an auto burst. Then it becomes a real tactical consequence, and having a soldier rush forward to act as a turret in subsequent turns doesn't work so well.

Thoughts:

Strength differential between the required strength and actual strength should ideally effect the recoil step rather than applying a flat bonus or penalty. Higher-strength soldiers will be able to bullet-spray more effectively that way. This should reinforce existing playstyles- in the early game you're trying to snipe off any aliens you can, in the late game you can sometimes go toe-to-toe with the weaker ones.

Walking shots with lasers resulting in a negative recoil makes sense realistically, but could have funky gameplay results. Worth trying it out.

You've made a better case for it than I had patience to do.  Thank you very much.

Going to definitely set it up so it takes full integer, so modders can use a bonus or penalty.  Gonna make it logical too, instead of this inversion I'm doing in my code of a positive number is a penalty and a negative number is a bonus.
Title: Re: Option for autofire recoil
Post by: Dioxine on August 16, 2014, 12:50:22 am
Actually I feel you're mis-applying Occam's razor in this case. Even the initial proposal has a distinct effect from rolling lower accuracy into auto shot, as it effects the likelihood the shot will hit 2 or 3 times. With a flat accuracy, the shot can potential hit 3 times rather often. If the second and third shots have lower accuracy however, then auto might become a bit less incentivised against high-health aliens.

40-30-20 has the same (or very close) chance of landing 3 hits as 30-30-30.

Also, even if it didn't have a gameplay effect, to be honest, it's a cool flavour option.
Granted.

The point of simulating recoil is not to drop accuracy. You can have any degree of accuracy you want with or without simulating recoil. The point of simulating recoil is essentially that the faster you take shots, the more likely your aim is to be effected by the "kick" of your weapon. (basically, it gives a larger incentive to strategic positioning and aimed shots than currently exists, as opposed to a "bullet spray" strategy) Ideally, simulating recoil should actually make your initial shot in a turn more likely to hit, given the penalty.
Ideally, if you're adding recoil, it should apply to every subsequent shot on the same turn for the same soldier, not just to the second and third shots in an auto burst. Then it becomes a real tactical consequence, and having a soldier rush forward to act as a turret in subsequent turns doesn't work so well.

This is interesting, but why exactly next turn does clean the slate? If you've used 100% TU in your previous turn to fire 4 snaps, why the recoil is cleared now? You're also implying that the TU value allocated per Snap, Aim, Auto shot doesn't include the time needed for bracing the gun again, which isn't neccesarily the truth. In what you're proposing, the only logical conclusion is that the recoil from the previous shot always influences your aim, next turn or not, unless you take some time to re-aim the weapon... which is what? Walking? A special "cool off" button? It's getting really complex, with each shot mode essentially needing 2 versions - normal (with re-aiming) and faster (but affected by recoil... but what if you have walked a few tiles between 2 "fast" shots...?

Strength differential between the required strength and actual strength should ideally effect the recoil step rather than applying a flat bonus or penalty.

This is making sense again, but I'll reitarate an obvious thing, weapon training has far more pronounced effect on controlling weapon's recoil than brute strength. Of course there are some guns with so violent recoil that a strong human has some edge over a weak one, and of course, a beefy guy would have less trouble with keeping a machine gun on target (while pretending to be Rambo instead of using a bipod like a sensible person)... but only because he could keep the heavy weapon raised with ease, not because his muscle mass absorbs recoil in any relevant way.
Title: Re: Option for autofire recoil
Post by: pkrcel on August 16, 2014, 01:52:24 am
The idea is way cool but I am with Dioxine here, the recoil in Xcom engine is embedded in the flat-rate auto accuracy that is lower than the snap one, and that's about all we need from a gameplay perspective.

Alas, if implemented properly, the feature would cause a negligible impact on gameplay...questioning if that's worth it.


Xcom is no simulation game, so even thou I'd like more detail....seems to me overkill in this case.

Of course I'm not against it on principle, I remember back in the days that I was pretty sure that firing without previously moving in Battlescape was ggod for your accuracy.... ;D

Title: Re: Option for autofire recoil
Post by: Arpia on August 17, 2014, 12:41:59 am
I have to agree that tying this to strength seems odd... to be honest tying it to anything seems odd, if anything the recoil of a given weapon should be tied to the weapon itself rather than a formula that utilises a unit's stats. I also think preparedness to fire would play more of a factor (in xcom's terms this would be standing or kneeling) I also think that 'recoil per shot' should just be kept to the autoshot feature, as the TU's taken for snap and aim would take into account things like lining up an initial shot and subsequent adjustments for any follow up shots.
Also, does this/can this impact weapons significantly? the point of making change in my opinion is to... change... so if it doesn't change the way a gun handles in autofire vs vanilla in at least a somewhat noticeable way... then you probably need to adjust your formulas (like someone said above - there's not enough difference between 30-30-30 vs 40-30-20)

food for thought/self rambling: The initial shot in a burst is just as likely to be a hit as a snapshot, with a much steeper decline in accuracy after that. typically the first round goes on target, the second can hit or miss, the third shot usually going off target so it's more closer to something like 50-30-10. ...maybe kneeling could only affect the last step??
Title: Re: Option for autofire recoil
Post by: Dioxine on August 19, 2014, 11:37:25 am
Good point. If there was an option for kneeling to influence the recoil (or, for that matter, an option to make some weapons impossible to fire/way inaccurate when not kneeling, say, a mortar), this would indeed make recoil interesting.