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

Accuracy bug explained #347

Closed
Iluvalar opened this issue May 5, 2019 · 19 comments

Comments

Projects
None yet
4 participants
@Iluvalar
Copy link
Contributor

commented May 5, 2019

Every weapons in the game have accuracy expressed in %.
When the droid or structures fire a projectile and random roll is made to determine if it's a hit or a miss.
When the projectile miss, it's directed at the ground in a circle with radius dependent on the weapon inaccuracy
So far, so good. But since the last struggle with ray casting and terrain around 2.3.5-2.3.7 i believe, someone in the dev team made the missing projectiles that touch the enemy hit box (a cylinder of radius determined by the pie file)l hit.

This is a crucial issue because the program was never designed to handle this correctly.
1- It tries to miss behind the target
2- Models are often bigger then the miss spread coded in the game causing many weapon to jump straight at 100% accuracy,
2.1- For exemple, I believe a cobra body vs an hmg get 100% hit, but a scorpion body can dodge 30% like a pro. Because the scorpion model is 1pixel smaller

The point 1 is annoying, it makes. the makes about 15% of the missed shot a hit. Up to 25% when the units are at point blank.
The point 2 however is game breaking. As it's an undocumented effect that can happen apparently randomly for every pair weapon <-> body.

The solutions to the problem are either
A- put back the missed flag test in place and prevent all damage that could be done by a MISSED shot at a target. (and accept the fact that visually a few bullets will land behind the units)
OR
B- improve the engine and give it better target to miss at. IE : always far enough of the target (ideally in a gaussian distribution) and never behind hit (because you can't miss behind a target)

Why accuracy matters so much :
Balancing the game via odd stats such as range, explosion radius or length of the research is impracticable. Linear progression (i boost 10%, it'S now 10% stronger) stats such at cost, damage, ROF and accuracy are crucial if we want to have any hope to balance something and keep our sanity.

However, the cost of the unit is not the cost of the weapon in WZ. It doesn't scale linearly at all. Same can be said for the DMG because the armor are addition logic with the DMG. A boost of 10% dmg in the right situation can yield a 30% increase in DPS.

there is nothing left beside ROF and accuracy. It would be impossible to ensure that a cannon shoot slower then a machine gun if the only balance handle was ROF. We NEED accuracy.

@Cyp

This comment has been minimized.

Copy link
Member

commented May 6, 2019

I think a gaussian distribution in the angle makes sense. Which would make more sense given as a spread at maximum range given in tiles (0 < value < ∞, lower is better) than as an accuracy (0 < value < 100, higher is better). Although one could arbitrarily declare spread = constant * (100 - old_accuracy) or something like that.

@Iluvalar

This comment has been minimized.

Copy link
Contributor Author

commented May 7, 2019

Back then, my patch was using a power of 2 (spherical distribution) as a compromise. I felt it was less CPU intensive, but visually close enough. Also, while realistic, a mortar that can miss infinitely far from his target can prove frustrating.

Note: We are only talking about MISSED shot, as a mostly visual effect. Making the shots LOOK very realistic. While actually the hit% in the weapon stat would still be valid. This ticket is about aligning the accuracy % in the stats with the right result. Not forking the game into an FPS...

@Iluvalar

This comment has been minimized.

Copy link
Contributor Author

commented May 9, 2019

This is too old to be commited, but might point exactly where to do some changes :
https://github.com/Iluvalar/warzone2100/commits/3.1-accuracy

@highlander1599

This comment has been minimized.

Copy link
Contributor

commented May 30, 2019

Is anyone working on this issue? If not I would work again on the new balance for the game.

@Iluvalar

This comment has been minimized.

Copy link
Contributor Author

commented May 30, 2019

Do not close this !!!
The other viable and simpler option, if needed, would be to save the "isHit" boolean in combat and prevent it from hitting the intended target if it's a miss.

(Forget about fancy gaussian distribution, but at least accurately miss the missed target.)

@highlander1599

This comment has been minimized.

Copy link
Contributor

commented May 30, 2019

My comment was not meant as a "close this issue". I just wanted to know if there is any progress even if it's only in the background. Accuracy is not the only issue with the current balance so I would rather like doing a new balance for the campaign (not for MP) twice (before and after an accuracy change) than sitting here around and do nothing. Unfortunately, I have no programming skills otherwise I would do it.

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented May 30, 2019

I did a few tests with Iluvalar's patch and the difference was noticable compared to master. The patch still works (accounting for removeZ() no longer being present) assuming it is only supposed to miss shots within the 270 degrees in front of the hitbox. Which is a decent compromise.

@highlander1599

This comment has been minimized.

Copy link
Contributor

commented May 30, 2019

OK, then I wait for a go from you.

@Iluvalar

This comment has been minimized.

Copy link
Contributor Author

commented May 30, 2019

Yes, it's only intended to miss when the projectile is declared a miss. The best would be to on top of that guarantee it with a flag, but the patch was close enough without a flag.

One thing to be noted concerning that patch if you use it verbatim : the result was quite interesting on artillery. There are some oopsy moments when artillery miss in a gaussian-like (TM) distribution. We might have to deal with a discussion about how we want artillery to miss. But it can be tuned.

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented May 31, 2019

There are some oopsy moments when artillery miss in a gaussian-like (TM) distribution. We might have to deal with a discussion about how we want artillery to miss. But it can be tuned.

Lol, yeah, I was testing a Pepperpot with your patch and there were times it missed very unrealistically. Or shot way off to the side from a long range.

We'll want to make artillery land relatively closer to targets than other weapons. Maybe even for any weapon that does splash damage too.

@Iluvalar

This comment has been minimized.

Copy link
Contributor Author

commented May 31, 2019

yeah, but it's not the code part. The code is ok, I believe the pepperpot is in the stats accurate at 40% ? I believe the code simulate that fine. We could see mods in the future which would want to have this behavior. All we have to do is to bump the stats of the pepperpot where we are used to have it 90-95% accuracy and the rest should be fine.

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented Jun 1, 2019

Using your equations the below situation manifests itself consistently with lower accuracy values (I used 1% here). In master it never misses like this due to the miss distance always being rather close to the target.

miss

It can be reproduced in master by setting this to something big like 2000 or whatever. So we'll want to make sure the angle is also sane (not to the exact side or behind ourself).

@KJeff01 KJeff01 added the Bug label Jun 1, 2019

@Iluvalar

This comment has been minimized.

Copy link
Contributor Author

commented Jun 1, 2019

worstShot = iHypot(removeZ(deltaPos))*100/resultHitChance/3;

it should fall, at worst, at 1/3 of the distance. I guess this formula just need an extra parenthesis ? I made this in 2012 sorry.

worstShot = (iHypot(removeZ(deltaPos))*100/resultHitChance)/3;

This maybe ?

@Cyp

This comment has been minimized.

Copy link
Member

commented Jun 2, 2019

The extra parentheses are redundant there. Assuming resultHitChance ≤ 100, then worstShot ≥ distance/3. In particular, if resultHitChance < 33.333, then worstShot > distance, so shooting backwards should be expected.

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented Jun 2, 2019

The * 100 part makes a huge value that won't be corrected by very low accuracy values.

As Cyp outlined, a miss distance greater than the position delta of the two objects allows shooting backwards. Your equations are like a Pac-Man shaped area that changes size depending on distance and accuracy, and if distance is too big and/or accuracy too small then the Pac-Man extends beyond the two objects and the misses can become more inaccurate and might fire behind the attacker.

Now if we can detect if the miss-shot will land 180 degrees "behind" the attacker then I think flipping either the x or y coordinate will make it look better and removes this issue from any fancy equation. Using my screenshot as an example, we would want to flip the x-coordinate of the miss location.

Or, we could check the length of the miss distance against iHypot((psAttacker->pos - predict).xy()), and set the miss distance to that value in that case, as another option... until the units are about 1-2 tiles away. Then the miss-shots start hitting due to the projectile angle not being off to the side enough. Here we can either be content with almost perfect accuracy, due to the distance, or, always shoot at extreme angles off to the side. The latter looks odd, though.

Also, it's possible to shoot inside your own hitbox or too close to it if the miss distance reaches the attacker. I think the only issue there is splash damage hitting the attacker.

@Iluvalar

This comment has been minimized.

Copy link
Contributor Author

commented Jun 2, 2019

Thanks Cyp ! Yes that's what it is.
Kjeff01, no, the 100 there is 100% and it have to stay there so the formula is readable and make sens. You can change that 3 or add any new factor k to the formula, but do not touch the 100.

We are not here to create an ULTRA range new mechanic in the game. What you suggest with perfect accuracy would double the dps of a 50% accurate unit at short range. And this would be a prominent new game mechanic. No no no !

The formula are good. The only problem it seem is to set the worstShot value so everyone is fine with it. At this point, it's much more just visual then anything.

I think it's the best we can get from this. You can change that /3 for a /6 or something if you prefer Kjeff, but it's visually the best we can get. If we were to account for the angular size of the target and adjusting the worstShot on that, it would make the missing area constant with distance. The formula i used have a nice concentrating effect when the units get closer.

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented Jun 2, 2019

I never suggested such things. That code will break at lower accuracies
and will need distance checking to correct the miss distance later to stop shooting backwards.

The best way to avoid that would be to limit the max miss distance enough to never touch the attacker in a straight line from the predicted target location (should also fall short a little bit), and be about a body radius away or more from the target. Ensuring very wide angle shots near 90 degrees to perfectly miss the target near that 1-2 tile threshold would be almost perfect for keeping the miss behavior intact.

Or, we could just start dividing by a value > 3 and hopefully control shooting backwards enough for practical ranges and accuracies.

Regardless, if shooting widely to the side is not implemented then it means a guaranteed increase of hitting the target within that 1-2 tile range because the angle is going to sometimes cause the projectile to collide with the target's hitbox on some random rolls. Resulting in this "ultra range" situation. So either that must be acceptable, or not.

@Iluvalar

This comment has been minimized.

Copy link
Contributor Author

commented Jun 2, 2019

yeah, that 3 is arbitrary and can be change. For the rest, yes i think you understand that we are trying to make visually pleasing something that is not particularly realistic. One way or the other.

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented Jun 3, 2019

I think /5 looks good enough. Made a PR for this.

@KJeff01 KJeff01 closed this in #371 Jun 14, 2019

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.