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); 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,10 +145,16 @@ 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;
hp[i] = u->hp / u->number; if (resurrect_unit(u)) {
hp_rem += hp[i]; /* Heiltrank benutzen */
hp[i] = u->hp / u->number;
hp_rem += hp[i];
}
else {
++dead;
}
} }
else { else {
++dead; ++dead;
@ -268,7 +277,7 @@ static bool stop_smoke_chance(void) {
if (config_changed(&cache)) { if (config_changed(&cache)) {
percent = config_get_int("volcano.stop.percent", 12); percent = config_get_int("volcano.stop.percent", 12);
} }
return percent!=0 && (rng_int() % 100) < percent; return percent != 0 && (rng_int() % 100) < percent;
} }
static bool outbreak_chance(void) { static bool outbreak_chance(void) {
@ -276,12 +285,12 @@ static bool outbreak_chance(void) {
if (config_changed(&cache)) { if (config_changed(&cache)) {
percent = config_get_int("volcano.outbreak.percent", 8); percent = config_get_int("volcano.outbreak.percent", 8);
} }
return percent!=0 && (rng_int() % 100) < percent; return percent != 0 && (rng_int() % 100) < percent;
} }
void volcano_update(void) void volcano_update(void)
{ {
region *r; region *r;
const struct terrain_type *t_active, *t_volcano; const struct terrain_type *t_active, *t_volcano;
t_volcano = get_terrain("volcano"); t_volcano = get_terrain("volcano");