ID:269277
 
In my game, I have monsters that walk in random directions. Is there a way to make a "wall" that they cannot pass into, but players can walk through?

I want to create this so that players can have some sort of safe area where monsters cannot go (A town).
well, make a turf, right, make it so, a mob without a client can't pass through it, like so
turf/NoMonster
Enter()
if(!usr.client) ..()
else return 0

just place this turf around the town or whereever you want it to be safe.
In response to Buzzyboy
turf/NoMonster
Enter()
if(!usr.client) ..()
else return 0

Ugh. How many times does it need to be repeated that you shouldn't be using usr here? Use the passed in parameter. Though it's still bad form to just test against the mob having a client as you may later decide you want mobs which aren't PCs or monsters to be able to move through(ie. npc helpers) in which case things won't work. It would be best to either give mobs a flag which determines whether or not they can enter town areas or make monsters derived from a monster base class and just deny them specifically.

The flag method
mob
var/enterTown = 0
player
enterTown = 1

turf
Enter(mob/M)
if(istype(M) && M.enterTown)
return ..()
return 0


The deny monster type method
mob
monster
//Monsters
turf
Enter(atom/A)
if(istype(A,/mob/monster))
return 0
return ..()
In response to Theodis
Thanks a million. I got it to work.