ID:146625
 
Code:
obj
var
wander
stepdelay
New()
if(wander)
walk_rand(src,stepdelay)
..()


Problem description:
how do i get npcs to rand walk just north south east and west like in dragon warrior games
Karl83 wrote:
Code:
> obj
> var
> wander
> stepdelay
> New()
> if(wander)
> walk_rand(src,stepdelay)
> ..()
>

Problem description:
how do i get npcs to rand walk just north south east and west like in dragon warrior games

say try putting a nubber for the step dealy like, a common delay used with random walk is walk_rand(src,5)

its just a thought.
In response to ElderKain
ok i have change the code and got it working but did a test run and npc move like lightspeed how do i delay the movement
obj
var
wander = 0
stepdelay

obj/proc/Move_mobs()
for(var/obj/M in world)
if(M.wander == 1)
spawn(rand(10, 30))
walk(M, pick(NORTH, EAST, SOUTH, WEST), stepdelay)
spawn(60)
Move_mobs()
<\dm>
In response to Karl83
Karl83 wrote:
ok i have change the code and got it working but did a test run and npc move like lightspeed how do i delay the movement
> obj
> var
> wander = 0
> stepdelay
>
> obj/proc/Move_mobs()
> for(var/obj/M in world)
> if(M.wander == 1)
> spawn(rand(10, 30))
> walk(M, pick(NORTH, EAST, SOUTH, WEST), stepdelay)
> spawn(60)
> Move_mobs()
>


Set stepdelay to a number...

The higher the number, the slower the mob will move.
In response to Aaiko
Lol Aaiko, thats almost exactly what I said in my last post.
In response to Karl83
A - You appear to be using objs where mobs tend to be used. Not major, they're both pretty much the same, but possibly not a good idea.

B - Why have you defined that procedure for objs, and yet have it affecting all objs? I bet you're calling it upon new, and that's why everything goes so fast. A better method is this:

mob
var/wander
var/stepdelay
New()
..()
spawn(1) if(wander) walk_rand(src,stepdelay)