ID:174612
 
This proc doesn't do anything and I have no idea why.
mob/proc/Hitdelay()
if(usr.spd>=0 && usr.spd<=3)
usr.delay=10
if(usr.spd>=4 && usr.spd<=7)
usr.delay=9
if(usr.spd>=8 && usr.spd<=11)
usr.delay=8
if(usr.spd>=12 && usr.spd<=15)
usr.delay=7
if(usr.spd>=16 && usr.spd<=19)
usr.delay=6
else
usr.delay=0
if(usr.spd>=16 && usr.spd<=19)
usr.delay=6
else
usr.delay=0

This is the problem. Look carefully at the actual logic of the code. You're doing all those other ifs, and then you undo all that effort by effectively saying "if usr.spd is less than 16 or larger than 19, set usr.delay to zero". Whoops... =)

All of those ifs (except the first one) should be changed to "else if". Then it should work.

Oh, and it's probably better to use src rather than usr here. For a detailed explanation of this, see usr Unfriendly. If you can't be bothered reading it all, or don't understand it, just remember to use usr ONLY when you can't use anything else. =)
In response to Crispy
Crispy wrote:
Oh, and it's probably better to use src rather than usr here. For a detailed explanation of this, see usr Unfriendly. If you can't be bothered reading it all, or don't understand it, just remember to use usr ONLY when you can't use anything else. =)

Actually that's a really bad rule of thumb for usr, because a lot of people already mistakenly assume that's the way to use it. Like in Entered(), when they forget there's an argument to the proc: they know src is wrong, so they use usr. Instant disaster.

The right rule of thumb is: No put usr in proc. Ungh.

Lummox JR
In response to Crispy
That didnt work

Heres the proc:
mob/proc/Hitdelay()
if(src.spd==0)
src.delay=14
else if(src.spd>=0 && src.spd<=3)
src.delay=10
else if(src.spd>=4 && src.spd<=7)
usr.delay=9
else if(src.spd>=8 && src.spd<=11)
src.delay=8
else if(src.spd>=12 && src.spd<=15)
src.delay=7
else if(src.spd>=16 && src.spd<=19)
src.delay=6
else
src.delay=0


And here is the verb that runs it

mob/pbag/verb/punch()
set name="Punch"
set desc="Throw a punch with your fist"
-----> usr.Hitdelay()
-----> sleep(usr.delay)
-----> usr.delay=0
if(usr.energy>=0)
set src in oview(1)
usr.potentialp=(usr.pl/usr.potential)*100
usr.energyp=(usr.energy/usr.menergy)
usr.energypd=usr.energyp*100
flick("wpunch",usr)
flick("hitpbag", src)
if(usr.spoints>=12)
usr.spd+=1
usr.spoints=0
if(usr.stpoints>=10)
usr.str+=1
usr.stpoints=0
if(usr.epoints>=1)
usr.menergy+=1
usr.epoints=0
if(usr.potentialp>=0 && usr.potentialp<=20)
usr.stpoints+=1/10*usr.energyp
usr.pl+=usr.str/5*usr.energyp
usr.epoints+=1/10*usr.energyp
usr.spoints+=1/15*usr.energyp
usr.energy -= usr.str/1
if(usr.potentialp>20 && usr.potentialp<=50)
usr.stpoints+=1/20*usr.energyp
usr.pl+=usr.str/15*usr.energyp
usr.epoints+=1/20*usr.energyp
usr.spoints+=1/25*usr.energyp
usr.energy-=usr.str
if(usr.potentialp>50 && usr.potentialp<=65)
usr.stpoints+=1/50*usr.energyp
usr.pl+=usr.str/50*usr.energyp
usr.epoints+=1/50*usr.energyp
usr.spoints+=1/60*usr.energyp
usr.energy-=usr.str
if(usr.potentialp>65 && usr.potentialp<=90)
usr.stpoints+=1/50*usr.energyp
usr.pl+=usr.str/75*usr.energyp
usr.epoints+=1/50*usr.energyp
usr.spoints+=1/60*usr.energyp
usr.energy-=usr.str
if(usr.potentialp>90 && usr.potentialp<=100)
usr.stpoints+=1/100*usr.energyp
usr.pl+=usr.str/150*usr.energyp
usr.spoints+=1/115*usr.energyp
usr.epoints+=1/100*usr.energyp
usr.energy-=usr.str
if(usr.potentialp>=100)
pl+=0
usr << "You don't think you can get any stronger"
else
pl+=0
else
usr << "You are too tired to continue"


I've asked several people and they can't find anything wrong with it. I'd really appreciet it if someone could fix it. I don't get any errors but when I punch, there is no delay.
In response to Tokabol
usr.Hitdelay()
i know it might not seem like much, but have you tried using it without the ? eg.
usr.Hitdelay()

In response to Lazyboy
That was supposed to be an html tag but it didnt work.
In response to Tokabol
I found out that the proc does work but not like I wanted to. It just delays the time before he punches but the stat gain doesn't change. How should I run the proc so that the stat gain slows down.
In response to Tokabol
I fixed it, it works just the way I want to so theres no need to respond to this post. A moderator may close it if they wish.