- FLIEHEnde oder NICHT kaempfende Einheiten koennen keine Beute mehr machen.
- Es gibt fuer select_enemy() u.a. jetzt eine Option, die ohne Beruecksichtigung des Advancements zu berechnen, wie fuer die o.g. Beuteverteilung benoetigt.
This commit is contained in:
Enno Rehling 2004-09-11 17:29:13 +00:00
parent 736739ca42
commit f68f9af5c5
9 changed files with 130 additions and 118 deletions

View File

@ -164,7 +164,7 @@ attack_firesword(const troop * at, int *casualties, int row)
int force = 1+rand()%10;
if (row==FIGHT_ROW) {
enemies = count_enemies(fi->side->battle, fi->side, minrow, maxrow);
enemies = count_enemies(fi->side->battle, fi->side, minrow, maxrow, true);
}
if (!enemies) {
if (casualties) *casualties = 0;
@ -184,7 +184,7 @@ attack_firesword(const troop * at, int *casualties, int row)
}
do {
dt = select_enemy(fi->side->battle, fi, minrow, maxrow);
dt = select_enemy(fi->side->battle, fi, minrow, maxrow, true);
assert(dt.fighter);
--force;
killed += terminate(dt, *at, AT_SPELL, damage, 1);
@ -231,7 +231,7 @@ attack_catapult(const troop * at, int * casualties, int row)
minrow = FIGHT_ROW;
maxrow = FIGHT_ROW;
n = min(CATAPULT_ATTACKS, count_enemies(b, af->side, minrow, maxrow));
n = min(CATAPULT_ATTACKS, count_enemies(b, af->side, minrow, maxrow, true));
#if CATAPULT_AMMUNITION
new_use_pooled(au, &rt_catapultammo, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, 1);
@ -239,7 +239,7 @@ attack_catapult(const troop * at, int * casualties, int row)
while (--n >= 0) {
/* Select defender */
dt = select_enemy(b, af, minrow, maxrow);
dt = select_enemy(b, af, minrow, maxrow, true);
if (!dt.fighter)
break;

View File

@ -1261,14 +1261,16 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
}
static int
count_side(const side * s, int minrow, int maxrow)
count_side(const side * s, int minrow, int maxrow, boolean advance)
{
void **fi;
int people = 0;
int unitrow[NUMROWS];
int i;
if (advance) {
for (i=0;i!=NUMROWS;++i) unitrow[i] = -1;
}
for (fi = s->fighters.begin; fi != s->fighters.end; ++fi) {
const fighter *fig = *fi;
@ -1276,11 +1278,12 @@ count_side(const side * s, int minrow, int maxrow)
if (fig->alive - fig->removed <= 0) continue;
row = statusrow(fig->status);
if (advance) {
if (unitrow[row] == -1) {
unitrow[row] = get_unitrow(fig);
}
row = unitrow[row];
}
if (row >= minrow && row <= maxrow) {
people += fig->alive - fig->removed;
}
@ -1290,7 +1293,7 @@ count_side(const side * s, int minrow, int maxrow)
/* new implementation of count_enemies ignores mask, since it was never used */
int
count_enemies(battle * b, side * as, int minrow, int maxrow)
count_enemies(battle * b, side * as, int minrow, int maxrow, boolean advance)
{
int i = 0;
void **si;
@ -1300,14 +1303,14 @@ count_enemies(battle * b, side * as, int minrow, int maxrow)
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);
i += count_side(side, minrow, maxrow, advance);
}
}
return i;
}
troop
select_enemy(battle * b, fighter * af, int minrow, int maxrow)
select_enemy(battle * b, fighter * af, int minrow, int maxrow, boolean advance)
{
side *as = af->side;
int si;
@ -1321,7 +1324,7 @@ select_enemy(battle * b, fighter * af, int minrow, int maxrow)
}
minrow = max(minrow, FIGHT_ROW);
enemies = count_enemies(b, as, minrow, maxrow);
enemies = count_enemies(b, as, minrow, maxrow, advance);
/* Niemand ist in der angegebenen Entfernung? */
if (enemies<=0) return no_troop;
@ -1330,19 +1333,24 @@ select_enemy(battle * b, fighter * af, int minrow, int maxrow)
for (si=0;as->enemies[si];++si) {
side *ds = as->enemies[si];
void ** fi;
int ui, unitrow[NUMROWS];
int unitrow[NUMROWS];
if (advance) {
int ui;
for (ui=0;ui!=NUMROWS;++ui) unitrow[ui] = -1;
}
for (fi=ds->fighters.begin;fi!=ds->fighters.end;++fi) {
fighter * df = *fi;
int dr;
ui = statusrow(df->status);
if (unitrow[ui]<0) {
unitrow[ui] = get_unitrow(df);
dr = statusrow(df->status);
if (advance) {
if (unitrow[dr]<0) {
unitrow[dr] = get_unitrow(df);
}
dr = unitrow[dr];
}
dr = unitrow[ui];
if (dr < minrow || dr > maxrow) continue;
if (df->alive - df->removed > enemies) {
@ -1386,7 +1394,7 @@ select_opponent(battle * b, troop at, int minrow, int maxrow)
}
}
#endif
dt = select_enemy(b, at.fighter, minrow, maxrow);
dt = select_enemy(b, at.fighter, minrow, maxrow, true);
#ifdef FIXED_OPPONENTS
if (dt.fighter!=NULL) {
fighter * df = dt.fighter;
@ -2180,7 +2188,7 @@ do_attack(fighter * af)
while (ta.index--) {
/* Wir suchen eine beliebige Feind-Einheit aus. An der können
* wir feststellen, ob noch jemand da ist. */
int enemies = count_enemies(b, af->side, FIGHT_ROW, LAST_ROW);
int enemies = count_enemies(b, af->side, FIGHT_ROW, LAST_ROW, true);
int apr, attacks = attacks_per_round(ta);
if (!enemies) break;
@ -2294,18 +2302,21 @@ loot_items(fighter * corpse)
while (itm) {
int i;
if (itm->number) {
for (i = 10; i != 0; i--) {
for (i = 10; i != 0; --i) {
int loot = itm->number / i;
itm->number -= loot;
/* Looten tun hier immer nur die Gegner. Das
* ist als Ausgleich für die neue Loot-regel
* (nur ganz tote Einheiten) fair.
* zusätzlich looten auch geflohene, aber
* nach anderen Regeln.
/* Looten tun hier immer nur die Gegner. Das ist als Ausgleich für die
* neue Loot-regel (nur ganz tote Einheiten) fair.
* zusätzlich looten auch geflohene, aber nach anderen Regeln.
*/
if (loot>0 && (itm->type->flags & (ITF_CURSED|ITF_NOTLOST)
|| rand()%100 >= 50 - corpse->side->battle->keeploot)) {
fighter *fig = select_enemy(b, corpse, FIGHT_ROW, LAST_ROW).fighter;
if (loot>0) {
int maxrow = BEHIND_ROW;
int lootchance = 50 + b->keeploot;
if (itm->type->flags & (ITF_CURSED|ITF_NOTLOST)) maxrow = LAST_ROW;
itm->number -= loot;
if (maxrow == LAST_ROW || rand() % 100 < lootchance) {
fighter *fig = select_enemy(b, corpse, FIGHT_ROW, maxrow, false).fighter;
if (fig) {
item * l = fig->loot;
while (l && l->type!=itm->type) l=l->next;
@ -2320,6 +2331,7 @@ loot_items(fighter * corpse)
}
}
}
}
itm = itm->next;
}
}

View File

@ -210,8 +210,8 @@ extern "C" {
/* for combar spells and special attacks */
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 int count_enemies(struct battle * b, struct side * as, int minrow, int maxrow);
extern troop select_enemy(struct battle * b, struct fighter * af, int minrow, int maxrow, boolean advance);
extern int count_enemies(struct battle * b, struct side * as, int minrow, int maxrow, boolean advance);
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 battlerecord(battle * b, const char *s);

View File

@ -141,7 +141,7 @@ sp_kampfzauber(fighter * fi, int level, double power, spell * sp)
sprintf(buf, "%s zaubert %s", unitname(fi->unit),
spell_name(sp, default_locale));
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (enemies==0) {
m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
message_all(b, m);
@ -150,7 +150,7 @@ sp_kampfzauber(fighter * fi, int level, double power, spell * sp)
}
while (force>0 && killed < enemies) {
dt = select_enemy(b, fi, minrow, maxrow);
dt = select_enemy(b, fi, minrow, maxrow, true);
assert(dt.fighter);
--force;
killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
@ -181,7 +181,7 @@ sp_versteinern(fighter * fi, int level, double power, spell * sp)
force = lovar(get_force(power, 0));
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
battlerecord(b, buf);
@ -191,7 +191,7 @@ sp_versteinern(fighter * fi, int level, double power, spell * sp)
battlerecord(b, buf);
while (force && stoned < enemies) {
troop dt = select_enemy(b, fi, minrow, maxrow);
troop dt = select_enemy(b, fi, minrow, maxrow, true);
fighter * df = dt.fighter;
unit * du = df->unit;
if (is_magic_resistant(mage, du, 0) == false) {
@ -240,7 +240,7 @@ sp_stun(fighter * fi, int level, double power, spell * sp)
assert(0);
}
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
battlerecord(b, buf);
@ -251,7 +251,7 @@ sp_stun(fighter * fi, int level, double power, spell * sp)
stunned = 0;
while (force && stunned < enemies) {
troop dt = select_enemy(b, fi, minrow, maxrow);
troop dt = select_enemy(b, fi, minrow, maxrow, true);
fighter * df = dt.fighter;
unit * du = df->unit;
@ -296,7 +296,7 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
force = lovar(power * 15);
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
battlemsg(b, fi->unit, msgt[0]);
return 0;
@ -383,7 +383,7 @@ sp_sleep(fighter * fi, int level, double power, spell * sp)
sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale));
force = lovar(power * 25);
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
@ -394,7 +394,7 @@ sp_sleep(fighter * fi, int level, double power, spell * sp)
battlerecord(b, buf);
while (force && enemies) {
dt = select_enemy(b, fi, minrow, maxrow);
dt = select_enemy(b, fi, minrow, maxrow, true);
assert(dt.fighter);
du = dt.fighter->unit;
if (is_magic_resistant(mage, du, 0) == false) {
@ -530,7 +530,7 @@ sp_mindblast(fighter * fi, int level, double power, spell * sp)
spell_name(sp, default_locale));
force = lovar(power * 25);
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
battlerecord(b, buf);
@ -540,7 +540,7 @@ sp_mindblast(fighter * fi, int level, double power, spell * sp)
battlerecord(b, buf);
while (force && enemies) {
dt = select_enemy(b, fi, minrow, maxrow);
dt = select_enemy(b, fi, minrow, maxrow, true);
assert(dt.fighter);
du = dt.fighter->unit;
if (humanoidrace(du->race) && !is_magic_resistant(mage, du, 0)) {
@ -600,7 +600,7 @@ sp_dragonodem(fighter * fi, int level, double power, spell * sp)
/* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */
force = lovar(get_force(level,6));
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
@ -614,7 +614,7 @@ sp_dragonodem(fighter * fi, int level, double power, spell * sp)
at.index = 0;
while (force && killed < enemies) {
dt = select_enemy(b, fi, minrow, maxrow);
dt = select_enemy(b, fi, minrow, maxrow, true);
assert(dt.fighter);
--force;
killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
@ -649,7 +649,7 @@ sp_immolation(fighter * fi, int level, double power, spell * sp)
/* Betrifft alle Gegner */
force = 99999;
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
@ -663,7 +663,7 @@ sp_immolation(fighter * fi, int level, double power, spell * sp)
at.index = 0;
while (force && killed < enemies) {
dt = select_enemy(b, fi, minrow, maxrow);
dt = select_enemy(b, fi, minrow, maxrow, true);
assert(dt.fighter);
--force;
killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
@ -698,7 +698,7 @@ sp_drainodem(fighter * fi, int level, double power, spell * sp)
/* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */
force = lovar(get_force(level,6));
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
@ -712,7 +712,7 @@ sp_drainodem(fighter * fi, int level, double power, spell * sp)
at.index = 0;
while (force && drained < enemies) {
dt = select_enemy(b, fi, minrow, maxrow);
dt = select_enemy(b, fi, minrow, maxrow, true);
assert(dt.fighter);
if (hits(at, dt, NULL)) {
drain_exp(dt.fighter->unit, 90);
@ -906,7 +906,7 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
break;
}
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
battlerecord(b, buf);
@ -1004,7 +1004,7 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
force = (int)get_force(power,10);
}
if (!count_enemies(b, fi->side, minrow, maxrow)) {
if (!count_enemies(b, fi->side, minrow, maxrow, true)) {
scat(", aber es gab niemanden mehr, der beeinflusst werden konnte.");
battlerecord(b, buf);
return 0;
@ -1183,7 +1183,7 @@ sp_frighten(fighter * fi, int level, double power, spell * sp)
sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale));
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
battlerecord(b, buf);
@ -1193,7 +1193,7 @@ sp_frighten(fighter * fi, int level, double power, spell * sp)
battlerecord(b, buf);
while (force && enemies) {
troop dt = select_enemy(b, fi, minrow, maxrow);
troop dt = select_enemy(b, fi, minrow, maxrow, true);
fighter *df = dt.fighter;
--enemies;
@ -1232,14 +1232,14 @@ sp_tiredsoldiers(fighter * fi, int level, double power, spell * sp)
sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale));
if (!count_enemies(b, fi->side, FIGHT_ROW, BEHIND_ROW)) {
if (!count_enemies(b, fi->side, FIGHT_ROW, BEHIND_ROW, true)) {
scat(", aber niemand war in Reichweite.");
battlerecord(b, buf);
return 0;
}
while (force) {
troop t = select_enemy(b, fi, FIGHT_ROW, BEHIND_ROW);
troop t = select_enemy(b, fi, FIGHT_ROW, BEHIND_ROW, true);
fighter *df = t.fighter;
if (!df)
@ -1292,7 +1292,7 @@ sp_windshield(fighter * fi, int level, double power, spell * sp)
force = (int)power;
at_malus = 2;
}
enemies = count_enemies(b, fi->side, minrow, maxrow);
enemies = count_enemies(b, fi->side, minrow, maxrow, true);
if (!enemies) {
scat(", aber niemand war in Reichweite.");
battlerecord(b, buf);
@ -1300,7 +1300,7 @@ sp_windshield(fighter * fi, int level, double power, spell * sp)
}
while (force && enemies) {
troop dt = select_enemy(b, fi, minrow, maxrow);
troop dt = select_enemy(b, fi, minrow, maxrow, true);
fighter *df = dt.fighter;
--enemies;

View File

@ -73,10 +73,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eressea-lua", "eressea\eres
{4C837BEC-A428-4287-84B3-8F8F9DE7FA00} = {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxmapper", "wxmapper\wxmapper.vcproj", "{552164AD-D42D-4088-A59E-CB5CF77BA528}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
@ -129,10 +125,6 @@ Global
{749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Debug.Build.0 = Debug|Win32
{749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Release.ActiveCfg = Release|Win32
{749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Release.Build.0 = Release|Win32
{552164AD-D42D-4088-A59E-CB5CF77BA528}.Debug.ActiveCfg = Debug|Win32
{552164AD-D42D-4088-A59E-CB5CF77BA528}.Debug.Build.0 = Debug|Win32
{552164AD-D42D-4088-A59E-CB5CF77BA528}.Release.ActiveCfg = Release|Win32
{552164AD-D42D-4088-A59E-CB5CF77BA528}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection

View File

@ -11,8 +11,10 @@
// lua includes
#include <lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/operator.hpp>
#include <luabind/iterator_policy.hpp>
#ifdef HAVE_LUABIND_B7
# include <luabind/operator.hpp>
#endif
// util includes
#include <util/base36.h>

View File

@ -18,8 +18,10 @@
// lua includes
#include <lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/operator.hpp>
#include <luabind/iterator_policy.hpp>
#ifdef HAVE_LUABIND_B7
# include <luabind/operator.hpp>
#endif
#include <ostream>
using namespace luabind;

View File

@ -12,8 +12,10 @@
// lua includes
#include <lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/operator.hpp>
#include <luabind/iterator_policy.hpp>
#ifdef HAVE_LUABIND_B7
# include <luabind/operator.hpp>
#endif
#include <ostream>
using namespace luabind;

View File

@ -28,8 +28,10 @@
// lua includes
#include <lua.hpp>
#include <luabind/luabind.hpp>
#include <luabind/operator.hpp>
#include <luabind/iterator_policy.hpp>
#ifdef HAVE_LUABIND_B7
# include <luabind/operator.hpp>
#endif
#include <ostream>
#include <string>