mob/var/HealthOverlay
mob/var/MagicOverlay
mob/proc/Bars()
usr.overlays -= usr.HealthOverlay
var/obj/HealthBar/O = new/obj/HealthBar
var/Length = 29
var/Percent = round((usr.hp/usr.maxhp) * Length)
O.icon_state = "[(Percent>Length)?(Length-1):Percent]"
if(Percent==29)
O.icon_state = "8"
usr.HealthOverlay = O
usr.overlays += usr.HealthOverlay
usr.overlays -= usr.MagicOverlay
mob/proc/Bars2()
var/obj/MagicBar/A = new/obj/MagicBar
var/Length1 = 29
var/Percent1 = round((usr.magic/usr.maxmagic) * Length1)
A.icon_state = "[(Percent1>Length1)?(Length1-1):Percent1]"
if(Percent1==29)
A.icon_state = "8"
usr.MagicOverlay = A
usr.overlays += usr.MagicOverlay
obj/HealthBar
icon='meter.dmi'
icon_state="8"
pixel_y=27
layer=10
obj/MagicBar
icon='magicmeter.dmi'
icon_state="8"
pixel_y=23
layer=9
ID:146922
Dec 7 2004, 8:11 pm
|
|
I want to make it so when the person gets attacked, healed, etc. The health and magic bars would update. But, they don't. I can't seem to figure out why?
|
Dec 8 2004, 4:31 am
|
|
You'll want to call Bars() and Bars2() from any place that you decrease the player's health or magic points... however, you may also want to address the use of usr in these two procs. In this case, you could use src, rather than usr, which would DEFINATELY provide more acceptable results. The only other thing that I noticed at a glance is that you're removing the magic bar from the overlay in the health bar's proc (you might want to move that down into Bars2() for your own sanity later on). Hopefully this helps!
|