Well Happy Birthday and what-not! Get some sleep! ;)

I'll give you another hint for get_dir_wrap(). If the distance from A to B along an axis (x or y) is greater than half the length of the map (along that axis), then it would be "faster" to wrap around the map than walk normally from A to B. So if you determine that normally get_dir() would return NORTH, but abs(B.y-A.y) is > world.maxy*0.5, you would send them SOUTH. Just remember to determine each axis separately, and then combine them at the end, and I think you'll be able to get it.
i think i got it for the most part

    proc
a_get_dir(atom/A=src, atom/B)
var/dir = get_dir(A,B)

if(dir & NORTH)
if(abs(B.y-A.y) > world.maxy*0.5)
return 2
else
return 1

if(dir & SOUTH)
if(abs(B.y-A.y) < world.maxy*0.5)
return 2
else
return 1

if(dir & EAST)
if(abs(B.x-A.x) > world.maxx*0.5)
return 8
else
return 4

if(dir & WEST)
if(abs(B.x-A.x) < world.maxx*0.5)
return 8
else
return 4


although now i need to check for northwest,northeast,southeast,southwest

which im not sure how i would compare?
Best response
That's where keeping them separate comes in: you combine them at the end, and the diagonals are handled for you!
    proc
a_get_dir(atom/A=src, atom/B)
var
dir = get_dir(A,B)
horizontal = 0
vertical = 0

if(dir & NORTH)
if(abs(B.y-A.y) > world.maxy*0.5)
vertical = 2
else
vertical = 1

else if(dir & SOUTH)
if(abs(B.y-A.y) < world.maxy*0.5)
vertical = 2
else
vertical = 1

if(dir & EAST)
if(abs(B.x-A.x) > world.maxx*0.5)
horizontal = 8
else
horizontal = 4

else if(dir & WEST)
if(abs(B.x-A.x) < world.maxx*0.5)
horizontal = 8
else
horizontal = 4

return horizontal | vertical
Thanks for being so helpful.
Okay i found a problem i got to the middle of the map and all the sudden im going back and forth D:
What are the two locations, and what are your map's dimensions? I ran through a couple of likely scenarios in my head, and the numbers seem to come out right.
it would be easier to show you

500x500 btw and here is what happens when i try to fly to a target for example

http://199.175.48.102/lolz.html

it just keeps going back and whatever..

proc/a_walk_towards(mob/M, mob/B, Lag, Speed)
walk(M,M.a_get_dir(M,B),Lag,Speed)


And i do in my fly code have a check for coordinates to stop walking.

        fly_to
format = "~$'fly'; ~$mob(planetmobs)"
priority = 3
Process(mob/user, mob/M)
var/tmp/thename = M.name

if(user.z == 2) return

if(M.Class == "Android" && !M.IsNPC && !user.AdvancedScouter) return

if(user.movingtotarget)
mb_msgout("You're currently flying to someone please type 'fly stop'.", user)
return

if(user.Flying)
user.movingeast = 0
user.movingwest = 0
user.movingsouth = 0
user.movingnorth = 0
user.movingnortheast = 0
user.movingnorthwest = 0
user.movingsouthwest = 0
user.movingsoutheast = 0
user.movingtotarget = 1
var/dir_to = user.a_get_dir(user, M)
mb_msgout("[user.name] starts flying [user.dir2text(dir_to)].", oview(0))
mb_msgout("You begin flying to [M.ClassColor][M.name][M.Reset].", user)
a_walk_towards(user,M,user.FlySpeed,32)
else
mb_msgout("You need to be flying first!", user)
return

while(user.movingtotarget && user.Flying)
if(!M)
mb_msgout("You have lost [thename]'s energy signal!", user)
user.movingeast = 0
user.movingwest = 0
user.movingsouth = 0
user.movingnorth = 0
user.movingnortheast = 0
user.movingnorthwest = 0
user.movingsouthwest = 0
user.movingsoutheast = 0
user.movingtotarget = 0
walk(user,0)
break
if(user.loc == M.loc)
mb_msgout("You have arrived to your destination!", user)
mb_msgout("[user.name] has arrived!", oview(0))
user.movingeast = 0
user.movingwest = 0
user.movingsouth = 0
user.movingnorth = 0
user.movingnortheast = 0
user.movingnorthwest = 0
user.movingsouthwest = 0
user.movingsoutheast = 0
user.movingtotarget = 0
walk(user,0)
break
if(user.loc != M.loc)
walk(user,0)
a_walk_towards(user,M,user.FlySpeed,32)

sleep(20)

