forked from github/server
for debugging, adjust side-counters
This commit is contained in:
parent
1e9538b8d8
commit
2af1c0d478
|
@ -2283,281 +2283,283 @@ seematrix(const faction * f, const side * s)
|
||||||
static void
|
static void
|
||||||
aftermath(battle * b)
|
aftermath(battle * b)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
region *r = b->region;
|
region *r = b->region;
|
||||||
ship *sh;
|
ship *sh;
|
||||||
side *s;
|
side *s;
|
||||||
cvector *fighters = &b->fighters;
|
cvector *fighters = &b->fighters;
|
||||||
void **fi;
|
void **fi;
|
||||||
int is = 0;
|
int is = 0;
|
||||||
bfaction * bf;
|
bfaction * bf;
|
||||||
int dead_peasants;
|
int dead_peasants;
|
||||||
boolean battle_was_relevant = (boolean)(b->turn+(b->has_tactics_turn?1:0)>2);
|
boolean battle_was_relevant = (boolean)(b->turn+(b->has_tactics_turn?1:0)>2);
|
||||||
|
|
||||||
#ifdef TROLLSAVE
|
#ifdef TROLLSAVE
|
||||||
int *trollsave = calloc(2 * cv_size(&b->factions), sizeof(int));
|
int *trollsave = calloc(2 * cv_size(&b->factions), sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (fi = fighters->begin; fi != fighters->end; ++fi) {
|
for (fi = fighters->begin; fi != fighters->end; ++fi) {
|
||||||
fighter *df = *fi;
|
fighter *df = *fi;
|
||||||
unit *du = df->unit;
|
unit *du = df->unit;
|
||||||
int dead;
|
int dead;
|
||||||
const attrib *a;
|
const attrib *a;
|
||||||
int pr_mercy = 0;
|
int pr_mercy = 0;
|
||||||
|
|
||||||
for (a = a_find(du->attribs, &at_prayer_effect); a; a = a->nexttype) {
|
for (a = a_find(du->attribs, &at_prayer_effect); a; a = a->nexttype) {
|
||||||
if (a->data.sa[0] == PR_MERCY) {
|
if (a->data.sa[0] == PR_MERCY) {
|
||||||
pr_mercy = a->data.sa[1];
|
pr_mercy = a->data.sa[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dead = du->number - df->alive;
|
dead = du->number - df->alive;
|
||||||
dead -= df->run.number;
|
dead -= df->run.number;
|
||||||
#ifdef TROLLSAVE
|
#ifdef TROLLSAVE
|
||||||
/* Trolle können regenerieren */
|
/* Trolle können regenerieren */
|
||||||
if (df->alive > 0 && dead && old_race(du->race) == RC_TROLL)
|
if (df->alive > 0 && dead && old_race(du->race) == RC_TROLL)
|
||||||
for (i = 0; i != dead; ++i) {
|
for (i = 0; i != dead; ++i) {
|
||||||
if (chance(TROLL_REGENERATION)) {
|
if (chance(TROLL_REGENERATION)) {
|
||||||
++df->alive;
|
++df->alive;
|
||||||
++df->side->alive;
|
++df->side->alive;
|
||||||
++df->side->battle->alive;
|
++df->side->battle->alive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trollsave[df->side->index] += dead - du->number + df->alive;
|
trollsave[df->side->index] += dead - du->number + df->alive;
|
||||||
#endif
|
#endif
|
||||||
/* Regeneration durch PR_MERCY */
|
/* Regeneration durch PR_MERCY */
|
||||||
if (dead && pr_mercy)
|
if (dead && pr_mercy)
|
||||||
for (i = 0; i != dead; ++i)
|
for (i = 0; i != dead; ++i)
|
||||||
if (rand()%100 < pr_mercy) {
|
if (rand()%100 < pr_mercy) {
|
||||||
++df->alive;
|
++df->alive;
|
||||||
++df->side->alive;
|
++df->side->alive;
|
||||||
++df->side->battle->alive;
|
++df->side->battle->alive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tote, die wiederbelebt werde können */
|
/* Tote, die wiederbelebt werde können */
|
||||||
if (playerrace(df->unit->race)) {
|
if (playerrace(df->unit->race)) {
|
||||||
df->side->casualties += dead;
|
df->side->casualties += dead;
|
||||||
}
|
}
|
||||||
#ifdef SHOW_KILLS
|
#ifdef SHOW_KILLS
|
||||||
if (df->hits + df->kills) {
|
if (df->hits + df->kills) {
|
||||||
struct message * m = new_message(du->faction, "killsandhits%u:unit%i:hits%i:kills", du, df->hits, df->kills);
|
struct message * m = new_message(du->faction, "killsandhits%u:unit%i:hits%i:kills", du, df->hits, df->kills);
|
||||||
brecord(du->faction, b->region, m);
|
brecord(du->faction, b->region, m);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wenn die Schlacht kurz war, dann gib Aura für den Präcombatzauber
|
/* Wenn die Schlacht kurz war, dann gib Aura für den Präcombatzauber
|
||||||
* zurück. Nicht logisch, aber die einzige Lösung, den Verlust der
|
* zurück. Nicht logisch, aber die einzige Lösung, den Verlust der
|
||||||
* Aura durch Dummy-Angriffe zu verhindern. */
|
* Aura durch Dummy-Angriffe zu verhindern. */
|
||||||
|
|
||||||
cv_foreach(s, b->sides) {
|
cv_foreach(s, b->sides) {
|
||||||
if (s->bf->lastturn+(b->has_tactics_turn?1:0)<=1) continue;
|
if (s->bf->lastturn+(b->has_tactics_turn?1:0)<=1) continue;
|
||||||
/* Prüfung, ob faction angegriffen hat. Geht nur über die Faction */
|
/* Prüfung, ob faction angegriffen hat. Geht nur über die Faction */
|
||||||
if (!s->bf->attacker) {
|
if (!s->bf->attacker) {
|
||||||
fighter *fig;
|
fighter *fig;
|
||||||
cv_foreach(fig, s->fighters) {
|
cv_foreach(fig, s->fighters) {
|
||||||
sc_mage * mage = get_mage(fig->unit);
|
sc_mage * mage = get_mage(fig->unit);
|
||||||
if (mage)
|
if (mage)
|
||||||
mage->spellpoints += mage->precombataura;
|
mage->spellpoints += mage->precombataura;
|
||||||
} cv_next(fig);
|
} cv_next(fig);
|
||||||
}
|
}
|
||||||
/* Alle Fighter durchgehen, Mages suchen, Precombataura zurück */
|
/* Alle Fighter durchgehen, Mages suchen, Precombataura zurück */
|
||||||
} cv_next(s);
|
} cv_next(s);
|
||||||
|
|
||||||
/* POSTCOMBAT */
|
/* POSTCOMBAT */
|
||||||
do_combatmagic(b, DO_POSTCOMBATSPELL);
|
do_combatmagic(b, DO_POSTCOMBATSPELL);
|
||||||
|
|
||||||
cv_foreach(s, b->sides) {
|
cv_foreach(s, b->sides) {
|
||||||
int snumber = 0;
|
int snumber = 0;
|
||||||
fighter *df;
|
fighter *df;
|
||||||
boolean relevant = false; /* Kampf relevant für dieses Heer? */
|
boolean relevant = false; /* Kampf relevant für dieses Heer? */
|
||||||
if (s->bf->lastturn+(b->has_tactics_turn?1:0)>1) {
|
if (s->bf->lastturn+(b->has_tactics_turn?1:0)>1) {
|
||||||
relevant = true;
|
relevant = true;
|
||||||
}
|
}
|
||||||
s->flee = 0;
|
s->flee = 0;
|
||||||
s->dead = 0;
|
s->dead = 0;
|
||||||
|
|
||||||
cv_foreach(df, s->fighters) {
|
cv_foreach(df, s->fighters) {
|
||||||
unit *du = df->unit;
|
unit *du = df->unit;
|
||||||
int dead = du->number - df->alive - df->run.number;
|
int dead = du->number - df->alive - df->run.number;
|
||||||
int sum_hp = 0;
|
int sum_hp = 0;
|
||||||
int n;
|
int n;
|
||||||
snumber +=du->number;
|
snumber +=du->number;
|
||||||
if (relevant && df->action_counter >= du->number) {
|
if (relevant && df->action_counter >= du->number) {
|
||||||
ship * sh = du->ship?du->ship:leftship(du);
|
ship * sh = du->ship?du->ship:leftship(du);
|
||||||
|
|
||||||
if (sh) fset(sh, SF_DAMAGED);
|
if (sh) fset(sh, SF_DAMAGED);
|
||||||
fset(du, UFL_LONGACTION);
|
fset(du, UFL_LONGACTION);
|
||||||
/* TODO: das sollte hier weg sobald anderswo üb
|
/* TODO: das sollte hier weg sobald anderswo üb
|
||||||
* erall UFL_LONGACTION getestet wird. */
|
* erall UFL_LONGACTION getestet wird. */
|
||||||
set_string(&du->thisorder, "");
|
set_string(&du->thisorder, "");
|
||||||
}
|
}
|
||||||
for (n = 0; n != df->alive; ++n) {
|
for (n = 0; n != df->alive; ++n) {
|
||||||
if (df->person[n].hp > 0)
|
if (df->person[n].hp > 0)
|
||||||
sum_hp += df->person[n].hp;
|
sum_hp += df->person[n].hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->dead += dead;
|
s->dead += dead;
|
||||||
|
|
||||||
if (df->alive == du->number) continue; /* nichts passiert */
|
if (df->alive == du->number) continue; /* nichts passiert */
|
||||||
|
|
||||||
/* die weggerannten werden später subtrahiert! */
|
/* die weggerannten werden später subtrahiert! */
|
||||||
assert(du->number >= 0);
|
assert(du->number >= 0);
|
||||||
|
|
||||||
if (df->run.hp) {
|
if (df->run.hp) {
|
||||||
#ifndef NO_RUNNING
|
#ifndef NO_RUNNING
|
||||||
if (df->alive == 0) {
|
if (df->alive == 0) {
|
||||||
/* Report the casualties */
|
/* Report the casualties */
|
||||||
reportcasualties(b, df, dead);
|
reportcasualties(b, df, dead);
|
||||||
|
|
||||||
/* Zuerst dürfen die Feinde plündern, die mitgenommenen Items
|
/* Zuerst dürfen die Feinde plündern, die mitgenommenen Items
|
||||||
* stehen in fig->run.items. Dann werden die Fliehenden auf
|
* stehen in fig->run.items. Dann werden die Fliehenden auf
|
||||||
* die leere (tote) alte Einheit gemapt */
|
* die leere (tote) alte Einheit gemapt */
|
||||||
if (fval(df,FIG_NOLOOT)){
|
if (fval(df,FIG_NOLOOT)){
|
||||||
merge_fleeloot(df, du);
|
merge_fleeloot(df, du);
|
||||||
} else {
|
} else {
|
||||||
loot_items(df);
|
loot_items(df);
|
||||||
loot_fleeing(df, du);
|
loot_fleeing(df, du);
|
||||||
}
|
}
|
||||||
scale_number(du, df->run.number);
|
scale_number(du, df->run.number);
|
||||||
du->hp = df->run.hp;
|
du->hp = df->run.hp;
|
||||||
set_string(&du->thisorder, "");
|
set_string(&du->thisorder, "");
|
||||||
setguard(du, GUARD_NONE);
|
setguard(du, GUARD_NONE);
|
||||||
fset(du, UFL_MOVED);
|
fset(du, UFL_MOVED);
|
||||||
leave(du->region, du);
|
leave(du->region, du);
|
||||||
if (df->run.region) {
|
if (df->run.region) {
|
||||||
travel(du, df->run.region, 1, NULL);
|
travel(du, df->run.region, 1, NULL);
|
||||||
df->run.region = du->region;
|
df->run.region = du->region;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* nur teilweise geflohene Einheiten mergen sich wieder */
|
/* nur teilweise geflohene Einheiten mergen sich wieder */
|
||||||
df->alive += df->run.number;
|
df->alive += df->run.number;
|
||||||
s->alive += df->run.number;
|
s->size[0] += df->run.number;
|
||||||
sum_hp += df->run.hp;
|
s->size[statusrow(df->status)] += df->run.number;
|
||||||
|
s->alive += df->run.number;
|
||||||
|
sum_hp += df->run.hp;
|
||||||
#ifndef NO_RUNNING
|
#ifndef NO_RUNNING
|
||||||
merge_fleeloot(df, du);
|
merge_fleeloot(df, du);
|
||||||
#endif
|
#endif
|
||||||
df->run.number = 0;
|
df->run.number = 0;
|
||||||
df->run.hp = 0;
|
df->run.hp = 0;
|
||||||
/* df->run.region = NULL;*/
|
/* df->run.region = NULL;*/
|
||||||
|
|
||||||
reportcasualties(b, df, dead);
|
reportcasualties(b, df, dead);
|
||||||
|
|
||||||
scale_number(du, df->alive);
|
scale_number(du, df->alive);
|
||||||
du->hp = sum_hp;
|
du->hp = sum_hp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (df->alive==0) {
|
if (df->alive==0) {
|
||||||
/* alle sind tot, niemand geflohen. Einheit auflösen */
|
/* alle sind tot, niemand geflohen. Einheit auflösen */
|
||||||
df->run.number = 0;
|
df->run.number = 0;
|
||||||
df->run.hp = 0;
|
df->run.hp = 0;
|
||||||
#ifndef NO_RUNNING
|
#ifndef NO_RUNNING
|
||||||
df->run.region = NULL;
|
df->run.region = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Report the casualties */
|
/* Report the casualties */
|
||||||
reportcasualties(b, df, dead);
|
reportcasualties(b, df, dead);
|
||||||
|
|
||||||
setguard(du, GUARD_NONE);
|
setguard(du, GUARD_NONE);
|
||||||
scale_number(du, 0);
|
scale_number(du, 0);
|
||||||
/* Distribute Loot */
|
/* Distribute Loot */
|
||||||
loot_items(df);
|
loot_items(df);
|
||||||
} else {
|
} else {
|
||||||
df->run.number = 0;
|
df->run.number = 0;
|
||||||
df->run.hp = 0;
|
df->run.hp = 0;
|
||||||
|
|
||||||
reportcasualties(b, df, dead);
|
reportcasualties(b, df, dead);
|
||||||
|
|
||||||
scale_number(du, df->alive);
|
scale_number(du, df->alive);
|
||||||
du->hp = sum_hp;
|
du->hp = sum_hp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s->flee += df->run.number;
|
s->flee += df->run.number;
|
||||||
|
|
||||||
if (playerrace(du->race)) {
|
if (playerrace(du->race)) {
|
||||||
/* tote im kampf werden zu regionsuntoten:
|
/* tote im kampf werden zu regionsuntoten:
|
||||||
* for each of them, a peasant will die as well */
|
* for each of them, a peasant will die as well */
|
||||||
is += dead;
|
is += dead;
|
||||||
}
|
}
|
||||||
if (du->hp < du->number) {
|
if (du->hp < du->number) {
|
||||||
log_error(("%s has less hitpoints (%u) than people (%u)\n",
|
log_error(("%s has less hitpoints (%u) than people (%u)\n",
|
||||||
itoa36(du->no), du->hp, du->number));
|
itoa36(du->no), du->hp, du->number));
|
||||||
du->hp=du->no;
|
du->hp=du->no;
|
||||||
}
|
}
|
||||||
} cv_next(df);
|
} cv_next(df);
|
||||||
s->alive+=s->healed;
|
s->alive+=s->healed;
|
||||||
assert(snumber==s->flee+s->alive+s->dead);
|
assert(snumber==s->flee+s->alive+s->dead);
|
||||||
} cv_next(s);
|
} cv_next(s);
|
||||||
dead_peasants = min(rpeasants(r), (is*BATTLE_KILLS_PEASANTS)/100);
|
dead_peasants = min(rpeasants(r), (is*BATTLE_KILLS_PEASANTS)/100);
|
||||||
deathcounts(r, dead_peasants + is);
|
deathcounts(r, dead_peasants + is);
|
||||||
chaoscounts(r, dead_peasants / 2);
|
chaoscounts(r, dead_peasants / 2);
|
||||||
rsetpeasants(r, rpeasants(r) - dead_peasants);
|
rsetpeasants(r, rpeasants(r) - dead_peasants);
|
||||||
|
|
||||||
for (bf=b->factions;bf;bf=bf->next) {
|
for (bf=b->factions;bf;bf=bf->next) {
|
||||||
faction * f = bf->faction;
|
faction * f = bf->faction;
|
||||||
fbattlerecord(f, r, " ");
|
fbattlerecord(f, r, " ");
|
||||||
cv_foreach(s, b->sides) {
|
cv_foreach(s, b->sides) {
|
||||||
if (seematrix(f, s)) {
|
if (seematrix(f, s)) {
|
||||||
sprintf(buf, "Heer %2d(%s): %d Tote, %d Geflohene, %d Überlebende",
|
sprintf(buf, "Heer %2d(%s): %d Tote, %d Geflohene, %d Überlebende",
|
||||||
s->index, sideabkz(s,false), s->dead, s->flee, s->alive);
|
s->index, sideabkz(s,false), s->dead, s->flee, s->alive);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "Heer %2d(Unb): %d Tote, %d Geflohene, %d Überlebende",
|
sprintf(buf, "Heer %2d(Unb): %d Tote, %d Geflohene, %d Überlebende",
|
||||||
s->index, s->dead, s->flee, s->alive);
|
s->index, s->dead, s->flee, s->alive);
|
||||||
}
|
}
|
||||||
fbattlerecord(f, r, buf);
|
fbattlerecord(f, r, buf);
|
||||||
} cv_next(s);
|
} cv_next(s);
|
||||||
}
|
}
|
||||||
/* Wir benutzen drifted, um uns zu merken, ob ein Schiff
|
/* Wir benutzen drifted, um uns zu merken, ob ein Schiff
|
||||||
* schonmal Schaden genommen hat. (moved und drifted
|
* schonmal Schaden genommen hat. (moved und drifted
|
||||||
* sollten in flags überführt werden */
|
* sollten in flags überführt werden */
|
||||||
|
|
||||||
for (fi = fighters->begin; fi != fighters->end; ++fi) {
|
for (fi = fighters->begin; fi != fighters->end; ++fi) {
|
||||||
fighter *df = *fi;
|
fighter *df = *fi;
|
||||||
unit *du = df->unit;
|
unit *du = df->unit;
|
||||||
item * l;
|
item * l;
|
||||||
|
|
||||||
for (l=df->loot; l; l=l->next) {
|
for (l=df->loot; l; l=l->next) {
|
||||||
const item_type * itype = l->type;
|
const item_type * itype = l->type;
|
||||||
sprintf(buf, "%s erbeute%s %d %s.", unitname(du), du->number==1?"t":"n",
|
sprintf(buf, "%s erbeute%s %d %s.", unitname(du), du->number==1?"t":"n",
|
||||||
l->number, locale_string(default_locale, resourcename(itype->rtype, l->number!=1)));
|
l->number, locale_string(default_locale, resourcename(itype->rtype, l->number!=1)));
|
||||||
fbattlerecord(du->faction, r, buf);
|
fbattlerecord(du->faction, r, buf);
|
||||||
i_change(&du->items, itype, l->number);
|
i_change(&du->items, itype, l->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wenn sich die Einheit auf einem Schiff befindet, wird
|
/* Wenn sich die Einheit auf einem Schiff befindet, wird
|
||||||
* dieses Schiff beschädigt. Andernfalls ein Schiff, welches
|
* dieses Schiff beschädigt. Andernfalls ein Schiff, welches
|
||||||
* evt. zuvor verlassen wurde. */
|
* evt. zuvor verlassen wurde. */
|
||||||
|
|
||||||
if (du->ship) sh = du->ship; else sh = leftship(du);
|
if (du->ship) sh = du->ship; else sh = leftship(du);
|
||||||
|
|
||||||
if (sh && fval(sh, SF_DAMAGED) && b->turn+(b->has_tactics_turn?1:0)>2) {
|
if (sh && fval(sh, SF_DAMAGED) && b->turn+(b->has_tactics_turn?1:0)>2) {
|
||||||
damage_ship(sh, 0.20);
|
damage_ship(sh, 0.20);
|
||||||
freset(sh, SF_DAMAGED);
|
freset(sh, SF_DAMAGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (battle_was_relevant) {
|
if (battle_was_relevant) {
|
||||||
ship **sp = &r->ships;
|
ship **sp = &r->ships;
|
||||||
while (*sp) {
|
while (*sp) {
|
||||||
ship * sh = *sp;
|
ship * sh = *sp;
|
||||||
freset(sh, SF_DAMAGED);
|
freset(sh, SF_DAMAGED);
|
||||||
if (sh->damage >= sh->size * DAMAGE_SCALE) {
|
if (sh->damage >= sh->size * DAMAGE_SCALE) {
|
||||||
destroy_ship(sh, r);
|
destroy_ship(sh, r);
|
||||||
}
|
}
|
||||||
if (*sp==sh) sp=&sh->next;
|
if (*sp==sh) sp=&sh->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef TROLLSAVE
|
#ifdef TROLLSAVE
|
||||||
free(trollsave);
|
free(trollsave);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sprintf(buf, "The battle lasted %d turns, %s and %s.\n",
|
sprintf(buf, "The battle lasted %d turns, %s and %s.\n",
|
||||||
b->turn,
|
b->turn,
|
||||||
b->has_tactics_turn==true?"had a tactic turn":"had no tactic turn",
|
b->has_tactics_turn==true?"had a tactic turn":"had no tactic turn",
|
||||||
battle_was_relevant==true?"was relevant":"was not relevant.");
|
battle_was_relevant==true?"was relevant":"was not relevant.");
|
||||||
battledebug(buf);
|
battledebug(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue