- ziemlicher Fehler in aftermath: Wenn Einheiten keine Personen verloren haben, haben sie auch keine Hitpoints verloren.
This commit is contained in:
Enno Rehling 2004-10-19 19:59:37 +00:00
parent c434b9c9d4
commit ba620d139a
4 changed files with 103 additions and 107 deletions

View File

@ -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; i<u->number; i++) hp[i] = h;
h = u->hp - (u->number * h);
for (i=0; i<h; i++) hp[i]++;
/* Schaden */
for (i=0; i<u->number; 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; i<u->number; 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)
{

View File

@ -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,9 +3904,8 @@ do_battle(void)
}
}
/* Funktionen, die außerhalb von battle.c verwendet werden. */
static int
nb_armor(unit *u, int index)
int
nb_armor(const unit *u, int index)
{
int a, av = 0;
int geschuetzt = 0;
@ -3941,66 +3941,3 @@ nb_armor(unit *u, int index)
return av;
}
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; i<u->number; i++) hp[i] = h;
h = u->hp - (u->number * h);
for (i=0; i<h; i++) hp[i]++;
/* Schaden */
for (i=0; i<u->number; 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; i<u->number; 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;
}

View File

@ -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);

View File

@ -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,8 +2147,7 @@ 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));
ADDMSG(&cap->faction->msgs, msg_message("shipnoconf", "ship", sh));
continue;
}
@ -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;
}
}