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

Function toggle_displacement

src/do_wear.c:147–178  ·  view source on GitHub ↗

putting on or taking off an item which confers displacement, or gaining or losing timed displacement after eating a displacer beast corpse or tin; give feedback and discover it iff displacement state is changing *and* hero is able to see self (or sense monsters); for timed, 'obj' is Null and this is only called for the message */

Source from the content-addressed store, hash-verified

145 hero is able to see self (or sense monsters); for timed, 'obj' is Null
146 and this is only called for the message */
147void
148toggle_displacement(
149 struct obj *obj,
150 long oldprop, /* prop[].extrinsic, with obj->owornmask
151 stripped by caller */
152 boolean on)
153{
154 if (on ? gi.initial_don : svc.context.takeoff.cancelled_don)
155 return;
156
157 if (!oldprop /* extrinsic displacement from something else */
158 && !(u.uprops[DISPLACED].intrinsic) /* timed, from eating */
159 && !(u.uprops[DISPLACED].blocked) /* (theoretical) */
160 /* we don't use canseeself() here because it augments vision
161 with touch, which isn't appropriate for deciding whether
162 we'll notice that monsters have trouble spotting the hero */
163 && ((!Blind /* see anything */
164 && !u.uswallow /* see surroundings */
165 && !Invisible) /* see self */
166 /* actively sensing nearby monsters via telepathy or extended
167 monster detection overrides vision considerations because
168 hero also senses self in this situation */
169 || (Unblind_telepat
170 || (Blind_telepat && Blind)
171 || Detect_monsters))) {
172 if (obj)
173 makeknown(obj->otyp);
174
175 You_feel("that monsters%s have difficulty pinpointing your location.",
176 on ? "" : " no longer");
177 }
178}
179
180/*
181 * The Type_on() functions should be called *after* setworn().

Callers 4

Cloak_onFunction · 0.85
Cloak_offFunction · 0.85
nh_timeoutFunction · 0.85
cpostfxFunction · 0.85

Calls 1

You_feelFunction · 0.85

Tested by

no test coverage detected