moving monster code to eressea (to be re-done in lua some day)

This commit is contained in:
Enno Rehling 2010-02-27 09:03:51 +00:00
parent 85ed970c54
commit 59748ca6c3
14 changed files with 1 additions and 513 deletions

View File

@ -34,11 +34,6 @@
#include <gamecode/summary.c>
#include <gamecode/xmlreport.c>
#include <races/dragons.c>
#include <races/illusion.c>
#include <races/races.c>
#include <races/zombies.c>
#include <attributes/alliance.c>
#include <attributes/attributes.c>
#include <attributes/fleechance.c>

View File

@ -47,7 +47,6 @@
#include <gamecode/items.h>
#include <gamecode/creport.h>
#include <gamecode/xmlreport.h>
#include <races/races.h>
#include <items/itemtypes.h>
#include <attributes/attributes.h>
@ -142,7 +141,6 @@ game_init(void)
register_xr();
debug_language("locales.log");
register_races();
register_names();
register_resources();
register_buildings();

View File

@ -278,42 +278,6 @@
>
</File>
</Filter>
<Filter
Name="races"
>
<File
RelativePath=".\races\dragons.c"
>
</File>
<File
RelativePath=".\races\dragons.h"
>
</File>
<File
RelativePath=".\races\illusion.c"
>
</File>
<File
RelativePath=".\races\illusion.h"
>
</File>
<File
RelativePath=".\races\races.c"
>
</File>
<File
RelativePath=".\races\races.h"
>
</File>
<File
RelativePath=".\races\zombies.c"
>
</File>
<File
RelativePath=".\races\zombies.h"
>
</File>
</Filter>
<File
RelativePath=".\eressea.c"
>

View File

@ -832,7 +832,7 @@ select_armor(troop t, boolean shield)
const armor * a = t.fighter->armors;
int geschuetzt = 0;
/* dragons do not use armor */
/* some monsters should not use armor (dragons in chainmail? ha!) */
if (!(u->race->battle_flags & BF_EQUIPMENT))
return NULL;

View File

@ -21,10 +21,6 @@
#include <kernel/config.h>
#include "race.h"
#include <races/zombies.h>
#include <races/dragons.h>
#include <races/illusion.h>
#include "alchemy.h"
#include "build.h"
#include "building.h"

View File

@ -1,20 +0,0 @@
SubDir TOP common races ;
TargetDirectory ;
SubDirHdrs $(SUBDIR)/../gamecode ;
SubDirHdrs $(SUBDIR)/../kernel ;
SubDirHdrs $(SUBDIR)/../util ;
SubDirHdrs $(SUBDIR)/.. ;
SubDirHdrs $(SUBDIR)/../.. ;
SubDirHdrs $(XMLHDRS) ;
SOURCES =
dragons.c
illusion.c
races.c
zombies.c
;
if $(BUILDTYPE) = REGULAR {
Library races : $(SOURCES) ;
}

View File

@ -1,53 +0,0 @@
/* 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>
#include "dragons.h"
/* kernel includes */
#include <kernel/region.h>
#include <kernel/unit.h>
/* util includes */
#include <util/rng.h>
#define age_chance(a,b,p) (MAX(0,a-b)*p)
#define DRAGONAGE 27
#define WYRMAGE 68
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->race = new_race[RC_DRAGON];
u->irace = NULL;
scale_number(u,1);
u->hp = (int) (unit_max_hp(u) * u->number * q);
}
}
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->race = new_race[RC_WYRM];
u->irace = NULL;
u->hp = (int) (unit_max_hp(u) * u->number * q);
}
}

View File

@ -1,29 +0,0 @@
/* 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.
*/
#ifndef H_RACE_DRAGONS
#define H_RACE_DRAGONS
#ifdef __cplusplus
extern "C" {
#endif
struct unit;
void age_firedragon(struct unit *u);
void age_dragon(struct unit *u);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,42 +0,0 @@
/* 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>
#include "illusion.h"
/* kernel includes */
#include <kernel/unit.h>
#include <kernel/faction.h>
#include <kernel/message.h>
/* libc includes */
#include <stdlib.h>
#include <assert.h>
#define ILLUSIONMAX 6
void
age_illusion(unit *u)
{
if (u->faction->race!=new_race[RC_ILLUSION]) {
if (u->age == ILLUSIONMAX) {
ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve",
"unit", u));
} else if (u->age > ILLUSIONMAX) {
set_number(u, 0);
ADDMSG(&u->faction->msgs, msg_message("illusiondissolve", "unit", u));
}
}
}

View File

