]> granicus.if.org Git - nethack/commitdiff
candelabrum in shop (trunk only)
authornethack.rankin <nethack.rankin>
Fri, 12 May 2006 00:30:32 +0000 (00:30 +0000)
committernethack.rankin <nethack.rankin>
Fri, 12 May 2006 00:30:32 +0000 (00:30 +0000)
     The code to have Izchak recognize the Candelabrum of Invocation
instead of just being uninterested in an item not stocked in his shop was
being skipped when the character is hallucinating.  Make it work for any
lighting store (slash'em sometimes has another candle shop, run by a
randomly named shopkeeper), and make it recogize Izchak even when
hallucinating.  Also, have him give a message about the need for 7 candles
if the candelabrum doesn't already have them attached.

include/extern.h
src/shk.c
src/shknam.c

index ea7c19a6a46990d59a800ed5609d3f1bdf09d81b..cc26e7d0b61524556925c27cc27e68a8b0a6ce2c 100644 (file)
@@ -1986,6 +1986,7 @@ E boolean FDECL(saleable, (struct monst *,struct obj *));
 E int FDECL(get_shop_item, (int));
 E const char *FDECL(shkname, (struct monst *));
 E boolean FDECL(shkname_is_pname, (struct monst *));
+E boolean FDECL(is_izchak, (struct monst *,BOOLEAN_P));
 
 /* ### sit.c ### */
 
index 2354299a785a1c43bf072a450c93f5d70f9fdcb4..cb331da37d1fe51df738107a52cc6a2ec6c344f0 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)shk.c      3.5     2006/04/14      */
+/*     SCCS Id: @(#)shk.c      3.5     2006/05/10      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1979,16 +1979,24 @@ struct monst *shkp;
 boolean quietly;
 {
        /* for unique situations */
-       if ((strcmp(shkname(shkp), "Izchak") == 0) &&
-            obj->otyp == CANDELABRUM_OF_INVOCATION) {
-               if (!quietly) {
-                   if (!u.uevent.invoked)
+       if (ESHK(shkp)->shoptype == CANDLESHOP &&
+               obj->otyp == CANDELABRUM_OF_INVOCATION) {
+           if (!quietly) {
+               if (is_izchak(shkp, TRUE) && !u.uevent.invoked) {
+                   verbalize("No thanks, I'd hang onto that if I were you.");
+                   if (obj->spe < 7)
                        verbalize(
-                           "No thanks, I'd hang onto that if I were you.");
-                   else
-                       verbalize("Take that out of here!");
+                           "You'll need %d%s candle%s to go along with it.",
+                                 (7 - obj->spe),
+                                 (obj->spe > 0) ? " more" : "",
+                                 plur(7 - obj->spe));
+                   /* [what if hero is already carrying enough candles?
+                      should Izchak explain how to attach them instead] */
+               } else {
+                   verbalize("I won't stock that.  Take it out of here!");
                }
-               return TRUE;
+           }
+           return TRUE;
        }
        return FALSE;
 }
@@ -3802,7 +3810,7 @@ struct monst *shkp;
        else if (shkmoney > 4000)
 #endif
                pline("%s says that business is good.", shkname(shkp));
-       else if (strcmp(shkname(shkp), "Izchak") == 0)
+       else if (is_izchak(shkp, FALSE))
                pline(Izchak_speaks[rn2(SIZE(Izchak_speaks))],shkname(shkp));
        else
                pline("%s talks about the problem of shoplifters.",shkname(shkp));
index e8f3f7593cea3ffcc91185718afdb0249c3991b6..87e9b77ffb1b799e4e72d03897a7c6f5ec1bbd78 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)shknam.c   3.5     2006/01/03      */
+/*     SCCS Id: @(#)shknam.c   3.5     2006/05/10      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -704,4 +704,21 @@ struct monst *mtmp;
     return (*shknm == '-' || *shknm == '+' || *shknm == '=');
 }
 
+boolean
+is_izchak(shkp, override_hallucination)
+struct monst *shkp;
+boolean override_hallucination;
+{
+    const char *shknm;
+
+    if (Hallucination && !override_hallucination) return FALSE;
+    if (!shkp->isshk) return FALSE;
+    /* outside of town, Izchak becomes just an ordinary shopkeeper */
+    if (!in_town(shkp->mx, shkp->my)) return FALSE;
+    shknm = ESHK(shkp)->shknam;
+    /* skip "+" prefix */
+    if (!letter(*shknm)) ++shknm;
+    return !strcmp(shknm, "Izchak");
+}
+
 /*shknam.c*/