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

Function invault

src/vault.c:316–629  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void
317invault(void)
318{
319 struct monst *guard;
320 struct obj *otmp;
321 boolean spotted;
322 int trycount, vaultroom = (int) vault_occupied(u.urooms);
323 int vgdeathcount;
324
325 if (!vaultroom) {
326 u.uinvault = 0;
327 return;
328 }
329 /* after a couple of guards don't come back from their trips to
330 the vault, future guards become more reluctant to turn up (even
331 if summoned via whistle) */
332 vgdeathcount = svm.mvitals[PM_GUARD].died;
333 if (vgdeathcount < 2 ||
334 (vgdeathcount < 50 && !rn2(vgdeathcount * vgdeathcount)))
335 ++u.uinvault;
336 if (u.uinvault < VAULT_GUARD_TIME
337 || (u.uinvault % (VAULT_GUARD_TIME / 2)) != 0)
338 return;
339
340 guard = findgd();
341 if (!guard) {
342 /* if time ok and no guard now. */
343 char buf[BUFSZ];
344 int x, y, gdx, gdy, typ;
345 coordxy rx, ry;
346 long umoney;
347
348 /* first find the goal for the guard */
349 if (!find_guard_dest((struct monst *) 0, &rx, &ry))
350 return;
351 gdx = rx, gdy = ry;
352 vaultroom -= ROOMOFFSET;
353
354 /* next find a good place for a door in the wall */
355 x = u.ux;
356 y = u.uy;
357 if (levl[x][y].typ != ROOM) { /* player dug a door and is in it */
358 if (levl[x + 1][y].typ == ROOM) {
359 x = x + 1;
360 } else if (levl[x][y + 1].typ == ROOM) {
361 y = y + 1;
362 } else if (levl[x - 1][y].typ == ROOM) {
363 x = x - 1;
364 } else if (levl[x][y - 1].typ == ROOM) {
365 y = y - 1;
366 } else if (levl[x + 1][y + 1].typ == ROOM) {
367 x = x + 1;
368 y = y + 1;
369 } else if (levl[x - 1][y - 1].typ == ROOM) {
370 x = x - 1;
371 y = y - 1;
372 } else if (levl[x + 1][y - 1].typ == ROOM) {
373 x = x + 1;

Callers 1

allmain.cFile · 0.85

Calls 15

vault_occupiedFunction · 0.85
rn2Function · 0.85
findgdFunction · 0.85
find_guard_destFunction · 0.85
makemonFunction · 0.85
set_malignFunction · 0.85
assign_levelFunction · 0.85
reset_faintFunction · 0.85
sobj_atFunction · 0.85
simpleonamesFunction · 0.85
fracture_rockFunction · 0.85
anFunction · 0.85

Tested by

no test coverage detected