server/src/races/zombies.c

83 lines
2.3 KiB
C
Raw Normal View History

/*
* Eressea PB(E)M host Copyright (C) 1998-2019
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>
#include <kernel/order.h>
2010-08-08 09:40:42 +02:00
#include <kernel/unit.h>
#include <kernel/faction.h>
#include <kernel/region.h>
/* util iclude */
#include <util/rng.h>
#include "monsters.h"
2010-08-08 09:40:42 +02:00
/* 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
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
void make_undead_unit(unit * u)
{
free_orders(&u->orders);
name_unit(u);
u->flags |= UFL_ISNEW;
}
2011-03-07 08:03:10 +01:00
void age_skeleton(unit * u)
2010-08-08 09:40:42 +02:00
{
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
2019-01-24 17:50:58 +01:00
int n = u->number / 2;
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
2019-01-24 17:50:58 +01:00
if (n < 1) n = 1;
u_setrace(u, get_race(RC_SKELETON_LORD));
u->irace = NULL;
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
{
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
2019-01-24 17:50:58 +01:00
int n = u->number / 2;
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
2019-01-24 17:50:58 +01:00
if (n < 1) n = 1;
u_setrace(u, get_race(RC_ZOMBIE_LORD));
u->irace = NULL;
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
{
if (is_monsters(u->faction) && rng_int() % 100 < age_chance(u->age, 27, 1)) {
2019-01-24 17:50:58 +01:00
int n = u->number / 2;
double q = (double)u->hp / (double)(unit_max_hp(u) * u->number);
u_setrace(u, get_race(RC_GHOUL_LORD));
u->irace = NULL;
2019-01-24 17:50:58 +01:00
scale_number(u, (n > 0) ? n : 1);
u->hp = (int)(unit_max_hp(u) * u->number * q);
}
2010-08-08 09:40:42 +02:00
}