ID:263931
 
Problem description:In my pokemon game the training dummies disappear in one hit (they respawn in a minute) but its not supposed to happen. i run my deathcheck on both the mob and the usr and it checks for 0 hp every attack. but i gave the dummie inf hp but i cant figure out the problem
    npc
Training_Dummy
icon = 'Training Dummy.dmi'
icon_state = ""
type1="Trainer"
type2="Bad"
HP=9999999999999999999999999999999999999999999999999999999999999999999999999999999...(continues for a long time)

    proc
deathcheck()
if(src.client)
if(src.HP <= 0)
view() << "[src] has fainted!"
usr.money /= 1.4
src.loc=locate(20,110,1)//mobs will respawn in this place
else
view() << "[usr] made [src] faint"
usr.money += rand(100,500)
del(src)
You dident put a HP check under the Else, its just checking if the mob is a client, which its not, then killing the training bag due to no HP check.

Try the if(src.HP <= 0) under the Else.
You shouldn't muck around with stupidly high HP values. That's just circumventing the problem. The solution is just to make the training dummies never die, by changing deathcheck()

mob/npc/Training_Dummy
deathcheck(var/mob/attacker)
//DO NOTHING
//BECAUSE YOU SEE
//WE CAN'T DIE


Additionally, using usr in deathcheck is wrong. This is how you're supposed to set it up:

mob
verb/attack(var/mob/M in oview(1))
M.HP -= 1
M.deathcheck(src)
proc
deathcheck(var/mob/attacker)
if(HP <= 0)
die(attacker)
return 1
else
return 0
die(var/mob/attacker)
del(src)
npc
die(var/mob/attacker)
view(src) << "[attacker] made [src] faint"
attacker.money += rand(100,500)
del(src)
player
die(var/mob/attacker)
view(src) << "[src] has been fainted'd by [attacker]"
src.money /= 1.4
src.loc = locate(20,110,1)
as garthor said it obiously will delete Non Player like the dummy o.o well a solution is on the deathcheck proc under the else put
if(istype(src,/mob/npc/Training_Dummy/)return
In response to Aang-Air bender
That code won't even compile.
In response to Aang-Air bender
Aside from mismatched parenthesis, that is not an object-oriented way of doing things. Please don't try to provide advice if you don't know what you're talking about.