]> granicus.if.org Git - nethack/commitdiff
costly_alteration() tweaking (trunk only)
authornethack.rankin <nethack.rankin>
Fri, 15 Apr 2005 02:41:53 +0000 (02:41 +0000)
committernethack.rankin <nethack.rankin>
Fri, 15 Apr 2005 02:41:53 +0000 (02:41 +0000)
     For cancellation I accidentally used terrain type WATER when I meant
object type POT_WATER, so being charged for cancelling holy or unholy water
wasn't working.  When I first put in COST_UNHOLY the name made some sense
based on its usage, but after later adding COST_UNBLSS it didn't any more;
change it to COST_UNCURS.

     A shopkeeper's complaint that you're uncursing or unblessing his wares
(only applies to water) now sets bknown flag since you know that the object
has become uncursed.  I hadn't realized that confused remove curse only
affects uncursed objects; this greatly simplifies extra code I added there
for costly_alteration().

[No fixes entry needed.]

include/hack.h
src/mkobj.c
src/potion.c
src/read.c
src/zap.c

index c9ae85eb81eec55ad79751fdf9e506e90e2b8508..d6600798fe770e15808ed8823687ded69643c581 100644 (file)
@@ -64,7 +64,7 @@
 #define COST_DRAIN   1 /* drain life upon an object */
 #define COST_UNCHRG  2 /* cursed charging */
 #define COST_UNBLSS  3 /* unbless (devalues holy water) */
-#define COST_UNHOLY  4 /* uncurse (devalues unholy water) */
+#define COST_UNCURS  4 /* uncurse (devalues unholy water) */
 #define COST_DECHNT  5 /* disenchant weapons or armor */
 #define COST_DEGRD   6 /* removal of rustproofing, dulling via engraving */
 #define COST_DILUTE  7 /* potion dilution */
