ID:2122493
 
(See the best response by Kaiochao.)
Code:
mob
var
isblind=0
obj
blindness
icon='blindness.dmi'
screen_loc="SOUTHWEST to NORTHEAST"
layer=MOB_LAYER-1
New()
for(var/turf/t in oview())
t.blind=1
turf
var
blind=0
Entered()
if(blind)
usr.isblind=1
var/obj/blindness/b=new
usr.client.screen+=b
Exited()
if(blind)
usr.isblind=0
for(var/obj/blindness/b in usr.client.screen)
usr.client.screen-=b
del b


Problem description:
The blindness object covers the mob. I'm trying to make it so the mob's icon isn't covered. I've tried looking through the layer variables in reference, and I've tried using layer=FLOAT_LAYER-1 along with various other attempts, but I can't seem to figure out how to have it so it doesn't cover the mob icon.
Best response
1. Stop abusing usr. You're blindly treating anything that moves as a mob with a client, which could get you a bunch of runtime errors. The atom.Entered() and Exited() procs give you a reference in their arguments to the mover that performed the action. You need to check if that mover is actually a mob, then make a mob-typed variable to access its mob-related properties.
turf
var
blind=0

Entered(atom/movable/Mover)
if(blind && ismob(Mover))
var mob/player = Mover
player.isblind=1
var/obj/blindness/b=new
player.client.screen+=b

Exited(atom/movable/Mover)
if(blind && ismob(Mover))
var mob/player = Mover
player.isblind=0
for(var/obj/blindness/b in player.client.screen)
player.client.screen-=b
del b

You're also abusing usr in /obj/blindness/New() when you call oview(). I'm not sure what you're trying to do with that, though.

2. You could take advantage of mob.sight in addition to a screen object. The screen object would have to be layered below the mob, which is fine, since actually blinding the mob will prevent anything else from being layered over it.
// to blind the player to everything other than the player:
player.sight = BLIND | SEE_SELF
Thanks for the help on suggesting mob.sight. And also thank you for the help in regards to poor use of usr. Just one more question, is there a way to layer the object behind the mob so that you can still see it, but also be able to see the mob? I'm still having trouble figuring out how to do that if it's possible.
In response to Zerok Kaiba
I forgot that screen objects can no longer be drawn below normal map objects.

I'm not really sure if there is a way. I'm assuming your screen object isn't just a solid color, or else you wouldn't need to use it.

You could create a clone in client.screen with a higher layer than the blindness, with screen_loc="CENTER" so it's more or less where the mob is. It might be feasible to make it constantly sync with the mob's appearance, if there's no built-in way to do that.
I see, yeah I was confused at first when I found I couldn't simply layer the screen object behind the mob. Alright, I guess it's just the next best option for when I want to do that. Thanks again for all your help.