ID:264996
 
Code:
    Tackle(mob/M in oview(1))
set category = "Attacks"
set name = "Tackle"
src.atkpwr=50
src.isspatk=1
if(!src.tacklepp){src<<"No PP left for this move!"; return}
else {src.tacklepp-=1}
view() << "<font color=red><i>[src] used Tackle!<br>[src.dmg] damage! "
src.DmgCalc(M)
src <<"<font color=white>[src.tacklepp] PP left!"
M.hp-=src.dmg


DmgCalc(mob/M)
if(src.type1==src.type2==src.atktype)
src.STAB=1.5
else
src.STAB=1
src.WRcheck(M)
if(src.isspatk)//send var to this proc
ATKStat=spatk
else
ATKStat=atk
var/A=2 * src.lvl / 5 + 2
var/B=A * src.ATKStat * src.atkpwr / M.def
var/C=B / 50
var/D=C + 2
var/E=rand(85,100)
var/F=D * src.STAB * src.WR * E / 100
var/H=round(F,1)
src.dmg=H
if(prob(6.25))
src.dmg *= 2
view()<<"<u>Critical Hit!"


Problem description:Im making a pokemon game (clearly) and i have a few attacks for testing with damage calculation but if its a Critical Hit, the damage applies in the next attack, not the one that says it was a Critical Hit.
Heres a screenshot
I saw a post in the forum yesterday about someone elses proc running "sleep(55)" after "flick(something about smoke)" even though sleep() came first in the coding. Is this a BYOND problem or a coding error on my part?
if(src.type1==src.type2==src.atktype)


How does this even compile?
In response to Jotdaniel
My friend told me to use that when i asked how would i check two variables for one other. I never tested to see if it actually worked but it doesnt give me issues so its not of major concern atm Lol.
Never mind. I found the issue. I had it displaying the damage before it calculated it. Just ignore all of this. Lol
In response to Quiet Screams
Anyway, to the actual problem at hand, your calling the damage caculation proc after displaying the damage dealt, so your always showing the damage done in the previous attack. This is also why your first attack showed null damage. The mechanics are working behind the scenes, you just fudged your display :P
In response to Jotdaniel
I actually figured this out like 2 minutes ago, xD but thanks.