ID:1037077
 
Keywords: attack, combo, wait
Code:
mob/proc
Wait()
if(usr.Hit=="1")
sleep(6)
usr.Hit="0"
return 1
if(usr.Hit=="2")
sleep(6)
usr.Hit="0"
return 1
if(usr.Hit=="3")
sleep(6)
usr.Hit="0"
return 1
if(usr.Hit=="4")
sleep(6)
usr.Hit="0"
return 1


mob/verb
Hit()
set hidden=1
if(usr.Attacking) return
if(usr.Hit=="0")
usr.Attacking=1
spawn(4) if(usr) usr.Attacking=0
flick("Hit1",usr)
usr.Hit="1"
for(var/mob/Enemy/M in get_step(usr,usr.dir))
var/damage = src.Strength-M.Strength
damage=max(0,damage+rand(-1,1))
M.Health-=damage
M.DeathCheck(usr)
return 1
if(usr.Hit=="1")
usr.Attacking=1
spawn(4) if(usr) usr.Attacking=0
flick("Hit2",usr)
usr.Hit="2"
for(var/mob/Enemy/M in get_step(usr,usr.dir))
var/damage = src.Strength-M.Strength
damage=max(0,damage+rand(-1,1))
M.Health-=damage
M.DeathCheck(usr)


Problem description: Two Problems. When I press A it activates the Hit() verb and when I release A it activates Wait() Proc. Problem. I can't get the hit verb to continue the attack if I press it again, and the wait proc doesnt restart the hit var when the sleep is up. Anyone know what I did wrong?

Why does wait need so many of the same if statements ...

mob/proc
Wait()
if(src.Hit == 4) src.Hit = 0 // if it equals the max amount of hits reset to 0
if(src.Hit > 0) // higher than 0 continue
sleep(6)
src.Hit = 0// don't need to use "usr" in this case.
//return 1 // no need for this ? what are you returning too?


mob/verb
Hit()
set hidden=1
if(usr.Attacking) return
if(!usr.Hit)
usr.Attacking=1
spawn(4) if(usr) usr.Attacking=0
flick("Hit[usr.Hit]",usr)
usr.Hit=++ // plus one
for(var/mob/Enemy/M in get_step(usr,usr.dir))
var/damage = src.Strength-M.Strength
damage=max(0,damage+rand(-1,1))
M.Health-=damage
M.DeathCheck(usr)
//return 1// again no need for this.
Still doesn't work.
In response to Isenggard
Isenggard wrote:
Still doesn't work.

You seriously didn't just copy and past that right... we aren't here to program for you.
Their is a much more efficient way to do this I just rearranged your code.. it's just an example of how you can make it much much smaller.
Making it smaller is good and dandy, and I appreciate the help. But I still can't figure out why my attack won't continue if I press A before the wait sleep time is up =P