ID:1673478
 
(See the best response by Pirion.)
Code:
obj
Jutsu
Sand_Wave
icon = 'SHOP.dmi'
icon_state = "sandwave"
jutsu = 1
Jlevel = 3
Click()
Sand_Wave()
verb
Sand_Wave()
var/objsteps = 9
var/damage = usr.chakrapower
if(Jlevel == 3)
chakracost = 10
if(usr.chakra >= chakracost)
usr.stunned = 1
flick("Handseals",usr)
usr.stunned = 0
var/obj/O =new/obj/sandwave/sandwavehead(usr.loc)
var/obj/f =new/obj/sandwave/sandwavehead(usr.loc)
var/obj/l =new/obj/sandwave/sandwavehead(usr.loc)
f:loc = get_step(O,NORTH)
l:loc = get_step(O,SOUTH)
usr.chakra -= src.chakracost
O:owner = usr
O:owners = usr
O:jdamage = damage
O:village = usr.village
O:objsteps = objsteps
O:dir = usr.dir
O:gosandwave(O)
f:owner = usr
f:owners = usr
f:jdamage = damage
f:village = usr.village
f:objsteps = objsteps
f:dir = usr.dir
f:gosandwave(f)

else
usr<< "you dont have enough chakra"
return

obj
sandwave
var/objsteps
var/village
var/owners
var/jdamage
sandwavehead
density = 1
icon = 'sandwave.dmi'
icon_state = "sandwavehead"
Bump(atom/a)
if(ismob(a))
src.density = 0
spawn(5)
src.density = 1
if(village == a:village)
return
if(owners == a)
return
a:stunned = 5
//a:stunned() edit
a:SandA = 1
a:myattacker = src.owner
src.jdamage -= a:defence
if(src.jdamage <=0)
src.jdamage = 0
a:health -= src.jdamage
a:DeathCheck()
if(isobj(a))
src.density = 0
spawn(5)
src.density = 1






obj
proc
gosandwave(var/obj/O)
set background = 1
src = O
step(src,src:dir)
step_size = 16
var/old_loc = src.loc
while(src)
if(src.loc != old_loc)
var/WB = new/obj/sand_wave/sandwaveback(src.loc)
old_loc = src.loc
WB:dir = src.dir
sleep(1)
if(src:objsteps <=0)
spawn(50)
del(src)
else
src:objsteps -=1
step(src,src.dir)


Sorry to be a bother but i cant figure this one out, i am trying to make a 32x96 sand wave projectile by piecing together 3 32x32 objects. I can spawn the objects where i want them HOWEVER, only one sand wave will move at a time, once it deletes itself the next one will start. the sand wave is a object that leaves a trail behind i didnt include its refrence. PLEASE HELP ME... i think it may be something with the gosandwave() proc but no changes i make fix it.

Thank you in advance
Deidarac4

Best response
You need to set waitfor to 0 in gosandwave(). The first time you sleep it will return and continue code execution.

THANKYOU! it worked first go i didnt know waitfor existed, thanks again.
In response to Deidarac4
The alternative would be to call the proc using spawn, like "spawn gosandwave()".
Also... sorry if cant add another question...but its to do with using a list() on this obj.
DESC
i run the procedure once there no more steps to be taken and i have two objects in my list i know they are both added to the list but only one type of that object in the list will be deleted (leaving a sand trail or head) i am doing this to delete all object at once. please byond geniuses help me!
PS:i am adding the objects to the list with Add().

obj
var/Dl[null]
proc
deletesl()
if(Dl == null)
return
else if(Dl != null)
for(var/obj/f in Dl)
del(f)
f = null
Dl = null

i cant make the indentation right this time for above ^^^^ sorry guys.
In response to Deidarac4
Deidarac4 wrote:
Also... sorry if cant add another question...but its to do with using a list() on this obj.
DESC
i run the procedure once there no more steps to be taken and i have two objects in my list i know they are both added to the list but only one type of that object in the list will be deleted (leaving a sand trail or head) i am doing this to delete all object at once. please byond geniuses help me!
PS:i am adding the objects to the list with Add().
> obj
> var/Dl[null]
> proc
> deletesl()
> if(Dl == null)
> return
> else if(Dl != null)
> for(var/obj/f in Dl)
> del(f)
> f = null
> Dl = null
>

i cant make the indentation right this time for above ^^^^ sorry guys.

The f=null is unnecessary since del f already nullifies f.
Dl=null should be indented one less to be out of the loop, otherwise you're clearing the list after the first object, forcing the loop to stop.
In response to Kaiochao
thankyou, now when you put it that way... haha i feel silly now. thanks