mob
NPC
Security
icon = 'security.dmi'
density = 1
New()
.=..()
spawn() for(var/mob/M in oview(7))
if(M.key == "Thief jack")
src.dir = (get_dir(src,M))
var/obj/laser/B = new(src.loc)
walk(B,src.dir)
sleep(10)
del(B)
And how do I fix it so I dont have to use the : proc on the obj/laser?
obj
laser
icon = 'laser.dmi'
density = 1
Bump(atom/M)
if(ismob(M))
M:HP -= 5
M:Die()
else if(M.density == 1)
del(src)
I think the reason it's not working is that right after the mob is created, it goes into a loop to check all mobs in view and shoot at them. The problem is, it will only shoot at the mob if it's you (which I think is the opposite of what you intended, unless I'm mistaken), and once it loops through the mobs that are in view that first time, it stops; it never goes through the loop again. Since the security laser is probably created before you are, it never sees you in time to shoot at you.
I'd rewrite it like this:
I think what you really want is something more like that.
Minor problem on the else if: M.density will automatically be 1 if it's bumped at all. You can safely get rid of the else if; del(src) should be called at the end of Bump() anyway unless you intend the laser to keep passing through.
To get rid of the : operator, you need to cast the item to a /mob type so the compiler knows what it's dealing with.
Try this:
Lummox JR