sh4rkman / SquadCalc

A Minimalist Squad Mortar Calculator
https://squadcalc.app
MIT License
30 stars 5 forks source link

Standard mortar results are off (higher) by several milliradians #107

Closed xuvvy closed 7 months ago

xuvvy commented 7 months ago

Comparing the SquadCalc mortar calculator to another mortar calculator shows that there is a discrepancy in calculation, possibly due to rounding errors, misinterpretation of the Squad height map or miscalculation, which can lead to several milliradians worth of error. The same exact point on any map has a consistently different milliradians result, meanwhile the stated angle is the same.

I have tested this on a live Squad server and across several maps and it seems like SquadCalc is always showing the standard mortar target angle to be several milliradians higher than actual, which results in mortar shots potentially falling marginally short. This result is consistent across servers and across maps.

Below are the images of the calculation from sqmortar.farssi.net (previously known as squadmortar.xyz) and SquadCalc for reference.

image image

Depending on where the issue lies in the code, it is possible that this issue is also the case for other projectiles, but I have only tested this in-game for the Standard Mortar emplacement.

sh4rkman commented 7 months ago

There is a lot a parameters used by calculators that could explain a difference between their calculations and ingame results but here are the main one that could explain a difference :

Since squadcalc and squadxyz both display the same distance in meter in everymap i have tried, and we both place the grid in the same exact way, i'm excluding the map size from the faulty parameters.

Now if i compare the same mortar/target calc in a situation where there is no heights difference between them, we found the same calculations. For this example the simplest test is to place both target and mortar on Kokan fields because it's pretty much the same height everywhere on the map

20231210_11h21m_iB5JYoV5gn2 (left: xyz / right: squadcalc, i'm rounding number but this is irrelevant)

That means that any differences between my calcs and xyz one's should be caused by the way we deduce from heightmaps the vertical difference in meter between weapon and target.

--

So who is closer to ingame reality ? Well, first a really important point : at long range, you'll need a lot of milliradians to cover an extra meter : the closer we get to max range (45° - 820milrad), the difference between squadcalc and xyz will appear bigger, even if in reality that means 1m diff ingame. What i mean is that, and you'll see in the next screenshots, the difference between shooting @ 987.8 versus 995 is less than 2 meters ingame. So you shouldn't worry too much if you see 5-10 and sometimes 20 milliradians differences between two calculators at long range : at the end it can be a 40cm difference.

That being said, to check who is more accurate in reality i set up a similar situation to your screenshot in the two calculators and ingame : https://imgur.com/a/V34t8pW

For the same weapon/target squadcalc says 995 and xyz 987, i ran 6 test shots for each :

See, the difference looks like less than a meter. Compiling all the shots in one image :

image (blue: xyz / red: squadcalc)

I'd say squadcalc is more precise after this test, mostly because it has 5 shots in a 2meter radius from target, when squad xyz has 4, but there is too much randomness due to spread that its difficult to say. But again we're almost talking centimeters, shouldn't worry too much and the natural ingame spread makes it hard to be more precise without running 100 test shots.

If you find a concrete calculation that is actually really wrong (more than two meter, remember shot spread) i'll investigate more, but as it is now i'd considere Gorodok very precise, and maybe more that xyz.

sh4rkman commented 7 months ago

alright i've extracted the Gorodok heightmap again from the SDK and this time scrupulously adjusted the vertical ratio : now squadcalc display 991 for this example, witch is right inbetween actual squadcalc (995) and xyz (987). Mortars should be pixel perfect now on Gorodok.

If you have another example of map where shots are off i'd be happy to correct it. I have already spotted inconsistency/light heightmap deviations on :