ID:169895
 
obj
KNIFE
name="KNIFE"
icon = 'icons/KNIFE.dmi'
Bump(atom/A)
if(istype(A,/mob/))
A<<"You get hit by a KNIFE"
del(src)
if(istype(A,/turf/water))
del(src)


Problem: I want it so that if it hits water it deletes itself. It is not doing this, any help?

~>Jiskuha
Add density = 1.
In response to DeathAwaitsU
I can't believe that slipped my mind. Anyways, Here is a new problem.

obj
KNIFE
name="KNIFE"
icon = 'icons/KNIFE.dmi'
density=1
Bump(atom/A)
if(istype(A,/mob/))
A<<"You get hit by a KNIFE"
del(src)
if(istype(A,/turf/water))
del(src)
if(istype(A,/turf))
sleep(20)
del(src)


How can i call a deathcheck proc for the player when they are hit. I't wont work if i do A.health--. I end up getting a compile error.

~>Jiskuha
In response to Jiskuha
var/mob/M=A

-Ryan
In response to Jiskuha
Any time you want to refer to a variable that dosn't exist universally, make sure you've defined the variable's type.

The other option, in case you are positive that your reference has the variable you're accesing, you can use the : operator rather than the . operator.

Hence, there are two ways to do what you want to do.

var/mob/m = A
--m.health
m.deathcheck()
OR
--A:health
A:deathcheck()

The problem with the second way is that if A turns out not to have deathcheck or a health variable, the procedure will crash. However, as long as you're checking with an istype() beforehand, you're pretty safe.