ID:142766
 
Code:
mob
proc
beam()
var/obj/A = new/obj/KamehamehaHead()
A.dir = src.dir
A.loc = src.loc
while(A)
var/obj/B = new/obj/KamehamehaTrail()
var/list/L[]
B.dir = A.dir
L+=B
sleep(2)
B.loc = A.loc
step(A,A.dir)
var/turf/T =A.loc
if(T.density)
del A
for(B in L)
del B

else
for(var/mob/M as mob in T)
if(M==src) continue
world<<"[M] has been hit by [src]'s Kamehameha"
del A
for(B in L)
del B


Problem description: The Beams head will delete fine, but the trail wont...anyone see the problem? thanks

It deletes them from the list, not from the world.

    var/trails = list()     
for(var/obj/trail/T in world)
if(T in trails)
del T


Further example:

obj
var/trails = list()

proc
Travel()
var/turf/T = get_step(src,src.dir)
if(!T || T.density == 1)
del src
else
var/obj/blast_trail/BT = new/obj/blast_trail(src.loc)
BT.dir = src.dir
src.trails += BT
step(src,src.dir)
spawn(5) Travel()
blast_head
density = 1
Del()
for(var/obj/blast_trail/BT in world)
if(BT in src.trails)
del BT
..()

blast_trail
density = 1

mob/verb/blast()
var/obj/blast_head/B = new/obj/blast_head(get_step(src,src.dir))
B.dir = src.dir
B.Travel()
hmm well why to put
for(var/mob/M as mob in T)
first when you put mob/M that means the M is already a mob why to put mob/M as mob? o.o well i think you should use a Bump() proc in the KamehamehaHead() hmm also delete ALL that proc because it wont real work better go to the KamehamehaHead code and put something like this:
obj
projectile
Kamehameha
icon='kamehameha.dmi'
icon_state = "kame_head"
density = 1
New()
spawn(75)
del (src)
Move()
var/turf/old_loc = src.loc
. = ..()
spawn()
if(!.) return
var/obj/O = new(old_loc)
O.dir = src.dir
O.icon = 'kamehameha.dmi'
O.icon_state="kame_tail"
src.trails += O
O.Owner = src
Bump(A)//under this defind how the bump will work
Del()
for(var/obj/o in src.trails)
del(o)
..()


mob/var/Owner
well now i can bet it will give you undefined path errorr so go to errorr line and add /projectile next to the new/obj also defind the blast's owner as the src/usr
In response to Siientxx
ok ive tried implementing the code and changing things left right and center, but fixing 1 error leads to another which fixing leads to 3 more and i just cant keep up.

im gunna post all the code i have that revolves around the beam and maybe someone can explain how to simplify it

mob
proc/tmp
Beamstrength()
BeamStrength = BeamStrength+1
sleep(5)
if(BeamStrength >= 10)
Charging = 0
usr.locked = 0
BeamStrength = 0
usr.icon_state = ""
usr.overlays-='projectiles{kamehameha-charge}.dmi'
return
mob
proc/tmp
Beamstrength2()
if(BeamStrength >= 1)
beam()
while(BeamStrength >= 1)
BeamStrength = BeamStrength-1
sleep(5)
usr.locked = 1
return
else
usr.icon_state = ""
usr.locked = 0
return


mob
All
verb
Kamehameha()
set category = "Skills"
if(Charging == 0)
usr.locked = 1
Charging = 1
usr.icon_state = "Kamehameha Charge"
usr.overlays+='projectiles{kamehameha-charge}.dmi'
while(Charging == 1)
Beamstrength()
else
if(BeamStrength >=3)
usr.icon_state = "Kamehameha Release"
usr.overlays-='projectiles{kamehameha-charge}.dmi'
Beamstrength2()


ok this is the 1st part of the code. to explain what it does simply if your not using it then you will start to charge, once the beam strength >3 and you re-click you will enter beamstrength2 proc which will release the beam

