MCPcopy Index your code
hub / github.com/NetHack/NetHack / use_stethoscope

Function use_stethoscope

src/apply.c:317–470  ·  view source on GitHub ↗

Strictly speaking it makes no sense for usage of a stethoscope to not take any time; however, unless it did, the stethoscope would be almost useless. As a compromise, one use per turn is free, another uses up the turn; this makes curse status have a tangible effect. */

Source from the content-addressed store, hash-verified

315 almost useless. As a compromise, one use per turn is free, another
316 uses up the turn; this makes curse status have a tangible effect. */
317staticfn int
318use_stethoscope(struct obj *obj)
319{
320 struct monst *mtmp;
321 struct rm *lev;
322 int res;
323 coordxy rx, ry;
324 boolean interference = (u.uswallow && is_whirly(u.ustuck->data)
325 && !rn2(Role_if(PM_HEALER) ? 10 : 3));
326
327 if (nohands(gy.youmonst.data)) {
328 You("have no hands!"); /* not `body_part(HAND)' */
329 return ECMD_OK;
330 } else if (Deaf) {
331 You_cant("hear anything!");
332 return ECMD_OK;
333 } else if (!freehand()) {
334 You("have no free %s.", body_part(HAND));
335 return ECMD_OK;
336 }
337 if (!getdir((char *) 0))
338 return ECMD_CANCEL;
339
340 res = (gh.hero_seq == svc.context.stethoscope_seq) ? ECMD_TIME : ECMD_OK;
341 svc.context.stethoscope_seq = gh.hero_seq;
342
343 gb.bhitpos.x = u.ux, gb.bhitpos.y = u.uy; /* tentative, reset below */
344 gn.notonhead = u.uswallow;
345 if (u.usteed && u.dz > 0) {
346 if (interference) {
347 pline("%s interferes.", Monnam(u.ustuck));
348 mstatusline(u.ustuck);
349 } else
350 mstatusline(u.usteed);
351 return res;
352 } else if (u.uswallow && (u.dx || u.dy || u.dz)) {
353 mstatusline(u.ustuck);
354 return res;
355 } else if (u.uswallow && interference) {
356 pline("%s interferes.", Monnam(u.ustuck));
357 mstatusline(u.ustuck);
358 return res;
359 } else if (u.dz) {
360 if (Underwater) {
361 Soundeffect(se_faint_splashing, 35);
362 You_hear("faint splashing.");
363 } else if (u.dz < 0 || !can_reach_floor(TRUE)) {
364 cant_reach_floor(u.ux, u.uy, (u.dz < 0), TRUE, FALSE);
365 } else if (its_dead(u.ux, u.uy, &res)) {
366 ; /* message already given */
367 } else if (Is_stronghold(&u.uz)) {
368 Soundeffect(se_crackling_of_hellfire, 35);
369 You_hear("the crackling of hellfire.");
370 } else {
371 pline_The("%s seems healthy enough.", surface(u.ux, u.uy));
372 }
373 return res;
374 } else if (obj->cursed && !rn2(2)) {

Callers 1

doapplyFunction · 0.85

Calls 15

rn2Function · 0.85
YouFunction · 0.85
You_cantFunction · 0.85
freehandFunction · 0.85
body_partFunction · 0.85
getdirFunction · 0.85
MonnamFunction · 0.85
mstatuslineFunction · 0.85
You_hearFunction · 0.85
can_reach_floorFunction · 0.85
cant_reach_floorFunction · 0.85
its_deadFunction · 0.85

Tested by

no test coverage detected