ID:159045
 
How would I make it when an NPC moves, it calls on the North(), South(), West(), East() for it's movement? I have player movement so that Diagonal movement is blocked, that's why I'm trying to set NPCs to the same movement so that they don't move diagonal all over the place. Here are the codes I'm using for the enemy movement:

step_towards(src,M)


&

step_rand(src)
I've tried making it that way, but whenever a mob would have to go diagonal to step_towards something, it'd just stand still (because I disabled those directions in Move()).

step(src,pick(NORTH, SOUTH, EAST, WEST))

works for just random movement (within a loop, of course), but for going towards something.. You'd have to somewhat rewrite Move(), and if the dir is diagonal, make it move vertical/horizontal with a 50% chance or something (If he's going south east, 50% chance for south, else east).

Anyways, I'm assuming there must be a better method.
In response to Mysame
How would I rewrite Move()?

I thought it would be similar to

client
North()
return


So I tried:

client
Move()
if(dir==NORTH)
return


Can you please explain it to me?
In response to Forerunnerz
Any help?
In response to Forerunnerz
Bump..
In response to Forerunnerz
Forget overriding Move() to do this, it won't really do a lot of good. What you need to do is not to use a function that does things you don't want. i.e., BYOND's walking functions use diagonal movement, but you don't want that, so you need to use something else.
There are a few pathfinding libraries available, which I believe you can tweak/override/configure to do what you want here.