From 71dc067213537e06e6acadca9d1d9cb5330cc553 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 16 Oct 2005 20:11:34 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=733 Vertraute und Kampfzauber separated combat spells from regular attacks to allow monsters without regular attacks to have combat spells. --- src/common/kernel/battle.c | 16 +++++++++------- src/common/kernel/race.c | 3 +++ src/common/kernel/xmlreader.c | 12 +++++++----- src/common/modules/autoseed.c | 5 +++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index b31a84694..ee02092b0 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -1940,14 +1940,16 @@ attack(battle *b, troop ta, const att *a, int numattack) int offset = row - FIGHT_ROW; switch(a->type) { + case AT_COMBATSPELL: + if (numattack==0 && af->magic > 0) { + /* Magier versuchen immer erstmal zu zaubern, erst wenn das + * fehlschlägt, wird af->magic == 0 und der Magier kämpft + * konventionell weiter */ + do_combatspell(ta, row); + } + break; case AT_STANDARD: /* Waffen, mag. Gegenstände, Kampfzauber */ - case AT_COMBATSPELL: - if (numattack==0 && af->magic > 0) { - /* Magier versuchen immer erstmal zu zaubern, erst wenn das - * fehlschlägt, wird af->magic == 0 und der Magier kämpft - * konventionell weiter */ - do_combatspell(ta, row); - } else { + if (numattack > 0 || af->magic <= 0) { weapon * wp = ta.fighter->person[ta.index].missile; if (row==FIGHT_ROW) wp = preferred_weapon(ta, true); /* Sonderbehandlungen */ diff --git a/src/common/kernel/race.c b/src/common/kernel/race.c index 509bb0eca..2410350d4 100644 --- a/src/common/kernel/race.c +++ b/src/common/kernel/race.c @@ -98,6 +98,9 @@ rc_new(const char * zName) sprintf(zBuffer, "%s_x", zName); rc->_name[3] = strdup(zBuffer); rc->precombatspell = NULL; + + rc->attack[0].type = AT_COMBATSPELL; + rc->attack[1].type = AT_NONE; return rc; } diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index aabdad71e..e54deb1e8 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -1181,6 +1181,7 @@ parse_races(xmlDocPtr doc) race * rc; xmlXPathObjectPtr result; int k; + struct att * attack; property = xmlGetProp(node, BAD_CAST "name"); assert(property!=NULL); @@ -1358,19 +1359,20 @@ parse_races(xmlDocPtr doc) /* reading eressea/races/race/attack */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "attack", xpath); + attack = rc->attack; for (k=0;k!=result->nodesetval->nodeNr;++k) { xmlNodePtr node = result->nodesetval->nodeTab[k]; - struct att * a = &rc->attack[k]; + while (attack->type!=AT_NONE) ++attack; property = xmlGetProp(node, BAD_CAST "damage"); if (property!=NULL) { - a->data.dice = strdup((const char*)property); + attack->data.dice = strdup((const char*)property); xmlFree(property); } else { - a->data.sp = xml_spell(node, "spell"); + attack->data.sp = xml_spell(node, "spell"); } - a->type = xml_ivalue(node, "type", 0); - a->flags = xml_ivalue(node, "flags", 0); + attack->type = xml_ivalue(node, "type", 0); + attack->flags = xml_ivalue(node, "flags", 0); } xmlXPathFreeObject(result); } diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index 332eff5af..1456eb955 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -155,7 +155,7 @@ fix_demand(region *r) return 0; } -/* nach 150 Rudnen ist Neustart erlaubt */ +/* nach 150 Runden ist Neustart erlaubt */ #define MINAGE_MULTI 150 newfaction * read_newfactions(const char * filename) @@ -513,7 +513,8 @@ autoseed(newfaction ** players, int nsize, boolean new_island) if (r->terrain==T_OCEAN && p==0 && (rmin==NULL || r->age<=MAXAGEDIFF)) { direction_t d; for (d=0;d!=MAXDIRECTIONS;++d) { - if (rconnect(r, d)==NULL) break; + region * rn = rconnect(r, d); + if (rn==NULL) break; } if (d!=MAXDIRECTIONS) { rmin=r;