ID:1422286
 
(See the best response by Taitz.)
Code:
mob/var
usandocn=0
loopcn=0
mob/verb/chidorinagashi()
set category = "Jutsus"
set name = "Chidori Nagashi"
if(usr.usandocn)
usr<<"Você deve aguardar para utilizar novamente esta habilidade!"
return
else
usr.frozen=1
usr.usandocn=1
usr.loopcn=1
var/turf/T
for(T in oview(2,usr))
var/obj/jutsus/chidorinagashi/N=new(T)
spawn(100) del N
nagashi()
spawn(70)
usr.loopcn=0
usr.usandocn=0
usr.frozen=0
obj/jutsus
chidorinagashi
icon='chidorinagashi.dmi'
mob/proc
nagashi()
for(var/mob/M in oview(2,usr))
if(!usr.loopcn)
return
else
var/dano=usr.Ninjutsu*4
view()<<"[M.name] levou dano de [dano] do chidori nagashi de [usr.name]!"
M.HP-=dano
M.Morte(M,usr)
spawn(5) M.nagashi()


Problem description:When i use the skill, if any mob is on usr oview(2) it works fine, but if it leaves the oview and come back the skill dont work anymore. what should i do??

Could you explain a little more?
In response to Ss4toby
shure, the skill works like this: when used, some objs are created in usr oview(2) and keeps damaging anyone who is inside the area of those objs that is usr oview(2) too. but if someone is not in usr.oview() and in the middle of the skill gets in there, its not damaging, and i want it to do so. understand my point? xD
Best response
First of all, you have a bad habit of using usr where you shouldn't, it is bad practice. usr should only be used in pseudo-verbs such as Click(), DblClick() etc, otherwise you should use src or none at all, since it would refer to the current object.

Also the problem you are experiencing is caused by the way you loop the nagashi() proc. A possible solution would be the following:
mob/proc
nagashi()
while(loopon) // Loop the nagashi while it is true.
for(var/mob/m in orange(2,src)) // Use orange() instead of oview, it will include invisible players as well in case you intend to use em.
var/dano=Ninjutsu*4 // Same damage calculation as yours.
view()<<"Text of your choice." // Output some message of your choosing.
m.HP-=dano // Detuct the damage from the enemy.
spawn m.Morte(m,src) // Instead of doing the death check right after the damage reduction you can do it in parallel.
sleep(5) // Sleep for 5 milliseconds, you can change it based on your choosing.,
In response to Taitz
thankx a lot =) im new here so i have some bad habits yet but im working on them x) apreciate your help.
In response to Taitz
hey, i did as you said, and now even when the skill finishs the loop continues and when the mob leave the orange() the game lags really hard. you know why? because i dont xD
This is the msg i get when the mob leaves the orange():
Infinite loop suspected--switching proc to background.
If it is not an infinite loop, either do 'set background=1' or set world.loop_checks=0.
proc name: nagashi (/mob/proc/nagashi)
usr: Tuckax (/mob/player)
src: Tuckax (/mob/player)
call stack:
Tuckax (/mob/player): nagashi()
Tuckax (/mob/player): Chidori Nagashi()
It's simple, you have to call the nagashi() function by doing this:
spawn nagashi()

When you do not use the spawn, then the skill will not turn off after 70 milliseconds as it is stated, since the nagashi() blocks the continuation of the skill. Using spawn to call nagashi() you make it work in parallel with the following statements within the verb.
In response to Taitz
idk what im doing wrong here is the code:
Code:
mob/var
usandocn=0
loopcn=0
mob/verb/chidorinagashi()
set category = "Jutsus"
set name = "Chidori Nagashi"
if(usr.usandocn)
usr<<"Você deve aguardar para utilizar novamente esta habilidade!"
return
else
usr.frozen=1
usr.usandocn=1
usr.loopcn=1
var/turf/T
for(T in oview(2,usr))
var/obj/jutsus/chidorinagashi/N=new(T)
spawn(70) del N
spawn nagashi()
spawn(70)
usr.loopcn=0
usr.usandocn=0
usr.frozen=0
obj/jutsus
chidorinagashi
icon='chidorinagashi.dmi'
mob/proc
nagashi()
while(loopcn)
for(var/mob/M in oview(2,usr))
var/dano=usr.Ninjutsu*4
view()<<"[M.name] levou dano de [dano] do chidori nagashi de [usr.name]!"
M.HP-=dano
spawn M.Morte(M,src)
sleep(5)

im still getting this msg after a mob leaves the oview():
Infinite loop suspected--switching proc to background.
If it is not an infinite loop, either do 'set background=1' or set world.loop_checks=0.
proc name: nagashi (/mob/proc/nagashi)
usr: Tuckax (/mob/player)
src: Tuckax (/mob/player)
call stack:
Tuckax (/mob/player): nagashi()
Tuckax (/mob/player): Chidori Nagashi()

please help xD
Your loop isn't delayed any, so it spirals out of control before it can finish, the sleep() inside of the for() loop isn't going to work for the while() because they're not in the same block of code so basically you're spawning a ton of for() loop calls that take time to complete.

while(loopcn)
for(var/mob/M in oview(2,src))
// Code here
sleep(5) // See the indentation difference here.


I'm not even going to get started on all of the other glaring problems with your code though, one problem at a time.
In response to Nadrew
dude thanks, i really apreciate your help and i was able to learn a lot from it =) god bless you