Bugfix Reichweiten von Zaubern und Spezialattacken

This commit is contained in:
Enno Rehling 2002-01-20 11:03:50 +00:00
parent f2f424fd00
commit ea98fd5c55
3 changed files with 86 additions and 77 deletions

View File

@ -145,24 +145,25 @@ static weapondata weapontable[WP_MAX + 1] =
weapon_type * oldweapontype[WP_MAX]; weapon_type * oldweapontype[WP_MAX];
static boolean static boolean
attack_firesword(const troop * at, int *casualties) attack_firesword(const troop * at, int *casualties, int row)
{ {
fighter *fi = at->fighter; fighter *fi = at->fighter;
troop dt; troop dt;
/* Immer aus der ersten Reihe nehmen */ /* Immer aus der ersten Reihe nehmen */
int minrow = FIGHT_ROW; int minrow = FIGHT_ROW;
int maxrow = FIGHT_ROW; int maxrow = FIGHT_ROW;
int enemies; int enemies = 0;
int killed = 0; int killed = 0;
const char *damage = "2d8"; const char *damage = "2d8";
int force = 1+rand()%10; int force = 1+rand()%10;
enemies = count_enemies(fi->side, FS_ENEMY, if (row==FIGHT_ROW) {
minrow, maxrow); enemies = count_enemies(fi->side, FS_ENEMY,
minrow, maxrow);
}
if (!enemies) { if (!enemies) {
if (casualties) *casualties = 0; if (casualties) *casualties = 0;
return false; /* if no enemy found, no use doing standarad attack */ return true; /* if no enemy found, no use doing standarad attack */
} }
if (fi->catmsg == -1) { if (fi->catmsg == -1) {
@ -187,7 +188,7 @@ attack_firesword(const troop * at, int *casualties)
} }
static boolean static boolean
attack_catapult(const troop * at, int * casualties) attack_catapult(const troop * at, int * casualties, int row)
{ {
fighter *af = at->fighter; fighter *af = at->fighter;
unit *au = af->unit; unit *au = af->unit;
@ -196,8 +197,11 @@ attack_catapult(const troop * at, int * casualties)
int d = 0, n; int d = 0, n;
int minrow, maxrow; int minrow, maxrow;
weapon * wp = af->person[at->index].weapon; weapon * wp = af->person[at->index].weapon;
assert(wp->type->itype==olditemtype[I_CATAPULT]);
assert(row>=FIGHT_ROW);
if (row>BEHIND_ROW) return false; /* keine weiteren attacken */
assert(wp->type->itype==olditemtype[I_CATAPULT]);
assert (af->person[at->index].reload==0); assert (af->person[at->index].reload==0);
if (af->catmsg == -1) { if (af->catmsg == -1) {
@ -233,7 +237,7 @@ attack_catapult(const troop * at, int * casualties)
} }
if (casualties) *casualties = d; if (casualties) *casualties = d;
return false; return false; /* keine weitren attacken */
} }

View File

@ -1256,6 +1256,8 @@ count_enemies(side * as, int mask, int minrow, int maxrow)
int i = 0; int i = 0;
void **si; void **si;
if (maxrow<FIRST_ROW) return 0;
for (si = b->sides.begin; si != b->sides.end; ++si) { for (si = b->sides.begin; si != b->sides.end; ++si) {
side *side = *si; side *side = *si;
if (enemy(side, as)) if (enemy(side, as))
@ -1376,7 +1378,6 @@ do_combatmagic(battle *b, combatmagic_t was)
void **fi; void **fi;
spell *sp; spell *sp;
fighter *fig; fighter *fig;
unit *mage;
region *r = b->region; region *r = b->region;
castorder *co; castorder *co;
castorder *cll[MAX_SPELLRANK]; castorder *cll[MAX_SPELLRANK];
@ -1389,64 +1390,65 @@ do_combatmagic(battle *b, combatmagic_t was)
} }
for (fi = b->fighters.begin; fi != b->fighters.end; ++fi) { for (fi = b->fighters.begin; fi != b->fighters.end; ++fi) {
fig = *fi; fighter * fig = *fi;
mage = fig->unit; unit * mage = fig->unit;
int row = get_unitrow(fig);
if (fig->alive > 0) { /* fighter kann im Kampf getötet worden sein */ if (row>BEHIND_ROW) continue;
if (fig->alive <= 0) continue; /* fighter kann im Kampf getötet worden sein */
level = eff_skill(mage, SK_MAGIC, r); level = eff_skill(mage, SK_MAGIC, r);
if (level > 0) { if (level > 0) {
char cmd[128]; char cmd[128];
switch(was) { switch(was) {
case DO_PRECOMBATSPELL: case DO_PRECOMBATSPELL:
sp = get_combatspell(mage, 0); sp = get_combatspell(mage, 0);
sl = get_combatspelllevel(mage, 0); sl = get_combatspelllevel(mage, 0);
break; break;
case DO_POSTCOMBATSPELL: case DO_POSTCOMBATSPELL:
sp = get_combatspell(mage, 2); sp = get_combatspell(mage, 2);
sl = get_combatspelllevel(mage, 2); sl = get_combatspelllevel(mage, 2);
break; break;
default: default:
/* Fehler! */ /* Fehler! */
return; return;
}
if (sp == NULL)
continue;
snprintf(cmd, 128, "ZAUBER %s", sp->name);
if (cancast(mage, sp, 1, 1, cmd) == false)
continue;
level = eff_spelllevel(mage, sp, level, 1);
if (sl > 0) level = min(sl, level);
if (level < 0) {
sprintf(buf, "%s versucht %s zu zaubern, doch der Zauber schlägt "
"fehl!", unitname(mage), sp->name);
battlerecord(b, buf);
continue;
}
power = spellpower(r, mage, sp, level);
if (power <= 0) { /* Effekt von Antimagie */
sprintf(buf, "%s versucht %s zu zaubern, doch der Zauber schlägt "
"fehl!", unitname(mage), sp->name);
battlerecord(b, buf);
continue;
}
if (fumble(r, mage, sp, sp->level) == true) {
sprintf(buf, "%s versucht %s zu zaubern, doch der Zauber schlägt "
"fehl!", unitname(mage), sp->name);
battlerecord(b, buf);
pay_spell(mage, sp, level, 1);
continue;
}
co = new_castorder(fig, 0, sp, r, level, power, 0, 0, 0);
add_castorder(&cll[(int)(sp->rank)], co);
} }
if (sp == NULL)
continue;
snprintf(cmd, 128, "ZAUBER %s", sp->name);
if (cancast(mage, sp, 1, 1, cmd) == false)
continue;
level = eff_spelllevel(mage, sp, level, 1);
if (sl > 0) level = min(sl, level);
if (level < 0) {
sprintf(buf, "%s versucht %s zu zaubern, doch der Zauber schlägt "
"fehl!", unitname(mage), sp->name);
battlerecord(b, buf);
continue;
}
power = spellpower(r, mage, sp, level);
if (power <= 0) { /* Effekt von Antimagie */
sprintf(buf, "%s versucht %s zu zaubern, doch der Zauber schlägt "
"fehl!", unitname(mage), sp->name);
battlerecord(b, buf);
continue;
}
if (fumble(r, mage, sp, sp->level) == true) {
sprintf(buf, "%s versucht %s zu zaubern, doch der Zauber schlägt "
"fehl!", unitname(mage), sp->name);
battlerecord(b, buf);
pay_spell(mage, sp, level, 1);
continue;
}
co = new_castorder(fig, 0, sp, r, level, power, 0, 0, 0);
add_castorder(&cll[(int)(sp->rank)], co);
} }
} }
for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) { for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) {
@ -1471,8 +1473,8 @@ do_combatmagic(battle *b, combatmagic_t was)
} }
void static void
do_combatspell(troop at) do_combatspell(troop at, int row)
{ {
spell *sp; spell *sp;
fighter *fi = at.fighter; fighter *fi = at.fighter;
@ -1485,6 +1487,8 @@ do_combatspell(troop at)
int sl; int sl;
char cmd[128]; char cmd[128];
if (row>BEHIND_ROW) return;
sp = get_combatspell(mage, 1); sp = get_combatspell(mage, 1);
if (sp == NULL) { if (sp == NULL) {
fi->magic = 0; /* Hat keinen Kampfzauber, kämpft nichtmagisch weiter */ fi->magic = 0; /* Hat keinen Kampfzauber, kämpft nichtmagisch weiter */
@ -1851,7 +1855,7 @@ attack(battle *b, troop ta, const att *a)
fighter *af = ta.fighter; fighter *af = ta.fighter;
troop td; troop td;
unit *au = af->unit; unit *au = af->unit;
int row = get_unitrow(af) - 1; int row = get_unitrow(af);
switch(a->type) { switch(a->type) {
case AT_STANDARD: /* Waffen, mag. Gegenstände, Kampfzauber */ case AT_STANDARD: /* Waffen, mag. Gegenstände, Kampfzauber */
@ -1860,7 +1864,7 @@ attack(battle *b, troop ta, const att *a)
/* Magier versuchen immer erstmal zu zaubern, erst wenn das /* Magier versuchen immer erstmal zu zaubern, erst wenn das
* fehlschlägt, wird af->magic == 0 und der Magier kämpft * fehlschlägt, wird af->magic == 0 und der Magier kämpft
* konventionell weiter */ * konventionell weiter */
do_combatspell(ta); do_combatspell(ta, row);
} else { } else {
weapon * wp; weapon * wp;
@ -1873,7 +1877,7 @@ attack(battle *b, troop ta, const att *a)
boolean standard_attack = true; boolean standard_attack = true;
if (wp && wp->type->attack) { if (wp && wp->type->attack) {
int dead; int dead;
standard_attack = wp->type->attack(&ta, &dead); standard_attack = wp->type->attack(&ta, &dead, row);
af->catmsg += dead; af->catmsg += dead;
/* TODO: dies hier ist nicht richtig. wenn die katapulte/etc. /* TODO: dies hier ist nicht richtig. wenn die katapulte/etc.
* keinen gegner gefunden haben, sollte es nicht erhöht werden. * keinen gegner gefunden haben, sollte es nicht erhöht werden.
@ -1886,9 +1890,10 @@ attack(battle *b, troop ta, const att *a)
} }
if (standard_attack) { if (standard_attack) {
boolean missile = false; boolean missile = false;
int offset = row-FIGHT_ROW;
if (wp && fval(wp->type, WTF_MISSILE)) missile=true; if (wp && fval(wp->type, WTF_MISSILE)) missile=true;
if (missile) td = select_enemy(af, missile_range[0]-row, missile_range[1]-row); if (missile) td = select_enemy(af, missile_range[0]-offset, missile_range[1]-offset);
else td = select_enemy(af, melee_range[0]-row, melee_range[1]-row); else td = select_enemy(af, melee_range[0]-offset, melee_range[1]-offset);
if (!td.fighter) return; if (!td.fighter) return;
if(td.fighter->person[td.index].last_action < b->turn) { if(td.fighter->person[td.index].last_action < b->turn) {
@ -1920,7 +1925,7 @@ attack(battle *b, troop ta, const att *a)
do_extra_spell(ta, a); do_extra_spell(ta, a);
break; break;
case AT_NATURAL: case AT_NATURAL:
td = select_enemy(af, FIGHT_ROW-row, FIGHT_ROW-row); td = select_enemy(af, row, row);
if (!td.fighter) return; if (!td.fighter) return;
if(td.fighter->person[td.index].last_action < b->turn) { if(td.fighter->person[td.index].last_action < b->turn) {
td.fighter->person[td.index].last_action = b->turn; td.fighter->person[td.index].last_action = b->turn;
@ -1935,7 +1940,7 @@ attack(battle *b, troop ta, const att *a)
} }
break; break;
case AT_DRAIN_ST: case AT_DRAIN_ST:
td = select_enemy(af, FIGHT_ROW-row, FIGHT_ROW-row); td = select_enemy(af, row, row);
if (!td.fighter) return; if (!td.fighter) return;
if(td.fighter->person[td.index].last_action < b->turn) { if(td.fighter->person[td.index].last_action < b->turn) {
td.fighter->person[td.index].last_action = b->turn; td.fighter->person[td.index].last_action = b->turn;
@ -1958,7 +1963,7 @@ attack(battle *b, troop ta, const att *a)
} }
break; break;
case AT_DRAIN_EXP: case AT_DRAIN_EXP:
td = select_enemy(af, FIGHT_ROW-row, FIGHT_ROW-row); td = select_enemy(af, row, row);
if (!td.fighter) return; if (!td.fighter) return;
if(td.fighter->person[td.index].last_action < b->turn) { if(td.fighter->person[td.index].last_action < b->turn) {
td.fighter->person[td.index].last_action = b->turn; td.fighter->person[td.index].last_action = b->turn;
@ -1973,7 +1978,7 @@ attack(battle *b, troop ta, const att *a)
} }
break; break;
case AT_DAZZLE: case AT_DAZZLE:
td = select_enemy(af, FIGHT_ROW-row, FIGHT_ROW-row); td = select_enemy(af, row, row);
if (!td.fighter) return; if (!td.fighter) return;
if(td.fighter->person[td.index].last_action < b->turn) { if(td.fighter->person[td.index].last_action < b->turn) {
td.fighter->person[td.index].last_action = b->turn; td.fighter->person[td.index].last_action = b->turn;
@ -1988,7 +1993,7 @@ attack(battle *b, troop ta, const att *a)
} }
break; break;
case AT_STRUCTURAL: case AT_STRUCTURAL:
td = select_enemy(af, FIGHT_ROW-row, FIGHT_ROW-row); td = select_enemy(af, row, row);
if (!td.fighter) return; if (!td.fighter) return;
if(ta.fighter->person[ta.index].last_action < b->turn) { if(ta.fighter->person[ta.index].last_action < b->turn) {
ta.fighter->person[ta.index].last_action = b->turn; ta.fighter->person[ta.index].last_action = b->turn;

View File

@ -193,7 +193,7 @@ typedef struct weapon_type {
int reload; /* time to reload this weapon */ int reload; /* time to reload this weapon */
weapon_mod * modifiers; weapon_mod * modifiers;
/* --- functions --- */ /* --- functions --- */
boolean (*attack)(const struct troop *, int *deaths); boolean (*attack)(const struct troop *, int *deaths, int row);
/* --- pointers --- */ /* --- pointers --- */
struct weapon_type * next; struct weapon_type * next;
} weapon_type; } weapon_type;