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

Function mkgrave

src/mklev.c:2352–2397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2350}
2351
2352staticfn void
2353mkgrave(struct mkroom *croom)
2354{
2355 coord m;
2356 int tryct = 0;
2357 struct obj *otmp;
2358 boolean dobell = !rn2(10);
2359
2360 if (croom->rtype != OROOM)
2361 return;
2362
2363 if (!find_okay_roompos(croom, &m))
2364 return;
2365
2366 /* Put a grave at <m.x,m.y> */
2367 make_grave(m.x, m.y, dobell ? "Saved by the bell!" : (char *) 0);
2368
2369 /* Possibly fill it with objects */
2370 if (!rn2(3)) {
2371 /* this used to use mkgold(), which puts a stack of gold on
2372 the ground (or merges it with an existing one there if
2373 present), and didn't bother burying it; now we create a
2374 loose, easily buriable, stack but we make no attempt to
2375 replicate mkgold()'s level-based formula for the amount */
2376 struct obj *gold = mksobj(GOLD_PIECE, TRUE, FALSE);
2377
2378 gold->quan = (long) (rnd(20) + level_difficulty() * rnd(5));
2379 gold->owt = weight(gold);
2380 gold->ox = m.x, gold->oy = m.y;
2381 add_to_buried(gold);
2382 }
2383 for (tryct = rn2(5); tryct; tryct--) {
2384 otmp = mkobj(RANDOM_CLASS, TRUE);
2385 if (!otmp)
2386 return;
2387 curse(otmp);
2388 otmp->ox = m.x;
2389 otmp->oy = m.y;
2390 add_to_buried(otmp);
2391 }
2392
2393 /* Leave a bell, in case we accidentally buried someone alive */
2394 if (dobell)
2395 (void) mksobj_at(BELL, m.x, m.y, TRUE, FALSE);
2396 return;
2397}
2398
2399/*
2400 * Major level transmutation: add a set of stairs (to the Sanctum) after

Callers 1

fill_ordinary_roomFunction · 0.85

Calls 11

rn2Function · 0.85
find_okay_roomposFunction · 0.85
make_graveFunction · 0.85
mksobjFunction · 0.85
rndFunction · 0.85
level_difficultyFunction · 0.85
weightFunction · 0.85
add_to_buriedFunction · 0.85
mkobjFunction · 0.85
curseFunction · 0.85
mksobj_atFunction · 0.85

Tested by

no test coverage detected