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

Function inherits

src/shk.c:2576–2679  ·  view source on GitHub ↗

decide whether a shopkeeper will take possession of dying hero's invent; when this returns True, it should call set_repo_loc() before returning; when it returns False, it should not do such because that might have already been called for some shopkeeper */

Source from the content-addressed store, hash-verified

2574 when it returns False, it should not do such because that might have
2575 already been called for some shopkeeper */
2576staticfn boolean
2577inherits(
2578 struct monst *shkp,
2579 int numsk,
2580 int croaked,
2581 boolean silently)
2582{
2583 long loss = 0L;
2584 long umoney;
2585 struct eshk *eshkp = ESHK(shkp);
2586 boolean take = FALSE, taken = FALSE,
2587 uinshop = (strchr(u.ushops, eshkp->shoproom) != (char *) 0);
2588 char takes[BUFSZ];
2589
2590 /* not strictly consistent; affects messages and prevents next player
2591 (if bones are saved) from blundering into or being ambushed by an
2592 invisible shopkeeper */
2593 shkp->minvis = shkp->perminvis = 0;
2594
2595 /* The simplifying principle is that first-come
2596 already took everything you had. */
2597 if (numsk > 1) {
2598 if (cansee(shkp->mx, shkp->my) && croaked && !silently) {
2599 takes[0] = '\0';
2600 if (has_head(shkp->data) && !rn2(2))
2601 Sprintf(takes, ", shakes %s %s,", noit_mhis(shkp),
2602 mbodypart(shkp, HEAD));
2603 pline("%s %slooks at your corpse%s and %s.", Shknam(shkp),
2604 helpless(shkp) ? "wakes up, " : "",
2605 takes, !inhishop(shkp) ? "disappears" : "sighs");
2606 }
2607 taken = uinshop;
2608 goto skip;
2609 }
2610
2611 /* get one case out of the way: you die in the shop, the
2612 shopkeeper is peaceful, nothing stolen, nothing owed */
2613 if (uinshop && inhishop(shkp) && !eshkp->billct
2614 && !eshkp->robbed && !eshkp->debit && NOTANGRY(shkp)
2615 && !eshkp->following && u.ugrave_arise < LOW_PM) {
2616 taken = (gi.invent != 0);
2617 if (taken && !silently)
2618 pline("%s gratefully inherits all your possessions.",
2619 Shknam(shkp));
2620 goto clear;
2621 }
2622
2623 if (eshkp->billct || eshkp->debit || eshkp->robbed) {
2624 if (uinshop && inhishop(shkp))
2625 loss = addupbill(shkp) + eshkp->debit;
2626 if (loss < eshkp->robbed)
2627 loss = eshkp->robbed;
2628 take = TRUE;
2629 }
2630
2631 if (eshkp->following || ANGRY(shkp) || take) {
2632 if (!gi.invent)
2633 goto skip;

Callers 2

paybillFunction · 0.85
paintEventMethod · 0.85

Calls 14

rn2Function · 0.85
mbodypartFunction · 0.85
ShknamFunction · 0.85
inhishopFunction · 0.85
addupbillFunction · 0.85
money_cntFunction · 0.85
money2monFunction · 0.85
currencyFunction · 0.85
pacify_shkFunction · 0.85
rouse_shkFunction · 0.85
home_shkFunction · 0.85
setpaidFunction · 0.85

Tested by

no test coverage detected