From 59748ca6c3131f18421f4e4d9d2811b9ba1c5fcc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 27 Feb 2010 09:03:51 +0000 Subject: [PATCH] moving monster code to eressea (to be re-done in lua some day) --- src/src/build/gamecode.c | 5 -- src/src/eressea.c | 2 - src/src/gamecode.vcproj | 36 ---------- src/src/kernel/battle.c | 2 +- src/src/kernel/race.c | 4 -- src/src/races/Jamfile | 20 ------ src/src/races/dragons.c | 53 --------------- src/src/races/dragons.h | 29 -------- src/src/races/illusion.c | 42 ------------ src/src/races/illusion.h | 28 -------- src/src/races/races.c | 139 --------------------------------------- src/src/races/races.h | 25 ------- src/src/races/zombies.c | 98 --------------------------- src/src/races/zombies.h | 31 --------- 14 files changed, 1 insertion(+), 513 deletions(-) delete mode 100644 src/src/races/Jamfile delete mode 100644 src/src/races/dragons.c delete mode 100644 src/src/races/dragons.h delete mode 100644 src/src/races/illusion.c delete mode 100644 src/src/races/illusion.h delete mode 100644 src/src/races/races.c delete mode 100644 src/src/races/races.h delete mode 100644 src/src/races/zombies.c delete mode 100644 src/src/races/zombies.h diff --git a/src/src/build/gamecode.c b/src/src/build/gamecode.c index 4d3b7a94f..63120bde0 100644 --- a/src/src/build/gamecode.c +++ b/src/src/build/gamecode.c @@ -34,11 +34,6 @@ #include #include -#include -#include -#include -#include - #include #include #include diff --git a/src/src/eressea.c b/src/src/eressea.c index 617515da5..f1ebce9c7 100644 --- a/src/src/eressea.c +++ b/src/src/eressea.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -142,7 +141,6 @@ game_init(void) register_xr(); debug_language("locales.log"); - register_races(); register_names(); register_resources(); register_buildings(); diff --git a/src/src/gamecode.vcproj b/src/src/gamecode.vcproj index a4e73a495..a372d588b 100644 --- a/src/src/gamecode.vcproj +++ b/src/src/gamecode.vcproj @@ -278,42 +278,6 @@ > - - - - - - - - - - - - - - - - - - diff --git a/src/src/kernel/battle.c b/src/src/kernel/battle.c index 04b81e705..3e6f60594 100644 --- a/src/src/kernel/battle.c +++ b/src/src/kernel/battle.c @@ -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; diff --git a/src/src/kernel/race.c b/src/src/kernel/race.c index 4dfa011fb..cb09db9dc 100644 --- a/src/src/kernel/race.c +++ b/src/src/kernel/race.c @@ -21,10 +21,6 @@ #include #include "race.h" -#include -#include -#include - #include "alchemy.h" #include "build.h" #include "building.h" diff --git a/src/src/races/Jamfile b/src/src/races/Jamfile deleted file mode 100644 index 99eeff83e..000000000 --- a/src/src/races/Jamfile +++ /dev/null @@ -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) ; -} diff --git a/src/src/races/dragons.c b/src/src/races/dragons.c deleted file mode 100644 index 2dec1a359..000000000 --- a/src/src/races/dragons.c +++ /dev/null @@ -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 -#include -#include "dragons.h" - -/* kernel includes */ -#include -#include - -/* util includes */ -#include - -#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); - } -} - diff --git a/src/src/races/dragons.h b/src/src/races/dragons.h deleted file mode 100644 index 7a859ef8d..000000000 --- a/src/src/races/dragons.h +++ /dev/null @@ -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 diff --git a/src/src/races/illusion.c b/src/src/races/illusion.c deleted file mode 100644 index cb5d3546e..000000000 --- a/src/src/races/illusion.c +++ /dev/null @@ -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 -#include -#include "illusion.h" - -/* kernel includes */ -#include -#include -#include - -/* libc includes */ -#include -#include - -#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)); - } - } -} diff --git a/src/src/races/illusion.h b/src/src/races/illusion.h deleted file mode 100644 index 24bcabac7..000000000 --- a/src/src/races/illusion.h +++ /dev/null @@ -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 diff --git a/src/src/races/races.c b/src/src/races/races.c deleted file mode 100644 index 03e2d3407..000000000 --- a/src/src/races/races.c +++ /dev/null @@ -1,139 +0,0 @@ -/* vi: set ts=2: - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (c) 1998 - 2007 | - * | | This program may not be used, modified or distributed - * +-------------------+ without prior permission by the authors of Eressea. - * - */ - -#include -#include -#include "races.h" - -#include "zombies.h" -#include "illusion.h" -#include "dragons.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -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"); -} diff --git a/src/src/races/races.h b/src/src/races/races.h deleted file mode 100644 index 90c9f78f6..000000000 --- a/src/src/races/races.h +++ /dev/null @@ -1,25 +0,0 @@ -/* vi: set ts=2: - * +-------------------+ Christian Schlittchen - * | | Enno Rehling - * | Eressea PBEM host | Katja Zedel - * | (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 - diff --git a/src/src/races/zombies.c b/src/src/races/zombies.c deleted file mode 100644 index a01d970e5..000000000 --- a/src/src/races/zombies.c +++ /dev/null @@ -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 -#include -#include "zombies.h" - -/* kernel includes */ -#include -#include -#include - -/* util iclude */ -#include - -/* libc includes */ -#include - -#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); - } -} - diff --git a/src/src/races/zombies.h b/src/src/races/zombies.h deleted file mode 100644 index 3bd864630..000000000 --- a/src/src/races/zombies.h +++ /dev/null @@ -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