Bump(atom/M)
if(isturf(M)) // If whatever the head bumps is a turf..
owner.kame = 0 // Allow the owner to fire another beam
owner.icon_state = "" // Give them their default icon_state
owner.move = 1 // Allow them to move
for(var/obj/O in src.Beam) // Checks for objects in the Head's Beam list...
del(O) // Deletes any objects found
del(src) // Deletes the head
else if(ismob(M)) // If whatever the head bumps is a mob...
view(src.owner) << "[src.owner]'s beam hits [M]!" // For all in the owner's view, gives a message
M:powerlevel-= M:ki
usr.DeathCheck(owner,M)
owner.kame = 0 // Allows the owner to fire another beam
src.owner.icon_state = "" // Sets them to their default icon_state
owner.move = 1 // Allows them to move
for(var/obj/O in src.Beam) //For all objects in the Head's Beam list...
del(O) //Delete any objects found
del(src) // Delete the head
else
if(!ismob(M) && !isturf(M) && !isobj(M) && !isarea(M))
owner.kame = 0 // Allow the owner to fire another beam
owner.icon_state = "" // Give them their default icon_state
owner.move = 1 // Allow them to move
for(var/obj/O in src.Beam) // Checks for objects in the Head's Beam list...
del(O) // Deletes any objects found
del(src) // Deletes the head
mob
proc
DeathCheck(mob/M)
if(M.powerlevel<=0&&M.npc)// if the hp's 0 and its a NPC.
world<<"<font color=red>[src] has killed [M]</font>"/// say theyve killed M
src.exp+=M.exp
del(M)///delete the npc frm the world cuz its dead
src.Level()// call the lvl proc
return/// stop runtime errors =D
if(M.powerlevel<=0&&M.client) // if hp 0 and its a client.
world<<"<font color=red><B>Player Death:[src] has been killed by [M]</B></font>"// same as before
M.powerlevel=M.powerlevel_max//give them full hp back.
M.loc=locate(180,18,1)//take them to spawn point, dont DEL them.
src.exp+=src.powerlevel// give them exp!!
src.Level()/// call lvl proc
Problem description: My Death Check don't work. When I try to kill a npc on my game it says error and more errors:
runtime error: Cannot execute null.DeathCheck().
proc name: Bump (/obj/Beams/Head/Bump)
usr: 0
src: Head (/obj/Beams/Head)
call stack:
Head (/obj/Beams/Head): Bump(Vegeta (/mob/npc/Vegeta))
Head (/obj/Beams/Head): Move(Sand (183,22,1) (/turf/Sand/Sand), 8)
What is wrong with my code?
2. usr abuse. usr doesn't exist in the context you're calling DeathCheck() with. usr is extremely unsafe, 98% of the time.
Bottom line: use owner.DeathCheck(M).
I'm not sure where all you new programmers learn about the : operator. Experimentation? Just DO NOT use it. :)