From c0a7762932ef0dd3d3c520e902e14e1609c72a58 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 29 Feb 2004 08:59:15 +0000 Subject: [PATCH] Neue Wirkung von Bauernblut --- src/common/gamecode/laws.c | 65 ++++++++++++++++++++----------------- src/common/kernel/alchemy.c | 9 ++--- src/common/kernel/alchemy.h | 3 +- src/common/kernel/eressea.c | 1 - src/common/kernel/item.c | 29 +++++++++-------- src/res/de/strings-wdw.xml | 4 +-- src/res/de/strings.xml | 4 +-- src/res/en/strings.xml | 4 +-- src/res/fr/strings.xml | 4 +-- 9 files changed, 65 insertions(+), 58 deletions(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 54b2e01b0..b9882c545 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -160,8 +160,7 @@ get_food(region *r) { unit *u; int peasantfood = rpeasants(r)*10; - int bauernblut = 0; - boolean bfind = false; + unit * demon = r->units; /* 1. Versorgung von eigenen Einheiten. Das vorhandene Silber * wird zunächst so auf die Einheiten aufgeteilt, dass idealerweise @@ -229,41 +228,47 @@ get_food(region *r) } } + /* 3. bestimmen, wie viele Bauern gefressen werden. + * bei fehlenden Bauern den Dämon hungern lassen + */ for (u = r->units; u; u = u->next) { if (u->race == new_race[RC_DAEMON]) { - /* Alles Bauernblut der Region zählen. - * warnung: bauernblut einer partei hilft im moment der anderen - * so selten wie das benutzt wird, ist das erstmal wursht, - * aber ein TODO fürs BUGS File. - * Es ist auch deshalb fast egal, weil es ja im Grunde nicht dem Dämon, - * sondern der Region zu gute kommt - und da ist der anwender schnuppe - */ - if (!bfind) { - unit * ud = u; - while (ud) { - attrib * a = a_find(ud->attribs, &at_bauernblut); - if (a) bauernblut += a->data.i; - do { ud=ud->next; } while (ud && ud->race!=new_race[RC_DAEMON]); - } - bfind = true; + int hungry = u->number; + + while (demon!=NULL && hungry>0) { + /* alwayy start with the first known uint that may have some blood */ + static const struct potion_type * pt_blood; + unit * ud = demon; + if (pt_blood==NULL) pt_blood = pt_find("peasantblood"); + demon = NULL; /* this will be re-set in the loop */ + while (ud!=NULL) { + if (ud->race==new_race[RC_DAEMON]) { + if (get_effect(ud, pt_blood)) { + /* new best guess for first blood-donor: */ + if (demon==NULL) demon = ud; + /* if he's in our faction, drain him: */ + if (ud->faction==u->faction) break; + } + } + ud=ud->next; + } + if (ud!=NULL) { + int blut = get_effect(ud, pt_blood); + blut = min(blut, hungry); + change_effect(ud, pt_blood, -blut); + hungry -= blut; } + } if (r->planep == NULL || !fval(r->planep, PFL_NOFEED)) { - int demons = u->number; - if (bauernblut>=demons) { - bauernblut -= demons; - demons = 0; - } else if (bauernblut) { - demons-=bauernblut; - } - if (peasantfood>=demons) { - peasantfood -= demons; - demons = 0; + if (peasantfood>=hungry) { + peasantfood -= hungry; + hungry = 0; } else { - demons -= peasantfood; + hungry -= peasantfood; peasantfood = 0; } - if (demons > 0) { - hunger(demons, u); /* nicht gefütterte dämonen hungern */ + if (hungry > 0) { + hunger(hungry, u); /* nicht gefütterte dämonen hungern */ } } } diff --git a/src/common/kernel/alchemy.c b/src/common/kernel/alchemy.c index 2f1e61f2f..76a716fc7 100644 --- a/src/common/kernel/alchemy.c +++ b/src/common/kernel/alchemy.c @@ -87,9 +87,11 @@ herbsearch(region * r, unit * u, int max) } } +#ifdef OLD_DEMON_POTION attrib_type at_bauernblut = { "bauernblut", NULL, NULL, NULL, NULL, NULL }; +#endif int use_potion(unit * u, const item_type * itype, int amount, const char * cmd) @@ -99,10 +101,9 @@ use_potion(unit * u, const item_type * itype, int amount, const char * cmd) assert(ptype!=NULL); if (use != NULL && use!=ptype) { - add_message(&u->faction->msgs, - new_message(u->faction, - "errusingpotion%u:unit%X:using%s:command", - u, use->itype->rtype, cmd)); + ADDMSG(&u->faction->msgs, + msg_message("errusingpotion", "unit using command", + u, use->itype->rtype, cmd)); return ECUSTOM; } diff --git a/src/common/kernel/alchemy.h b/src/common/kernel/alchemy.h index caa1473cf..276d19819 100644 --- a/src/common/kernel/alchemy.h +++ b/src/common/kernel/alchemy.h @@ -83,8 +83,9 @@ void herbsearch(struct region * r, struct unit * u, int max); int use_potion(struct unit * u, const struct item_type * itype, int amount, const char * cmd); void init_potions(void); +#ifdef OLD_DEMON_POTION extern struct attrib_type at_bauernblut; - +#endif extern int get_effect(const struct unit * u, const struct potion_type * effect); extern int change_effect(struct unit * u, const struct potion_type * effect, int value); extern attrib_type at_effect; diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 6cdb70400..c2db2bbc9 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -3079,7 +3079,6 @@ attrib_init(void) at_register(&at_eventhandler); at_register(&at_stealth); at_register(&at_mage); - at_register(&at_bauernblut); at_register(&at_countdown); at_register(&at_showitem); at_register(&at_curse); diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 63d678d92..6932eec40 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -428,6 +428,7 @@ static const char * it_aliases[][2] = { { "Runenschwert", "runesword" }, { "p12", "truthpotion" }, { "p1", "goliathwater" }, + { "p5", "peasantblood" }, { NULL, NULL }, }; static const char * @@ -1392,7 +1393,7 @@ static translate_t translation[] = { { "Laen", "laen", "laen_p", "laen", "laen_p" }, { "Goliathwasser", "goliathwater", "goliathwater_p", NULL, NULL }, { "Wasser des Lebens", "p2", "p2_p", NULL, NULL }, - { "Bauernblut", "p5", "p5_p", NULL, NULL }, + { "Bauernblut", "peasantblood", "peasantblood_p", NULL, NULL }, { "Gehirnschmalz", "p6", "p6_p", NULL, NULL }, { "Nestwärme", "p8", "p8_p", NULL, NULL }, { "Pferdeglück", "p9", "p9_p", NULL, NULL }, @@ -1997,21 +1998,21 @@ use_foolpotion(struct unit *u, int targetno, const struct item_type *itype, int static int use_bloodpotion(struct unit *u, const struct potion_type *ptype, int amount, const char *cmd) { - int i; assert(ptype==oldpotiontype[P_BAUERNBLUT]); unused(ptype); - for (i=0;i!=amount;++i) { - if (old_race(u->race) == RC_DAEMON) { - attrib * a = (attrib*)a_find(u->attribs, &at_bauernblut); - if (!a) a = a_add(&u->attribs, a_new(&at_bauernblut)); - a->data.i += 100; - } else { - /* bekommt nicht: */ - cmistake(u, cmd, 165, MSG_EVENT); - u->race = new_race[RC_GHOUL]; - u_setfaction(u, findfaction(MONSTER_FACTION)); - break; - } + if (u->race == new_race[RC_DAEMON] ) { +#ifdef OLD_DEMON_POTION + attrib * a = (attrib*)a_find(u->attribs, &at_bauernblut); + if (!a) a = a_add(&u->attribs, a_new(&at_bauernblut)); + a->data.i += 100*amount; +#else + change_effect(u, ptype, 100*amount); +#endif + } else { + /* bekommt nicht: */ + cmistake(u, cmd, 165, MSG_EVENT); + u->race = new_race[RC_GHOUL]; + u_setfaction(u, findfaction(MONSTER_FACTION)); } return 0; } diff --git a/src/res/de/strings-wdw.xml b/src/res/de/strings-wdw.xml index 775e05396..866e462b2 100644 --- a/src/res/de/strings-wdw.xml +++ b/src/res/de/strings-wdw.xml @@ -1506,7 +1506,7 @@ Wundsalbe - + Bauernblut @@ -1552,7 +1552,7 @@ Wundsalben - + Bauernblut diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index 6b6642a58..b48064a39 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -1506,7 +1506,7 @@ Wundsalbe - + Bauernblut @@ -1552,7 +1552,7 @@ Wundsalben - + Bauernblut diff --git a/src/res/en/strings.xml b/src/res/en/strings.xml index f39aeaaf9..98e2abb43 100644 --- a/src/res/en/strings.xml +++ b/src/res/en/strings.xml @@ -1109,10 +1109,10 @@ ointments - + peasant blood - + peasant bloods diff --git a/src/res/fr/strings.xml b/src/res/fr/strings.xml index 9285d9d9d..3a200a29c 100644 --- a/src/res/fr/strings.xml +++ b/src/res/fr/strings.xml @@ -1133,10 +1133,10 @@ onguents de soin - + fiole d'essence vitale - + fioles d'essence vitale