ID:143205
 
Code:
proc/kill(mob/M as mob in world)
M.loc=locate(50,50,4)
M.Deaths+=1


DeathCheck(mob/M as mob in world)
if (M.HP <= 0)
world << "[src] dies!"
M.kill()

(the two different codes are in different places )
Problem description:
Ok so the code compiles perfectily fine. When i run the game and i use a kill verb or shoot something to kill a mob/usr, i get this error :-


runtime error: Cannot modify null.loc.
proc name: kill (/mob/proc/kill)
usr: Tyr (/mob)
src: Tyr (/mob)
call stack:
Tyr (/mob): kill(null)
Tyr (/mob): Kill(Tyr (/mob))

I cant seem to fix it =\ (its prob one of the simplest things).

any help will be appreciated, thanks ^^.
...Okay...

Odd...

Here you go...

mob
proc/kill(mob/M as mob in world)
M.loc=locate(50,50,4)
M.Deaths+=1
proc/DeathCheck(mob/M as mob in world)
if(M.HP <= 0)
world << "[M] dies!"
M.kill()


Did it help?
Your problem is that you're calling M.kill(), when the victim is meant to be the argument (by your definition). You need to call kill(M).

If kill() is a mob procedure, you can use that to determine the killer, as well.

mob/proc/kill(mob/theVictim)
// Do whatever you want here.
theVictim.Deaths++
src.Kills++
mob/verb/Magically_Kill(mob/theMob in world)
usr.kill(theMob)


However, that procedure limits you in the fact that you must have a killer. Personally, I'd write a general procedure with seperate Victim and Killer arguments.

proc/Death(mob/theVictim, mob/theKiller)



[EDIT]

I just realized what you're doing, as well. Personally, I'd design it to that your DeathCheck procedure itself would handle the actual killing as well as checking to see if they should be killed.
In response to Volte
So how does nothing die?
In response to Garthor
I'm not going to write the entire thing for him, I was just showing him what the problem was.

If you're talking about how I said the problem was that you must have a killer (not a victim), I'm saying that sometimes you want to make them die without a player who caused it (falling into spikes, burning, stuff like that).
In response to Volte
Thanks guys, i got it working ^^. yay! lol. it was simple now that i think about it =\, anyway, once again thanks.