diff --git a/src/races/dragons.c b/src/races/dragons.c index ec16f78dc..5ab877c40 100644 --- a/src/races/dragons.c +++ b/src/races/dragons.c @@ -27,26 +27,26 @@ static int age_chance(int a, int b, int p) { return (r < 0) ? 0 : r; } -#define DRAGONAGE 27 -#define WYRMAGE 68 +#define DRAGONAGE 27 +#define WYRMAGE 68 + +static void evolve_dragon(unit * u, const struct race *rc) { + scale_number(u, 1); + u_setrace(u, rc); + u->irace = NULL; + u->hp = unit_max_hp(u); +} void age_firedragon(unit * u) { if (u->number > 0 && rng_int() % 100 < age_chance(u->age, DRAGONAGE, 1)) { - double q = (double)u->hp / (double)(unit_max_hp(u) * u->number); - u_setrace(u, get_race(RC_DRAGON)); - u->irace = NULL; - scale_number(u, 1); - u->hp = (int)(unit_max_hp(u) * u->number * q); + evolve_dragon(u, get_race(RC_DRAGON)); } } void age_dragon(unit * u) { if (u->number > 0 && rng_int() % 100 < age_chance(u->age, WYRMAGE, 1)) { - double q = (double)u->hp / (double)(unit_max_hp(u) * u->number); - u_setrace(u, get_race(RC_WYRM)); - u->irace = NULL; - u->hp = (int)(unit_max_hp(u) * u->number * q); + evolve_dragon(u, get_race(RC_WYRM)); } }