mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 09:53:38 +02:00
agent::attack_dir(): Cleanup
This commit is contained in:
parent
5638bfae4c
commit
ca7dbc3962
1 changed files with 5 additions and 2 deletions
7
agent.cc
7
agent.cc
|
@ -81,8 +81,11 @@ agent::attack_dir(int dir_x, int dir_y)
|
|||
if (dead || a->dead)
|
||||
return true;
|
||||
|
||||
int dice = random() % ((int) round(attr.attack * energy) + (int) round(a->attr.defense * a->energy));
|
||||
if (dice < attr.attack * energy) {
|
||||
int attack_dice = round(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();
|
||||
} else {
|
||||
die();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue