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)
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue