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,10 +145,16 @@ 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 */
hp[i] = u->hp / u->number;
hp_rem += hp[i];
else if (healings > 0) {
--healings;
if (resurrect_unit(u)) {
/* Heiltrank benutzen */
hp[i] = u->hp / u->number;
hp_rem += hp[i];
}
else {
++dead;
}
}
else {
++dead;
@ -268,7 +277,7 @@ static bool stop_smoke_chance(void) {
if (config_changed(&cache)) {
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) {
@ -276,12 +285,12 @@ static bool outbreak_chance(void) {
if (config_changed(&cache)) {
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;
t_volcano = get_terrain("volcano");