anbotero / deus-ex-human-renovation

Automatically exported from code.google.com/p/deus-ex-human-renovation
0 stars 0 forks source link

Poor weapon scope behavior #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It seems that the weapon scope wanders strangely at relatively high levels of 
accuracy, tending to veer off at angles at or close to multiples of 45 degrees, 
with a tendency to stop altogether sometimes.

I will be looking into fixing this for the next version.

Original issue reported on code.google.com by lemong...@gmail.com on 27 Dec 2012 at 8:18

GoogleCodeExporter commented 9 years ago
Note: This was also the case in Deus Ex 2.0, and probably in the original 
release of Deus Ex as well, not a bug introduced by this mod.

Original comment by lemong...@gmail.com on 27 Dec 2012 at 8:24

GoogleCodeExporter commented 9 years ago
I've isolated and fixed the problem here.

Explanation:
The weapon keeps two values (new random values chosen every 0.25 seconds or 
so), one for how much the scope should wander up/down and one for how much it 
should wander left/right. Each tick, those values are multiplied by the time 
that has passed since the last tick, and adjusts your view rotation by those 
values. The problem is that the view rotation itself is made of integers, so 
"1.25" gets truncated to "1", and so forth. Most importantly, it means that any 
adjustments below 1.0 (0.5, 0.2, etc.) get rounded down to zero, resulting in 
strange behavior like weapon scopes that like to move only up/down or only 
left/right, with a weird distribution of angles, or not at all, particularly at 
high accuracy or with a high frame rate.

Now the game rounds the value intelligently before casting to an int, so a 
value of 0.75 has a 75% chance of rounding to 1 and a 25% of rounding to 0, for 
instance.

Original comment by lemong...@gmail.com on 21 Feb 2013 at 6:50