ID:139519
 
Code:
mob
proc
Death(mob/Killer)
if(src.HP<=0)
if(src.key) //if its a player you wana do something different right?
world<<"<b>Player Death:<font color=red> [src] died to [usr]"
Killer.loc=locate(/turf/Death)
Killer.HP=src.MaxHP
Killer.Ki=src.MaxKi //sends the dead guy back to the start
else
src<<"You killed [src]."
src.LevelUP(1) //check if the player has enough EXP to level up
del src


Problem description:It dont delete Monster

How are you initially calling the Death() proc?
Also, I would highly recommend not deleting a /mob, and just placing it elsewhere with it "hibernating" until it can be re-used. This saves a lot of workload, and enables you to use less atoms while keeping the same affect.
In response to Maximus_Alex2003
Attack()
set hidden=1
if(usr.Attacking) return
usr.Attacking=1
Attaker=usr
spawn(4) if(usr) usr.Attacking=0;Attaker=null

if("punch1" in icon_states(icon))
flick("punch1",src)
if("kick1" in icon_states(icon))
flick("kick1",src)
// if(usr.induel)
for(var/mob/M in get_step(usr,usr.dir))
if(M.client||/mob/Monster)
var/mob/D=M
M.attacked=1
var/damage = round((usr.Str*usr.Dmgmulti+rand(10,20))-(D.Def/1.5),1)
damage=max(0,damage+rand(-1,1))
D.HP-=damage
D.DamageShow(damage,0,0,0)
D.PLUPDATE()
D.KO()
D.Death(usr)
In response to Hassanjalil
You really should stop making unnecessary references and defining atoms, if they already exist.
What I mean by this is, you already have the player in /mob form, so you do not need "Attacker = usr".
Judging by the use of "set hidden = 1", this is a /mob/verb that players get.

The line "spawn(4) if(usr) usr.Attacking=0;Attaker=null" serves no logical purpose except for cluttered code.
From this line, I can only assume you are checking to see if the usr, a.k.a. the player doing to Attack, exists or not. If they don't exist, they wouldn't call the verb, so that line is not needed at all.

Going back to your Death() proc, I see some flaws:
//  How to call Death: Victim.Death(Killer)
mob/proc/Death(mob/Killer)
{
if (src.HP <= 0)
// Check to see if the Victim's HP is less than or equal to 0.
{
if (src.client)
// If the Victim is a real Human Player or a Computer AI Player, by seeing if they have a /client.
// Only Human Player's can have a /client.
{
world << "<b>Player Death:<font color=red> [Killer] hath brutally slain thy [src]!";
// Output to the world that [Killer], the Killer, has killed [src], the Victim.
src.loc = locate(/turf/Death);
// Relocate the Victim to it's apparent rightful place.
src.HP = src.MaxHP;
// Reset the Victim's HP and Ki to their MaxHP and MaxKi.
src.Ki = src.MaxKi;
}
else
{
Killer << "You doth slain thy [src].";
// Output to the Killer that they have killed the Victim.
Killer.LevelUP(1);
// Perform your LevelUp process that apparently checks the Killer to see if they level up?
del src;
// Not what you want to do, but this is what you are asking for.
// I highly recommend you NOT to delete /mob's that can be stored elsewhere, and then later
// reused by relocting them, and adjusting their variables. This saves on space, workload,
// and etc.
// This is also not the process I would follow for a death-check, but I'm following your format.
}
}
}
Make sure your Levelup proc ends nicely, if your levelup proc loops it will stop anything after you call that proc. Now if this is the case then it makes sense that your del isent called. Make sense?
In response to Maximus_Alex2003
Actually, every time you do a sleep() or spawn() like that, you SHOULD do a sanity check to see if the player still exists in the world. If the player logs out or is disconnected before that sleep() or spawn() ends, a runtime error will occur.

Another thing, he should use Flick() instead of setting their icons like that.

Oh, and... "if(M.client||/mob/Monster)" - huh? That is most definitely WRONG. If his intention is to check whether it's a player or a monster he is attacking, that "/mob/Monster" should be "istype(/mob/Monster)".
In response to Spunky_Girl
Uhm, yeah, exactly. I don't know why you're telling me this since I obviously didn't call a spawn() or sleep(), so a sanity check is absolutely unnecessary.

Actually, it's not that he "should" use flick(). If the OP wants to keep their icon at an icon_state, it's fine.

Why not tell him, since this has no relevancy to me?
In response to Maximus_Alex2003
Oh, sorry. I forgot to quote what you said...

Maximus_Alex2003 wrote:
The line "spawn(4) if(usr) usr.Attacking=0;Attaker=null" serves no logical purpose except for cluttered code.
From this line, I can only assume you are checking to see if the usr, a.k.a. the player doing to Attack, exists or not. If they don't exist, they wouldn't call the verb, so that line is not needed at all.

And I am telling you it IS necessary to avoid an otherwise unwanted and (what really is unnecessary -->) runtime error. What you're saying about how if the player isn't there to call it in the first place, it won't get called is just stating the obvious. But in the scenario I am giving you, is that it HAS been called, but then the caller is deleted, disconnected, logged out, whatever, before the spawn()/sleep() ends. Whatever line comes after the spawn()/sleep() will cause a runtime error, which is bad.
In response to Spunky_Girl
You didn't understand the context clearly. I said the whole entire line is not needed, I didn't say a specific part of the line is. Please look into things a little more.