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

Function dopay

src/shk.c:1742–2035  ·  view source on GitHub ↗

the #pay command */

Source from the content-addressed store, hash-verified

1740
1741/* the #pay command */
1742int
1743dopay(void)
1744{
1745 struct eshk *eshkp;
1746 struct monst *shkp;
1747 struct monst *nxtm, *resident;
1748 Bill *ibill = (Bill *) NULL;
1749 long ltmp;
1750 long umoney;
1751 int sk = 0, seensk = 0, nexttosk = 0;
1752 boolean paid = FALSE, stashed_gold = (hidden_gold(TRUE) > 0L),
1753 pay_done;
1754
1755 gm.multi = 0;
1756
1757 /* Find how many shk's there are, how many are in
1758 * sight, and are you in a shop room with one.
1759 */
1760 nxtm = resident = 0;
1761 for (shkp = next_shkp(fmon, FALSE); shkp;
1762 shkp = next_shkp(shkp->nmon, FALSE)) {
1763 sk++;
1764 if (m_next2u(shkp)) {
1765 /* next to an irate shopkeeper? prioritize that */
1766 if (nxtm && ANGRY(nxtm))
1767 continue;
1768 nexttosk++;
1769 nxtm = shkp;
1770 }
1771 if (canspotmon(shkp))
1772 seensk++;
1773 if (inhishop(shkp) && (*u.ushops == ESHK(shkp)->shoproom))
1774 resident = shkp;
1775 }
1776
1777 if (nxtm && nexttosk == 1) {
1778 shkp = nxtm;
1779 goto proceed;
1780 }
1781
1782 if ((!sk && (!Blind || Blind_telepat)) || (!Blind && !seensk)) {
1783 There("appears to be no shopkeeper here to receive your payment.");
1784 return ECMD_OK;
1785 }
1786
1787 if (!seensk) {
1788 You_cant("see...");
1789 return ECMD_OK;
1790 }
1791
1792 /* The usual case. Allow paying at a distance when
1793 * inside a tended shop. Should we change that?
1794 */
1795 if (sk == 1 && resident) {
1796 shkp = resident;
1797 goto proceed;
1798 }
1799

Callers 1

do_attackFunction · 0.85

Calls 15

hidden_goldFunction · 0.85
next_shkpFunction · 0.85
inhishopFunction · 0.85
ThereFunction · 0.85
You_cantFunction · 0.85
ShknamFunction · 0.85
getposFunction · 0.85
YouFunction · 0.85
MonnamFunction · 0.85
rouse_shkFunction · 0.85
rn2Function · 0.85
money_cntFunction · 0.85

Tested by

no test coverage detected