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

Function maybe_adjust_light

src/mkobj.c:1703–1736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1701}
1702
1703void
1704maybe_adjust_light(struct obj *obj, int old_range)
1705{
1706 char buf[BUFSZ];
1707 coordxy ox, oy;
1708 int new_range = arti_light_radius(obj), delta = new_range - old_range;
1709
1710 /* radius of light emitting artifact varies by curse/bless state
1711 so will change after blessing or cursing */
1712 if (delta) {
1713 obj_adjust_light_radius(obj, new_range);
1714 /* simplifying assumptions: hero is wielding or wearing this object;
1715 artifacts have to be in use to emit light and monsters' gear won't
1716 change bless or curse state */
1717 if (!Blind && get_obj_location(obj, &ox, &oy, 0)) {
1718 *buf = '\0';
1719 if (iflags.last_msg == PLNMSG_OBJ_GLOWS)
1720 /* we just saw "The <obj> glows <color>." from dipping */
1721 Strcpy(buf, (obj->quan == 1L) ? "It" : "They");
1722 else if (carried(obj) || cansee(ox, oy))
1723 Strcpy(buf, Yname2(obj));
1724 if (*buf) {
1725 /* initial activation says "dimly" if cursed,
1726 "brightly" if uncursed, and "brilliantly" if blessed;
1727 when changing intensity, using "less brightly" is
1728 straightforward for dimming, but we need "brighter"
1729 rather than "more brightly" for brightening; ugh */
1730 pline("%s %s %s%s.", buf, otense(obj, "shine"),
1731 (abs(delta) > 1) ? "much " : "",
1732 (delta > 0) ? "brighter" : "less brightly");
1733 }
1734 }
1735 }
1736}
1737
1738/*
1739 * bless(), curse(), unbless(), uncurse() -- any relevant message

Callers 7

polyselfFunction · 0.85
skinbackFunction · 0.85
blessFunction · 0.85
unblessFunction · 0.85
curseFunction · 0.85
uncurseFunction · 0.85
seffect_enchant_armorFunction · 0.85

Calls 6

arti_light_radiusFunction · 0.85
obj_adjust_light_radiusFunction · 0.85
get_obj_locationFunction · 0.85
Yname2Function · 0.85
otenseFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected