ID:180634
 
ok can someone tell me how to put life bars in a stat window?
On 4/23/01 6:07 am Mloren wrote:
ok can someone tell me how to put life bars in a stat window?

Was my code not sufficient?

mob
var
obj/meter/meter
health = 50
maxhealth = 100

New()
..()
src.meter = new

Stat()
src.meter.num = (src.health/src.maxhealth)*30
src.meter.Update()
statpanel("Stats")
stat("Health:",src.meter)

obj/meter
name = ""
icon = 'meter.dmi'
icon_state = "0" //that's zero, not ( ) or O
var/num = 0
proc/Update()
src.icon_state = "[round(src.num)]"
In response to Spuzzum
thats all very well, but i have my code set up a little differently, and i have no intention of recoding my mobs and objs to match that :D

all i need to know is how to make it appear in the stat panel, i already know the rest....

my stat panel looks like:

mob
Stat()
if(statpanel("Stats"))
stat("Strength: [usr.STR]")
stat("Agility: [usr.DEX]")
stat("Intelligence: [usr.INT]")
stat("Constitution: [usr.CON]")
stat("Health: ", 'meter.dmi')

but this doesnt work...
what should this line:
stat("Health: ", 'meter.dmi')
say?
In response to Mloren
On 4/24/01 12:05 am Mloren wrote:
thats all very well, but i have my code set up a little differently, and i have no intention of recoding my mobs and objs to match that :D

all i need to know is how to make it appear in the stat panel, i already know the rest....

my stat panel looks like:

mob
Stat()
if(statpanel("Stats"))
stat("Strength: [usr.STR]")
stat("Agility: [usr.DEX]")
stat("Intelligence: [usr.INT]")
stat("Constitution: [usr.CON]")
stat("Health: ", 'meter.dmi')

but this doesnt work...
what should this line:
stat("Health: ", 'meter.dmi')
say?

You need to compare the current value of health, and then display an obj with the appropriate icon.

mob
var/obj/health_meter

New()
health_meter = new
..()

Stat()
if(statpanel("Stats"))
stat(...) //blah blah blah =)

var/health = (src.HP/src.HP_MAX)*100
switch(health)
if(1 to 10)
health_meter.icon = 'meter1.dmi'
if(11 to 20)
health_meter.icon = 'meter2.dmi'
if(21 to 30)
...
if(91 to 100)
health_meter.icon = 'meter10.dmi'

stat("Health:",health_meter)
In response to Spuzzum
What about a life bar over the mobs head when the mob is not at max health?
In response to karver
What if the Hp changes?