produce an occupation string appropriate for the current activity */
| 35 | |
| 36 | /* produce an occupation string appropriate for the current activity */ |
| 37 | staticfn const char * |
| 38 | lock_action(void) |
| 39 | { |
| 40 | /* "unlocking"+2 == "locking" */ |
| 41 | static const char *const actions[] = { |
| 42 | "unlocking the door", /* [0] */ |
| 43 | "unlocking the chest", /* [1] */ |
| 44 | "unlocking the box", /* [2] */ |
| 45 | "picking the lock" /* [3] */ |
| 46 | }; |
| 47 | |
| 48 | /* if the target is currently unlocked, we're trying to lock it now */ |
| 49 | if (gx.xlock.door && !(gx.xlock.door->doormask & D_LOCKED)) |
| 50 | return actions[0] + 2; /* "locking the door" */ |
| 51 | else if (gx.xlock.box && !gx.xlock.box->olocked) |
| 52 | return gx.xlock.box->otyp == CHEST ? actions[1] + 2 : actions[2] + 2; |
| 53 | /* otherwise we're trying to unlock it */ |
| 54 | else if (gx.xlock.picktyp == LOCK_PICK) |
| 55 | return actions[3]; /* "picking the lock" */ |
| 56 | else if (gx.xlock.picktyp == CREDIT_CARD) |
| 57 | return actions[3]; /* same as lock_pick */ |
| 58 | else if (gx.xlock.door) |
| 59 | return actions[0]; /* "unlocking the door" */ |
| 60 | else if (gx.xlock.box) |
| 61 | return gx.xlock.box->otyp == CHEST ? actions[1] : actions[2]; |
| 62 | else |
| 63 | return actions[3]; |
| 64 | } |
| 65 | |
| 66 | /* try to open/close a lock */ |
| 67 | staticfn int |