Fix targetAttackWeight()
selecting targets that can't be hit
#4223
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Deduct target weight of objects if line of fire is obstructed by terrain.
This is probably one of the most important bug fixes of all time. WZ makes a terrible mistake of not having the target auto-selection account for terrain obstruction (hills) in-between the attacker and potential target. This means the micro-AI can easily get tunnel vision on something it can't hit (within long range) but is visible at the same time. As such, objects that have the ability to shoot downwards have a colossal advantage over those that shoot upwards.
In effect the battles of campaign and low oil will feel a lot more fair and smooth with this fix. Hard to pass chokepoints with hills, like the one in Beta 6, should no longer draw out battles longer than usual if you don't click on something directly within a straight firing line. Or by rushing into them to reach the poorly selected unit.
Not sure if the two ifs should be side by side or turned into an if-elseif. I left it as it is in case guard behavior may wish to track a nearby damaged unit over a hill under vision. This PR should probably have a performance impact check done on it since this gets called a lot. Would like additional testing on this--I've already played up to Beta 3 with it so far.
Fixes #4163
In this video I recorded to show pastdue some weeks ago, you can see my units freely choosing enemy units that it can fire at, instead of the ones behind the hill as in Arc's video. This bug affects mobile units too, not just holding ones, so if I showed my tanks moving in this recording, they would still fire at the debug units I was putting to the right side of them (unlike any past release).
Weapon.Jitter.Fixed.mp4