2010-08-08 09:40:42 +02:00
|
|
|
#include <platform.h>
|
|
|
|
|
|
|
|
/* kernel includes */
|
2014-06-30 03:10:02 +02:00
|
|
|
#include <kernel/race.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
#include <kernel/region.h>
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
|
|
|
|
/* util includes */
|
|
|
|
#include <util/rng.h>
|
|
|
|
|
2019-01-24 17:50:58 +01:00
|
|
|
static int age_chance(int a, int b, int p) {
|
|
|
|
int r = (a - b) * p;
|
|
|
|
return (r < 0) ? 0 : r;
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2019-03-24 17:24:16 +01:00
|
|
|
#define DRAGONAGE 27
|
|
|
|
#define WYRMAGE 68
|
|
|
|
|
|
|
|
static void evolve_dragon(unit * u, const struct race *rc) {
|
|
|
|
scale_number(u, 1);
|
2019-04-25 08:44:48 +02:00
|
|
|
u->hp = unit_max_hp(u);
|
2019-03-24 17:24:16 +01:00
|
|
|
u_setrace(u, rc);
|
|
|
|
u->irace = NULL;
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
void age_firedragon(unit * u)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
if (u->number > 0 && rng_int() % 100 < age_chance(u->age, DRAGONAGE, 1)) {
|
2019-03-24 17:24:16 +01:00
|
|
|
evolve_dragon(u, get_race(RC_DRAGON));
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
void age_dragon(unit * u)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
if (u->number > 0 && rng_int() % 100 < age_chance(u->age, WYRMAGE, 1)) {
|
2019-03-24 17:24:16 +01:00
|
|
|
evolve_dragon(u, get_race(RC_WYRM));
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|