ID:142269
 
Code:
    



mob
proc




Damage(var/mob/a,var/mob/b,dmg,tech)
a<<"<font color=green>You hit [b] with [tech] for [dmg] damage!"
b<<"<font color=red>You've been hit by [a]'s [tech] for [dmg] damage!"
b.Stam-=dmg/4
b.Health-=dmg
b.Knock(a,b)
b.Death(a,b)
b.loadhud()
return



loadhud()
var/obj/base/b=new/obj/base
var/obj/tube1/c=new/obj/tube1
var/obj/tube2/d=new/obj/tube2
var/obj/tube3/e=new/obj/tube3
var/obj/tube4/j=new/obj/tube4
var/obj/top/f=new/obj/top
var/obj/chak1/g=new/obj/chak1
var/obj/chak2/h=new/obj/chak2
var/obj/chak3/i=new/obj/chak3
var/obj/chak4/k=new/obj/chak4
var/obj/stam1/l=new/obj/stam1
var/obj/stam2/m=new/obj/stam2
var/obj/stam3/n=new/obj/stam3
var/obj/stam4/o=new/obj/stam4
var/obj/Health1/p=new/obj/Health1
var/obj/Health2/q=new/obj/Health2
var/obj/Health3/r=new/obj/Health3
var/obj/Health4/s=new/obj/Health4
usr.client.screen+=b
usr.client.screen+=c
usr.client.screen+=d
usr.client.screen+=e
usr.client.screen+=j
usr.client.screen+=f
usr.client.screen+=g
usr.client.screen+=h
usr.client.screen+=i
usr.client.screen+=k
usr.client.screen+=l
usr.client.screen+=m
usr.client.screen+=n
usr.client.screen+=o
usr.client.screen+=p
usr.client.screen+=q
usr.client.screen+=r
usr.client.screen+=s
b.checker()
g.checker()
h.checker()
i.checker()
k.checker()
l.checker()
m.checker()
n.checker()
o.checker()
p.checker()
q.checker()
r.checker()
s.checker()



obj

base
icon='base.dmi'
proc
checker()
var/b=usr.Chakra+usr.Stam+usr.Health
var/c=usr.MChakra+usr.MStam+usr.MHealth
if(b<<c*1.5/10)
src.icon_state="0"
if(b>=c*1.5/10)
src.icon_state="15"
if(b>=c*3/10)
src.icon_state="30"
if(b>=c*4.5/10)
src.icon_state="45"
if(b>=c*6/10)
src.icon_state="60"
if(b>=c*7.5/10)
src.icon_state="75"
if(b>=c*9/10)
src.icon_state="90"
if(b>=c*9.9/10)
src.icon_state="100"


Problem description:

Well, what's happening is I'm getting this error:
runtime error: Cannot read 0.client
proc name: loadhud (/mob/proc/loadhud)
usr: 0
src: Bravo1 (/mob)
call stack:
Bravo1 (/mob): loadhud()
Katon Karyu Endan (/obj/jutsu/Katon/Katon_Karyu_Endan): Bump(Bravo1 (/mob))

every time the object causing the damage bumps into the player, the player gets damaged and the proc is called with the one hit as it's target, as you can see with b.loadhud()(I've tried b:loadhud() as well) it keeps telling me it can't read the client. Any help or fixes know of? If so, include the portion which has the fix. Thanks for all the help.

It means that you're trying to add the HUD to the mob's client's screen, but there is no client. You should use the sanity check if(b.client) to get that to work. Also, you should really make that more efficient. For example, you could make all your HUD /obj/HUD/whatever. Then, you can say for(var/X in typesof(/obj/HUD)-/obj/HUD) client.screen += new X blah blah blah. Also, if you didn't understand what I said, read the DM guide.
In response to Jeff8500
I understood, and ran the sanity check, but it's still not detecting the client, it has the same error. I just don't know what to do now ;__;
You can simplify the loadhud() proc this way:
mob/proc/loadhud()
if(!client)
//If the mob doesn't have a client, this proc was
//likely an extraneous call, and should crash. If
//this isn't the behavior you want, just change
//this to a return statement.

CRASH("loadhud() call attemp for a non-player mob.")

//NEVER use usr in a proc. It's a bad idea.

//The newlist() proc creates an instance of each
//typepath provided to it, and returns all the objs as
//a list.
var/list/screen_objs = newlist(
/obj/base,
/obj/tube1,
/obj/tube2,
/obj/tube3,
/obj/tube4,
/obj/top,
/obj/chak1,
/obj/chak2,
/obj/chak3,
/obj/chak4,
/obj/stam1,
/obj/stam2,
/obj/stam3,
/obj/stam4,
/obj/Health1,
/obj/Health2,
/obj/Health3,
/obj/Health4
)

//If nothing is explicitly included, a variable or proc
//call reverts to src, meaning the following is the same
//as doing src.client.screen += screen_objs. You should,
//as I stated above, never use usr in a proc.
client.screen += screen_objs

for(var/obj/o in screen_objs)
if(hascall(o, "checker"))
//If the obj has the checker() proc, then call
//it.
o.checker()

You're also using usr in your checker() proc, which you should fix. Another error there is that you're using the << operator, which is valid, but not at all what you want in this context.
In response to Popisfizzy
I replaced the code and I'm getting an error that o.checker is an undefined proc, I have not changed the proc I included for changing it's state and is still called checker, however I'll make the proc a general application for all those within the obj/HUD/ type and see if that works, if not I'll get back to this post. Thanks for the help though, all but one little problem is solved ^_^.
In response to Bravo1
Nevermind, got it fixed. I needed a o:checker instead of o.checker

Thanks for all the help!!
In response to Bravo1
ARGH!!!
This thing still isn't working!!

It read fine in the code but when I went to play it brang up an even ;arger error, stating that each variable being checker in order to change the state, such as M.Health, was not readable.
The error:

runtime error: Cannot read 0.Health
proc name: checker (/obj/Health4/proc/checker)
usr: 0
src: Health4 (/obj/Health4)
call stack:
Health4 (/obj/Health4): checker()
Bravo1 (/mob): loadhud()
Bravo1 (/mob): Damage(Bravo1 (/mob), Bravo1 (/mob), 17.5, "Katon Hibashiri")
Katon Hibashiri (/obj/jutsu/Katon/Katon_Hibashiri): Bump(Bravo1 (/mob))


NOTE: this is after the fix using the lists for the hud suggested to me by Jeff and it's also happening for every single variable there!

It's like, when you log in, it reads just fine, it'll load just fine, but once you try to call it through another proc, even with the client redefined it suddenly doesn't.
In response to Bravo1
Popisfizzy wrote (in [link]):
You're also using usr in your checker() proc, which you should fix.

Never use usr in a proc.
In response to Popisfizzy
Then would it be a good idea to define the "usr" that I'm using and instead of that, use a variable that represents a mob, which I've assigned before the proc?
In response to Bravo1
In your case, src would probably be the same as what you want usr to be, so it would probably work fine.
In response to Popisfizzy
I ended up carrying over the mo from proc to proc

as such:
startproc()
proc1(jimbob)

proc1(var/mob/a)
a.proc2(a)

proc2(var/mob/a)
a.proc3(a)

proc3(var/mob/a)
a<<"You're the target foo!"


I ended up solving it and jimbob got the message. =P
In response to Bravo1
Better solution: place the proc under /obj and not /obj/base.