ID:1794907
 
(See the best response by Kaiochao.)
Code:
shadowfist
icon='shadowfist.dmi'
layer=5
density=1
nopassive=1
New()
..()
spawn(20)if(src)del src
Bump(A)
if(istype(A,/mob))
var/mob/O=owner
var/mob/D=A
if(O && D)
loc=D.loc
if(O.aff==D.aff)return
var/damage=O.pow*0.25
damage+=(D.maxhp-D.hp)*0.03
if(O.imitation==D)damage*=1.2
if(O.tier42)D.deadlyshadows(20*O.tier42)
D.dmgch(O)
damage=(damage*D.variable)+D.variable2
D.damage(damage)
D.death(O)
if(istype(A,/turf))
var/turf/T = A
if(T.density)
loc=T.loc
if(istype(A,/obj))
var/obj/T = A
if(T.density)
projduel(A)


For some reason, I keep getting an error with this.

if(istype(A,/turf))
var/turf/T = A
if(T.density)
loc=T.loc


It has something to do with that --^

BUG: Bad ref (2:41065) in IncRefCount(DM Nara Jutsus.dm:852)
BUG: Bad ref (2:41065) in DecRefCount(DM Nara Jutsus.dm:852)

Those are the errors I get. It's line 852, which is:
loc=T.loc



On an unrelated note, I was told I shouldn't delete objects through New(). Is there a better way to go about doing this?
Best response
Error aside, you should be setting loc to T (the turf), not T.loc (the area containing the turf T).
Does that apply to objects as well? Some objects I also do loc=T.loc