index d84ff79daee72eaba03e933bc8be4ef2e7a97586..ec635534b434013aff6a2fdf67128dc18909c079 100644 (file)
@@ -369,6 +369,7 @@ int alter_type;
 {
     xchar ox, oy;
     char objroom;
+    boolean set_bknown;
     const char *those, *them, *what;
     struct monst *shkp = 0;
 
@@ -401,9 +402,15 @@ int alter_type;
     else
        those = "those", them = "them";
 
+    /* when shopkeeper describes the object as being uncursed or unblessed
+       hero will know that it is now uncursed; will also make the feedback
+       from `I x' after bill_dummy_object() be more specific for this item */
+    set_bknown = (alter_type == COST_UNCURS || alter_type == COST_UNBLSS);
+
     switch (obj->where) {
     case OBJ_FREE:     /* obj_no_longer_held() */
     case OBJ_INVENT:
+       if (set_bknown) obj->bknown = 1;
        what = simple_typename(obj->otyp);
        if (obj->quan != 1L) what = makeplural(what);
        verbalize("You %s %s %s, you pay for %s!",
@@ -411,6 +418,7 @@ int alter_type;
        bill_dummy_object(obj);
        break;
     case OBJ_FLOOR:
+       if (set_bknown) obj->bknown = 1;
        if (costly_spot(u.ux, u.uy) && objroom == *u.ushops) {
            verbalize("You %s %s, you pay for %s!",
                      alteration_verbs[alter_type], those, them);
index 1c531049738993d585ef7d7ef12ab89aab8ec6c6..399105794609fe08dc0c56d120134de1aab73e87 100644 (file)
@@ -1693,7 +1693,7 @@ dodip()
                                          hcolor(NH_AMBER));
                                obj->bknown = 1;
                                if (obj->otyp == POT_WATER && obj->unpaid)
-                                   costly_alteration(obj, COST_UNHOLY);
+                                   costly_alteration(obj, COST_UNCURS);
                                uncurse(obj);
        poof:
                                if(!(objects[potion->otyp].oc_name_known) &&
index 4a572e1c30da33bf48a967ac530487e8311542d9..c88d25aaafb676b46e34615e0a6ab54ab6c5b0ab 100644 (file)
@@ -964,39 +964,22 @@ struct obj *sobj;
                        if (sobj->blessed || wornmask ||
                             obj->otyp == LOADSTONE ||
                             (obj->otyp == LEASH && obj->leashmon)) {
-                           unsigned save_bknown, save_cursed, save_blessed;
-                           boolean was_cursed = !!obj->cursed,
-                                   was_blessed = !!obj->blessed,
-                                   was_normal = !(was_cursed || was_blessed);
-
-                           if(confused) blessorcurse(obj, 2);
-                           else uncurse(obj);
                            /* water price varies by curse/bless status */
-                           if (obj->unpaid && obj->otyp == POT_WATER) {
-                               if ((was_cursed && !obj->cursed) ||
-                                       (was_blessed && !obj->blessed)) {
-                                   /* make `Ix' more specific for this item */
-                                   save_bknown = obj->bknown;
-                                   obj->bknown = 1;
-                                   /* temporarily restore curse/bless to
-                                      obtain the right shop price (if potion
-                                      went from cursed directly to blessed
-                                      or vice versa its price didn't change
-                                      but hero will have to buy it anyway) */
-                                   save_cursed = obj->cursed;
-                                   obj->cursed = was_cursed ? 1 : 0;
-                                   save_blessed = obj->blessed;
-                                   obj->blessed = was_blessed ? 1 : 0;
-                                   costly_alteration(obj, was_cursed ?
-                                                   COST_UNHOLY : COST_UNBLSS);
-                                   obj->bknown = save_bknown;
-                                   obj->cursed = save_cursed;
-                                   obj->blessed = save_blessed;
-                               } else if (was_normal &&
-                                       (obj->blessed || obj->cursed)) {
-                                   alter_cost(obj, 0L);
-                               }
-                           } /* unpaid water */
+                           boolean shop_h2o = (obj->unpaid &&
+                                               obj->otyp == POT_WATER);
+
+                           if (confused) {
+                               blessorcurse(obj, 2);
+                               /* blessorcurse() only affects uncursed items
+                                  so no need to worry about price of water
+                                  going down (hence no costly_alteration) */
+                               if (shop_h2o && (obj->cursed || obj->blessed))
+                                   alter_cost(obj, 0L);  /* price goes up */
+                           } else if (obj->cursed) {
+                               if (shop_h2o)
+                                   costly_alteration(obj, COST_UNCURS);
+                               uncurse(obj);
+                           }
                        }
                    }
                }
index 61b9e49b6a713364b91839ec257d1045b9a5626b..93bd5f888b072c15287c930e3fa878ebee0e08f5 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -855,7 +855,7 @@ register struct obj *obj;
                (obj->spe && (obj->oclass == ARMOR_CLASS ||
                        obj->oclass == WEAPON_CLASS || is_weptool(obj))) ||
                otyp == POT_ACID || otyp == POT_SICKNESS ||
-               (otyp == WATER && (obj->blessed || obj->cursed))) {
+               (otyp == POT_WATER && (obj->blessed || obj->cursed))) {
            if (obj->spe != ((obj->oclass == WAND_CLASS) ? -1 : 0) &&
                    otyp != WAN_CANCELLATION && /* can't cancel cancellation */
                    otyp != MAGIC_LAMP && /* cancelling doesn't remove djini */
@@ -876,8 +876,8 @@ register struct obj *obj;
                }
                break;
              case POTION_CLASS:
-               costly_alteration(obj, (otyp == WATER && obj->cursed) ?
-                                       COST_UNHOLY : COST_CANCEL);
+               costly_alteration(obj, (otyp != POT_WATER) ? COST_CANCEL :
+                                     obj->cursed ? COST_UNCURS : COST_UNBLSS);
                if (otyp == POT_SICKNESS || otyp == POT_SEE_INVISIBLE) {
                    /* sickness is "biologically contaminated" fruit juice;
                       cancel it and it just becomes fruit juice...