ID:144046
 
Code:
    verb/Attack(mob/M in oview(1))
set category = "Battle"
var/damage = src.str - M.def
if(M.client)
M.hp -= damage
src.Levelup()
M.Deathcheck(src)
else
if(usr.Waiting <= 0)
M.hp -= damage
usr.Waiting = 1
var/waittime = round(usr.Weaponwaitime * 2)
spawn(waittime)
usr.Waiting = 0
src.Levelup()
M.Deathcheck(src)


Problem description:

When my defense gets higher then the enemy's strenght, they do negative damage. I need help badly, anyone who helps will be greatly appritiated!!
if(damage <= 0) damage=0

Quite simple.


--Vito
In response to Vito Stolidus
Using <= instead of < there is quite useless. =)
I suggest you use the max() and you can set a minimum damage it has to do. If you always want it to do at least 1 damage then make the max 1.
In response to CYN
Yeah, probably the best way to set minimum and maximum caps for values is to just use min() and max(), no checks needed.
In response to Kaioken
damage = max(damage,0)