MCPcopy Create free account
hub / github.com/NetHack/NetHack / u_adtyp_resistance_obj

Function u_adtyp_resistance_obj

src/zap.c:5675–5698  ·  view source on GitHub ↗

Is hero wearing or wielding an object with resistance to attack damage type? Returns the percentage protection that the object gives. */

Source from the content-addressed store, hash-verified

5673/* Is hero wearing or wielding an object with resistance to attack
5674 damage type? Returns the percentage protection that the object gives. */
5675int
5676u_adtyp_resistance_obj(int dmgtyp)
5677{
5678 int prop = adtyp_to_prop(dmgtyp);
5679
5680 if (!prop)
5681 return 0;
5682
5683 /* FIXME? these percentages (99 and 90) seem too high... */
5684
5685 /* items that give an extrinsic resistance when worn or wielded or
5686 carried give 99% protection to your items */
5687 if ((u.uprops[prop].extrinsic & (W_ARMOR | W_ACCESSORY | W_WEP | W_ART))
5688 != 0L)
5689 return 99;
5690
5691 /* worn dwarvish cloaks give 90% protection against heat and cold to
5692 carried items */
5693 if (uarmc && uarmc->otyp == DWARVISH_CLOAK
5694 && (dmgtyp == AD_COLD || dmgtyp == AD_FIRE))
5695 return 90;
5696
5697 return 0;
5698}
5699
5700/* Rolls to see whether an object in inventory resists damage from the
5701 given damage type, due to an equipped item protecting it. Use

Callers 2

item_resistance_messageFunction · 0.85

Calls 1

adtyp_to_propFunction · 0.85

Tested by

no test coverage detected