git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3242 c06c8d41-db1a-0410-9941-cceddc491573
PR42BCP5BPRFD2MP5H6CIJP7E57Q6TKL6SOXZWFKMFVR2OZWHT7AC
D4A2TDSEJ7H6NYORPBZYLAWXUM55MIDMKQR67ODNZM334KWCUAAQC
VK3LNDA3TXEPBMLDWBTEBDOZMPP3YUED3A624XMHWI6FI7LP3HGAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
AREBCIU2RU2RNHBWD4GARWEBKSL7HDFGDLII22H56OJO2AQUOMLQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
KFULGQQOHWUTXOM3BXCCYPGGVGGY4Z6265XUFRCBPNLTZAEHJZSQC
WBAFNYODKTL3YSG3UOJITBJSTFYGJLIWKRNK6NMGIIP5TPC2BDGQC
RBAGQ2PB7V5YAM5KSHSZR2E3MLKDSRVM5XYGI2TIXP5QMVBOQHDQC
X5WLJCJVW55SXZVP7IKP7ADCJIGNKN4PKAXFECVR6TNK7XSMZR7QC
QDTVLBRGHDTRUVT7I3O72K6TMOYAUSAJBZUHGOEFU2RKJNUPWZSQC
R22TTMI6WXWULC7ODKFF3QCB7MOTETQQ6IR4BUCUPOCQKQNCTT5AC
CEK6M777MI5JVDC3KHE3JD3FETVSJ4VN6DGATBI5P3O6P5XHY4DAC
PFMHSDAXQN4VDSDA6QBDIK2DPJKGYX5HYLTSZNTKMRJYXYLIKGOQC
SVY2PTCLXR3KNPQAWXVXTTGCC5DR334HOAKHYO3VDDRWM2BWMALAC
4Q5OYUKF2SGF7WHMIVYFZVXXDCFUCYY534VLOGKWYRSPYKRXMVDAC
if (!you.is_undead)
poison_player( 2 + random2(3), true );
}
hurted = resist_adjust_damage(&you, flavour, resist, hurted);
if (hurted < original)
mpr("You partially resist.");
int resist_adjust_damage(actor *defender, int res, int rawdamage,
bool ranged)
// Gets the percentage of the total damage of this damage flavour that can
// be resisted.
static inline int get_resistible_fraction(beam_type flavour)
{
switch (flavour)
{
case BEAM_LAVA:
case BEAM_ICE:
return (50);
case BEAM_POISON_ARROW:
return (40);
default:
return (100);
}
}
// Adjusts damage for elemntal resists, electricity and poison.
//
// FIXME: Does not (yet) handle life draining, player acid damage
// (does handle monster acid damage), miasma, and other exotic
// attacks.
//
// beam_type is just use to determine the damage flavour, it does not
// necessarily imply that the attack is a beam attack.
int resist_adjust_damage(actor *defender, beam_type flavour,
int res, int rawdamage, bool ranged)
if (defender->atype() == ACT_MONSTER && res >= 3)
return (0);
if (!res)
return (rawdamage);
const bool monster = defender->atype() == ACT_MONSTER;
// Check if this is a resist that pretends to be boolean for
// damage purposes - only electricity at the moment, raw poison
// damage uses the normal formula.
int res_base = is_boolean_resist(flavour)? 2 : 1;
const int resistible_fraction = get_resistible_fraction(flavour);
int resistible = rawdamage * resistible_fraction / 100;
const int irresistible = rawdamage - resistible;