ID:2109150
 
(See the best response by Rushnut.)
Code:

mob
Vampire
Bump(mob/M)
..()
if(istype(M,/mob))
M.Bite()


Problem description:I cant make "if(istype(M,/obj)" but if I remove "(mob/M)" on bump the vampire cant bite!How I can make if(istype(M,/obj) and delete the obj? Also how I can make vampires respawn at a random location from 0 to 100 x?
Need help,please.
Best response
Firstly your Bump() has mob/M defined, so M will only ever be a mob. You want Bump(atom/A).

Then you'll need to typecast in each if statement. So you'll have

if(istype(A,/mob))
var/mob/M = A
//(...)


Then simply add an else if branch for your objects

else if(istype(A,/obj))
var/obj/O = A
del(O)



As for respawning, look into the locate() proc and the rand() proc. You can find them in the reference, open up DM and press F1.
In response to Rushnut
Thanks, that really helped me!
Working fine now
In response to Rushnut
Rushnut wrote:
Firstly your Bump() has mob/M defined, so M will only ever be a mob. You want Bump(atom/A).

/proc/foo(mob/M)
world.log << M.type // "/obj"

/world/New()
foo(new /obj)


Procs don't typecheck their arguments.