toxic
New()
..()
while(src)
for(var/mob/M in locate(src.x,src.y,src.z))
//make mobs lose health
var/dmg = M.MaxHealth*rand(0,0.1)
if(dmg > 0)
F_damage(M, 10, "#FF0000")
M.Health -= dmg
Update(M)
if(M.deathCheck())
view(M) << "<font color=lime>[M] has died from radioactive poisoning!"
sleep(rand(25,50))
Problem description: The toxic turf is supposed to slowly kill the player if they stay on it. The problem is that the Update proc and the F_damage proc are not working properly (damage isn't flashing above the player and healthbar doesn't go down). However, the player still eventually dies. Those two procs work fine when the player is fighting monsters.
Here is the code for the Update (note, there will be more in the Update proc as I develop the game):
proc
Update(mob/M)
M.Bars(M)
mob
var
tmp/HPB
mob/proc/Bars(mob/M)
if(!M.HPB)
M.HPB=new/obj/overtop/health
if(M.HPB)
M.overlays-=M.HPB
var/obj/overtop/health/O=new/obj/overtop/health
var/Length=20
var/Percent=round(M.Health/M.MaxHealth*Length)
O.icon_state = "[(Percent>Length)?(Length-1):Percent]"
if(Percent<=0)O.icon_state = "0"
M.HPB=O
M.overlays+=M.HPB
What could be the problem? Thanks in advance!
rand(0,0.1) will ALWAYS give you 0: rand() between two numbers will only give you an integer.
I don't know why your mobs are dying considering you are never doing any damage to them.