if(!user.IsNPC) user.ShowMap()
I think the issue is me using walk instead of step ugh but the main reason im using it was because if i add a while loop in a movement proc the other while loop wont work to show the map every 2s..hm
Hmmm, what location is "Raditz" at?
well in that one 147,365
OH, ok, now I see. So you're passing him. I thought you meant there was a bug with the get_dir() code.

One option would be to set up a counter inside that while() loop to track when to update the map, and use the while() loop to step() the player:
                var/mapUpdate = 20
while(user.movingtotarget && user.Flying)
if(!M || user.loc == M.loc)
if(!M) mb_msgout("You have lost [thename]'s energy signal!", user)
else if(user.loc == M.loc)
mb_msgout("You have arrived to your destination!", user)
mb_msgout("[user.name] has arrived!", oview(0))

user.movingeast = 0
user.movingwest = 0
user.movingsouth = 0
user.movingnorth = 0
user.movingnortheast = 0
user.movingnorthwest = 0
user.movingsouthwest = 0
user.movingsoutheast = 0
user.movingtotarget = 0
walk(user,0)
break

a_step_towards(user,M,user.FlySpeed,32)

sleep(user.FlySpeed)

if(!user.IsNPC)
mapUpdate -= user.FlySpeed
if(mapUpdate <= 0)
mapUpdate = 20
user.ShowMap()
It's still going on no matter what.

Basically it goes tiles past the target..then tries going back and keeps repeating going east and west etc.
If i use step() in the movement proc there is no issues but for some reason it breaks the other while loop.

proc/a_walk_towards(mob/M, mob/B, Lag)
while(M.moving)
step(M,M.a_get_dir(M,B))
sleep(Lag)


        fly_to
format = "~$'fly'; ~$mob(planetmobs)"
priority = 3
Process(mob/user, mob/M)
var/tmp/thename = M.name

if(user.z == 2) return

if(M.Class == "Android" && !M.IsNPC && !user.AdvancedScouter) return

if(user.movingtotarget)
mb_msgout("You're currently flying to someone please type 'fly stop'.", user)
return

if(user.Flying)
user.movingeast = 0
user.movingwest = 0
user.movingsouth = 0
user.movingnorth = 0
user.movingnortheast = 0
user.movingnorthwest = 0
user.movingsouthwest = 0
user.movingsoutheast = 0
user.movingtotarget = 1
var/dir_to = user.a_get_dir(user, M)
mb_msgout("[user.name] starts flying [user.dir2text(dir_to)].", oview(0))
mb_msgout("You begin flying to [M.ClassColor][M.name][M.Reset].", user)
user.moving = 1
a_walk_towards(user,M,10-user.FlySpeed)
else
mb_msgout("You need to be flying first!", user)
return

var/mapUpdate = 20
while(user.movingtotarget && user.Flying)
if(!M || user.loc == M.loc)
if(!M) mb_msgout("You have lost [thename]'s energy signal!", user)
else if(user.loc == M.loc)
mb_msgout("You have arrived to your destination!", user)
mb_msgout("[user.name] has arrived!", oview(0))

user.movingeast = 0
user.movingwest = 0
user.movingsouth = 0
user.movingnorth = 0
user.movingnortheast = 0
user.movingnorthwest = 0
user.movingsouthwest = 0
user.movingsoutheast = 0
user.movingtotarget = 0
user.moving = 0
break

sleep(user.FlySpeed)

if(!user.IsNPC)
mapUpdate -= user.FlySpeed
if(mapUpdate <= 0)
mapUpdate = 20
user.ShowMap()
I got it to work i had to make a tmp variable for the mapupdate on the user

proc/a_walk_towards(mob/M, mob/B, Lag)
var/thename = B.name

while(M.moving && M.movingtotarget && M.Flying)

if(!B || M.loc == B.loc)
if(!B) mb_msgout("You have lost [thename]'s energy signal!", M)
else if(M.loc == B.loc)
mb_msgout("You have arrived to your destination!", M)
mb_msgout("[M.name] has arrived!", oview(0))

M.movingeast = 0
M.movingwest = 0
M.movingsouth = 0
M.movingnorth = 0
M.movingnortheast = 0
M.movingnorthwest = 0
M.movingsouthwest = 0
M.movingsoutheast = 0
M.movingtotarget = 0
M.moving = 0
if(!M.IsNPC) M.ShowMap()
break

step(M,M.a_get_dir(M,B))

sleep(Lag)

if(!M.IsNPC)
M.MapUpdate -= 5
if(M.MapUpdate <= 0)
M.MapUpdate = 20
M.ShowMap()


works.
Out of curiosity, what are you actually using all of those 'movingX' variables for, along with 'moving' and 'movingtotarget'.

Seems like a lot of variables for that ;)
Page: 1 2