proc
battle(mob/attacker, mob/victim)
if(victim.stats) // if the victim's stats are null then it can't be attacked because it's a non attackable NPC
//the attacks strength plus a times a random number of 0.5 through 1.5 plus a random number 1 through 3
var/dmg = round(attacker.stats["Strength"] * rand(1/2, 3/2) + rand(1, 3)- \
//minus the same formula for the victims defense
victim.stats["Defense"] * rand(1/2, 3/2) + rand(1, 3))
//same formula for their speed
var/dodge = round(attacker.stats["Speed"] * rand(1/2, 3/2) + rand(1, 3)- \
victim.stats["Speed"] * rand(1/2, 3/2) + rand(1, 3))
//if dodge variable ended up being 0 or less the victim dodged the attack
if(dodge <= 0)
chat("[_m] [pick(dodgemessages)] [m]'s attack.", "battleoutput", view())
//if not attempt to block
else
//if the dmg is 0 or less the victim blocked the attack
if(dmg <= 0)
chat("[_m] [pick(blockmessages)] [m]'s attack.", "battleoutput", view())
//if not do the damage
else
victim.stats["Health"] -= dmg
chat("[m] [pick(attackmessages)] [_m].", "battleoutput", view())
Problem description:
I made some messages that output the dodge and dmg variables to me. Even when the dmg variable is 0 the dmg line runs instead of the block line(last if/else statement).