count_enemies ist verflucht lahm. Ich werde mal sehen, ob ich das shcneller machen kann.

This commit is contained in:
Enno Rehling 2004-04-18 21:44:24 +00:00
parent 619a2ff69c
commit 1e9538b8d8
4 changed files with 316 additions and 321 deletions

View File

@ -175,8 +175,7 @@ attack_firesword(const troop * at, int *casualties, int row)
int force = 1+rand()%10; int force = 1+rand()%10;
if (row==FIGHT_ROW) { if (row==FIGHT_ROW) {
enemies = count_enemies(fi->side->battle, fi->side, FS_ENEMY, enemies = count_enemies(fi->side->battle, fi->side, minrow, maxrow);
minrow, maxrow);
} }
if (!enemies) { if (!enemies) {
if (casualties) *casualties = 0; if (casualties) *casualties = 0;
@ -243,7 +242,7 @@ attack_catapult(const troop * at, int * casualties, int row)
minrow = FIGHT_ROW; minrow = FIGHT_ROW;
maxrow = FIGHT_ROW; maxrow = FIGHT_ROW;
n = min(CATAPULT_ATTACKS, count_enemies(b, af->side, FS_ENEMY, minrow, maxrow)); n = min(CATAPULT_ATTACKS, count_enemies(b, af->side, minrow, maxrow));
#if CATAPULT_AMMUNITION #if CATAPULT_AMMUNITION
new_use_pooled(au, &rt_catapultammo, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 1); new_use_pooled(au, &rt_catapultammo, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 1);

View File

@ -502,74 +502,74 @@ hpflee(int status)
} }
int int
get_unitrow(fighter * af) get_unitrow(const fighter * af)
{ {
static boolean * counted = NULL; static boolean * counted = NULL;
static size_t csize = 0; static size_t csize = 0;
battle * b = af->side->battle; battle * b = af->side->battle;
void **si; void **si;
int enemyfront = 0; int enemyfront = 0;
int line, result; int line, result;
int retreat = 0; int retreat = 0;
int size[NUMROWS]; int size[NUMROWS];
int row = statusrow(af->status); int row = statusrow(af->status);
int front = 0; int front = 0;
size_t bsize; size_t bsize;
#ifdef FAST_GETUNITROW #ifdef FAST_GETUNITROW
if (!b->nonblockers && b->alive==af->row.alive) { if (!b->nonblockers && b->alive==af->row.alive) {
return af->row.cached; return af->row.cached;
} }
#endif #endif
bsize = cv_size(&b->sides); bsize = cv_size(&b->sides);
if (csize<bsize) { if (csize<bsize) {
if (counted) free(counted); if (counted) free(counted);
csize=bsize; csize=bsize;
counted = calloc(sizeof(boolean), bsize); counted = calloc(sizeof(boolean), bsize);
} }
else memset(counted, 0, bsize*sizeof(boolean)); else memset(counted, 0, bsize*sizeof(boolean));
memset(size, 0, sizeof(size)); memset(size, 0, sizeof(size));
for (line=FIRST_ROW;line!=NUMROWS;++line) { for (line=FIRST_ROW;line!=NUMROWS;++line) {
/* how many enemies are there in the first row? */ /* how many enemies are there in the first row? */
for (si = b->sides.begin; si != b->sides.end; ++si) { for (si = b->sides.begin; si != b->sides.end; ++si) {
side *s = *si; side *s = *si;
if (s->size[line] && enemy(s, af->side)) if (s->size[line] && enemy(s, af->side))
{ {
void ** sf; void ** sf;
enemyfront += s->size[line]; /* - s->nonblockers[line] (nicht, weil angreifer) */ enemyfront += s->size[line]; /* - s->nonblockers[line] (nicht, weil angreifer) */
for (sf = b->sides.begin; sf != b->sides.end; ++sf) { for (sf = b->sides.begin; sf != b->sides.end; ++sf) {
side * ally = *sf; side * ally = *sf;
if (!counted[ally->index] && enemy(s, ally) && !enemy(ally, af->side)) if (!counted[ally->index] && enemy(s, ally) && !enemy(ally, af->side))
{ {
int i; int i;
counted[ally->index] = true; counted[ally->index] = true;
for (i=0;i!=NUMROWS;++i) size[i] += ally->size[i] - ally->nonblockers[i]; for (i=0;i!=NUMROWS;++i) size[i] += ally->size[i] - ally->nonblockers[i];
} }
} }
} }
} }
if (enemyfront) break; if (enemyfront) break;
} }
if (enemyfront) { if (enemyfront) {
for (line=FIRST_ROW;line!=NUMROWS;++line) { for (line=FIRST_ROW;line!=NUMROWS;++line) {
front += size[line]; front += size[line];
if (!front || front<enemyfront/10) ++retreat; if (!front || front<enemyfront/10) ++retreat;
else if (front) break; else if (front) break;
} }
} }
/* every entry in the size[] array means someone trying to defend us. /* every entry in the size[] array means someone trying to defend us.
* 'retreat' is the number of rows falling. * 'retreat' is the number of rows falling.
*/ */
result = max(FIRST_ROW, row - retreat); result = max(FIRST_ROW, row - retreat);
#ifdef FAST_GETUNITROW #ifdef FAST_GETUNITROW
af->row.alive = b->alive; af->row.alive = b->alive;
af->row.cached = result; af->row.cached = result;
#endif #endif
return result; return result;
} }
static int static int
@ -1297,80 +1297,84 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
return true; return true;
} }
/* ------------------------------------------------------------- */ static int
int count_side(const side * s, int minrow, int maxrow)
count_enemies(battle * b, side * as, int mask, int minrow, int maxrow)
/* new implementation of count_enemies ignores mask, since it was never used */
{ {
int i = 0; void **fi;
void **si; int people = 0;
if (maxrow<FIRST_ROW) return 0; for (fi = s->fighters.begin; fi != s->fighters.end; ++fi) {
const fighter *fig = *fi;
int row;
for (si = b->sides.begin; si != b->sides.end; ++si) { if (fig->alive - fig->removed <= 0) continue;
side *side = *si; row = get_unitrow(fig);
if (as==NULL || enemy(side, as))
{
void **fi;
for (fi = side->fighters.begin; fi != side->fighters.end; ++fi) { if (row >= minrow && row <= maxrow) {
fighter *fig = *fi; people += fig->alive - fig->removed;
int row; }
}
if (fig->alive - fig->removed <= 0) return people;
continue; }
else
row = get_unitrow(fig); /* new implementation of count_enemies ignores mask, since it was never used */
int
if (row >= minrow && row <= maxrow) count_enemies(battle * b, side * as, int minrow, int maxrow)
i += fig->alive - fig->removed; {
} int i = 0;
} void **si;
}
return i; if (maxrow<FIRST_ROW) return 0;
for (si = b->sides.begin; si != b->sides.end; ++si) {
side *side = *si;
if (as==NULL || enemy(side, as)) {
i += count_side(side, minrow, maxrow);
}
}
return i;
} }
/* ------------------------------------------------------------- */
troop troop
select_enemy(battle * b, fighter * af, int minrow, int maxrow) select_enemy(battle * b, fighter * af, int minrow, int maxrow)
{ {
side *as = af?af->side:NULL; side *as = af?af->side:NULL;
troop dt = no_troop; troop dt = no_troop;
void ** si; void ** si;
int enemies; int enemies;
if (af && af->unit->race->flags & RCF_FLY) { if (af && af->unit->race->flags & RCF_FLY) {
/* flying races ignore min- and maxrow and can attack anyone fighting /* flying races ignore min- and maxrow and can attack anyone fighting
* them */ * them */
minrow = FIGHT_ROW; minrow = FIGHT_ROW;
maxrow = BEHIND_ROW; maxrow = BEHIND_ROW;
} }
minrow = max(minrow, FIGHT_ROW); minrow = max(minrow, FIGHT_ROW);
enemies = count_enemies(b, as, FS_ENEMY, minrow, maxrow); enemies = count_enemies(b, as, minrow, maxrow);
if (!enemies) if (!enemies)
return dt; /* Niemand ist in der angegebenen Entfernung */ return dt; /* Niemand ist in der angegebenen Entfernung */
enemies = rand() % enemies; enemies = rand() % enemies;
for (si=b->sides.begin;!dt.fighter && si!=b->sides.end;++si) { for (si=b->sides.begin;!dt.fighter && si!=b->sides.end;++si) {
side *ds = *si; side *ds = *si;
void ** fi; void ** fi;
if (as!=NULL && !enemy(as, ds)) continue; if (as!=NULL && !enemy(as, ds)) continue;
for (fi=ds->fighters.begin;fi!=ds->fighters.end;++fi) { for (fi=ds->fighters.begin;fi!=ds->fighters.end;++fi) {
fighter * df = *fi; fighter * df = *fi;
int dr = get_unitrow(df); int dr = get_unitrow(df);
if (dr < minrow || dr > maxrow) continue; if (dr < minrow || dr > maxrow) continue;
if (df->alive - df->removed > enemies) { if (df->alive - df->removed > enemies) {
dt.index = enemies; dt.index = enemies;
dt.fighter = df; dt.fighter = df;
enemies = 0; enemies = 0;
break; break;
} }
else enemies -= (df->alive - df->removed); else enemies -= (df->alive - df->removed);
} }
} }
assert(!enemies); assert(!enemies);
return dt; return dt;
} }
/* /*
@ -2115,7 +2119,7 @@ do_attack(fighter * af)
while (ta.index--) { while (ta.index--) {
/* Wir suchen eine beliebige Feind-Einheit aus. An der können /* Wir suchen eine beliebige Feind-Einheit aus. An der können
* wir feststellen, ob noch jemand da ist. */ * wir feststellen, ob noch jemand da ist. */
int enemies = count_enemies(b, af->side, FS_ENEMY, FIGHT_ROW, LAST_ROW); int enemies = count_enemies(b, af->side, FIGHT_ROW, LAST_ROW);
if (!enemies) break; if (!enemies) break;
for (apr=attacks_per_round(ta); apr > 0; apr--) { for (apr=attacks_per_round(ta); apr > 0; apr--) {

View File

@ -1,15 +1,15 @@
/* vi: set ts=2: /* vi: set ts=2:
* *
* Eressea PB(E)M host Copyright (C) 1998-2003 * Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de) * Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea-pbem.de) * Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
* *
* This program may not be used, modified or distributed without * This program may not be used, modified or distributed without
* prior permission by the authors of Eressea. * prior permission by the authors of Eressea.
*/ */
#ifndef H_KRNL_BATTLE #ifndef H_KRNL_BATTLE
#define H_KRNL_BATTLE #define H_KRNL_BATTLE
@ -17,16 +17,16 @@
extern "C" { extern "C" {
#endif #endif
/** new code defines **/ /** new code defines **/
#undef FAST_GETUNITROW #undef FAST_GETUNITROW
/** more defines **/ /** more defines **/
#define FS_ENEMY 1 #define FS_ENEMY 1
#define FS_HELP 2 #define FS_HELP 2
/***** Verteidigungslinien. /***** Verteidigungslinien.
* Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enthält Summen * Eressea hat 4 Verteidigungslinien. 1 ist vorn, 5. enthält Summen
*/ */
#define NUMROWS 5 #define NUMROWS 5
#define SUM_ROW 0 #define SUM_ROW 0
#define FIGHT_ROW 1 #define FIGHT_ROW 1
@ -36,73 +36,73 @@ extern "C" {
#define LAST_ROW (NUMROWS-1) #define LAST_ROW (NUMROWS-1)
#define FIRST_ROW FIGHT_ROW #define FIRST_ROW FIGHT_ROW
typedef struct bfaction { typedef struct bfaction {
struct bfaction * next; struct bfaction * next;
struct side * sides; struct side * sides;
struct faction *faction; struct faction *faction;
int lastturn; /* last time this struct faction was involved in combat */ int lastturn; /* last time this struct faction was involved in combat */
boolean attacker; boolean attacker;
} bfaction; } bfaction;
typedef struct battle { typedef struct battle {
cvector leaders; cvector leaders;
struct region *region; struct region *region;
struct plane *plane; struct plane *plane;
bfaction * factions; bfaction * factions;
int nfactions; int nfactions;
cvector fighters; cvector fighters;
cvector sides; cvector sides;
cvector meffects; cvector meffects;
int max_tactics; int max_tactics;
int turn; int turn;
boolean has_tactics_turn; boolean has_tactics_turn;
int keeploot; int keeploot;
boolean reelarrow; boolean reelarrow;
int dh; int dh;
int alive; int alive;
boolean small; boolean small;
#ifdef FAST_GETUNITROW #ifdef FAST_GETUNITROW
boolean nonblockers; boolean nonblockers;
#endif #endif
} battle; } battle;
typedef struct tactics { typedef struct tactics {
cvector fighters; cvector fighters;
int value; int value;
} tactics; } tactics;
typedef struct side { typedef struct side {
struct tactics leader; /* der beste Taktiker des Heeres */ struct tactics leader; /* der beste Taktiker des Heeres */
struct side * nextF; /* nächstes Heer der gleichen Partei */ struct side * nextF; /* nächstes Heer der gleichen Partei */
struct battle * battle; struct battle * battle;
struct bfaction * bf; /* Die Partei, die hier kämpft */ struct bfaction * bf; /* Die Partei, die hier kämpft */
const struct group * group; const struct group * group;
# define E_ENEMY 1 # define E_ENEMY 1
# define E_ATTACKING 2 # define E_ATTACKING 2
int enemy[128]; int enemy[128];
cvector fighters; /* vector der Einheiten dieser Fraktion */ cvector fighters; /* vector der Einheiten dieser Fraktion */
int index; /* Eintrag der Fraktion in b->matrix/b->enemies */ int index; /* Eintrag der Fraktion in b->matrix/b->enemies */
int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */ int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */
int nonblockers[NUMROWS]; /* Anzahl nichtblockierender Kämpfer, z.B. Schattenritter. */ int nonblockers[NUMROWS]; /* Anzahl nichtblockierender Kämpfer, z.B. Schattenritter. */
int alive; /* Die Partei hat den Kampf verlassen */ int alive; /* Die Partei hat den Kampf verlassen */
int removed; /* stoned */ int removed; /* stoned */
int flee; int flee;
int dead; int dead;
int casualties; int casualties;
int healed; int healed;
boolean dh; boolean dh;
boolean stealth; /* Die Einheiten sind getarnt */ boolean stealth; /* Die Einheiten sind getarnt */
const struct faction *stealthfaction; const struct faction *stealthfaction;
} side; } side;
typedef struct weapon { typedef struct weapon {
int count, used; int count, used;
const struct weapon_type * type; const struct weapon_type * type;
int attackskill : 8; int attackskill : 8;
int defenseskill : 8; int defenseskill : 8;
} weapon; } weapon;
/*** fighter::person::flags ***/ /*** fighter::person::flags ***/
#define FL_TIRED 1 #define FL_TIRED 1
#define FL_DAZZLED 2 /* durch Untote oder Dämonen eingeschüchtert */ #define FL_DAZZLED 2 /* durch Untote oder Dämonen eingeschüchtert */
#define FL_PANICED 4 #define FL_PANICED 4
@ -110,127 +110,127 @@ typedef struct weapon {
#define FL_SLEEPING 16 #define FL_SLEEPING 16
#define FL_STUNNED 32 /* eine Runde keinen Angriff */ #define FL_STUNNED 32 /* eine Runde keinen Angriff */
/*** fighter::flags ***/ /*** fighter::flags ***/
#define FIG_ATTACKED 1 #define FIG_ATTACKED 1
#define FIG_NOLOOT 2 #define FIG_NOLOOT 2
typedef unsigned char armor_t; typedef unsigned char armor_t;
enum { enum {
#ifdef COMPATIBILITY #ifdef COMPATIBILITY
AR_MAGICAL, AR_MAGICAL,
#endif #endif
AR_PLATE, AR_PLATE,
AR_CHAIN, AR_CHAIN,
AR_RUSTY_CHAIN, AR_RUSTY_CHAIN,
AR_SHIELD, AR_SHIELD,
AR_RUSTY_SHIELD, AR_RUSTY_SHIELD,
AR_EOGSHIELD, AR_EOGSHIELD,
AR_EOGCHAIN, AR_EOGCHAIN,
AR_MAX, AR_MAX,
AR_NONE AR_NONE
}; };
typedef struct fighter { typedef struct fighter {
struct side *side; struct side *side;
struct unit *unit; /* Die Einheit, die hier kämpft */ struct unit *unit; /* Die Einheit, die hier kämpft */
struct building *building; /* Gebäude, in dem die Einheit evtl. steht */ struct building *building; /* Gebäude, in dem die Einheit evtl. steht */
status_t status; /* Kampfstatus */ status_t status; /* Kampfstatus */
struct weapon * weapons; struct weapon * weapons;
int armor[AR_MAX]; /* Anzahl Rüstungen jeden Typs */ int armor[AR_MAX]; /* Anzahl Rüstungen jeden Typs */
int alive; /* Anzahl der noch nicht Toten in der Einheit */ int alive; /* Anzahl der noch nicht Toten in der Einheit */
int fighting; /* Anzahl der Kämpfer in der aktuellen Runde */ int fighting; /* Anzahl der Kämpfer in der aktuellen Runde */
int removed; /* Anzahl Kaempfer, die nicht tot sind, aber int removed; /* Anzahl Kaempfer, die nicht tot sind, aber
aus dem Kampf raus sind (zB weil sie aus dem Kampf raus sind (zB weil sie
versteinert wurden). Diese werden auch versteinert wurden). Diese werden auch
in alive noch mitgezählt! */ in alive noch mitgezählt! */
int magic; /* Magietalent der Einheit */ int magic; /* Magietalent der Einheit */
int horses; /* Anzahl brauchbarer Pferde der Einheit */ int horses; /* Anzahl brauchbarer Pferde der Einheit */
int elvenhorses; /* Anzahl brauchbarer Elfenpferde der Einheit */ int elvenhorses; /* Anzahl brauchbarer Elfenpferde der Einheit */
struct item * loot; struct item * loot;
int catmsg; /* Merkt sich, ob Katapultmessage schon generiert. */ int catmsg; /* Merkt sich, ob Katapultmessage schon generiert. */
struct person { struct person {
int attack : 8; /* (Magie) Attackenbonus der Personen */ int attack : 8; /* (Magie) Attackenbonus der Personen */
int defence : 8; /* (Magie) Paradenbonus der Personen */ int defence : 8; /* (Magie) Paradenbonus der Personen */
int damage : 8; /* (Magie) Schadensbonus der Personen im Nahkampf */ int damage : 8; /* (Magie) Schadensbonus der Personen im Nahkampf */
int damage_rear : 8; /* (Magie) Schadensbonus der Personen im Fernkampf */ int damage_rear : 8; /* (Magie) Schadensbonus der Personen im Fernkampf */
int hp : 16; /* Trefferpunkte der Personen */ int hp : 16; /* Trefferpunkte der Personen */
int flags : 8; /* (Magie) Diverse Flags auf Kämpfern */ int flags : 8; /* (Magie) Diverse Flags auf Kämpfern */
int speed : 8; /* (Magie) Geschwindigkeitsmultiplkator. */ int speed : 8; /* (Magie) Geschwindigkeitsmultiplkator. */
int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss. int reload : 4; /* Anzahl Runden, die die Waffe x noch laden muss.
* dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */ * dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */
int last_action : 8; /* In welcher Runde haben wir zuletzt etwas getan */ int last_action : 8; /* In welcher Runde haben wir zuletzt etwas getan */
struct weapon * missile; /* missile weapon */ struct weapon * missile; /* missile weapon */
struct weapon * melee; /* melee weapon */ struct weapon * melee; /* melee weapon */
} * person; } * person;
int flags; int flags;
struct { struct {
int number; /* number of people who have flown */ int number; /* number of people who have flown */
int hp; /* accumulated hp of fleeing people */ int hp; /* accumulated hp of fleeing people */
#ifndef NO_RUNNING #ifndef NO_RUNNING
struct region *region; /* destination of fleeing people */ struct region *region; /* destination of fleeing people */
struct item * items; /* items they take */ struct item * items; /* items they take */
#endif #endif
} run; } run;
int action_counter; /* number of active actions the struct unit did in the fight */ int action_counter; /* number of active actions the struct unit did in the fight */
#ifdef SHOW_KILLS #ifdef SHOW_KILLS
int kills; int kills;
int hits; int hits;
#endif #endif
#ifdef FAST_GETUNITROW #ifdef FAST_GETUNITROW
struct { struct {
int alive; int alive;
int cached; int cached;
} row; } row;
#endif #endif
} fighter; } fighter;
typedef struct troop { typedef struct troop {
struct fighter *fighter; struct fighter *fighter;
int index; int index;
} troop; } troop;
/* schilde */ /* schilde */
enum { enum {
SHIELD_REDUCE, SHIELD_REDUCE,
SHIELD_ARMOR, SHIELD_ARMOR,
SHIELD_WIND, SHIELD_WIND,
SHIELD_BLOCK, SHIELD_BLOCK,
SHIELD_MAX SHIELD_MAX
}; };
typedef struct meffect { typedef struct meffect {
fighter *magician; /* Der Zauberer, der den Schild gezaubert hat */ fighter *magician; /* Der Zauberer, der den Schild gezaubert hat */
int typ; /* Wirkungsweise des Schilds */ int typ; /* Wirkungsweise des Schilds */
int effect; int effect;
int duration; int duration;
} meffect; } meffect;
extern const troop no_troop; extern const troop no_troop;
extern void do_battle(void); extern void do_battle(void);
/* for combar spells and special attacks */ /* for combar spells and special attacks */
extern int damage_unit(struct unit *u, const char *dam, boolean armor, boolean magic); extern int damage_unit(struct unit *u, const char *dam, boolean armor, boolean magic);
extern troop select_enemy(struct battle * b, struct fighter * af, int minrow, int maxrow); extern troop select_enemy(struct battle * b, struct fighter * af, int minrow, int maxrow);
extern int count_enemies(struct battle * b, struct side * as, int mask, int minrow, int maxrow); extern int count_enemies(struct battle * b, struct side * as, int minrow, int maxrow);
extern boolean terminate(troop dt, troop at, int type, const char *damage, boolean missile); extern boolean terminate(troop dt, troop at, int type, const char *damage, boolean missile);
extern void battlemsg(battle * b, struct unit * u, const char * s); extern void battlemsg(battle * b, struct unit * u, const char * s);
extern void battlerecord(battle * b, const char *s); extern void battlerecord(battle * b, const char *s);
extern int hits(troop at, troop dt, weapon * awp); extern int hits(troop at, troop dt, weapon * awp);
extern void damage_building(struct battle *b, struct building *bldg, int damage_abs); extern void damage_building(struct battle *b, struct building *bldg, int damage_abs);
extern struct cvector * fighters(struct battle *b, struct fighter *af, int minrow, int maxrow, int mask); extern struct cvector * fighters(struct battle *b, struct fighter *af, int minrow, int maxrow, int mask);
extern int countallies(struct side * as); extern int countallies(struct side * as);
extern int get_unitrow(struct fighter * af); extern int get_unitrow(const struct fighter * af);
extern boolean helping(struct side * as, struct side * ds); extern boolean helping(struct side * as, struct side * ds);
extern void rmfighter(fighter *df, int i); extern void rmfighter(fighter *df, int i);
extern struct region * fleeregion(const struct unit * u); extern struct region * fleeregion(const struct unit * u);
extern struct troop select_corpse(struct battle * b, struct fighter * af); extern struct troop select_corpse(struct battle * b, struct fighter * af);
extern fighter * make_fighter(struct battle * b, struct unit * u, side * s, boolean attack); extern fighter * make_fighter(struct battle * b, struct unit * u, side * s, boolean attack);
extern int statusrow(int status); extern int statusrow(int status);
extern void drain_exp(struct unit *u, int d); extern void drain_exp(struct unit *u, int d);
extern void rmtroop(troop dt); extern void rmtroop(troop dt);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -139,8 +139,7 @@ sp_kampfzauber(fighter * fi, int level, double power, spell * sp)
force = lovar(get_force(power,10)); force = lovar(get_force(power,10));
} }
enemies = count_enemies(b, fi->side, FS_ENEMY, enemies = count_enemies(b, fi->side, minrow, maxrow);
minrow, maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
battlerecord(b, buf); battlerecord(b, buf);
@ -181,8 +180,7 @@ sp_versteinern(fighter * fi, int level, double power, spell * sp)
force = lovar(get_force(power,0)); force = lovar(get_force(power,0));
enemies = count_enemies(b, fi->side, FS_ENEMY, enemies = count_enemies(b, fi->side, minrow, maxrow);
minrow, maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
battlerecord(b, buf); battlerecord(b, buf);
@ -241,7 +239,7 @@ sp_stun(fighter * fi, int level, double power, spell * sp)
assert(0); assert(0);
} }
enemies = count_enemies(b, fi->side, FS_ENEMY, minrow, maxrow); enemies = count_enemies(b, fi->side, minrow, maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
battlerecord(b, buf); battlerecord(b, buf);
@ -297,7 +295,7 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
force = lovar(power * 15); force = lovar(power * 15);
enemies = count_enemies(b, fi->side, FS_ENEMY, minrow, maxrow); enemies = count_enemies(b, fi->side, minrow, maxrow);
if (!enemies) { if (!enemies) {
battlemsg(b, fi->unit, msgt[0]); battlemsg(b, fi->unit, msgt[0]);
return 0; return 0;
@ -383,7 +381,7 @@ sp_sleep(fighter * fi, int level, double power, spell * sp)
sprintf(buf, "%s zaubert %s", unitname(mage), sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale)); spell_name(sp, default_locale));
force = lovar(power * 25); force = lovar(power * 25);
enemies = count_enemies(b, fi->side, FS_ENEMY, minrow, maxrow); enemies = count_enemies(b, fi->side, minrow, maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
@ -530,7 +528,7 @@ sp_mindblast(fighter * fi, int level, double power, spell * sp)
spell_name(sp, default_locale)); spell_name(sp, default_locale));
force = lovar(power * 25); force = lovar(power * 25);
enemies = count_enemies(b, fi->side, FS_ENEMY, minrow, maxrow); enemies = count_enemies(b, fi->side, minrow, maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
battlerecord(b, buf); battlerecord(b, buf);
@ -615,8 +613,7 @@ sp_dragonodem(fighter * fi, int level, double power, spell * sp)
/* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */ /* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */
force = lovar(get_force(level,6)); force = lovar(get_force(level,6));
enemies = count_enemies(b, fi->side, FS_ENEMY, minrow, enemies = count_enemies(b, fi->side, minrow, maxrow);
maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
@ -665,8 +662,7 @@ sp_immolation(fighter * fi, int level, double power, spell * sp)
/* Betrifft alle Gegner */ /* Betrifft alle Gegner */
force = 99999; force = 99999;
enemies = count_enemies(b, fi->side, FS_ENEMY, minrow, enemies = count_enemies(b, fi->side, minrow, maxrow);
maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
@ -715,8 +711,7 @@ sp_drainodem(fighter * fi, int level, double power, spell * sp)
/* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */ /* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */
force = lovar(get_force(level,6)); force = lovar(get_force(level,6));
enemies = count_enemies(b, fi->side, FS_ENEMY, minrow, enemies = count_enemies(b, fi->side, minrow, maxrow);
maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
@ -924,7 +919,7 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
break; break;
} }
enemies = count_enemies(b, fi->side, FS_ENEMY, minrow, maxrow); enemies = count_enemies(b, fi->side, minrow, maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
battlerecord(b, buf); battlerecord(b, buf);
@ -1021,7 +1016,7 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
force = (int)get_force(power,10); force = (int)get_force(power,10);
} }
if (!count_enemies(b, fi->side, FS_ENEMY, minrow, maxrow)) { if (!count_enemies(b, fi->side, minrow, maxrow)) {
scat(", aber es gab niemanden mehr, der beeinflusst werden konnte."); scat(", aber es gab niemanden mehr, der beeinflusst werden konnte.");
battlerecord(b, buf); battlerecord(b, buf);
return 0; return 0;
@ -1200,8 +1195,7 @@ sp_frighten(fighter * fi, int level, double power, spell * sp)
sprintf(buf, "%s zaubert %s", unitname(mage), sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale)); spell_name(sp, default_locale));
enemies = count_enemies(b, fi->side, FS_ENEMY, enemies = count_enemies(b, fi->side, minrow, maxrow);
minrow, maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
battlerecord(b, buf); battlerecord(b, buf);
@ -1250,8 +1244,7 @@ sp_tiredsoldiers(fighter * fi, int level, double power, spell * sp)
sprintf(buf, "%s zaubert %s", unitname(mage), sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale)); spell_name(sp, default_locale));
if (!count_enemies(b, fi->side, FS_ENEMY, FIGHT_ROW, if (!count_enemies(b, fi->side, FIGHT_ROW, BEHIND_ROW)) {
BEHIND_ROW)) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
battlerecord(b, buf); battlerecord(b, buf);
return 0; return 0;
@ -1311,8 +1304,7 @@ sp_windshield(fighter * fi, int level, double power, spell * sp)
force = (int)power; force = (int)power;
at_malus = 2; at_malus = 2;
} }
enemies = count_enemies(b, fi->side, FS_ENEMY, enemies = count_enemies(b, fi->side, minrow, maxrow);
minrow, maxrow);
if (!enemies) { if (!enemies) {
scat(", aber niemand war in Reichweite."); scat(", aber niemand war in Reichweite.");
battlerecord(b, buf); battlerecord(b, buf);