diff --git a/src/common/items/weapons.c b/src/common/items/weapons.c index da1702d38..d7abb83bc 100644 --- a/src/common/items/weapons.c +++ b/src/common/items/weapons.c @@ -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; diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 93cdbbe71..9828a4ebe 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -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; - for (i=0;i!=NUMROWS;++i) unitrow[i] = -1; + 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 (unitrow[row] == -1) { - unitrow[row] = get_unitrow(fig); + if (advance) { + if (unitrow[row] == -1) { + unitrow[row] = get_unitrow(fig); + } + row = unitrow[row]; } - 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]; - for (ui=0;ui!=NUMROWS;++ui) unitrow[ui] = -1; + 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; @@ -2162,34 +2170,34 @@ attack(battle *b, troop ta, const att *a, int numattack) void do_attack(fighter * af) { - troop ta; - unit *au = af->unit; - side *side = af->side; - battle *b = side->battle; + troop ta; + unit *au = af->unit; + side *side = af->side; + battle *b = side->battle; - ta.fighter = af; + ta.fighter = af; - assert(au && au->number); - /* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen - * Kämpfern beruht, darf die Reihenfolge und Größe der Einheit keine - * Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der - * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zufällig - * mit einer großen Einheit zuerst drankommt, extrem bevorteilt. */ - ta.index = af->fighting; + assert(au && au->number); + /* Da das Zuschlagen auf Einheiten und nicht auf den einzelnen + * Kämpfern beruht, darf die Reihenfolge und Größe der Einheit keine + * Rolle spielen, Das tut sie nur dann, wenn jeder, der am Anfang der + * Runde lebte, auch zuschlagen darf. Ansonsten ist der, der zufällig + * mit einer großen Einheit zuerst drankommt, extrem bevorteilt. */ + ta.index = af->fighting; - 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); + 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, true); int apr, attacks = attacks_per_round(ta); - if (!enemies) break; + if (!enemies) break; - for (apr=0;apr!=attacks;++apr) { + for (apr=0;apr!=attacks;++apr) { int a; - for (a=0; a!=10 && au->race->attack[a].type!=AT_NONE; ++a) { + for (a=0; a!=10 && au->race->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. */ + * Waffen-Angriff handelt, dann gilt der Speed nicht. */ if (au->race->attack[a].type!=AT_STANDARD) continue; else { weapon * wp = preferred_weapon(ta, true); @@ -2197,9 +2205,9 @@ do_attack(fighter * af) } } attack(b, ta, &(au->race->attack[a]), apr); - } - } - } + } + } + } } void @@ -2286,42 +2294,46 @@ make_side(battle * b, const faction * f, const group * g, boolean stealth, const void loot_items(fighter * corpse) { - unit * u = corpse->unit; - item * itm = u->items; - battle * b = corpse->side->battle; - u->items = NULL; + unit * u = corpse->unit; + item * itm = u->items; + battle * b = corpse->side->battle; + u->items = NULL; - while (itm) { - int i; - if (itm->number) { - 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. - */ - 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 (fig) { - item * l = fig->loot; - while (l && l->type!=itm->type) l=l->next; - if (!l) { - l = calloc(sizeof(item), 1); - l->next = fig->loot; - fig->loot = l; - l->type = itm->type; - } - l->number += loot; - } - } - } - } - itm = itm->next; - } + while (itm) { + int i; + if (itm->number) { + for (i = 10; i != 0; --i) { + int loot = itm->number / i; + /* 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) { + 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; + if (!l) { + l = calloc(sizeof(item), 1); + l->next = fig->loot; + fig->loot = l; + l->type = itm->type; + } + l->number += loot; + } + } + } + } + } + itm = itm->next; + } } #ifndef NO_RUNNING diff --git a/src/common/kernel/battle.h b/src/common/kernel/battle.h index e23080ded..9dc1b6be2 100644 --- a/src/common/kernel/battle.h +++ b/src/common/kernel/battle.h @@ -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); diff --git a/src/common/kernel/combatspells.c b/src/common/kernel/combatspells.c index 8af0903b6..ab75df87d 100644 --- a/src/common/kernel/combatspells.c +++ b/src/common/kernel/combatspells.c @@ -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; diff --git a/src/eressea.sln b/src/eressea.sln index 86f7fb861..9fad009a8 100644 --- a/src/eressea.sln +++ b/src/eressea.sln @@ -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 diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp index 0c224db2d..2206d4521 100644 --- a/src/eressea/lua/building.cpp +++ b/src/eressea/lua/building.cpp @@ -11,8 +11,10 @@ // lua includes #include #include -#include #include +#ifdef HAVE_LUABIND_B7 +# include +#endif // util includes #include diff --git a/src/eressea/lua/faction.cpp b/src/eressea/lua/faction.cpp index 2dadfffa4..cd64bb797 100644 --- a/src/eressea/lua/faction.cpp +++ b/src/eressea/lua/faction.cpp @@ -18,8 +18,10 @@ // lua includes #include #include -#include #include +#ifdef HAVE_LUABIND_B7 +# include +#endif #include using namespace luabind; diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp index f66760016..0f6c89051 100644 --- a/src/eressea/lua/region.cpp +++ b/src/eressea/lua/region.cpp @@ -12,8 +12,10 @@ // lua includes #include #include -#include #include +#ifdef HAVE_LUABIND_B7 +# include +#endif #include using namespace luabind; diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp index 85b95241e..c25c39538 100644 --- a/src/eressea/lua/unit.cpp +++ b/src/eressea/lua/unit.cpp @@ -28,8 +28,10 @@ // lua includes #include #include -#include #include +#ifdef HAVE_LUABIND_B7 +# include +#endif #include #include