ID:138364
 
Does anyone have a nice way of doing health bars over mob icons? I'm finding it hard to figure a way of doing it that will still allow me to use overlays for clothes and equipment. Am I correct in my assumptions that 1. an overlay has to have the same icon_state as the mob and 2. it's not possible to reference an overlay, unless you know it's image name. I would like all other mobs to be able to see the bar. I will only implement this if it is relatively CPU light (I don't want to do things with image()).

All comments welcome, Thanks.
On 10/5/00 9:19 am Al wrote:
Does anyone have a nice way of doing health bars over mob icons? I'm finding it hard to figure a way of doing it that will still allow me to use overlays for clothes and equipment. Am I correct in my assumptions that 1. an overlay has to have the same icon_state as the mob and 2. it's not possible to reference an overlay, unless you know it's image name. I would like all other mobs to be able to see the bar. I will only implement this if it is relatively CPU light (I don't want to do things with image()).

All comments welcome, Thanks.

The health bar question is a good one, which I'll leave to others to answer.

But I thought I'd mention an alternative: It actually works quite well to use icon tinting to indicate health. In Living & Dead, I make the icon more red for every 10% of health they lose -- this turned out to be quite effective.

Now it might be somewhat more complicated with clothing overlays and such.
Does anyone have a nice way of doing health bars over mob icons? I'm finding it hard to figure a way of doing it that will still allow me to use overlays for clothes and equipment. Am I correct in my assumptions that 1. an overlay has to have the same icon_state as the mob and 2. it's not possible to reference an overlay, unless you know it's image name. I would like all other mobs to be able to see the bar. I will only implement this if it is relatively CPU light (I don't want to do things with image()).

All comments welcome, Thanks.

Hmm. This *might* work...

mob
var/obj/powerOverlay


New()
. = ..()
powerOverlay = new()


proc/SetPower(myValue)
overlays -= powerOverlay
powerOverlay.icon = 'power.dmi'
powerOverlay.icon_state = num2text(myValue)
overlays += powerOverlay

I'm not sure, though, whether its icon state would change automatically when the mob's does. It's worth a try.

In response to Guy T.
All comments welcome, Thanks.

I'm not sure, though, whether its icon state would change automatically when the mob's does. It's worth a try.

I shouldn't change, unless the meter has similar icon_states that the object has (like "fighting"). Incidentally (I like that word... I've used it three times over the past two days =), the meter effect could be accomplished with a simple image() that deletes itself and redisplays itself. For example (as always, pseudo-code; take with a horseshoe hanging over your door, a rabbit's foot in your pocket, and a pile of salt behind you):

#define number_of_icon_states 30 //number of icon states in your meter (not including the zero "0" state)
#define meter_refresh_time 6 //how long you want to wait before it updates the overlay

mob
health = 50
max_health = 100
obj/health_bar
health_bar_overlay

New()
..()
Tick()

proc/Tick()
del src.health_bar
src.health_bar = new //I think this works... it should assume /obj
del src.health_bar_overlay
src.health_bar.icon_state = num2text(round((src.health/ src.max_health)*[number_of_icon_states]),1) //get a number from 0 to [number_of_icon_states]
src.health_bar_overlay = image(src.health_bar,src)
spawn([meter_refresh_time]) Tick()