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

Function loot_mon

src/pickup.c:2430–2481  ·  view source on GitHub ↗

loot_mon() returns amount of time passed. */

Source from the content-addressed store, hash-verified

2428/* loot_mon() returns amount of time passed.
2429 */
2430int
2431loot_mon(struct monst *mtmp, int *passed_info, boolean *prev_loot)
2432{
2433 int c = -1;
2434 int timepassed = 0;
2435 struct obj *otmp;
2436 char qbuf[QBUFSZ];
2437
2438 /* 3.3.1 introduced the ability to remove saddle from a steed.
2439 * *passed_info is set to TRUE if a loot query was given.
2440 * *prev_loot is set to TRUE if something was actually acquired in here.
2441 */
2442 if (mtmp && mtmp != u.usteed && (otmp = which_armor(mtmp, W_SADDLE))) {
2443 if (passed_info)
2444 *passed_info = 1;
2445 Sprintf(qbuf, "Do you want to remove the saddle from %s?",
2446 x_monnam(mtmp, ARTICLE_THE, (char *) 0,
2447 SUPPRESS_SADDLE, FALSE));
2448 if ((c = yn_function(qbuf, ynqchars, 'n', TRUE)) == 'y') {
2449 if (nolimbs(gy.youmonst.data)) {
2450 You_cant("do that without limbs."); /* not body_part(HAND) */
2451 return 0;
2452 }
2453 if (otmp->cursed) {
2454 You("can't. The saddle seems to be stuck to %s.",
2455 x_monnam(mtmp, ARTICLE_THE, (char *) 0,
2456 SUPPRESS_SADDLE, FALSE));
2457 /* the attempt costs you time */
2458 return 1;
2459 }
2460 extract_from_minvent(mtmp, otmp, TRUE, FALSE);
2461 if (flags.verbose)
2462 You("take %s off of %s.",
2463 thesimpleoname(otmp), mon_nam(mtmp));
2464 otmp = hold_another_object(otmp, "You drop %s!", doname(otmp),
2465 (const char *) 0);
2466 nhUse(otmp);
2467 timepassed = rnd(3);
2468 if (prev_loot)
2469 *prev_loot = TRUE;
2470 } else if (c == 'q') {
2471 return 0;
2472 }
2473 }
2474 /* 3.4.0 introduced ability to pick things up from swallower's stomach */
2475 if (u.uswallow) {
2476 int count = passed_info ? *passed_info : 0;
2477
2478 timepassed = pickup(count);
2479 }
2480 return timepassed;
2481}
2482
2483/*
2484 * Decide whether an object being placed into a magic bag will cause

Callers 2

dopickupFunction · 0.85
doloot_coreFunction · 0.85

Calls 11

which_armorFunction · 0.85
yn_functionFunction · 0.85
You_cantFunction · 0.85
YouFunction · 0.85
extract_from_minventFunction · 0.85
thesimpleonameFunction · 0.85
mon_namFunction · 0.85
hold_another_objectFunction · 0.85
donameFunction · 0.85
rndFunction · 0.85
pickupFunction · 0.85

Tested by

no test coverage detected