2010-08-08 09:40:42 +02:00
|
|
|
/* vi: set ts=2:
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
|
|
|
* 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>
|
|
|
|
#include <kernel/config.h>
|
|
|
|
|
|
|
|
/* kernel includes */
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
|
|
|
/* util iclude */
|
|
|
|
#include <util/rng.h>
|
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
#define UNDEAD_MIN 90 /* mind. zahl vor weg gehen */
|
|
|
|
#define UNDEAD_BREAKUP 25 /* chance dafuer */
|
|
|
|
#define UNDEAD_BREAKUP_FRACTION (25+rng_int()%70) /* anteil der weg geht */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2014-03-16 05:03:17 +01:00
|
|
|
#define age_chance(a,b,p) (_max(0,a-b)*p)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
void age_undead(unit * u)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
|
|
|
region *r = u->region;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
/* untote, die einer partei angehoeren, koennen sich
|
2011-03-07 08:03:10 +01:00
|
|
|
* absplitten, anstatt sich zu vermehren. monster
|
|
|
|
* untote vermehren sich nur noch */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
if (u->number > UNDEAD_MIN && !is_monsters(u->faction)
|
|
|
|
&& rng_int() % 100 < UNDEAD_BREAKUP) {
|
2010-08-08 09:40:42 +02:00
|
|
|
int m;
|
|
|
|
unit *u2;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for (m = u->number; m; m--) {
|
2011-03-07 08:03:10 +01:00
|
|
|
if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION)
|
|
|
|
++n;
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|
|
|
|
u2 = create_unit(r, get_monsters(), 0, new_race[RC_UNDEAD], 0, NULL, u);
|
|
|
|
make_undead_unit(u2);
|
|
|
|
transfermen(u, u2, u->number - n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
void age_skeleton(unit * u)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2011-03-07 08:03:10 +01:00
|
|
|
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
|
2014-03-16 05:03:17 +01:00
|
|
|
int n = _max(1, u->number / 2);
|
2011-03-07 08:03:10 +01:00
|
|
|
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
|
2013-05-02 03:50:24 +02:00
|
|
|
u_setrace(u, new_race[RC_SKELETON_LORD]);
|
2010-08-08 09:40:42 +02:00
|
|
|
u->irace = NULL;
|
2011-03-07 08:03:10 +01:00
|
|
|
scale_number(u, n);
|
|
|
|
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_zombie(unit * u)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2011-03-07 08:03:10 +01:00
|
|
|
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
|
2014-03-16 05:03:17 +01:00
|
|
|
int n = _max(1, u->number / 2);
|
2011-03-07 08:03:10 +01:00
|
|
|
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
|
2013-05-02 03:50:24 +02:00
|
|
|
u_setrace(u, new_race[RC_ZOMBIE_LORD]);
|
2010-08-08 09:40:42 +02:00
|
|
|
u->irace = NULL;
|
2011-03-07 08:03:10 +01:00
|
|
|
scale_number(u, n);
|
|
|
|
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_ghoul(unit * u)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2011-03-07 08:03:10 +01:00
|
|
|
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
|
2014-03-16 05:03:17 +01:00
|
|
|
int n = _max(1, u->number / 2);
|
2011-03-07 08:03:10 +01:00
|
|
|
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
|
2013-05-02 03:50:24 +02:00
|
|
|
u_setrace(u, new_race[RC_GHOUL_LORD]);
|
2010-08-08 09:40:42 +02:00
|
|
|
u->irace = NULL;
|
2011-03-07 08:03:10 +01:00
|
|
|
scale_number(u, n);
|
|
|
|
u->hp = (int)(unit_max_hp(u) * u->number * q);
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|
|
|
|
}
|