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

Function water_damage

src/trap.c:4711–4852  ·  view source on GitHub ↗

Get an object wet and damage it appropriately. Returns an erosion return value (ER_*). */

Source from the content-addressed store, hash-verified

4709/* Get an object wet and damage it appropriately.
4710 Returns an erosion return value (ER_*). */
4711int
4712water_damage(
4713 struct obj *obj, /* might be Null; return ER_NOTHING if so */
4714 const char *ostr, /* if non-Null, use instead of cxname() in messages */
4715 boolean force) /* if True, skip luck-based protection check */
4716{
4717 boolean in_invent = obj && carried(obj), described = FALSE;
4718
4719 if (!obj)
4720 return ER_NOTHING;
4721
4722 if (splash_lit(obj))
4723 return ER_DAMAGED;
4724
4725 if (!ostr)
4726 ostr = cxname(obj);
4727
4728 if (obj->otyp == CAN_OF_GREASE && obj->spe > 0) {
4729 return ER_NOTHING;
4730 } else if (obj->otyp == TOWEL && obj->spe < 7) {
4731 /* a negative change induces a reverse increment, adding abs(change);
4732 spe starts 0..6, arg passed to rnd() is 1..7, change is -7..-1,
4733 final spe is 1..7 and always greater than its starting value */
4734 wet_a_towel(obj, -rnd(7 - obj->spe), TRUE);
4735 return ER_NOTHING;
4736 } else if (obj->greased) {
4737 if (!rn2(2)) {
4738 obj->greased = 0;
4739 if (in_invent) {
4740 pline_The("grease on %s washes off.", yname(obj));
4741 described = TRUE; /* used to modify potion feedback */
4742 update_inventory();
4743 }
4744 /* ungreased potions of acid will always be destroyed by water */
4745 if (obj->otyp == POT_ACID) {
4746 pot_acid_damage(obj, in_invent, described);
4747 return ER_DESTROYED;
4748 }
4749 }
4750 return ER_GREASED;
4751 } else if (Is_container(obj)
4752 && (!Waterproof_container(obj) || (obj->cursed && !rn2(3)))) {
4753 if (in_invent) {
4754 pline("Some %s gets into your %s!", hliquid("water"), ostr);
4755 gm.mentioned_water = !Hallucination;
4756 }
4757 water_damage_chain(obj->cobj, FALSE);
4758 return ER_DAMAGED; /* contents were damaged */
4759 } else if (Waterproof_container(obj)) {
4760 if (in_invent && !Blind && !Underwater) {
4761 pline_The("%s cannot get into your %s.", hliquid("water"), ostr);
4762 gm.mentioned_water = !Hallucination;
4763 makeknown(obj->otyp); /* if an oilskin sack, discover it; doesn't
4764 * matter for chest, large box, ice box */
4765 }
4766 /* not actually damaged, but because we /didn't/ get the "water
4767 gets into!" message, the player now has more information and
4768 thus we need to waste any potion they may have used (also,

Callers 10

dositFunction · 0.85
H2Opotion_dipFunction · 0.85
dodipFunction · 0.85
flooreffectsFunction · 0.85
trapeffect_rust_trapFunction · 0.85
water_damage_chainFunction · 0.85
kick_nondoorFunction · 0.85
dipfountainFunction · 0.85
wash_handsFunction · 0.85
dipsinkFunction · 0.85

Calls 15

splash_litFunction · 0.85
cxnameFunction · 0.85
wet_a_towelFunction · 0.85
rndFunction · 0.85
rn2Function · 0.85
pline_TheFunction · 0.85
ynameFunction · 0.85
update_inventoryFunction · 0.85
pot_acid_damageFunction · 0.85
hliquidFunction · 0.85
water_damage_chainFunction · 0.85
YourFunction · 0.85

Tested by

no test coverage detected