BUG 2419: fix and speed up volcano-survival through potions.

This commit is contained in:
Enno Rehling 2018-02-16 20:06:36 +01:00
parent ad86e69e6b
commit e697a23f9d
1 changed files with 20 additions and 11 deletions

View File

@ -86,18 +86,18 @@ static bool resurrect_unit(unit *u) {
change_effect(u, oldpotiontype[P_HEAL], 3);
heiltrank = true;
}
if (heiltrank && chance(0.50)) {
if (heiltrank && (rng_int() % 2)) {
return true;
}
}
return false;
}
static int
damage_unit(unit * u, const char *dam, bool physical, bool magic)
static int damage_unit(unit * u, const char *dam, bool physical, bool magic)
{
int *hp, hpstack[20];
int h;
int healings;
int i, dead = 0, hp_rem = 0;
assert(u->number);
@ -134,6 +134,9 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
hp[i] -= damage;
}
/* does this unit have any healing potions or effects? */
healings = i_get(u->items, oldpotiontype[P_HEAL]) * 4;
healings += get_effect(u, oldpotiontype[P_HEAL]);
/* Auswirkungen */
for (i = 0; i < u->number; i++) {
if (hp[i] <= 0) {
@ -142,8 +145,10 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
hp[i] = u->hp / u->number;
hp_rem += hp[i];
}
else if (resurrect_unit(u)) {
/* Heiltrank */
else if (healings > 0) {
--healings;
if (resurrect_unit(u)) {
/* Heiltrank benutzen */
hp[i] = u->hp / u->number;
hp_rem += hp[i];
}
@ -151,6 +156,10 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
++dead;
}
}
else {
++dead;
}
}
else {
hp_rem += hp[i];
}