ID:142893
 
Code:
for(var/mob/M in range(O,4))
M.overlays+=I
M.health-=rand(35,60)
sleep(1)
M.overlays-=I
sleep(1)
M.Death()


Problem description:The O would be the object that causes this. There is one problem. My character has 100 health and this is supposed to do from 35 to 60. Yet, my character dies after being hit by this. Why is that? Also, just so I won't have to post again, is it possible to have the games interface to become full screen when the game starts?

DisturbedSixx wrote:
Code:
> for(var/mob/M in range(O,4))
> M.overlays+=I
> M.health-=rand(35,60)
> sleep(1)
> M.overlays-=I
> sleep(1)
> M.Death()
>

My character has 100 health and this is supposed to do from 35 to 60. Yet, my character dies after being hit by this. Why is that?

With the code that was supplied, im guessing that the M.Death() proc is actually where a mob dies, and in this case, you just call M.Death() without actually checking to see if the mobs health reaches 0 or not. After you subtract the damage from the health, Check whether the health has dropped to sufficient levels for a 'death' and then call the Death proc for the mob.
In response to Hassifa
In the Death proc itself, I check to see if the players health went to 0 or lower.
In response to DisturbedSixx
It would probably help if you showed your Death proc.
In response to Kaiochao
Not really but here it is:
mob/proc/Death()
if(src.health<=0)
src<<"You have died."
src.loc=locate(4,4,1)
src.health=100
In response to DisturbedSixx
I'm guessing the proc is called more than once for whatever is calling it. If the code is called twice when you thought it was only called once, then the person could still die.
One thing I think you should know is that putting sleep(1) only causes the code to delay for 1/10th of a second.
In response to Naokohiro
Most likely cause is whatever object this for() is connected to calls it multiple times for various reasons. Can't tell you unless I see what the for() is connected to.
In response to Pyro_dragons
A good idea to check that it is loading more than once or not put the following into the top of the damage thing (Where you are supposed to only be getting 35-60 damage)
world << "Damage!"
If Damage appears on the screen more than once in the text window, than you are calling it more than once.