ID:175370
 
I'm trying to make an attack system for my game, but my deathcheck proc isnt working. Here is my attack verb:
verb
attack(mob/M in oview(1))
set hidden=1
usr << 'attack.wav'
if(M)
var/damage = usr.str
usr.HP -= damage
flick(M,"hit")
Deathcheck()


here is my deathcheck proc:
proc/Deathcheck()
if(usr.HP ==0)
usr.loc = locate(2,5,2)
usr<< "you have died!"


its simple, so i think that im leaving something out...

Thanks,
~Aleis~
Aleis wrote:
    proc/Deathcheck()
if(usr.HP ==0)
usr.loc = locate(2,5,2)
usr<< "you have died!"

Two problems:

  • Don't put usr in procs; it's not safe. This should be src.
  • That should be if(src.HP<=0), since your HP may go negative when you subtract too much damage. The ==0 check will only trigger if you lose exactly as much health as you have left.

    Lummox JR
In response to Lummox JR
Ok, I'll try that, thanks. And, sorry about earlier
Also, when you called DeathCheck, you didn't tell it which mob you were calling if for. It should be M.DeathCheck()
Aleis wrote:
I'm trying to make an attack system for my game, but my deathcheck proc isnt working. Here is my attack verb:
verb
> attack(mob/M in oview(1))
> set hidden=1
> usr << 'attack.wav'
> if(M)
> var/damage = usr.str
> usr.HP -= damage
> flick(M,"hit")
> Deathcheck()

here is my deathcheck proc:
proc/Deathcheck()
if(usr.HP ==0)
> usr.loc = locate(2,5,2)
> usr<< "you have died!"

its simple, so i think that im leaving something out...

Thanks,
~Aleis~

You might wanna reset some stats too:
proc/Deathcheck()
if(usr.HP ==0)
usr.loc = locate(2,5,2)
usr<< "you have died!"

src.hp = src.maxhp
src.mp = src.maxhp

etc etc
In response to Magnus VI
That would be it! thanks "Magnus".

Thanks,
~Aleis~