ID:562607
 
(See the best response by Stephen001.)
How can I use the player when I can't use usr or src? What can I put here that will always be the player?

Example:
mob/proc/UpdateBar()
winset(HERE,"hp","value=[round(100*hp/maxhp)]")
winset(HERE,"mp","value=[round(100*mp/maxmp)]")
My recommendation actually, is to move mob/proc/UpdateBar() to be a client proc, as winset() ultimately send a command to a client. So if you're happily re-assigning mobs that a client uses or some such, having the client own the procedure makes more sense. Pass in the mob the player's notion of health comes from.

client/proc/UpdateBar(var/mob/M)
winset(src,"hp","value=[round(100*M.hp/M.maxhp)]")
winset(src,"mp","value=[round(100*M.mp/M.maxmp)]")


Out of curiosity, why can't you use src in your example?
I can't use src because the src is the NPC monster. Your suggestion didn't help unfortunately. Here's the error message I'm getting.

runtime error: Cannot execute null.UpdateBar().
proc name: Bump (/mob/Monster/Bump)
source file: J_AI.dm,475
usr: Bandit (/mob/Monster/Human/Bandit)
src: Bandit (/mob/Monster/Human/Bandit)
call stack:
Bandit (/mob/Monster/Human/Bandit): Bump(Leptoon (/mob/pc))
It's hard to help without seeing the rest of the piece of code. Could you post the rest of what goes with this?
My confusion, is why UpdateBar() would we called on an NPC monster. It should be called on the player. Can you show us where you are calling UpdateBar()?
It's called when a player bumps a monster or vice versa. Here's the monster bump code (it obviously works fine on the player one). It's from a demo called J_AI.

mob/Monster
Bump(atom/O)
usr.UpdateBar()
if(isobj(O))//if O is a obj
three_steps(O,dir)//make O step in mobs direction
else if(ismob(O))//if not a obj but a mob and mob is active attack
if(active)
J_Attack(O)//if active J_Attack O
..()
Best response
mob/Monster
Bump(atom/O)
if (istype(O, /mob/Player))
var/mob/Player/P = O
P.UpdateBar()
if(isobj(O))//if O is a obj
three_steps(O,dir)//make O step in mobs direction
else if(ismob(O))//if not a obj but a mob and mob is active attack
if(active)
J_Attack(O)//if active J_Attack O
..()


Basically the monster needs to check if the thing it bumped was a player, and call UpdateBar() on it appropriately.
Thanks!