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

View file

@ -86,18 +86,18 @@ static bool resurrect_unit(unit *u) {
change_effect(u, oldpotiontype[P_HEAL], 3); change_effect(u, oldpotiontype[P_HEAL], 3);
heiltrank = true; heiltrank = true;
} }
if (heiltrank && chance(0.50)) { if (heiltrank && (rng_int() % 2)) {
return true; return true;
} }
} }
return false; return false;
} }
static int static int damage_unit(unit * u, const char *dam, bool physical, bool magic)
damage_unit(unit * u, const char *dam, bool physical, bool magic)
{ {
int *hp, hpstack[20]; int *hp, hpstack[20];
int h; int h;
int healings;
int i, dead = 0, hp_rem = 0; int i, dead = 0, hp_rem = 0;
assert(u->number); assert(u->number);
@ -134,6 +134,9 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
hp[i] -= damage; 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 */ /* Auswirkungen */
for (i = 0; i < u->number; i++) { for (i = 0; i < u->number; i++) {
if (hp[i] <= 0) { 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[i] = u->hp / u->number;
hp_rem += hp[i]; hp_rem += hp[i];
} }
else if (resurrect_unit(u)) { else if (healings > 0) {
/* Heiltrank */ --healings;
if (resurrect_unit(u)) {
/* Heiltrank benutzen */
hp[i] = u->hp / u->number; hp[i] = u->hp / u->number;
hp_rem += hp[i]; hp_rem += hp[i];
} }
@ -151,6 +156,10 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
++dead; ++dead;
} }
} }
else {
++dead;
}
}
else { else {
hp_rem += hp[i]; hp_rem += hp[i];
} }