wishing tweak: detect X vs X detection (trunk only)
Allow wishing for a "potion of detect objects" to generate a
"potion of object detection", or for a "spellbook of monster detection"
to generate a "spellbook of detect monsters".
To get a spellbook you'll need to explicitly specify "spellbook"
even when using a name that's unique to books: asking for "detect food"
will yield a "scroll of food detection" rather than "spellbook of detect
food" because it finds potions and scrolls first. [That's nothing new
for the case where a spellbook and potion or scroll have the same name,
only new behavior for "detect X" vs "X detection" matches.]
Wishing for "detect food" used to yield a random food item rather
than a "spellbook of detect food". That's fixed now, although as
mentioned above it will actually produce a "scroll of food detection".
This commit is contained in:
@@ -519,6 +519,7 @@ adopt/adapt/improve the Paranoid_Quit patch; default is paranoid_confirm:pray
|
||||
paranoid_confirm:attack yes vs y to attack a peaceful monster
|
||||
paranoid_confirm:pray y to confirm #pray; supersedes prayconfirm
|
||||
paranoid_confirm:Remove always pick from inventory for 'R' and 'T'
|
||||
flexibility for specifying "detect <foo>" vs "<foo> detection" when wishing
|
||||
|
||||
|
||||
Platform- and/or Interface-Specific New Features
|
||||
|
||||
29
src/objnam.c
29
src/objnam.c
@@ -2082,12 +2082,15 @@ const char *u_str; /* from user, so might be variant spelling */
|
||||
const char *o_str; /* from objects[], so is in canonical form */
|
||||
boolean retry_inverted; /* optional extra "of" handling */
|
||||
{
|
||||
static NEARDATA const char
|
||||
detect_SP[] = "detect ", SP_detection[] = " detection";
|
||||
char *p, buf[BUFSZ];
|
||||
|
||||
/* ignore spaces & hyphens and upper/lower case when comparing */
|
||||
if (fuzzymatch(u_str, o_str, " -", TRUE)) return TRUE;
|
||||
|
||||
if (retry_inverted) {
|
||||
const char *u_of, *o_of;
|
||||
char *p, buf[BUFSZ];
|
||||
|
||||
/* when just one of the strings is in the form "foo of bar",
|
||||
convert it into "bar foo" and perform another comparison */
|
||||
@@ -2119,6 +2122,29 @@ boolean retry_inverted; /* optional extra "of" handling */
|
||||
return fuzzymatch(u_str + 7, o_str + 6, " -", TRUE);
|
||||
else if (!strncmpi(u_str, "elfin ", 6))
|
||||
return fuzzymatch(u_str + 6, o_str + 6, " -", TRUE);
|
||||
} else if (!strncmp(o_str, detect_SP, sizeof detect_SP - 1)) {
|
||||
/* check for "detect <foo>" vs "<foo> detection" */
|
||||
if ((p = strstri(u_str, SP_detection)) != 0 &&
|
||||
!*(p + sizeof SP_detection - 1)) {
|
||||
/* convert "<foo> detection" into "detect <foo>" */
|
||||
*p = '\0';
|
||||
Strcat(strcpy(buf, detect_SP), u_str);
|
||||
/* "detect monster" -> "detect monsters" */
|
||||
if (!strcmpi(u_str, "monster")) Strcat(buf, "s");
|
||||
*p = ' ';
|
||||
return fuzzymatch(buf, o_str, " -", TRUE);
|
||||
}
|
||||
} else if (strstri(o_str, SP_detection)) {
|
||||
/* and the inverse, "<foo> detection" vs "detect <foo>" */
|
||||
if (!strncmpi(u_str, detect_SP, sizeof detect_SP - 1)) {
|
||||
/* convert "detect <foo>s" into "<foo> detection" */
|
||||
p = makesingular(u_str + sizeof detect_SP - 1);
|
||||
Strcat(strcpy(buf, p), SP_detection);
|
||||
/* caller may be looping through objects[], so avoid
|
||||
churning through all the obufs */
|
||||
releaseobuf(p);
|
||||
return fuzzymatch(buf, o_str, " -", TRUE);
|
||||
}
|
||||
} else if (!strcmp(o_str, "aluminum")) {
|
||||
/* this special case doesn't really fit anywhere else... */
|
||||
/* (note that " wand" will have been stripped off by now) */
|
||||
@@ -2591,6 +2617,7 @@ struct obj *no_wish;
|
||||
/* false hits on, e.g., rings for "ring mail". */
|
||||
if(strncmpi(bp, "enchant ", 8) &&
|
||||
strncmpi(bp, "destroy ", 8) &&
|
||||
strncmpi(bp, "detect food", 11) &&
|
||||
strncmpi(bp, "food detection", 14) &&
|
||||
strncmpi(bp, "ring mail", 9) &&
|
||||
strncmpi(bp, "studded leather armor", 21) &&
|
||||
|
||||
Reference in New Issue
Block a user