ID:1333477
 
(See the best response by Kaiochao.)
Problem description:
When a zombie starts to chase me and I change my z location(they don't stop chasing me after that. I didn't put this in the game yet), if I go next to the x,y location they are they start to bite me.
I suppose it is the get_dist proc that's causing this trouble. So, how does get_dist() exactly work?
get_dist() returns the distance between two atoms in tiles, so it depends on how you are using it. Can you post the code?
In response to Magnum2k
The code is ugly and it's not even zombie-like yet. But, if it really helps:
mob/zombie
proc
ai()
while(src)
if(!target)
search()
else
if(!freeze)
if(get_dist(src, target) > 1)
step_to(src, target)
for(var/obj/destructible/d in get_step(src,dir))
for(var/obj/destructible/dest in oview(src, 1))
if(!dest.destroyed)
step_to(src, dest)
break
if(prob(34)) d.takeDamage()
else
target << "I'm biting you!"
sleep(7)
Best response
Apparently, get_dist ignores the z-level difference. You'll have to compare that yourself.
In response to Kaiochao
So the next question would be - is that behavior intended?
I can't see what it would return that was reasonable, in the case of z-level difference, so ... yes, I suspect it was intended.
Exactly. What is the distance between z levels? It's completely arbitrary, and up to the design of the game. So taking z level differences into account in the built-in distance checks would not work, because it would be different for all games. So doing this check can only be left up to the developer.

For example, in my own big project (one you may have seen me going on about lately), the z levels actually do correspond to floors in the buildings on the maps. So in my case, there is a correspondence between the z-levels (for sake of calculations, I consider them to be 3 "tiles" apart, based on the estimate that each tile in my game is somewhere around 3' square, so there is likely about 3 tiles of distance between the floors of the average building; somewhere around 9 feet- 8' between floor and ceiling, another 1' for floor thickness.)

So for my own custom distance calculations, I use that as the distance between z levels. 3 tiles.

But would that apply to all games? Absolutely not. A game might only be using z levels for separate regions/chunks that aren't actually meant to be considered as stacked. That game might need to find a total distance from the source to the edge of their z level, plus the distance covered on the next region over, and so-on until they reach the target. Or a game might be using z level as stacked "floors", but their scale might be different. They might need to estimate the distance between floors at more or less than 3 tiles.

So again, there's really no way for the built-in functions to take z levels into account for distances, because the distance between z levels will vary from game to game.