@ -1,28 +0,0 @@
/* 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.
*/
#ifndef H_RACE_ILLUSION
#define H_RACE_ILLUSION
#ifdef __cplusplus
extern "C" {
#endif
struct unit;
void age_illusion(struct unit *u);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,139 +0,0 @@
/* vi: set ts=2:
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
* | | Enno Rehling <enno@eressea.de>
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
* | (c) 1998 - 2007 |
* | | This program may not be used, modified or distributed
* +-------------------+ without prior permission by the authors of Eressea.
*
*/
#include <platform.h>
#include <kernel/config.h>
#include "races.h"
#include "zombies.h"
#include "illusion.h"
#include "dragons.h"
#include <kernel/building.h>
#include <kernel/equipment.h>
#include <kernel/faction.h>
#include <kernel/item.h>
#include <kernel/pathfinder.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/ship.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
#include <util/attrib.h>
#include <util/functions.h>
#include <util/rng.h>
static void
oldfamiliars(unit * u)
{
char fname[64];
/* these familiars have no special skills.
*/
snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]);
create_mage(u, M_GRAY);
equip_unit(u, get_equipment(fname));
}
static void
set_show_item(faction *f, item_t i)
{
attrib *a = a_add(&f->attribs, a_new(&at_showitem));
a->data.v = (void*)olditemtype[i];
}
static void
equip_newunits(const struct equipment * eq, struct unit *u)
{
struct region *r = u->region;
switch (old_race(u->race)) {
case RC_ELF:
set_show_item(u->faction, I_FEENSTIEFEL);
break;
case RC_GOBLIN:
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
set_number(u, 10);
break;
case RC_HUMAN:
if (u->building==NULL) {
const building_type * btype = bt_find("castle");
if (btype!=NULL) {
building *b = new_building(btype, r, u->faction->locale);
b->size = 10;
u->building = b;
fset(u, UFL_OWNER);
}
}
break;
case RC_CAT:
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
break;
case RC_AQUARIAN:
{
ship *sh = new_ship(st_find("boat"), u->faction->locale, r);
sh->size = sh->type->construction->maxsize;
u->ship = sh;
fset(u, UFL_OWNER);
}
break;
case RC_CENTAUR:
rsethorses(r, 250+rng_int()%51+rng_int()%51);
break;
}
}
static item *
default_spoil(const struct race * rc, int size)
{
item * itm = NULL;
if (rng_int()%100 < RACESPOILCHANCE) {
char spoilname[32];
const item_type * itype;
sprintf(spoilname, "%sspoil", rc->_name[0]);
itype = it_find(spoilname);
if (itype!=NULL) {
i_add(&itm, i_new(itype, size));
}
}
return itm;
}
/* Die Funktionen werden über den hier registrierten Namen in races.xml
* in die jeweilige Rassendefiniton eingebunden */
void
register_races(void)
{
/* function initfamiliar */
register_function((pf_generic)oldfamiliars, "oldfamiliars");
register_function((pf_generic)allowed_dragon, "movedragon");
register_function((pf_generic)allowed_swim, "moveswimming");
register_function((pf_generic)allowed_fly, "moveflying");
register_function((pf_generic)allowed_walk, "movewalking");
/* function age for race->age() */
register_function((pf_generic)age_undead, "ageundead");
register_function((pf_generic)age_illusion, "ageillusion");
register_function((pf_generic)age_skeleton, "ageskeleton");
register_function((pf_generic)age_zombie, "agezombie");
register_function((pf_generic)age_ghoul, "ageghoul");
register_function((pf_generic)age_dragon, "agedragon");
register_function((pf_generic)age_firedragon, "agefiredragon");
/* function itemdrop
* to generate battle spoils
* race->itemdrop() */
register_function((pf_generic)default_spoil, "defaultdrops");
register_function((pf_generic)equip_newunits, "equip_newunits");
}

View File

@ -1,25 +0,0 @@
/* vi: set ts=2:
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
* | | Enno Rehling <enno@eressea.de>
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
* | (c) 1998 - 2007 |
* | | This program may not be used, modified or distributed
* +-------------------+ without prior permission by the authors of Eressea.
*
*/
#ifndef H_RACES
#define H_RACES
#ifdef __cplusplus
extern "C" {
#endif
extern void register_races(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,98 +0,0 @@
/* 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>
#include "zombies.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>
#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 */
#define age_chance(a,b,p) (MAX(0,a-b)*p)
void
age_undead(unit *u)
{
region *r = u->region;
int n = 0;
/* untote, die einer partei angehoeren, koennen sich
* absplitten, anstatt sich zu vermehren. monster
* untote vermehren sich nur noch */
if (u->number > UNDEAD_MIN && !is_monsters(u->faction) && rng_int() % 100 < UNDEAD_BREAKUP) {
int m;
unit *u2;
n = 0;
for (m = u->number; m; m--) {
if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION) ++n;
}
u2 = create_unit(r, get_monsters(), 0, new_race[RC_UNDEAD], 0, NULL, u);
make_undead_unit(u2);
transfermen(u, u2, u->number - n);
}
}
void
age_skeleton(unit *u)
{
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) {
int n = MAX(1,u->number/2);
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
u->race = new_race[RC_SKELETON_LORD];
u->irace = NULL;
scale_number(u,n);
u->hp = (int) (unit_max_hp(u) * u->number * q);
}
}
void
age_zombie(unit *u)
{
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) {
int n = MAX(1,u->number/2);
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
u->race = new_race[RC_ZOMBIE_LORD];
u->irace = NULL;
scale_number(u,n);
u->hp = (int) (unit_max_hp(u) * u->number * q);
}
}
void
age_ghoul(unit *u)
{
if (is_monsters(u->faction) && rng_int()%100 < age_chance(u->age, 27, 1)) {
int n = MAX(1,u->number/2);
double q = (double) u->hp / (double) (unit_max_hp(u) * u->number);
u->race = new_race[RC_GHOUL_LORD];
u->irace = NULL;
scale_number(u,n);
u->hp = (int) (unit_max_hp(u) * u->number * q);
}
}

View File

@ -1,31 +0,0 @@
/* 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.
*/
#ifndef H_RACE_ZOMBIES
#define H_RACE_ZOMBIES
#ifdef __cplusplus
extern "C" {
#endif
struct unit;
void age_undead(struct unit *u);
void age_skeleton(struct unit *u);
void age_zombie(struct unit *u);
void age_ghoul(struct unit *u);
#ifdef __cplusplus
}
#endif
#endif