\#force feedback and some reformatting

Failed #force due to wielding wrong implement didn't phrase things
well if current weapon was a stack.

Plus some reformatting split out from a forthcoming #engrave patch.
This commit is contained in:
PatR
2024-04-20 16:56:36 -07:00
parent a429eed984
commit 2afca0fc56
2 changed files with 36 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 engrave.c $NHDT-Date: 1664616835 2022/10/01 09:33:55 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.131 $ */ /* NetHack 3.7 engrave.c $NHDT-Date: 1713657038 2024/04/20 23:50:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.156 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -800,7 +800,8 @@ doengrave_sfx_item(struct _doengrave_ctx *de)
de->frosted ? "frosty" : "dusty"); de->frosted ? "frosty" : "dusty");
de->dengr = TRUE; de->dengr = TRUE;
} else { } else {
pline("%s can't wipe out this engraving.", Yname2(de->otmp)); pline("%s can't wipe out this engraving.",
Yname2(de->otmp));
} }
} else { } else {
pline("%s %s.", Yobjnam2(de->otmp, "get"), pline("%s %s.", Yobjnam2(de->otmp, "get"),
@@ -833,7 +834,8 @@ doengrave_ctx_verb(struct _doengrave_ctx *de)
{ {
switch (de->type) { switch (de->type) {
default: default:
de->everb = de->adding ? "add to the weird writing on" : "write strangely on"; de->everb = de->adding ? "add to the weird writing on"
: "write strangely on";
break; break;
case DUST: case DUST:
de->everb = de->adding ? "add to the writing in" : "write in"; de->everb = de->adding ? "add to the writing in" : "write in";
@@ -898,7 +900,7 @@ doengrave(void)
if (!u_can_engrave()) if (!u_can_engrave())
return ECMD_FAIL; return ECMD_FAIL;
de = (struct _doengrave_ctx *) alloc(sizeof(struct _doengrave_ctx)); de = (struct _doengrave_ctx *) alloc(sizeof (struct _doengrave_ctx));
doengrave_ctx_init(de); doengrave_ctx_init(de);
gm.multi = 0; /* moves consumed */ gm.multi = 0; /* moves consumed */
@@ -1022,7 +1024,8 @@ doengrave(void)
} }
/* Early exit for some implements. */ /* Early exit for some implements. */
if (!de->ptext) { if (!de->ptext) {
if (de->otmp && de->otmp->oclass == WAND_CLASS && !can_reach_floor(TRUE)) if (de->otmp && de->otmp->oclass == WAND_CLASS
&& !can_reach_floor(TRUE))
cant_reach_floor(u.ux, u.uy, FALSE, TRUE); cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
de->ret = ECMD_TIME; de->ret = ECMD_TIME;
goto doengr_exit; goto doengr_exit;
@@ -1069,7 +1072,8 @@ doengrave(void)
/* defer deletion until after we *know* we're engraving */ /* defer deletion until after we *know* we're engraving */
de->eow = TRUE; de->eow = TRUE;
} }
} else if (de->type == DUST || de->type == MARK || de->type == ENGR_BLOOD) { } else if (de->type == DUST || de->type == MARK
|| de->type == ENGR_BLOOD) {
You("cannot wipe out the message that is %s the %s here.", You("cannot wipe out the message that is %s the %s here.",
(de->oep->engr_type == BURN) (de->oep->engr_type == BURN)
? (de->frosted ? "melted into" : "burned into") ? (de->frosted ? "melted into" : "burned into")
@@ -1082,7 +1086,8 @@ doengrave(void)
You("will overwrite the current message."); You("will overwrite the current message.");
de->eow = TRUE; de->eow = TRUE;
} }
} else if (de->oep && Strlen(de->oep->engr_txt[actual_text]) >= BUFSZ - 1) { } else if (de->oep
&& Strlen(de->oep->engr_txt[actual_text]) >= BUFSZ - 1) {
There("is no room to add anything else here."); There("is no room to add anything else here.");
de->ret = ECMD_TIME; de->ret = ECMD_TIME;
goto doengr_exit; goto doengr_exit;
@@ -1097,10 +1102,12 @@ doengrave(void)
if (de->otmp != &hands_obj) if (de->otmp != &hands_obj)
You("%s the %s with %s.", de->everb, de->eloc, doname(de->otmp)); You("%s the %s with %s.", de->everb, de->eloc, doname(de->otmp));
else else
You("%s the %s with your %s.", de->everb, de->eloc, body_part(FINGERTIP)); You("%s the %s with your %s.",
de->everb, de->eloc, body_part(FINGERTIP));
/* Prompt for engraving! */ /* Prompt for engraving! */
Sprintf(de->qbuf, "What do you want to %s the %s here?", de->everb, de->eloc); Sprintf(de->qbuf, "What do you want to %s the %s here?",
de->everb, de->eloc);
getlin(de->qbuf, de->ebuf); getlin(de->qbuf, de->ebuf);
/* convert tabs to spaces and condense consecutive spaces to one */ /* convert tabs to spaces and condense consecutive spaces to one */
mungspaces(de->ebuf); mungspaces(de->ebuf);
@@ -1442,7 +1449,8 @@ save_engravings(NHFILE *nhfp)
} }
if (perform_bwrite(nhfp)) { if (perform_bwrite(nhfp)) {
if (nhfp->structlevel) if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &no_more_engr, sizeof no_more_engr); bwrite(nhfp->fd, (genericptr_t) &no_more_engr,
sizeof no_more_engr);
} }
if (release_data(nhfp)) if (release_data(nhfp))
head_engr = 0; head_engr = 0;
@@ -1457,19 +1465,21 @@ rest_engravings(NHFILE *nhfp)
head_engr = 0; head_engr = 0;
while (1) { while (1) {
if (nhfp->structlevel) if (nhfp->structlevel)
mread(nhfp->fd, (genericptr_t) &lth, sizeof(unsigned)); mread(nhfp->fd, (genericptr_t) &lth, sizeof (unsigned));
if (lth == 0) if (lth == 0)
return; return;
ep = newengr(lth); ep = newengr(lth);
if (nhfp->structlevel) { if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t) ep, sizeof(struct engr) + lth); mread(nhfp->fd, (genericptr_t) ep, sizeof (struct engr) + lth);
} }
ep->nxt_engr = head_engr; ep->nxt_engr = head_engr;
head_engr = ep; head_engr = ep;
ep->engr_txt[actual_text] = (char *) (ep + 1); /* Andreas Bormann */ ep->engr_txt[actual_text] = (char *) (ep + 1); /* Andreas Bormann */
ep->engr_txt[remembered_text] = ep->engr_txt[actual_text] + ep->engr_szeach; ep->engr_txt[remembered_text] = ep->engr_txt[actual_text]
ep->engr_txt[pristine_text] = ep->engr_txt[remembered_text] + ep->engr_szeach; + ep->engr_szeach;
ep->engr_txt[pristine_text] = ep->engr_txt[remembered_text]
+ ep->engr_szeach;
while (ep->engr_txt[actual_text][0] == ' ') while (ep->engr_txt[actual_text][0] == ' ')
ep->engr_txt[actual_text]++; ep->engr_txt[actual_text]++;
while (ep->engr_txt[remembered_text][0] == ' ') while (ep->engr_txt[remembered_text][0] == ' ')

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 lock.c $NHDT-Date: 1703070191 2023/12/20 11:03:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.131 $ */ /* NetHack 3.7 lock.c $NHDT-Date: 1713657045 2024/04/20 23:50:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.136 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -241,7 +241,7 @@ forcelock(void)
You("succeed in forcing the lock."); You("succeed in forcing the lock.");
exercise(gx.xlock.picktyp ? A_DEX : A_STR, TRUE); exercise(gx.xlock.picktyp ? A_DEX : A_STR, TRUE);
/* breakchestlock() might destroy gx.xlock.box; if so, gx.xlock context will /* breakchestlock() might destroy xlock.box; if so, xlock context will
be cleared (delobj -> obfree -> maybe_reset_pick); but it might not, be cleared (delobj -> obfree -> maybe_reset_pick); but it might not,
so explicitly clear that manually */ so explicitly clear that manually */
breakchestlock(gx.xlock.box, (boolean) (!gx.xlock.picktyp && !rn2(3))); breakchestlock(gx.xlock.box, (boolean) (!gx.xlock.picktyp && !rn2(3)));
@@ -441,7 +441,8 @@ pick_lock(
count = 0; count = 0;
c = 'n'; /* in case there are no boxes here */ c = 'n'; /* in case there are no boxes here */
for (otmp = gl.level.objects[cc.x][cc.y]; otmp; otmp = otmp->nexthere) { for (otmp = gl.level.objects[cc.x][cc.y]; otmp;
otmp = otmp->nexthere) {
/* autounlock on boxes: only the one that was just discovered to /* autounlock on boxes: only the one that was just discovered to
be locked; don't include any other boxes which might be here */ be locked; don't include any other boxes which might be here */
if (autounlock && otmp != container) if (autounlock && otmp != container)
@@ -681,11 +682,14 @@ doforce(void)
return ECMD_OK; return ECMD_OK;
} }
if (!u_have_forceable_weapon()) { if (!u_have_forceable_weapon()) {
You_cant("force anything %s weapon.", boolean use_plural = uwep && uwep->quan > 1;
You_cant("force anything %s weapon%s.",
!uwep ? "when not wielding a" !uwep ? "when not wielding a"
: (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep)) : (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))
? "without a proper" ? (use_plural ? "without proper" : "without a proper")
: "with that"); : (use_plural ? "with that" : "with those"),
use_plural ? "s" : "");
return ECMD_OK; return ECMD_OK;
} }
if (!can_reach_floor(TRUE)) { if (!can_reach_floor(TRUE)) {