ID:143836
 
Code:
mob
Warrior_Skills
verb/Double_Strike(mob/M as mob in oview(1))
set category = "Skills"
M.attacked = 1
var/damage = usr.Strength*2-M.Defense+rand(0,5)
M.Health -= damage
if(damage > 0)
Double_Strike = rand(1,3)
if(Double_Strike==2)
M << "[usr] attacks you and does [damage] damage"
usr. << "[src]: Double Strike!"
M.Health-=damage
else
usr. << "You missed!"
else
M << "[usr]'s attack bounces off of you!"
usr << "Your attack bounces off of [src]!"
M.Deathcheck()
usr.Levelup()


Problem description:
I'm trying to make skills for classes and this is one for my Warrior classes. Anyway when I use this skill on a monster it says that I miss but the monster still takes damage and dies anyway. Sometimes it will say that I perform the skill but it usually doesnt. Anyone know why?

> mob
> Warrior_Skills
> verb/Double_Strike(mob/M as mob in oview(1))
> set category = "Skills"
> M.attacked = 1
> var/damage = usr.Strength*2-M.Defense+rand(0,5)
> M.Health -= damage //M is being hit here and takes the damage every time.
> if(damage > 0)
> Double_Strike = rand(1,3)
> if(Double_Strike==2)
> M << "[usr] attacks you and does [damage] damage"
> usr. << "[src]: Double Strike!"
> M.Health-=damage
> else
> usr. << "You missed!" //You failed to do the Double Strike, but M still gets the damage from above.
> else
> M << "[usr]'s attack bounces off of you!"
> usr << "Your attack bounces off of [src]!"
> M.Deathcheck()
> usr.Levelup()
>


As you can see, M is taking the damage from the first hit every time. Even if you fail to do the Double Strike, M's Health is still being decreased and he is dying when you do your Deathcheck().
In response to Zythyr
Oh i see now. Thnx for the help
In response to Monkeykid0049
Also, the Double_Strike variable is unneeded. Instead of randomizing it and checking if it's 2, just use if(prob(33)).