Merge pull request #185 from stm2/race_attacks

apply possible number of racial attacks consistently
This commit is contained in:
Enno Rehling 2015-05-08 09:30:54 -07:00
commit ac2099aa0f
5 changed files with 20 additions and 8 deletions

View File

@ -2294,16 +2294,18 @@ void do_attack(fighter * af)
/* Wir suchen eine beliebige Feind-Einheit aus. An der können
* wir feststellen, ob noch jemand da ist. */
int apr, attacks = attacks_per_round(ta);
assert(attacks <= RACE_ATTACKS);
if (!count_enemies(b, af, FIGHT_ROW, LAST_ROW, SELECT_FIND))
break;
for (apr = 0; apr != attacks; ++apr) {
int a;
for (a = 0; a != 10 && u_race(au)->attack[a].type != AT_NONE; ++a) {
for (a = 0; a < RACE_ATTACKS && u_race(au)->attack[a].type != AT_NONE; ++a) {
if (apr > 0) {
/* Wenn die Waffe nachladen muss, oder es sich nicht um einen
* Waffen-Angriff handelt, dann gilt der Speed nicht. */
if (u_race(au)->attack[a].type != AT_STANDARD)
/* FIXME allow multiple AT_NATURAL attacks? */
if (u_race(au)->attack[a].type != AT_STANDARD)
continue;
else {
weapon *wp = preferred_weapon(ta, true);

View File

@ -169,6 +169,7 @@ const race * rc_find(const char *name) {
race *rc_get_or_create(const char *zName)
{
race *rc;
int i;
assert(zName);
rc = rc_find_i(zName);
@ -191,7 +192,8 @@ race *rc_get_or_create(const char *zName)
rc->precombatspell = NULL;
rc->attack[0].type = AT_COMBATSPELL;
rc->attack[1].type = AT_NONE;
for (i = 1; i < RACE_ATTACKS; ++i)
rc->attack[i].type = AT_NONE;
rc->index = num_races++;
++cache_breaker;
rc->next = races;

View File

@ -40,6 +40,8 @@ extern "C" {
#define RACESPOILCHANCE 5 /* Chance auf rassentypische Beute */
#define RACE_ATTACKS 10 /* maximum number of attacks */
struct param;
struct spell;
@ -145,7 +147,7 @@ extern "C" {
int battle_flags;
int ec_flags;
race_t oldfamiliars[MAXMAGIETYP];
struct att attack[10];
struct att attack[RACE_ATTACKS];
signed char bonus[MAXSKILLS];
const char *(*generate_name) (const struct unit *);

View File

@ -1610,7 +1610,7 @@ static int parse_races(xmlDocPtr doc)
xmlChar *propValue;
race *rc;
xmlXPathObjectPtr result;
int k, study_speed_base;
int k, study_speed_base, attacks;
struct att *attack;
propValue = xmlGetProp(node, BAD_CAST "name");
@ -1838,10 +1838,16 @@ static int parse_races(xmlDocPtr doc)
xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "attack", xpath);
attack = rc->attack;
attacks = 0;
for (k = 0; k != result->nodesetval->nodeNr; ++k) {
xmlNodePtr node = result->nodesetval->nodeTab[k];
while (attack->type != AT_NONE)
while (attack->type != AT_NONE) {
++attack;
if (attacks++ >= RACE_ATTACKS) {
log_error("too many attacks for race '%s'\n", rc->_name);
assert(!"aborting");
}
}
propValue = xmlGetProp(node, BAD_CAST "damage");
if (propValue != NULL) {

View File

@ -2339,7 +2339,7 @@ static bool display_race(faction * f, unit * u, const race * rc)
/* b_damage : Schaden */
at_count = 0;
for (a = 0; a < 6; a++) {
for (a = 0; a < RACE_ATTACKS; a++) {
if (rc->attack[a].type != AT_NONE) {
at_count++;
}
@ -2371,7 +2371,7 @@ static bool display_race(faction * f, unit * u, const race * rc)
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
for (a = 0; a < 6; a++) {
for (a = 0; a < RACE_ATTACKS; a++) {
if (rc->attack[a].type != AT_NONE) {
if (a != 0)
bytes = (int)strlcpy(bufp, ", ", size);