ID:2255642
 
(See the best response by Nadrew.)
mob/density=0
mob/var/delay=2
mob/var/tmp/move=1
mob/Move()
set background =1
if(src.move)
src.move=0
var/turf/A = get_step(src,dir)
for(var/mob/X in A) if(!X.key)
return 0
..()
sleep(src.delay)
src.move=1


i'm trying to make players pass through each other , but when i do this, they can also pass through NPCs, which i don't want, how do i go about this? i want them to only pass through players and not npcs
Best response
You could utilize the almost-never-used 'group' variable. Or just check 'client' in your existing code (and not key).
I would use Cross() for this instead of Move().
mob
// Don't set density to 0

Cross(atom/movable/mover)
// Allow crossing if both src and the mover are mobs with clients.
if(client && ismob(mover))
var mob/m = mover
return m.client != null
return ..()
I tend to employ a global team variable for a lot of things. It comes in handy for more flexible monster AI and determining attack hits in certain instances.

atom/movable
var
team
team_density = 1

Cross(atom/movable/o)
. = ..()
if(team&&!.&&team==o.team&&(!o.team_density||!team_density)) //if I have a team, the crossing obj's team is the same as my team, and one of us doesn't have team density.
return 1


With this kind of a setup, you can simply swap the player's team on Login()/Logout()

mob
team_density = 0

Login()
..()
team = "players"

Logout()
team = null


Teams also come in handy for things like minigames, guildwar-esque PVP modes, etc.
In response to Nadrew
Nadrew wrote:
You could utilize the almost-never-used 'group' variable. Or just check 'client' in your existing code (and not key).

This is interesting, didn't know it existed.