-/* NetHack 3.6 lock.c $NHDT-Date: 1521499715 2018/03/19 22:48:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.80 $ */
+/* NetHack 3.6 lock.c $NHDT-Date: 1548978605 2019/01/31 23:50:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.84 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
/* JNetHack Copyright */
/* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
-/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016 */
+/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2022 */
/* JNetHack may be freely redistributed. See license for details. */
#include "hack.h"
{
/* "unlocking"+2 == "locking" */
static const char *actions[] = {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
"unlocking the door", /* [0] */
"unlocking the chest", /* [1] */
"unlocking the box", /* [2] */
/* unfortunately we don't have a 'tknown' flag to record
"known to be trapped" so declining to disarm and then
retrying lock manipulation will find it all over again */
+/*JP
if (yn("You find a trap! Do you want to try to disarm it?") == 'y') {
+*/
+ if (yn("ã©\82ð\8c©\82Â\82¯\82½\81I\8aO\82µ\82Ü\82·\82©\81H") == 'y') {
const char *what;
boolean alreadyunlocked;
/* disarming while using magic key always succeeds */
if (xlock.door) {
xlock.door->doormask &= ~D_TRAPPED;
+/*JP
what = "door";
+*/
+ what = "\94à";
alreadyunlocked = !(xlock.door->doormask & D_LOCKED);
} else {
xlock.box->otrapped = 0;
+/*JP
what = (xlock.box->otyp == CHEST) ? "chest" : "box";
+*/
+ what = (xlock.box->otyp == CHEST) ? "\95ó\94 " : "\94 ";
alreadyunlocked = !xlock.box->olocked;
}
+#if 0 /*JP:T*/
You("succeed in disarming the trap. The %s is still %slocked.",
what, alreadyunlocked ? "un" : "");
+#else
+ You("ã©\82ð\8aO\82µ\82½\81D%s\82Í\8c®\82ª%s\82Ü\82Ü\82¾\81D",
+ what, alreadyunlocked ? "\8aJ\82¢\82½" : "\82©\82©\82Á\82½");
+#endif
exercise(A_WIS, TRUE);
} else {
+/*JP
You("stop %s.", lock_action());
+*/
+ You("%s\82Ì\82ð\82â\82ß\82½\81D", lock_action());
exercise(A_WIS, FALSE);
}
return ((xlock.usedtime = 0));
if (!rn2(3) || otmp->oclass == POTION_CLASS) {
chest_shatter_msg(otmp);
if (costly)
- loss +=
- stolen_value(otmp, u.ux, u.uy, peaceful_shk, TRUE);
+ loss += stolen_value(otmp, u.ux, u.uy, peaceful_shk, TRUE);
if (otmp->quan == 1L) {
obfree(otmp, (struct obj *) 0);
continue;
}
+ /* this works because we're sure to have at least 1 left;
+ otherwise it would fail since otmp is not in inventory */
useup(otmp);
}
if (box->otyp == ICE_BOX && otmp->otyp == CORPSE) {
/* for a +0 weapon, probability that it survives an unsuccessful
* attempt to force the lock is (.992)^50 = .67
*/
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline("%sour %s broke!", (uwep->quan > 1L) ? "One of y" : "Y",
xname(uwep));
#else
You("succeed in forcing the lock.");
*/
pline("\8c®\82ð\82±\82¶\8aJ\82¯\82½\81D");
+ exercise(xlock.picktyp ? A_DEX : A_STR, TRUE);
+ /* breakchestlock() might destroy xlock.box; if so, xlock context will
+ be cleared (delobj -> obfree -> maybe_reset_pick); but it might not,
+ so explicitly clear that manually */
breakchestlock(xlock.box, (boolean) (!xlock.picktyp && !rn2(3)));
+ reset_pick(); /* lock-picking context is no longer valid */
- exercise((xlock.picktyp) ? A_DEX : A_STR, TRUE);
- return ((xlock.usedtime = 0));
+ return 0;
}
void
{
xlock.usedtime = xlock.chance = xlock.picktyp = 0;
xlock.magic_key = FALSE;
- xlock.door = 0;
- xlock.box = 0;
+ xlock.door = (struct rm *) 0;
+ xlock.box = (struct obj *) 0;
}
-/* level change; don't reset if hero is carrying xlock.box with him/her */
+/* level change or object deletion; context may no longer be valid */
void
-maybe_reset_pick()
+maybe_reset_pick(container)
+struct obj *container; /* passed from obfree() */
{
- if (!xlock.box || !carried(xlock.box))
+ /*
+ * If a specific container, only clear context if it is for that
+ * particular container (which is being deleted). Other stuff on
+ * the current dungeon level remains valid.
+ * However if 'container' is Null, clear context if not carrying
+ * xlock.box (which might be Null if context is for a door).
+ * Used for changing levels, where a floor container or a door is
+ * being left behind and won't be valid on the new level but a
+ * carried container will still be. There might not be any context,
+ * in which case redundantly clearing it is harmless.
+ */
+ if (container ? (container == xlock.box)
+ : (!xlock.box || !carried(xlock.box)))
reset_pick();
}
You("%s\82ð\82Â\82©\82Þ\82±\82Æ\82ª\82Å\82«\82È\82¢\81I\8eè\82ª\82È\82¢\82ñ\82¾\82à\82Ì\81I", xname(pick));
return PICKLOCK_DID_NOTHING;
} else if (u.uswallow) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
You_cant("%sunlock %s.", (picktyp == CREDIT_CARD) ? "" : "lock or ",
mon_nam(u.ustuck));
#else
if (cc.x == u.ux && cc.y == u.uy) { /* pick lock on a container */
const char *verb;
char qsfx[QBUFSZ];
+#if 0 /*JP*/
boolean it;
+#endif
int count;
if (u.dz < 0) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
There("isn't any sort of lock up %s.",
Levitation ? "here" : "there");
#else
You("\82±\82±\82©\82ç%s\82É\93Í\82©\82È\82¢\81D", the(xname(otmp)));
return PICKLOCK_LEARNED_SOMETHING;
}
+#if 0 /*JP*/
it = 0;
+#endif
if (otmp->obroken)
/*JP
verb = "fix";
/*JP
verb = "lock", it = 1;
*/
- verb = "\8c®\82ð\82©\82¯\82é", it = 1;
+ verb = "\8c®\82ð\82©\82¯\82é";
else if (picktyp != LOCK_PICK)
/*JP
verb = "unlock", it = 1;
*/
- verb = "\8c®\82ð\82Í\82¸\82·", it = 1;
+ verb = "\8c®\82ð\82Í\82¸\82·";
else
/*JP
verb = "pick";
Sprintf(qsfx, " here; %s %s?", verb, it ? "it" : "its lock");
*/
Sprintf(qsfx, "\82ª\82 \82é\81D%s\81H", verb);
-#if 0 /*JP*/
+#if 0 /*JP:T*/
(void) safe_qbuf(qbuf, "There is ", qsfx, otmp, doname,
ansimpleoname, "a box");
#else
return PICKLOCK_LEARNED_SOMETHING;
} else if (picktyp == CREDIT_CARD && !otmp->olocked) {
/* credit cards are only good for unlocking */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
You_cant("do that with %s.",
an(simple_typename(picktyp)));
#else
door = &levl[cc.x][cc.y];
mtmp = m_at(cc.x, cc.y);
- if (mtmp && canseemon(mtmp) && mtmp->m_ap_type != M_AP_FURNITURE
- && mtmp->m_ap_type != M_AP_OBJECT) {
+ if (mtmp && canseemon(mtmp) && M_AP_TYPE(mtmp) != M_AP_FURNITURE
+ && M_AP_TYPE(mtmp) != M_AP_OBJECT) {
if (picktyp == CREDIT_CARD
&& (mtmp->isshk || mtmp->data == &mons[PM_ORACLE]))
/*JP
*/
verbalize("\82¢\82Â\82à\83j\83R\83j\83R\8c»\8bà\95¥\82¢\81D");
else
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline("I don't think %s would appreciate that.",
mon_nam(mtmp));
#else
return PICKLOCK_LEARNED_SOMETHING;
}
-#if 0 /*JP*/
+#if 0 /*JP:T*/
Sprintf(qbuf, "%s it?",
(door->doormask & D_LOCKED) ? "Unlock" : "Lock");
#else
|| objects[uwep->otyp].oc_skill == P_FLAIL
|| objects[uwep->otyp].oc_skill > P_LANCE)
: uwep->oclass != ROCK_CLASS)) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
You_cant("force anything %s weapon.",
!uwep ? "when not wielding a"
: (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))
since we're about to set lknown, there's no need to
remember and then reset its current value */
otmp->lknown = 0;
-#if 0 /*JP*/
+#if 0 /*JP:T*/
There("is %s here, but its lock is already %s.",
doname(otmp), otmp->obroken ? "broken" : "unlocked");
#else
otmp->lknown = 1;
continue;
}
-#if 0 /*JP*/
+#if 0 /*JP:T*/
(void) safe_qbuf(qbuf, "There is ", " here; force its lock?",
otmp, doname, ansimpleoname, "a box");
#else
*/
pline_The("\92µ\82Ë\8b´\82Í\82à\82¤\8aJ\82¢\82Ä\82¢\82é\81D");
else if (container_at(cc.x, cc.y, TRUE))
+#if 0 /*JP:T*/
pline("%s like something lootable over there.",
Blind ? "Feels" : "Seems");
+#else
+ pline("\82±\82±\82É\82Í\89½\82©\93ü\82ê\95¨\82ª\82 \82é\82æ\82¤\82¾\81D");
+#endif
else
/*JP
You("%s no door there.", Blind ? "feel" : "see");
{
register struct monst *mtmp = m_at(x, y);
- if (mtmp && mtmp->m_ap_type != M_AP_FURNITURE) {
- if (mtmp->m_ap_type == M_AP_OBJECT)
+ if (mtmp && M_AP_TYPE(mtmp) != M_AP_FURNITURE) {
+ if (M_AP_TYPE(mtmp) == M_AP_OBJECT)
goto objhere;
if (!quietly) {
if ((mtmp->mx != x) || (mtmp->my != y)) {
/* worm tail */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline("%s%s blocks the way!",
!canspotmon(mtmp) ? Something : s_suffix(Monnam(mtmp)),
!canspotmon(mtmp) ? "" : " tail");
!canspotmon(mtmp) ? "" : "\82Ì\90K\94ö");
#endif
} else {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline("%s blocks the way!",
!canspotmon(mtmp) ? "Some creature" : Monnam(mtmp));
#else
return TRUE;
}
if (OBJ_AT(x, y)) {
- objhere:
+ objhere:
if (!quietly)
/*JP
pline("%s's in the way.", Something);
*/
pline("\92µ\82Ë\8b´\82ð\95Â\82ß\82é\96¾\94\92\82È\95û\96@\82Í\82È\82¢\81D");
else {
- nodoor:
+ nodoor:
/*JP
You("%s no door there.", Blind ? "feel" : "see");
*/
return FALSE;
}
block_point(x, y);
- door->typ = SDOOR;
+ door->typ = SDOOR, door->doormask = D_NODOOR;
if (vis)
/*JP
pline_The("doorway vanishes!");
/* & trap doors, but is it ever OK for anything else? */
if (t_at(x, y)) {
/* maketrap() clears doormask, so it should be NODOOR */
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline("%s springs up in the doorway, but %s.", dustcloud,
quickly_dissipates);
#else
/*JP
msg = "The door locks!";
*/
- msg = "\94à\82É\8c®\82ª\82©\82©\82Á\82½\81I";
+ msg = "\94à\82É\8c®\82ª\82©\82©\82Á\82½\81I";
break;
case D_ISOPEN:
/*JP
/*JP
"A cloud of dust springs up and assembles itself into a door!";
*/
- "\82Ù\82±\82è\82ª\82½\82¿\82±\82ß\81C\8fW\82Ü\82Á\82Ä\94à\82É\82È\82Á\82½\81I";
+ "\82Ù\82±\82è\82ª\82½\82¿\82±\82ß\81C\8fW\82Ü\82Á\82Ä\94à\82É\82È\82Á\82½\81I";
break;
default:
res = FALSE;
long save_Blinded;
if (otmp->oclass == POTION_CLASS) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
You("%s %s shatter!", Blind ? "hear" : "see", an(bottlename()));
#else
if (Blind)