diff --git a/src/common/attributes/fleechance.c b/src/common/attributes/fleechance.c new file mode 100644 index 000000000..04b9ffb38 --- /dev/null +++ b/src/common/attributes/fleechance.c @@ -0,0 +1,41 @@ +/* vi: set ts=2: + * + * + * Eressea PB(E)M host Copyright (C) 1998-2000 + * 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-pbem.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 "fleechance.h" + +#include + +attrib_type at_fleechance = { + "fleechance", + NULL, + NULL, + NULL, + NULL, + NULL, +}; + +attrib * +make_fleechance(float fleechance) +{ + attrib * a = a_new(&at_fleechance); + a->data.flt = fleechance; + return a; +} + +void +init_fleechance(void) +{ + at_register(&at_fleechance); +} diff --git a/src/common/attributes/fleechance.h b/src/common/attributes/fleechance.h new file mode 100644 index 000000000..893efc5c2 --- /dev/null +++ b/src/common/attributes/fleechance.h @@ -0,0 +1,18 @@ +/* vi: set ts=2: + * + * + * Eressea PB(E)M host Copyright (C) 1998-2000 + * 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-pbem.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. + */ + +extern struct attrib_type at_fleechance; + +extern struct attrib * make_fleechance(float fleechance); +extern void init_fleechance(void); diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index cf61f2174..0044942f0 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2041,35 +2041,39 @@ display_item(faction *f, unit *u, const item_type * itype) FILE *fp; char t[NAMESIZE + 1]; char filename[MAX_PATH]; - const char *name; + const char *name, *info; if (u && *i_find(&u->items, itype) == NULL) return false; - name = resourcename(itype->rtype, 0); - sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name); - fp = fopen(filename, "r"); - if (!fp) { - name = locale_string(f->locale, resourcename(itype->rtype, 0)); + info = mkname("info", itype->rtype->_name[0]); + name = LOC(u->faction->locale, info); + if (name==info) { + name = resourcename(itype->rtype, 0); sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name); fp = fopen(filename, "r"); - } - if (!fp) { - name = resourcename(itype->rtype, 0); - sprintf(filename, "%s/items/%s", resourcepath(), name); - fp = fopen(filename, "r"); - } - if (!fp) return false; - - sprintf(buf, "%s: ", LOC(f->locale, name)); - - while (fgets(t, NAMESIZE, fp) != NULL) { - if (t[strlen(t) - 1] == '\n') { - t[strlen(t) - 1] = 0; + if (!fp) { + name = locale_string(f->locale, resourcename(itype->rtype, 0)); + sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(f->locale), name); + fp = fopen(filename, "r"); } - strcat(buf, t); - } - fclose(fp); + if (!fp) { + name = resourcename(itype->rtype, 0); + sprintf(filename, "%s/items/%s", resourcepath(), name); + fp = fopen(filename, "r"); + } + if (!fp) return false; - addmessage(0, f, buf, MSG_EVENT, ML_IMPORTANT); + sprintf(buf, "%s: ", LOC(f->locale, name)); + + while (fgets(t, NAMESIZE, fp) != NULL) { + if (t[strlen(t) - 1] == '\n') { + t[strlen(t) - 1] = 0; + } + strcat(buf, t); + } + fclose(fp); + name = buf; + } + addmessage(0, f, name, MSG_EVENT, ML_IMPORTANT); return true; } diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index 2ce99a494..63fd61600 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -1466,8 +1466,8 @@ randomevents(void) && (u->race->flags & RCF_DESERT)) { if (fval(u, FL_ISNEW)) continue; if (rand()%100 < 5) { - ADDMSG(&u->faction->msgs, new_message(u->faction, - "desertion%u:unit%r:region", u, r)); + ADDMSG(&u->faction->msgs, msg_message("desertion", + "unit region", u, r)); u_setfaction(u, findfaction(MONSTER_FACTION)); } } diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 112fec1c8..8180eb69f 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -64,6 +64,7 @@ typedef enum combatmagic { /* attributes includes */ #include +#include #include #include #include @@ -2078,8 +2079,8 @@ double fleechance(unit * u) { double c = 0.20; /* Fluchtwahrscheinlichkeit in % */ - region *r = u->region; - + region * r = u->region; + attrib * a = a_find(u->attribs, &at_fleechance); /* Einheit u versucht, dem Getümmel zu entkommen */ c += (eff_skill(u, SK_STEALTH, r) * 0.05); @@ -2096,6 +2097,8 @@ fleechance(unit * u) c = min(c, 0.75); } + if (a!=NULL) c += a->data.flt; + return c; } diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index d14bd6252..3b95947b0 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -2013,6 +2013,7 @@ init_tokens(const struct locale * lang) init_directions(&lnames->directions, lang); for (rc=races;rc;rc=rc->next) { addtoken(&lnames->races, LOC(lang, rc_name(rc, 1)), (void*)rc); + addtoken(&lnames->races, LOC(lang, rc_name(rc, 0)), (void*)rc); } for (i=0;i!=MAXPARAMS;++i) addtoken(&lnames->tokens[UT_PARAM], LOC(lang, parameters[i]), (void*)i); diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 3bb755963..e5c9f4e83 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -32,6 +32,7 @@ #include "unit.h" /* util includes */ +#include #include #include @@ -1329,6 +1330,7 @@ static translate_t translation[] = { { "Mallorn", "mallorn", "mallorn_p", "mallorn", "mallorn_p" }, { "Wagen", "cart", "cart_p", "cart", "cart_p" }, { "Plattenpanzer", "plate", "plate_p", "plate", "plate_p" }, + { "Trollgürtel", "trollbelt", "trollbelt_p", "trollbelt", "trollbelt_p" }, { "Balsam", "balm", "balm_p", "balm", "balm_p" }, { "Gewürz", "spice", "spice_p", "spice", "spice_p" }, { "Myrrhe", "myrrh", "myrrh_p", "myrrh", "myrrh_p" }, @@ -1913,6 +1915,23 @@ use_bloodpotion(struct unit *u, const struct potion_type *ptype, const char *cmd return 0; } +#include +static int +use_mistletoe(struct unit * user, const struct item_type * itype, const char * cmd) +{ + if (user->number!=1) { + ADDMSG(&user->faction->msgs, msg_message("use_singleperson", + "unit item region command", user, itype, user->region, cmd)); + return -1; + } + new_use_pooled(user, itype->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 1); + a_add(&user->attribs, make_fleechance((float)1.0)); + ADDMSG(&user->faction->msgs, msg_message("use_item", + "unit item", user, itype)); + + return 0; +} + void init_oldpotions(void) { @@ -2394,6 +2413,7 @@ init_items(void) register_function((pf_generic)use_antimagiccrystal, "useantimagiccrystal"); register_function((pf_generic)use_warmthpotion, "usewarmthpotion"); register_function((pf_generic)use_bloodpotion, "usebloodpotion"); + register_function((pf_generic)use_mistletoe, "usemistletoe"); register_function((pf_generic)give_horses, "givehorses"); } diff --git a/src/common/kernel/message.c b/src/common/kernel/message.c index 60d59fb50..bbc5cad10 100644 --- a/src/common/kernel/message.c +++ b/src/common/kernel/message.c @@ -293,6 +293,7 @@ int read_messages(FILE * F, struct xml_stack * stack) { xml_state state; + memset(&state, 0, sizeof(state)); return xml_parse(F, &msgcallback, &state, stack); } diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 662184909..9f545209a 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -4437,7 +4437,7 @@ sp_recruit(castorder *co) rsetpeasants(r, rpeasants(r) - n); u = create_unit(r, f, n, f->race, 0, (n == 1 ? "Bauer" : "Bauern"), mage); - set_string(&u->thisorder, locale_string(u->faction->locale, keywords[K_WORK])); + set_string(&u->thisorder, locale_string(u->faction->locale, "defaultorder")); sprintf(buf, "%s konnte %d %s anwerben", unitname(mage), n, n == 1 ? "Bauer" : "Bauern"); @@ -4956,7 +4956,7 @@ sp_illusionary_shapeshift(castorder *co) sprintf(buf, "%s %s keine %s-Gestalt annehmen.", unitname(u), u->number > 1 ? "können" : "kann", - rc_name(rc, 2)); + LOC(u->faction->locale, rc_name(rc, 2))); addmessage(r, mage->faction, buf, MSG_MAGIC, ML_MISTAKE); return 0; } @@ -4967,7 +4967,7 @@ sp_illusionary_shapeshift(castorder *co) u->irace = rc; sprintf(buf, "%s läßt %s als %s erscheinen.", - unitname(mage), unitname(u), rc_name(rc, u->number != 1)); + unitname(mage), unitname(u), LOC(u->faction->locale, rc_name(rc, u->number != 1))); addmessage(r, mage->faction, buf, MSG_MAGIC, ML_INFO); return cast_level; diff --git a/src/common/util/attrib.h b/src/common/util/attrib.h index e6f3c7839..b98de9ca1 100644 --- a/src/common/util/attrib.h +++ b/src/common/util/attrib.h @@ -25,6 +25,7 @@ typedef struct attrib { afun f; void * v; int i; + float flt; char c; short s; short sa[2]; diff --git a/src/common/util/xml.c b/src/common/util/xml.c index f436dcae0..2379b694d 100644 --- a/src/common/util/xml.c +++ b/src/common/util/xml.c @@ -98,6 +98,7 @@ xml_parse(FILE * stream, struct xml_callbacks * cb, void * data, xml_stack * sta { xml_stack * start = stack; enum { TAG, ENDTAG, ATNAME, ATVALUE, PLAIN } state = PLAIN; + boolean startline = true; char tokbuffer[1024]; char * pos = tokbuffer; int quoted = 0; @@ -199,8 +200,20 @@ xml_parse(FILE * stream, struct xml_callbacks * cb, void * data, xml_stack * sta case '>': *pos='\0'; return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR, data); + case '\n': + /* ignore */ + if (!startline) *pos++ = ' '; + startline = true; + break; + case ' ': + case '\t': + if (!startline) { + *pos++ = (char)c; + } + break; default: *pos++ = (char)c; + startline = false; } break; /* case PLAIN */ case TAG: @@ -219,6 +232,7 @@ xml_parse(FILE * stream, struct xml_callbacks * cb, void * data, xml_stack * sta } if (cb && cb->tagbegin) cb->tagbegin(stack, data); state = PLAIN; + startline = true; pos = tokbuffer; break; default: diff --git a/src/eressea/main.c b/src/eressea/main.c index 89dfcd60e..02b58cac3 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -717,7 +717,11 @@ main(int argc, char *argv[]) for (u=r->units;u;u=u->next) scale_number(u, 1); } } - if (g_writemap) return crwritemap(); + if (g_writemap) return crwritemap(); + { + faction * monster = findfaction(MONSTER_FACTION); + display_item(monster, monster->units, it_find("mistletoe")); + } if ((i=processturn(orders))!=0) return i; #ifdef CLEANUP_CODE diff --git a/src/res/de/messages.xml b/src/res/de/messages.xml index c4fa6eb4c..3f21f046c 100644 --- a/src/res/de/messages.xml +++ b/src/res/de/messages.xml @@ -317,36 +317,44 @@ "'$command' - $unit($unit) marched into $region($region) during the last turn and is too exhausted to attack." - + + + + + + + + "$unit($unit) in $region($region): '$command' - $resource($item,0) können nur von Ein-Personen Einheiten benutzt werden." + "$unit($unit) in $region($region): '$command' - $resource($item,0) can only be used by single-person units." + + + + + + + + "$unit($unit) benutzt ein $resource($item,1)." + "$unit($unit) uses a $resource($item,1)." + + + - - - "$unit($unit) in $region($region): '$command' - ${error}." - - + "$unit($unit) in $region($region): '$command' - ${error}." - + - - - "$unit($unit) in $region($region): '$command' - Auf dem Schiff befinden sich zuwenig erfahrene Seeleute." - - - - - "$unit($unit) in $region($region): '$command' - There are not enough experienced sailors on board the ship." - - + "$unit($unit) in $region($region): '$command' - Auf dem Schiff befinden sich zuwenig erfahrene Seeleute." + "$unit($unit) in $region($region): '$command' - There are not enough experienced sailors on board the ship." @@ -7345,7 +7353,7 @@ "Zur Feier des Geburtstags von ${name} wird in $region($region) ein großes Feuerwerk abgebrannt, welches noch hier zu bewundern ist. Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel." "A large firework in honor of ${name}, visible all over the sky, has been started in $region($region)." - + @@ -7354,7 +7362,7 @@ "Zur Feier des Geburtstags von ${name} brennt $unit($unit) ein großes Feuerwerk ab. Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel." "A large firework in honor of ${name} is visible all over the sky." - + diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index bcb6b8162..4b60dc3b5 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -5,6 +5,15 @@ + + + Im Mistelzweig ruht eine magische Kraft + besonderer Art. Der Anwender wird von seinen Feinden in Frieden + gelassen, eine Woche lang läßt jeder Kämpfer ihn unbeschadet + seines Weges ziehen. + The magical misteltoe has a wonderous property: It's use will make one person able to escape unharmed from every conflict, no enemy will lay hand on the bearer for one week. + + Klon diff --git a/src/res/eressea.xml b/src/res/eressea.xml index cab53147c..7b4c46c0e 100644 --- a/src/res/eressea.xml +++ b/src/res/eressea.xml @@ -9,7 +9,6 @@ - Game specific diff --git a/src/res/vinyambar-classic.xml b/src/res/vinyambar-classic.xml index ad6c69e1d..29beb2f55 100644 --- a/src/res/vinyambar-classic.xml +++ b/src/res/vinyambar-classic.xml @@ -9,7 +9,6 @@ - Game specific diff --git a/src/res/vinyambar.xml b/src/res/vinyambar.xml index 72b6cd422..15e720eae 100644 --- a/src/res/vinyambar.xml +++ b/src/res/vinyambar.xml @@ -8,7 +8,7 @@ - + Game specific