ID:264638
 
Code:
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).
Does the dodge line work?
The dmg value might not be what you expect.

Try performing a "world << dmg" before the last condition check. Make pure dmg is a valid number and that it truly is less than 1.

ts
In response to Tsfreaks
Tsfreaks wrote:
The dmg value might not be what you expect.

Try performing a "world << dmg" before the last condition check. Make pure dmg is a valid number and that it truly is less than 1.

ts

I wrote:
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).

The dmg variable indeed comes to zero. <s>The block line will only run if it is below 0.</s> The dmg var is -1 and still doing the same thing.

As for dodge it always comes out to around 6. I haven't tweeked the stats to test this out, but I will look and see.
In response to Ultima Anime
I don't know it seems pretty strange if the variable is 0 or below it should be working. Also, are you aware that you are using attacker and victim for the procedure, then calling m and _m in the outputs?
In response to Ulterior Motives
Okay, just tried the dodge var and tweeked other vars. The dmg var no matter how far below 0 it doesn't work same with the block var. I have no clue what is wrong. Yes, I know about using m and _m, I had to break the code down to make it readable and just kept the basic outputs the same. Just so people could get the basic idea when I placed it in Design Philosophy.