Skip to content

Commit

Permalink
Credit cards may slip through a lock when cursed or hero is fumbling
Browse files Browse the repository at this point in the history
Note by copperwater: Another slight nerf to credit cards as an unlocking
tool. In the original concept of the idea this was possible to happen
for a non-cursed credit card when the hero wasn't fumbling, but I
figured it should only really punish when there's some negative
circumstance mucking things up.

As implemented this patch had a flat 5% chance if cursed or fumbling; I
modified it back to the original idea which is Dex based. I also noticed
that the new code was inserted at the wrong point, before the "still
busy" check, meaning this check would have triggered every turn of
unlocking, rather than once per the unlock attempt. Moved it so that it
triggers after the unlock attempt resolves, which is not perfect
(ideally it would have a chance of happening at any point during the
process) but good enough.
  • Loading branch information
Nephi Allred authored and copperwater committed Apr 19, 2024
1 parent 4179e8a commit 98cdcf7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/xnh-changelog-9.0.md
Expand Up @@ -26,6 +26,8 @@ changes:
- Every lock in the game may be unopenable by using a credit card. Boxes have a
40% chance, and doors have a chance that starts at 10% and increases with
depth.
- Also, if the card is cursed or you are fumbling, the card may slip through the
lock, ending up inside a box or on the other side of a door.
- Cockatrice nests may contain chickatrices and cockatrice eggs.
- Eating troll meat provides 2d6 turns of intrinsic regneneration.
- Drinking from a magic fountain when either HP or Pw is below 60% may give a
Expand Down
28 changes: 27 additions & 1 deletion src/lock.c
Expand Up @@ -67,7 +67,9 @@ lock_action(void)
static int
picklock(void)
{
coordxy doorx = u.ux + u.dx, doory = u.uy + u.dy;
coordxy doorx = u.ux + u.dx, doory = u.uy + u.dy, behind_x, behind_y;
boolean credit_card_slipped;

if (gx.xlock.box) {
if (gx.xlock.box->where != OBJ_FLOOR
|| gx.xlock.box->ox != u.ux || gx.xlock.box->oy != u.uy) {
Expand Down Expand Up @@ -129,6 +131,30 @@ picklock(void)
if (rn2(100) >= gx.xlock.chance)
return 1; /* still busy */

if (gx.xlock.picktyp == CREDIT_CARD && (Fumbling || gx.xlock.pick->cursed)
/* 1/(Dex/4) chance if Fumbling; 1/2*Dex chance otherwise */
&& !rn2(Fumbling ? ((ACURR(A_DEX) + 3) / 4)
: ACURR(A_DEX) * 2)) {
if (gx.xlock.door) {
behind_x = doorx + (gx.xlock.door->horizontal ? 0 : u.dx);
behind_y = doory + (gx.xlock.door->horizontal ? u.dy : 0);
credit_card_slipped = isok(behind_x, behind_y)
&& SPACE_POS(levl[behind_x][behind_y].typ);
} else {
credit_card_slipped = TRUE;
}
if (credit_card_slipped) {
Your("%s slips through the crack!", xname(gx.xlock.pick));
obj_extract_self(gx.xlock.pick);
if (gx.xlock.door) {
place_object(gx.xlock.pick, behind_x, behind_y);
} else {
add_to_container(gx.xlock.box, gx.xlock.pick);
}
return ((gx.xlock.usedtime = 0));
}
}

/* using the Master Key of Thievery finds traps if its bless/curse
state is adequate (non-cursed for rogues, blessed for others;
checked when setting up 'xlock') */
Expand Down

0 comments on commit 98cdcf7

Please sign in to comment.