ID:144737
 
Code:
obj/bullet
icon='keyblades.dmi'
density=1
Bump(mob/M)
if(istype(M,/mob))
M.Health-=5
M.Death()
del(src)
else
..()

mob/proc
Death()
if(src.Health<=0)
world << "[src] died!"
src.loc=locate(2,2,1)
src.Health = 100
src.Mana = 100

mob/verb
Throw_Keyblade()
if(src.kequipt==0)
src<<"You need a keyblade equipted to do this."
else
view()<<"[src] throw's his keyblade!"
var/obj/bullet/B=new(usr.loc)
walk(B,usr.dir)
sleep(7)
walk(B,turn(src.dir,180))


Problem description: Now, I have 2 main problem's. One is that when it comes back to me, it hurt's me and two, I can keep on shooting them even before it comes back to me. How can I fix does two thing's?

1) under if(istype(M,/mob)), check if the item belong to the person it hits (meaning make an extra var here), if it does belong to the person, del src.

2) Again, make another var keeping track to see if it was already thrown and spawn()/sleep() the var back to 0

3) De-indent sleep()

- GhostAnime
In response to GhostAnime
I understood all of it except the check if it's the owner. Do I
do if(istype(M,/src))? Or what I don't understand that part.
In response to DarkD3vil666
You make a var which is the src that throws the thing and put the var in the
if(istype(M,var))

In response to SSJ-Chao
I get an error saying "/var:not a prototype".
In response to DarkD3vil666
You change the bolded var into the variable that is the src, or you.
In response to SSJ-Chao
..The problem with what you guys were talking about is that the var is not (very likely) a path type.. eg: /mob/player

This is what I meant for using a variable for checking if it's the owner:
obj/missile
var/owner//lets say this is the only item that needs an owner var, which is why it's not under /obj only atm
verb/Deploy()
var/obj/missile/M = new(get_step(usr,usr.dir))//location is at 1 step ahead of usr
M.owner=usr//should be obvious
Bump(atom/A)
if(ismob(A))//aka istype(A,/mob)
if(A==owner)//checks if A is the owner
del src//should be obvious


- GhostAnime