agent::attack_dir(): Cleanup

This commit is contained in:
Petr Baudis 2011-12-03 19:25:39 +01:00
parent 5638bfae4c
commit ca7dbc3962

View file

@ -81,8 +81,11 @@ agent::attack_dir(int dir_x, int dir_y)
if (dead || a->dead) if (dead || a->dead)
return true; return true;
int dice = random() % ((int) round(attr.attack * energy) + (int) round(a->attr.defense * a->energy)); int attack_dice = round(attr.attack * energy);
if (dice < attr.attack * energy) { int defense_dice = round(a->attr.defense * a->energy);
int dice = random() % (attack_dice + defense_dice);
if (dice < attack_dice) {
a->die(); a->die();
} else { } else {
die(); die();