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

Function paygd

src/vault.c:1204–1247  ·  view source on GitHub ↗

Routine when dying or quitting with a vault guard around */

Source from the content-addressed store, hash-verified

1202
1203/* Routine when dying or quitting with a vault guard around */
1204void
1205paygd(boolean silently)
1206{
1207 struct monst *grd = findgd();
1208 long umoney = money_cnt(gi.invent);
1209 struct obj *coins, *nextcoins;
1210 int gdx, gdy;
1211 char buf[BUFSZ];
1212
1213 if (!umoney || !grd)
1214 return;
1215
1216 if (u.uinvault) {
1217 if (!silently)
1218 Your("%ld %s goes into the Magic Memory Vault.",
1219 umoney, currency(umoney));
1220 gdx = u.ux;
1221 gdy = u.uy;
1222 } else {
1223 if (grd->mpeaceful) /* peaceful guard has no "right" to your gold */
1224 goto remove_guard;
1225
1226 mnexto(grd, RLOC_NOMSG);
1227 if (!silently)
1228 pline("%s remits your gold to the vault.", Monnam(grd));
1229 gdx = svr.rooms[EGD(grd)->vroom].lx + rn2(2);
1230 gdy = svr.rooms[EGD(grd)->vroom].ly + rn2(2);
1231 Sprintf(buf, "To Croesus: here's the gold recovered from %s the %s.",
1232 svp.plname,
1233 pmname(&mons[u.umonster], flags.female ? FEMALE : MALE));
1234 make_grave(gdx, gdy, buf);
1235 }
1236 for (coins = gi.invent; coins; coins = nextcoins) {
1237 nextcoins = coins->nobj;
1238 if (objects[coins->otyp].oc_class == COIN_CLASS) {
1239 freeinv(coins);
1240 place_object(coins, gdx, gdy);
1241 stackobj(coins);
1242 }
1243 }
1244 remove_guard:
1245 mongone(grd);
1246 return;
1247}
1248
1249/*
1250 * amount of gold in carried containers

Callers 1

really_doneFunction · 0.85

Calls 14

findgdFunction · 0.85
money_cntFunction · 0.85
YourFunction · 0.85
currencyFunction · 0.85
mnextoFunction · 0.85
MonnamFunction · 0.85
rn2Function · 0.85
pmnameFunction · 0.85
make_graveFunction · 0.85
freeinvFunction · 0.85
place_objectFunction · 0.85
stackobjFunction · 0.85

Tested by

no test coverage detected