try to force a locked chest */
| 213 | |
| 214 | /* try to force a locked chest */ |
| 215 | staticfn int |
| 216 | forcelock(void) |
| 217 | { |
| 218 | if ((gx.xlock.box->ox != u.ux) || (gx.xlock.box->oy != u.uy)) |
| 219 | return ((gx.xlock.usedtime = 0)); /* you or it moved */ |
| 220 | |
| 221 | if (gx.xlock.usedtime++ >= 50 || !uwep || nohands(gy.youmonst.data)) { |
| 222 | You("give up your attempt to force the lock."); |
| 223 | if (gx.xlock.usedtime >= 50) /* you made the effort */ |
| 224 | exercise((gx.xlock.picktyp) ? A_DEX : A_STR, TRUE); |
| 225 | return ((gx.xlock.usedtime = 0)); |
| 226 | } |
| 227 | |
| 228 | if (gx.xlock.picktyp) { /* blade */ |
| 229 | if (rn2(1000 - (int) uwep->spe) > (992 - greatest_erosion(uwep) * 10) |
| 230 | && !uwep->cursed && !obj_resists(uwep, 0, 99)) { |
| 231 | /* for a +0 weapon, probability that it survives an unsuccessful |
| 232 | * attempt to force the lock is (.992)^50 = .67 |
| 233 | */ |
| 234 | pline("%sour %s broke!", (uwep->quan > 1L) ? "One of y" : "Y", |
| 235 | xname(uwep)); |
| 236 | useup(uwep); |
| 237 | You("give up your attempt to force the lock."); |
| 238 | exercise(A_DEX, TRUE); |
| 239 | return ((gx.xlock.usedtime = 0)); |
| 240 | } |
| 241 | } else /* blunt */ |
| 242 | wake_nearby(FALSE); /* due to hammering on the container */ |
| 243 | |
| 244 | if (rn2(100) >= gx.xlock.chance) |
| 245 | return 1; /* still busy */ |
| 246 | |
| 247 | You("succeed in forcing the lock."); |
| 248 | exercise(gx.xlock.picktyp ? A_DEX : A_STR, TRUE); |
| 249 | /* breakchestlock() might destroy xlock.box; if so, xlock context will |
| 250 | be cleared (delobj -> obfree -> maybe_reset_pick); but it might not, |
| 251 | so explicitly clear that manually */ |
| 252 | breakchestlock(gx.xlock.box, (boolean) (!gx.xlock.picktyp && !rn2(3))); |
| 253 | reset_pick(); /* lock-picking context is no longer valid */ |
| 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | void |
| 259 | reset_pick(void) |
nothing calls this directly
no test coverage detected