| 314 | } |
| 315 | |
| 316 | void |
| 317 | invault(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; |
no test coverage detected