From ba620d139a220fede9c00f03eeaa2d21eac35aa5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 19 Oct 2004 19:59:37 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=301 - ziemlicher Fehler in aftermath: Wenn Einheiten keine Personen verloren haben, haben sie auch keine Hitpoints verloren. --- src/common/gamecode/randenc.c | 63 +++++++++++++++++ src/common/kernel/battle.c | 127 +++++++++------------------------- src/common/kernel/battle.h | 2 +- src/common/kernel/movement.c | 18 ++--- 4 files changed, 103 insertions(+), 107 deletions(-) diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index e64332163..350c36dc4 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -658,6 +658,69 @@ chaosfactor(region * r) return ((double) a->data.i / 1000.0); } +static int +damage_unit(unit *u, const char *dam, boolean armor, boolean magic) +{ + int *hp = malloc(u->number * sizeof(int)); + int h; + int i, dead = 0, hp_rem = 0, heiltrank; + + if (u->number==0) return 0; + h = u->hp/u->number; + /* HP verteilen */ + for (i=0; inumber; i++) hp[i] = h; + h = u->hp - (u->number * h); + for (i=0; inumber; i++) { + int damage = dice_rand(dam); + if (magic) damage = (int)(damage * (1.0 - magic_resistance(u))); + if (armor) damage -= nb_armor(u, i); + hp[i] -= damage; + } + + /* Auswirkungen */ + for (i=0; inumber; i++) { + if (hp[i] <= 0){ + heiltrank = 0; + + /* Sieben Leben */ + if (old_race(u->race) == RC_CAT && (chance(1.0 / 7))) { + hp[i] = u->hp/u->number; + hp_rem += hp[i]; + continue; + } + + /* Heiltrank */ + if (get_effect(u, oldpotiontype[P_HEAL]) > 0) { + change_effect(u, oldpotiontype[P_HEAL], -1); + heiltrank = 1; + } else if (get_potion(u, P_HEAL) > 0) { + i_change(&u->items, oldpotiontype[P_HEAL]->itype, -1); + change_effect(u, oldpotiontype[P_HEAL], 3); + heiltrank = 1; + } + if (heiltrank && (chance(0.50))) { + hp[i] = u->hp/u->number; + hp_rem += hp[i]; + continue; + } + + dead++; + } else { + hp_rem += hp[i]; + } + } + + scale_number(u, u->number - dead); + u->hp = hp_rem; + + free(hp); + + return dead; +} + void drown(region *r) { diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 066fc530c..df3b33bd1 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -2472,12 +2472,13 @@ aftermath(battle * b) sum_hp += df->person[n].hp; } - if (df->alive == du->number) continue; /* nichts passiert */ - /* die weggerannten werden später subtrahiert! */ assert(du->number >= 0); - if (df->run.hp) { + if (df->alive == du->number) { + du->hp = sum_hp; + continue; /* nichts passiert */ + } else if (df->run.hp) { #ifndef NO_RUNNING if (df->alive == 0) { /* Report the casualties */ @@ -3903,104 +3904,40 @@ do_battle(void) } } -/* Funktionen, die außerhalb von battle.c verwendet werden. */ -static int -nb_armor(unit *u, int index) -{ - int a, av = 0; - int geschuetzt = 0; - - if (!(u->race->battle_flags & BF_EQUIPMENT)) return AR_NONE; - - /* Normale Rüstung */ - - a = 0; - do { - if (armordata[a].shield == 0) { - geschuetzt += get_item(u, armordata[a].item); - if (geschuetzt > index) - av += armordata[a].prot; - } - ++a; - } - while (a != AR_MAX); - - /* Schild */ - - a = 0; - do { - if (armordata[a].shield == 1) { - geschuetzt += get_item(u, armordata[a].item); - if (geschuetzt > index) - av += armordata[a].prot; - } - ++a; - } - while (a != AR_MAX); - - return av; -} - - int -damage_unit(unit *u, const char *dam, boolean armor, boolean magic) +nb_armor(const unit *u, int index) { - int *hp = malloc(u->number * sizeof(int)); - int h; - int i, dead = 0, hp_rem = 0, heiltrank; + int a, av = 0; + int geschuetzt = 0; - if (u->number==0) return 0; - h = u->hp/u->number; - /* HP verteilen */ - for (i=0; inumber; i++) hp[i] = h; - h = u->hp - (u->number * h); - for (i=0; irace->battle_flags & BF_EQUIPMENT)) return AR_NONE; - /* Schaden */ - for (i=0; inumber; i++) { - int damage = dice_rand(dam); - if (magic) damage = (int)(damage * (1.0 - magic_resistance(u))); - if (armor) damage -= nb_armor(u, i); - hp[i] -= damage; - } + /* Normale Rüstung */ - /* Auswirkungen */ - for (i=0; inumber; i++) { - if (hp[i] <= 0){ - heiltrank = 0; + a = 0; + do { + if (armordata[a].shield == 0) { + geschuetzt += get_item(u, armordata[a].item); + if (geschuetzt > index) + av += armordata[a].prot; + } + ++a; + } + while (a != AR_MAX); - /* Sieben Leben */ - if (old_race(u->race) == RC_CAT && (chance(1.0 / 7))) { - hp[i] = u->hp/u->number; - hp_rem += hp[i]; - continue; - } + /* Schild */ - /* Heiltrank */ - if (get_effect(u, oldpotiontype[P_HEAL]) > 0) { - change_effect(u, oldpotiontype[P_HEAL], -1); - heiltrank = 1; - } else if (get_potion(u, P_HEAL) > 0) { - i_change(&u->items, oldpotiontype[P_HEAL]->itype, -1); - change_effect(u, oldpotiontype[P_HEAL], 3); - heiltrank = 1; - } - if (heiltrank && (chance(0.50))) { - hp[i] = u->hp/u->number; - hp_rem += hp[i]; - continue; - } + a = 0; + do { + if (armordata[a].shield == 1) { + geschuetzt += get_item(u, armordata[a].item); + if (geschuetzt > index) + av += armordata[a].prot; + } + ++a; + } + while (a != AR_MAX); - dead++; - } else { - hp_rem += hp[i]; - } - } - - scale_number(u, u->number - dead); - u->hp = hp_rem; - - free(hp); - - return dead; + return av; } + diff --git a/src/common/kernel/battle.h b/src/common/kernel/battle.h index a3ed28339..5f3c8b991 100644 --- a/src/common/kernel/battle.h +++ b/src/common/kernel/battle.h @@ -213,7 +213,7 @@ extern "C" { extern void do_battle(void); /* for combar spells and special attacks */ - extern int damage_unit(struct unit *u, const char *dam, boolean armor, boolean magic); + extern int nb_armor(const struct unit *u, int index); 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); diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index fbc703290..a293f2d7c 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -771,12 +771,10 @@ bewegung_blockiert_von(unit * reisender, region * r) int sk = eff_skill(u, SK_OBSERVATION, r); if (get_item(reisender, I_RING_OF_INVISIBILITY) >= reisender->number && !get_item(u, I_AMULET_OF_TRUE_SEEING)) continue; - if (u->faction==reisender->faction - || ucontact(u, reisender) - || alliedunit(u, reisender->faction, HELP_GUARD)) - { - contact = true; - } else if (sk>=perception) { + if (u->faction==reisender->faction) contact = true; + else if (ucontact(u, reisender)) contact = true; + else if (alliedunit(u, reisender->faction, HELP_GUARD)) contact = true; + else if (sk>=perception) { perception = sk; guard = u; } @@ -2149,9 +2147,8 @@ regain_orientation(region * r) if(r->terrain != T_OCEAN || rand() % 10 >= storms[month(0)]) { remove_curse(&sh->attribs, C_DISORIENTATION, 0); - add_message(&cap->faction->msgs, - new_message(cap->faction, "shipnoconf%h:ship", sh)); - continue; + ADDMSG(&cap->faction->msgs, msg_message("shipnoconf", "ship", sh)); + continue; } for(u=r->units;u;u=u->next) { @@ -2159,8 +2156,7 @@ regain_orientation(region * r) && allied(cap, u->faction, HELP_GUARD) && is_disorientated(u) == false) { remove_curse(&sh->attribs, C_DISORIENTATION, 0); - add_message(&cap->faction->msgs, - new_message(cap->faction, "shipnoconf%h:ship", sh)); + ADDMSG(&cap->faction->msgs, msg_message("shipnoconf", "ship", sh)); break; } }