chrishayesmu / XCOM-LW-CommunityEdition

14 stars 2 forks source link

Being immediately adjacent to an enemy sometimes doesn't count as flanking #52

Open chrishayesmu opened 2 years ago

chrishayesmu commented 2 years ago

This seems to occur when:

  1. The enemy is in cover.
  2. The other unit is immediately adjacent to the enemy.
  3. The unit is positioned such that, if you drew a line between the unit and the enemy, that line would not intersect the enemy's cover.

For some reason, this tends to only occur on one side of the enemy; moving the unit to the other side (but still meeting the requirements above) will result in the expected flank. Moving one tile away from the enemy so that you're no longer immediately adjacent will also result in flanking.

Example image showing a situation where this bug has occurred

chrishayesmu commented 2 years ago

My current speculation is that this has to do with XGUnitNativeBase.IsFlankedByLoc, and how it handles situations where a unit is flanked on the X or Y axis but the positions aren't quite the same between the two units. I'm doing some native debugging to try and figure out the math it uses. Here are a couple of observations I've made with a console command that calls IsFlankedByLoc:

Target pos: -913.00, 249.01, 250.15
Unit pos (flank not working): -1008.999512, 238.998413, 259.147491
Unit pos (flank working): -816.998291, 249.013000, 259.147034
Target pos: 437.00, 1679.00, 74.15
Unit pos (flank not working): 430.999908, 1583.000000, 83.149902
Unit pos (flank working): 437.000793, 1775.000000, 83.149788