mob/proc/beam()
var/obj/KamehamehaHead/B = new/obj/KamehamehaHead(get_step(src,src.dir))
B.dir = src.dir
B.Travel()

obj/var/trails = list()

mob/proc/Travel()
var/turf/T = get_step(src,src.dir)
if(!T || T.density == 1)
del src
else
var/obj/KamehamehaTrail/BT = new/obj/KamehamehaTrail(src.loc)
BT.dir = src.dir
src.trails += BT
step(src,src.dir)
spawn(5) Travel()

obj/KamehamehaHead
icon = 'projectiles{finalflash-release}.dmi'
icon_state = "end"
density = 1
Del()
for(var/obj/KamehamehaTrail/BT in world)
if(BT in src.trails)del BT
..()


now this is my attempt at twisting your code around Siientxx..as you can peobly tell i havent done a very gd job (otherwise i owuldnt be posting for help lol)

problem being im getting loads of duplicate definition erros and loads more others. if anyone wants to scan through the code and tell me where its going wrong please feel free to do so. cheers.
In response to Ultimate165
on the obj/Kamehameha code the dm tags under the Del() are kinda messed up o.o also you tried my code?
In response to Ultimate165
You don't have to put return at the end of those procs (Which should not be tmp) because that's the end of it any way. Also, you should tab over the code under Del(). The proc Travel() is for objects only, in this case, for the beams. So change it to obj/proc/Travel() from mob/proc/Travel(). Trails is also an obj only variable list so it should be obj/var/trails = list()

    for(var/obj/KamehamehaTrail/BT in world)
if(BT in src.trails)
del BT
..()


Also, read up on boolean. Instead of charging == 0 and charging == 1 use !charging and charging. Here's the travel proc, fixed a bit, in optional sense.

obj/proc/Travel()
var/atom/A = get_step(src,src.dir)
if(!A)
del src; return
else
var/obj/KamehamehaTrail/BT = new/obj/KamehamehaTrail(src.loc)
BT.dir = src.dir
src.trails += BT
step(src,src.dir)
spawn(5) Travel()


Bump() should delete the blast if it bumps a dense atom, excluding mob, which is where it would deal damage or whatever.

In response to Aang-Air bender
yea i tried your code.

mob/proc/beam()
obj
Kamehamehahead
icon = 'projectiles{finalflash-release}.dmi'
icon_state = "end"
density = 1
New()
spawn(75)
del (src)
Move()
var/turf/old_loc = src.loc
. = ..()
spawn()
if(!.) return
var/obj/O = new(old_loc)
O.dir = src.dir
O.icon = 'projectiles{finalflash-release}.dmi'
O.icon_state="middle"
src.trails += O
O.Owner = src
Bump(A)//under this defind how the bump will work
Del()
for(var/obj/o in src.trails)
del(o)
..()


mob/var/Owner


got these 3 errors

Procs.dm:45:error:src.trails:undefined var
Procs.dm:46:error:O.Owner:undefined var
Procs.dm:49:error:src.trails:undefined var

In response to Ultimate165
put
mob/var/Owner
and
obj/var/list/trails = list()
In response to Aang-Air bender
sorry, neither of your codes are working for me lol. starting to give me a headache now so im gunna shoot off to bed, ill post both of your codes how ive got them and the errors im recieving.

obj/var/list/trails = list()
mob/proc/beam()
obj
Kamehamehahead
icon = 'projectiles{finalflash-release}.dmi'
icon_state = "end"
density = 1
New()
spawn(75)
del (src)
Move()
var/turf/old_loc = src.loc
. = ..()
spawn()
if(!.) return
var/obj/O = new(old_loc)
mob/var/Owner
O.dir = src.dir
O.icon = 'projectiles{finalflash-release}.dmi'
O.icon_state="middle"
src.trails += O
O.Owner = src
Bump(A)//under this defind how the bump will work
Del()
for(var/obj/o in src.trails)
del(o)
..()


loading Style.dms
Procs.dm:46:error:O.Owner:undefined var
Procs.dm:41:mob :warning: unused label
Procs.dm:41:Owner :warning: variable defined but not used

