ID:144400
 
Code:
mob
verb
Attack()
if(src.attacking == 0)
if(src.weapontype == "bow")
var/obj/fx/arrow/a = new(src.loc)
a.shooter = src
walk(a,src.dir,1)

src.attacking = 1
src.movement = 0
sleep(7)
src.attacking = 0
src.movement = 1
return


obj/fx/arrow
icon = 'fx.dmi'
icon_state = "arrow"
layer = 50
density = 1
var/mob/shooter
New()
world << "[src.shooter] is shooter" // debug , nothing is the owner
spawn(30)
del src

Bump(atom/O)
if(istype(O,/obj/fx/arrow))
loc = O.loc
return
if(istype(O,/turf/water))
O.density = 0
sleep(5)
O.density = 1
return
if(ismob(O))
if(O == shooter) // player shot a player
return
// shooter.arrow(M) // ATTTTTAAAAAACKKKKK
walk(src,0)


Problem description:

What I am doing is creating an arrow and just making it walk watever direction the shooter is facing. But for some reason, when I try the debug, nothing is set as shooter and
im pretty sure 'a.shooter = src' should be doing that. What is wrong?
Because new() is called before the line a.shooter=src is being run.
In response to Jp
thats wierd because I have totally set owners after creation before..so im not really gettin ya
In response to Drakiel
The lines are called in this order:
var/obj/fx/arrow/a = new(src.loc)
world << "[src.shooter] is shooter" // debug , nothing is the owner
spawn(30)
a.shooter = src
walk(a,src.dir,1)


See what's happening now?
In response to Jp
Ok , I fixed it by messing the the New() proc.

New(Loc,obj/fx/arrow,mob/Owner)
shooter = Owner
world << "[src.shooter] is shooter" // debug , nothing is the owner
walk(src,shooter.dir,1)
spawn(30)
del src

//calling it by

new/obj/fx/arrow(src.loc,src,src)
In response to Drakiel
Good - that's how these sorts of things should be set up.

Except...

New(Loc,obj/fx/arrow,mob/Owner)


How come you've got a '/obj/fx/arrow' argument to the creation of an arrow? And how come it's the mob that owns it when you create it? You can just get rid of that argument.