ID:261373
 
I want it so when i kill a charecter it deletes them same with monsters.I did this but it dont seem to work


verb
attack(mob/M as mob in oview(1))
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = rand(1,10)
world << "[damage] damage!"
M:HP -= damage
M:DeathCheck()
DeathCheck()
if (HP <= 0)
world << "[src] dies!"
del(src)
Open Server wrote:
I want it so when i kill a charecter it deletes them same with monsters.I did this but it dont seem to work


verb
attack(mob/M as mob in oview(1))
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = rand(1,10)
world << "[damage] damage!"
M:HP -= damage
M:DeathCheck()
DeathCheck()
if (HP <= 0)
world << "[src] dies!"
del(src)

The bottom part of the code is doing the following:

Call deathcheck for the targetted mob,
Call deathcheck for the attacker
if attacker's health is less than or equal to 0, delete the attacker and announce its death.

You'll probably want to be aiming it at the target instead of the attacker. And, you should probably have the information checking for death in the deathcheck proc...