ID:263871
 
Code:
obj
ToushirouShikai
Head
icon='Daiguren Hyourinmaru.dmi'
icon_state = "shikai_head"
var/trails = 0
Bump(A)
if(ismob(A))
if(src.Owner==A)
return
else
var/mob/O = src.Owner
var/mob/M = A
var/dmg = (O.rei/3 - M.rei/3 + 40)
if(dmg<=0)
dmg = 0
var/mob/P = M
P.health -= dmg
for(var/obj/D in src.trails)
del (D)
del src
if(M.health<=0)
M.Death(O)
Move()
var/turf/old_loc = src.loc
. = ..()
if(!.) return
var/obj/O = new(old_loc)
O.name = "trail"
O.icon_state="shikai_tail"
O.icon = 'Daiguren Hyourinmaru.dmi'
O.dir = src.dir
src.trails += O


Problem description:

it kinda works the problem is it goes away but i dont want to
                        for(var/obj/D in src.trails)
del (D)
del src


This part is wrong. del(src) should be at the VERY end of the proc. Deleting src will cause the proc to stop and, therefore, nothing else will be processed, including deleting parts of the tail after the first one found, and causing M to die.

            var/trails = 0


This is also wrong. It should be:

            var/list/trails = list()
In response to Garthor
obj
ToushirouShikai
Head
icon='Daiguren Hyourinmaru.dmi'
icon_state = "shikai_head"
density = 1
var/list/trails = list()
Bump(A)
if(ismob(A))
if(src.Owner==A)
return
else
var/mob/O = src.Owner
var/mob/M = A
var/dmg = (O.rei/3 - M.rei/3 + 40)
if(dmg<=0)
dmg = 0
var/mob/P = M
P.health -= dmg
P.Death(O)
for(var/obj/D in src.trails)
del D
del src
Move()
var/turf/oldloc = src.loc
. = ..()
if(!.)return
var/obj/O = new()
O.icon = 'Daiguren Hyourinmaru.dmi'
O.icon_state = "shikai_tail"
O.name = "Tail"
O.density = 1
O.loc = oldloc
O.dir = src.dir
O.Owner = src
src.trails += O


is it good?
In response to Pirata Inmortal
Once again, del(src) cannot be within the for() loop. It has to be outside the loop.