Re: mine distance for claw
« Reply #1 on: November 09, 2016, 08:09:36 PM »
OK don't have time to write a really good explaination but, in a nutshell, it's calculating distance from the top left corner of the mine.
hall is 4x4
mine is 3x3
hall size is taken into account
mine size is not
units are located where their top-left corner is (you can play with the map editor to see this)
Probably they have re-used code from the unit attack AI to find the closest enemy (with annoy factor).Its the same thing as the old tower bug, where towers firing up and left would hit other towers that wouldnt fire back, because the size of the destination is being taken into account, but not the size of the source.
In this case you can think of the mine as shooting peons at the hall
As mentioned the distance is what I call "square" distance - the maximum X or
Y distance from the top left corner of the mine to the closest point on the hall.
so with that map....
because of the extra 2 squares in the width of the mine, the distance becomes 5 not 3, which is greater than the distance between the halls (which is 4) so in effect they are the same distance, in which case the peon will go for the hall with the lower Y co-ordinate (as they were both on the .PUD, if u built them it would go for the one you built first.
... this is why you dont see this bug on the other side of the map where the halls are to the left of the mine, because then the distance is
only 3, so its less then the Y offset....
(btw: the calculations on the pic above should have -1 on them, = 5 not 6 , but u get the idea)