no matter where i stick that damned mob/var/Owner it will not define the damn thing lol getting very stressing :(


mob/proc/beam()
var/obj/KamehamehaHead/B = new/obj/KamehamehaHead(get_step(src,src.dir))
B.dir = src.dir
B.Travel()

obj/var/trails = list()

obj/proc/Travel()
var/turf/T = get_step(src,src.dir)
if(!T || T.density == 1)
del src
else
var/obj/KamehamehaTrail/BT = new/obj/KamehamehaTrail(src.loc)
BT.dir = src.dir
src.trails += BT
step(src,src.dir)
spawn(5) Travel()

obj/KamehamehaHead
icon = 'projectiles{finalflash-release}.dmi'
icon_state = "end"
density = 1
Del()
for(var/obj/KamehamehaTrail/BT in world)
if(BT in src.trails)
del BT
..()


Procs.dm:41: Inconsistent indentation.
Procs.dm:50: Inconsistent indentation.
Stats.dm:1:error: mob: expected end of statement

and with this code im getting an inconsistent indentation error with the del BT at the bottom.

thanks for your help guys, gdnight.


In response to Ultimate165
I've tested my code, and it works. The reason it's not working is on your side. :/
The list is being recreated on each iteration of the loop. The declaration of L needs to be outside the while().

Also, you need to indent the del B line once more, so that it's within the for() loop.
In response to Ultimate165
mob/proc/beam()
var/obj/KamehamehaHead/B = new/obj/KamehamehaHead(get_step(src,src.dir))
B.dir = src.dir
B.Travel()

obj/var/trails = list()

obj/proc/Travel()
var/turf/T = get_step(src,src.dir)
if(!T || T.density == 1)
del src
else
var/obj/KamehamehaTrail/BT = new/obj/KamehamehaTrail(src.loc)
BT.dir = src.dir
src.trails += BT
step(src,src.dir)
spawn(5) Travel()

obj/KamehamehaHead
icon = 'projectiles{finalflash-release}.dmi'
icon_state = "end"
density = 1
Del()
for(var/obj/KamehamehaTrail/BT in world)
if(BT in src.trails)
del BT
..()


Procs.dm:48:error:BT:duplicate definition
Procs.dm:48:error:world:duplicate definition
Procs.dm:48:error:in :instruction not allowed here
Procs.dm:48:error::empty type name (indentation error?)
Procs.dm:49:error:BT:duplicate definition
Procs.dm:49:error:src.trails:duplicate definition
Procs.dm:49:error:in :instruction not allowed here
Procs.dm:49:error::empty type name (indentation error?)
Procs.dm:50:error:BT:value not allowed here
Procs.dm:50:error:del :instruction not allowed here
Procs.dm:50:error::empty type name (indentation error?)
Procs.dm:49:error::empty type name (indentation error?)

errors after errors lol
In response to Garthor
this doesnt work either. the beam only fires 1 space and the trail delete code still doesnt work
In response to Siientxx
mob/proc/beam()
var/obj/KamehamehaHead/B = new/obj/KamehamehaHead(get_step(src,src.dir))
B.dir = src.dir
B.Travel()

obj/var/trails = list()
var/obj/KamehamehaTrail/BT

obj/proc/Travel()
var/turf/T = get_step(src,src.dir)
if(!T || T.density == 1)
del src
for(var/obj/KamehamehaTrail/BT in world)
if(BT in src.trails)
del BT
..()


else
var/obj/KamehamehaTrail/BT = new/obj/KamehamehaTrail(src.loc)
BT.dir = src.dir
src.trails += BT
step(src,src.dir)
spawn(5)
Travel()


ok i messed with the code a bit more...it now compiles...but wont delete the trails...well it deletes the last trail, not the ones before it lol
In response to Ultimate165
well take out one of those dm tags from the Del() line and i TOLD you to defind the dmg under the Bump(A)
In response to Ultimate165
Then you didn't follow my advice.