forked from github/server
BUG 2378: Fix magic armor resistance calculation.
Use frac_one constant where applicable.
This commit is contained in:
parent
1866b95e14
commit
5af5daa355
|
@ -1141,7 +1141,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
|
|||
const weapon_type *dwtype = NULL;
|
||||
const weapon_type *awtype = NULL;
|
||||
const weapon *weapon;
|
||||
variant res = frac_make(1, 1);
|
||||
variant res = frac_one;
|
||||
|
||||
int rda, sk = 0, sd;
|
||||
bool magic = false;
|
||||
|
@ -1185,6 +1185,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
|
|||
}
|
||||
|
||||
if (magic) {
|
||||
res = frac_sub(frac_one, res);
|
||||
res = frac_mul(frac_make(da, 1), res);
|
||||
da = res.sa[0] / res.sa[1];
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ int *casualties)
|
|||
killed += terminate(dt, *at, AT_SPELL, damage, 1);
|
||||
}
|
||||
} while (force && killed < enemies);
|
||||
if (casualties)
|
||||
if (killed > 0 && casualties)
|
||||
*casualties = killed;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -405,7 +405,7 @@ static int required(int size, int msize, int maxneed)
|
|||
static int matmod(const unit * u, const resource_type * rtype, int value)
|
||||
{
|
||||
if (rtype->modifiers) {
|
||||
variant save = frac_make(1, 1);
|
||||
variant save = frac_one;
|
||||
const struct building_type *btype = NULL;
|
||||
const struct race *rc = u_race(u);
|
||||
resource_mod *mod;
|
||||
|
|
|
@ -106,8 +106,8 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
|
|||
int damage = dice_rand(dam);
|
||||
if (magic) {
|
||||
variant magres = magic_resistance(u);
|
||||
magres = frac_sub(frac_make(1, 1), magres);
|
||||
damage = damage * magres.sa[0] / magres.sa[1];
|
||||
int save = magres.sa[0] / magres.sa[1];
|
||||
damage -= damage * save;
|
||||
}
|
||||
if (physical) {
|
||||
damage -= nb_armor(u, i);
|
||||
|
|
Loading…
Reference in New Issue