ID:2035411
 
(See the best response by Kaiochao.)
Code:
obj
lanza
icon='lanca.dmi'
density = 1
speed = 14
New()
spawn(100)
del src
Bump(A)
if(ismob(A))
var/mob/M = A
for(var/obj/Lanzatrail/G in world)
del G
if(M == src.Gowner)
del src
return
if(M.ispedal)
del src
return
for(var/mob/M in view(8,src)) if(istype(M,/mob))
spawn(1)
var/mob/O = src.Gowner
var/damage = O.reiatsu*2 - M.reiatsu/5
if(damage < 1)
damage = 1
if(O.bankai)
damage = O.reiatsu*2.5 - M.reiatsu/6
if(M.chadref)
var/K = new/obj/reflection(M.loc)
K:attack = damage
K:dir = M.dir
K:Gowner = M
walk(K,M.dir)
del src
M.health -= damage
M.DamageShow(damage)
if(M.enemy)
O.hollowprotection = 1
M.Death(O)
del(src)
if(istype(A,/turf/))
var/turf/T = A
if(T.density)
del(src)
if(istype(A,/obj/))
del(src)


Problem description:
This is supposed to be a projectile, which when it bumps into a mob does AOE dmg, but it doesn't. It only does dmg to the mob it hits. I would appreciate it if someone had an answer for this. Thank you.


Best response
You're deleting it after it damages the first mob, before it can affect the next mob.
Just a heads-up, you're mixing tabs and spaces so your indentation looks atrocious. That could be cleaned up a lot. I also suggest you give K a proper type, so you don't have to abuse the : operator. Using : when you don't have to is bad form; it also prevents you from catching some things at compile-time that would could come up at runtime instead.
Might give you a few ideas on how to improve it.

Setting a atom's loc to null when no references exist of it cause it to be garbage collected(deleted) since it doesn't exist anywhere after setting the location to null instead of a turf for example.

You can set the life of the projectile when you create it inside of the parameters that would be sent to New()

obj/lanza
icon ='lanca.dmi'
density = 1
speed = 14

New(halflife=100)
spawn(halflife)
src.loc = null
..()
Bump(mob/M)
if(istype(M,/obj/) || istype(M,/turf/) || M.ispedal || M == src.Gowner){loc = null;return}
/*
for(var/obj/Lanzatrail/G in world)
G.loc = null
*/


// To improve the above you could instead of using the world's contents keep a list of these objects when created.

var damage, obj/reflect
for(var/mob/Mob in hearers(8,src))
spawn(world.tick_lag)
damage = owner.bankai ? (owner.reiatsu*2.5) - (Mob.reiatsu/6) : (owner.reiatsu*2) - (Mob.reiatsu/5)
if(0 >= damage)
damage = 1
if(M.chadref)
reflect = new/obj/reflection(M.loc)
reflect.attack = damage
reflect.dir = M.dir
reflect.Gowner = M
walk(reflect,M.dir)
damage = round(damage,1)
M.health -= damage
M.DamageShow(damage)
if(M.enemy)
src.Gowner.hollowprotection = 1
M.Death(src.Gowner)
In response to Kozuma3
The object won't be garbage collected since it still has a reference to Gowner.

I could be wrong, but I think this is a leaked source of some kind. With that considered, I think it would safer for the OP to continue using del, otherwise a memory leak is liable to be created.
In response to Kaiochao
Thank you!
In response to FKI
FKI wrote:
The object won't be garbage collected since it still has a reference to Gowner.

The references an object has don't matter; it's only references to the object, not from it, that matter.
In response to Lummox JR
Lummox JR wrote:
FKI wrote:
The object won't be garbage collected since it still has a reference to Gowner.

The references an object has don't matter; it's only references to the object, not from it, that matter.

Appreciate you pointing that out. Somewhere down the line I confused myself.