mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
agent::attack_dir(): Do not deal instantkills, instead deduce just some amount of energy
This commit is contained in:
parent
83bbb30125
commit
56c30d4086
1 changed files with 6 additions and 8 deletions
14
agent.cc
14
agent.cc
|
@ -81,16 +81,14 @@ agent::attack_dir(int dir_x, int dir_y)
|
|||
if (dead || a->dead)
|
||||
return true;
|
||||
|
||||
/* Very simple RPG-ish interaction. */
|
||||
int attack_dice = round(attr.attack * energy);
|
||||
int attack_roll = random() % attack_dice;
|
||||
int defense_dice = round(a->attr.defense * a->energy);
|
||||
|
||||
int dice = random() % (attack_dice + defense_dice);
|
||||
if (dice < attack_dice) {
|
||||
a->die();
|
||||
} else {
|
||||
die();
|
||||
}
|
||||
return true;
|
||||
int defense_roll = random() % defense_dice;
|
||||
if (attack_roll > defense_roll)
|
||||
a->chenergy(defense_roll - attack_roll);
|
||||
return attack_roll >= defense_roll;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue