wishing tweaks

When a wish request for "<foo> armor" fails to match anything, check
whether it matches "<foo> mail" before resorting to selecting a random piece
of armor.  Most of the suits are named "mail", and while I don't think many
people will ask for "ring armor", I do think that "crystal plate armor" and
"gray dragon scale armor" are sometimes tried.

     This also greatly simplifies the handling for spelling variant "armour"
by rewriting it to "armor".  Unfortunately "grey" vs "gray" can't be handled
the same way since both spellings are used by the program.
This commit is contained in:
nethack.rankin
2005-02-01 05:35:34 +00:00
parent 191db348ec
commit 2886b276ea
2 changed files with 24 additions and 13 deletions
+1
View File
@@ -102,6 +102,7 @@ when adding an item to inventory, try to stack it with the quiver slot
before trying against other carried objects before trying against other carried objects
#adjust can be used to split an inventory stack #adjust can be used to split an inventory stack
cockatrice meat has a distinct flavor to some cockatrice meat has a distinct flavor to some
wish request for "<something> armor" will match item named "<something> mail"
Platform- and/or Interface-Specific New Features Platform- and/or Interface-Specific New Features
+23 -13
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)objnam.c 3.5 2004/11/11 */ /* SCCS Id: @(#)objnam.c 3.5 2005/01/31 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1299,12 +1299,12 @@ static const char *wrp[] = {
"wand", "ring", "potion", "scroll", "gem", "amulet", "wand", "ring", "potion", "scroll", "gem", "amulet",
"spellbook", "spell book", "spellbook", "spell book",
/* for non-specific wishes */ /* for non-specific wishes */
"weapon", "armor", "armour", "tool", "food", "comestible", "weapon", "armor", "tool", "food", "comestible",
}; };
static const char wrpsym[] = { static const char wrpsym[] = {
WAND_CLASS, RING_CLASS, POTION_CLASS, SCROLL_CLASS, GEM_CLASS, WAND_CLASS, RING_CLASS, POTION_CLASS, SCROLL_CLASS, GEM_CLASS,
AMULET_CLASS, SPBOOK_CLASS, SPBOOK_CLASS, AMULET_CLASS, SPBOOK_CLASS, SPBOOK_CLASS,
WEAPON_CLASS, ARMOR_CLASS, ARMOR_CLASS, TOOL_CLASS, FOOD_CLASS, WEAPON_CLASS, ARMOR_CLASS, TOOL_CLASS, FOOD_CLASS,
FOOD_CLASS FOOD_CLASS
}; };
@@ -1765,12 +1765,6 @@ struct alt_spellings {
{ "smooth shield", SHIELD_OF_REFLECTION }, { "smooth shield", SHIELD_OF_REFLECTION },
{ "grey dragon scale mail", GRAY_DRAGON_SCALE_MAIL }, { "grey dragon scale mail", GRAY_DRAGON_SCALE_MAIL },
{ "grey dragon scales", GRAY_DRAGON_SCALES }, { "grey dragon scales", GRAY_DRAGON_SCALES },
{ "enchant armour", SCR_ENCHANT_ARMOR },
{ "destroy armour", SCR_DESTROY_ARMOR },
{ "scroll of enchant armour", SCR_ENCHANT_ARMOR },
{ "scroll of destroy armour", SCR_DESTROY_ARMOR },
{ "leather armour", LEATHER_ARMOR },
{ "studded leather armour", STUDDED_LEATHER_ARMOR },
{ "iron ball", HEAVY_IRON_BALL }, { "iron ball", HEAVY_IRON_BALL },
{ "lantern", BRASS_LANTERN }, { "lantern", BRASS_LANTERN },
{ "mattock", DWARVISH_MATTOCK }, { "mattock", DWARVISH_MATTOCK },
@@ -2112,6 +2106,12 @@ struct obj *no_wish;
/* can't use spellings list for this one due to shuffling */ /* can't use spellings list for this one due to shuffling */
if (!strncmpi(bp, "grey spell", 10)) if (!strncmpi(bp, "grey spell", 10))
*(bp + 2) = 'a'; *(bp + 2) = 'a';
if ((p = strstri(bp, "armour")) != 0) {
/* skip past "armo", then copy remainer beyond "u" */
p += 4;
while ((*p = *(p + 1)) != '\0') ++p; /* self terminating */
}
} }
/* dragon scales - assumes order of dragons */ /* dragon scales - assumes order of dragons */
@@ -2159,9 +2159,9 @@ struct obj *no_wish;
context.botl=1; context.botl=1;
return (&zeroobj); return (&zeroobj);
#else #else
otmp = mksobj(GOLD_PIECE, FALSE, FALSE); otmp = mksobj(GOLD_PIECE, FALSE, FALSE);
otmp->quan = cnt; otmp->quan = cnt;
otmp->owt = weight(otmp); otmp->owt = weight(otmp);
context.botl=1; context.botl=1;
return (otmp); return (otmp);
#endif #endif
@@ -2184,8 +2184,8 @@ struct obj *no_wish;
strncmpi(bp, "destroy ", 8) && strncmpi(bp, "destroy ", 8) &&
strncmpi(bp, "food detection", 14) && strncmpi(bp, "food detection", 14) &&
strncmpi(bp, "ring mail", 9) && strncmpi(bp, "ring mail", 9) &&
strncmpi(bp, "studded leather arm", 19) && strncmpi(bp, "studded leather armor", 21) &&
strncmpi(bp, "leather arm", 11) && strncmpi(bp, "leather armor", 13) &&
strncmpi(bp, "tooled horn", 11) && strncmpi(bp, "tooled horn", 11) &&
strncmpi(bp, "food ration", 11) && strncmpi(bp, "food ration", 11) &&
strncmpi(bp, "meat ring", 9) strncmpi(bp, "meat ring", 9)
@@ -2212,6 +2212,7 @@ struct obj *no_wish;
} }
} }
retry:
/* "grey stone" check must be before general "stone" */ /* "grey stone" check must be before general "stone" */
for (i = 0; i < SIZE(o_ranges); i++) for (i = 0; i < SIZE(o_ranges); i++)
if(!strcmpi(bp, o_ranges[i].name)) { if(!strcmpi(bp, o_ranges[i].name)) {
@@ -2293,6 +2294,15 @@ srch:
j++; j++;
} }
} }
/* if we've stripped off "armor" and failed to match anything
in objects[], append "mail" and try again to catch misnamed
requests like "plate armor" and "yellow dragon scale armor" */
if (oclass == ARMOR_CLASS && !strstri(bp, "mail")) {
/* modifying bp's string is ok; we're about to resort
to random armor if this also fails to match anything */
Strcat(bp, " mail");
goto retry;
}
if (!strcmpi(bp, "spinach")) { if (!strcmpi(bp, "spinach")) {
contents = SPINACH; contents = SPINACH;
typ = TIN; typ = TIN;