player is applying a key, lock pick, or credit card */
| 355 | |
| 356 | /* player is applying a key, lock pick, or credit card */ |
| 357 | int |
| 358 | pick_lock( |
| 359 | struct obj *pick, |
| 360 | coordxy rx, coordxy ry, /* coordinates of door/container, for autounlock: |
| 361 | * doesn't prompt for direction if these are set */ |
| 362 | struct obj *container) /* container, for autounlock */ |
| 363 | { |
| 364 | struct obj dummypick; |
| 365 | int picktyp, c, ch; |
| 366 | coord cc; |
| 367 | struct rm *door; |
| 368 | struct obj *otmp; |
| 369 | char qbuf[QBUFSZ]; |
| 370 | boolean autounlock = (rx != 0 || container != NULL); |
| 371 | |
| 372 | /* 'pick' might be Null [called by do_loot_cont() for AUTOUNLOCK_UNTRAP] */ |
| 373 | if (!pick) { |
| 374 | dummypick = cg.zeroobj; |
| 375 | pick = &dummypick; /* pick->otyp will be STRANGE_OBJECT */ |
| 376 | } |
| 377 | picktyp = pick->otyp; |
| 378 | |
| 379 | /* check whether we're resuming an interrupted previous attempt */ |
| 380 | if (gx.xlock.usedtime && picktyp == gx.xlock.picktyp) { |
| 381 | static char no_longer[] = "Unfortunately, you can no longer %s %s."; |
| 382 | |
| 383 | if (nohands(gy.youmonst.data)) { |
| 384 | const char *what = (picktyp == LOCK_PICK) ? "pick" : "key"; |
| 385 | |
| 386 | if (picktyp == CREDIT_CARD) |
| 387 | what = "card"; |
| 388 | pline(no_longer, "hold the", what); |
| 389 | reset_pick(); |
| 390 | return PICKLOCK_LEARNED_SOMETHING; |
| 391 | } else if (u.uswallow || (gx.xlock.box && !can_reach_floor(TRUE))) { |
| 392 | pline(no_longer, "reach the", "lock"); |
| 393 | reset_pick(); |
| 394 | return PICKLOCK_LEARNED_SOMETHING; |
| 395 | } else { |
| 396 | const char *action = lock_action(); |
| 397 | |
| 398 | You("resume your attempt at %s.", action); |
| 399 | gx.xlock.magic_key = is_magic_key(&gy.youmonst, pick); |
| 400 | set_occupation(picklock, action, 0); |
| 401 | return PICKLOCK_DID_SOMETHING; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | if (nohands(gy.youmonst.data)) { |
| 406 | You_cant("hold %s -- you have no hands!", doname(pick)); |
| 407 | return PICKLOCK_DID_NOTHING; |
| 408 | } else if (u.uswallow) { |
| 409 | You_cant("%sunlock %s.", (picktyp == CREDIT_CARD) ? "" : "lock or ", |
| 410 | mon_nam(u.ustuck)); |
| 411 | return PICKLOCK_DID_NOTHING; |
| 412 | } |
| 413 | |
| 414 | if (pick != &dummypick && picktyp != SKELETON_KEY |
no test coverage detected