server/src/races/dragons.c

53 lines
1.4 KiB
C
Raw Normal View History

/*
2010-08-08 09:40:42 +02:00
*
*
* Eressea PB(E)M host Copyright (C) 1998-2015
2010-08-08 09:40:42 +02:00
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <platform.h>
/* kernel includes */
#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
#define DRAGONAGE 27
#define WYRMAGE 68
2011-03-07 08:03:10 +01:00
void age_firedragon(unit * u)
2010-08-08 09:40:42 +02:00
{
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);
}
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
{
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);
}
2010-08-08 09:40:42 +02:00
}