updateHealth(value2=0,heal=0)
set waitfor=0
if(isplayer(src))
var/mob/M=src
if(M.ko)
if(M.HP>M.MaxHP*0.25)
M.UnHurt()
var/bars=round(M.baramt,1)
var/bar_on=1
var/percent=round((M.HP/M.MaxHP)*M.baramt,1)
if(percent>=bars)
percent=round(bars,1)
if(percent<=0) percent=1
healthnum(num2text(round(HP,1)))
if(percent>100 && percent<=200)
percent-=100
bar_on=2
if(percent>200 && percent<=300)
percent-=200
bar_on=3
if(percent>300 && percent<=400)
percent-=300
bar_on=4
if(percent>400 && percent<=500)
percent-=400
bar_on=5
if(percent>500 && percent<=600)
percent-=500
bar_on=6
if(percent>600 && percent<=700)
percent-=600
bar_on=7
percent*=1.59
for(var/obj/HMeters/o in hudobjs)
var/max=percent
if(o.bar_id>0)
if(bar_on>o.bar_id)
max=159
if(bar_on<o.bar_id)
o.icon_state=""
max=0
max=159-max
baricon=new/icon(o.baseicon)
baricon.Crop(159,32,max,1)
o.icon=baricon
Problem description:
I was looking for new ways to make HP bars and I eventually came up with this, a method using icon cropping, it works okay but there's a problem, in my game each player has multiple bars which drain one by one (tenkaichi's design), and this part works pretty nicely, however when healing, it won't advance to the next bar despite the hp var itself and bar tracker saying which says its currently on the next bar.