ID:165430
 
How would I make an NPC wander on a certain turf like say... grass. I was think something like walk_rand(turf/grass). but I got an error that said value not allowed here. I know it can be done because FFO made there guards not leave town by placing different turfs for the inside of town and the outside. so can someone tell me how to do it.
So you want to limit the bug from going to other places?

area/No_Bugs
Exit(atom/A)
if(istype(A,/mob/bug))
return 0
else
return 1
In response to Dragon_fire6653
Dragon_fire6653 wrote:
So you want to limit the bug from going to other places?

> area/No_Bugs
> Enter(atom/A)
> if(istype(A,/mob/bug))
> return 0
> else
> return 1
>

You know, that wouldn't be very convinient for the mapper. Instead, you should try something like Dragon_fire6653's, except a couple differences to make it more efficient:
> area/Bugs_alowed
> Exit(atom/A) //When a bug attempts to exit this zone
> if(istype(A,/mob/bug)) return //if it really is a bug attempting to exit, stop the procedure
..() //if the proc wasn't stopped, call it's default
>

This proves a bit more efficient.
Make a check to see what type of turf is in the new location and if it's the right turf then make it walk, if not make it search again. There are other ways, that's just one that came to my mind.
In response to Avren
Seems i've made a mistake by using Enter() instead of Exit() ...I'll go change that.
Arcangelbjr wrote:
How would I make an NPC wander on a certain turf like say... grass. I was think something like walk_rand(turf/grass). but I got an error that said value not allowed here.

That's just stupid. Did you actualy read the reference entry for walk_rand()? Even if it DID support walk-threw-certain-turfs feature (and it doesn't), the arguments would be layed out differently...the first arg is the movable you want to do the moving.

I know it can be done because FFO made there guards not leave town by placing different turfs for the inside of town and the outside. so can someone tell me how to do it.

You may want to use areas instead. You can either make a custom walk_rand() proc (preferably a dynamic one that will accept type paths like what you tried to do with walk_rand()), (which isn't hard, of course) or you can use walk_rand() and override the turf/area's Enter() proc and disallow movement if the object trying to enter is of type X (like, /mob/guard) (and that isn't hard to do either).
Your choice.
In response to Kaioken
How about you put them on a cerian z coridnate thats how I made fish swin in the sea in one of my games.
In response to Avren
Avren wrote:
> > area/Bugs_alowed
> > Exit(atom/A) //When a bug attempts to exit this zone
> > if(istype(A,/mob/bug)) return //if it really is a bug attempting to exit, stop the procedure
> ..() //if the proc wasn't stopped, call it's default
> >

This proves a bit more efficient.

Understand that Exit() is used by Move() to determine whether the movable is allowed to exit the atom or not. It isn't used like Exited() to execute special code once the movable exited the turf, etc. Because of that, the return value is especially important, and in addition, just calling the parent proc will have no effect. What you want to do is return the value the default/parent proc returned, so the Exit() proc will still behave correctly (change '..()' to 'return ..()'; the former just calls the parent proc but doesn't do anything with the returned value - it's lost).
In response to Dragon_fire6653
ok the bug is not me, the bug is a NPC that I dont want leaving a certain path. the error is when I go into the are that says bugs allowed I cannot get out. maybe I am not substituting a variable right but the name of the thing is bug and it works but I my player cannot get out once I step in.
In response to Arcangelbjr
Would you please read? Both codes posted here are quite incorrect. The fixes needed have been pointed out; also, if you want help, post your code which doesn't work correctly, duh.