agent::attack_dir(): Do not deal instantkills, instead deduce just some amount of energy

This commit is contained in:
Petr Baudis 2011-12-03 19:46:43 +01:00
parent 83bbb30125
commit 56c30d4086

View file

@ -81,16 +81,14 @@ agent::attack_dir(int dir_x, int dir_y)
if (dead || a->dead) if (dead || a->dead)
return true; return true;
/* Very simple RPG-ish interaction. */
int attack_dice = round(attr.attack * energy); int attack_dice = round(attr.attack * energy);
int attack_roll = random() % attack_dice;
int defense_dice = round(a->attr.defense * a->energy); int defense_dice = round(a->attr.defense * a->energy);
int defense_roll = random() % defense_dice;
int dice = random() % (attack_dice + defense_dice); if (attack_roll > defense_roll)
if (dice < attack_dice) { a->chenergy(defense_roll - attack_roll);
a->die(); return attack_roll >= defense_roll;
} else {
die();
}
return true;
} }
void void