]> granicus.if.org Git - nethack/commitdiff
Fire/Frost Brand vs rusting
authornethack.rankin <nethack.rankin>
Tue, 19 Apr 2005 04:15:51 +0000 (04:15 +0000)
committernethack.rankin <nethack.rankin>
Tue, 19 Apr 2005 04:15:51 +0000 (04:15 +0000)
     Implement the suggestion that Fire Brand avoids damage from rust traps
by boiling away the water.  Rather than making this be trap-specific, it
applies to all types of erosion which go through erode_obj().  That includes
hitting rust monsters but not dipping into potions or fountains, nor falling
into moats.  And it doesn't provide 100% protection, just a high chance of
avoiding rust damage.  Also, Frost Brand gets similar protection by freezing.

     The message handling needed some rewriting for the branch version.
That compiles ok but hasn't been tested.  It would have been simpler just to
move Yobjnam2() over even if nothing else was changed to use it yet....

doc/fixes34.4
include/extern.h
src/artifact.c
src/mhitm.c
src/mhitu.c
src/wield.c

index 442a7f0bf874f5f984d2e950661367a478db453c..853f902110583cb9d6e949242abbd9e597aca2b4 100644 (file)
@@ -113,7 +113,7 @@ armor which auto-curses when worn by hero should do same if worn by monster
 limit how high accuracy, damage, or protection can become via eating rings
 when blinded hero detects a trap by touch, make sure it shows up on the map
 confused remove curse will cause loss of knowledge of items' curse/bless state
-With astral vision, the ";" command should only display "normal vision"
+with astral vision, the ";" command should only display "normal vision"
        for things that could be seen without astral vision
 
 
@@ -135,6 +135,7 @@ when adding an item to inventory, try to stack it with the quiver slot
 #adjust can be used to split an inventory stack
 cockatrice meat has a distinct flavor to some
 wish request for "<something> armor" will match item named "<something> mail"
+Fire Brand and Frost Brand have a chance to avoid taking rust damage
 
 
 Platform- and/or Interface-Specific New Features
index 0b6c47a1a836c3157fa9a3fcbd69ffa83515a002..8156471322c2b7e36e248e9d93e6949e280c9e27 100644 (file)
@@ -60,6 +60,7 @@ E const char *FDECL(artifact_name, (const char *,short *));
 E boolean FDECL(exist_artifact, (int,const char *));
 E void FDECL(artifact_exists, (struct obj *,const char *,BOOLEAN_P));
 E int NDECL(nartifact_exist);
+E boolean FDECL(arti_immune, (struct obj *,int));
 E boolean FDECL(spec_ability, (struct obj *,unsigned long));
 E boolean FDECL(confers_luck, (struct obj *));
 E boolean FDECL(arti_reflects, (struct obj *));
index 5894603b950ff8e655bcc1a6e023e3f3ca83d964..2d9cbb71951ec469e0bbec380202beb16346d439 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)artifact.c 3.5     2003/08/11      */
+/*     SCCS Id: @(#)artifact.c 3.5     2005/04/15      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -545,6 +545,22 @@ touch_artifact(obj,mon)
     return 1;
 }
 
+/* decide whether an artifact itself is vulnerable to a particular type
+   of erosion damage, independent of the properties of its bearer */
+boolean
+arti_immune(obj, dtyp)
+struct obj *obj;
+int dtyp;
+{
+    register const struct artifact *weap = get_artifact(obj);
+
+    if (!weap) return FALSE;
+    if (dtyp == AD_PHYS) return FALSE; /* nothing is immune to phys dmg */
+    return (weap->attk.adtyp == dtyp ||
+           weap->defn.adtyp == dtyp ||
+           weap->cary.adtyp == dtyp);
+}
+
 /* decide whether an artifact's special attacks apply against mtmp */
 STATIC_OVL int
 spec_applies(weap, mtmp)
@@ -1551,5 +1567,5 @@ int orc_count;
               pline("%s stops glowing.", bare_artifactname(uwep));
       }
 }
-/*artifact.c*/
 
+/*artifact.c*/
index edd8208ff233bc5a93e791c9bd5ba802fc2fabe6..db8fae376b1c94afbcc1353c8f26463061c55163 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mhitm.c    3.5     2004/10/20      */
+/*     SCCS Id: @(#)mhitm.c    3.5     2005/04/15      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1308,33 +1308,13 @@ register struct obj *obj;
        boolean is_acid;
 
        if (!magr || !mdef || !obj) return; /* just in case */
-
        if (dmgtype(mdef->data, AD_CORR))
            is_acid = TRUE;
        else if (dmgtype(mdef->data, AD_RUST))
            is_acid = FALSE;
        else
            return;
-
-       if (!mdef->mcan &&
-           (is_acid ? is_corrodeable(obj) : is_rustprone(obj)) &&
-           (is_acid ? obj->oeroded2 : obj->oeroded) < MAX_ERODE) {
-               if (obj->greased || obj->oerodeproof || (obj->blessed && rn2(3))) {
-                   if (cansee(mdef->mx, mdef->my) && flags.verbose)
-                       pline("%s weapon is not affected.",
-                                        s_suffix(Monnam(magr)));
-                   if (obj->greased && !rn2(2)) obj->greased = 0;
-               } else {
-                   if (cansee(mdef->mx, mdef->my)) {
-                       pline("%s%s!",
-                           Yobjnam2(obj, (is_acid ? "corrode" : "rust")),
-                           (is_acid ? obj->oeroded2 : obj->oeroded)
-                               ? " further" : "");
-                   }
-                   if (is_acid) obj->oeroded2++;
-                   else obj->oeroded++;
-               }
-       }
+       (void) erode_obj(obj, is_acid, FALSE, FALSE);
 }
 
 STATIC_OVL void
index 67c892057c8508003072871bfc2196c947b021df..14476dd9a956e7d58065893450a07a0a4cd07ccd 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mhitu.c    3.5     2005/02/09      */
+/*     SCCS Id: @(#)mhitu.c    3.5     2005/04/15      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2077,7 +2077,6 @@ urustm(mon, obj)
 register struct monst *mon;
 register struct obj *obj;
 {
-       boolean vis;
        boolean is_acid;
 
        if (!mon || !obj) return; /* just in case */
@@ -2087,26 +2086,7 @@ register struct obj *obj;
            is_acid = FALSE;
        else
            return;
-
-       vis = cansee(mon->mx, mon->my);
-
-       if ((is_acid ? is_corrodeable(obj) : is_rustprone(obj)) &&
-           (is_acid ? obj->oeroded2 : obj->oeroded) < MAX_ERODE) {
-               if (obj->greased || obj->oerodeproof || (obj->blessed && rn2(3))) {
-                   if (vis)
-                       pline("Somehow, %s weapon is not affected.",
-                                               s_suffix(mon_nam(mon)));
-                   if (obj->greased && !rn2(2)) obj->greased = 0;
-               } else {
-                   if (vis)
-                       pline("%s%s!",
-                               Yobjnam2(obj, (is_acid ? "corrode" : "rust")),
-                               (is_acid ? obj->oeroded2 : obj->oeroded)
-                                   ? " further" : "");
-                   if (is_acid) obj->oeroded2++;
-                   else obj->oeroded++;
-               }
-       }
+       (void) erode_obj(obj, is_acid, FALSE, FALSE);
 }
 
 int
index 66a1b0d69ca8b7996fa6ea3a5f0c9ae51f308a1a..05d695083c88533a6baef9f994d44f6ae09cb52c 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)wield.c    3.5     2005/03/28      */
+/*     SCCS Id: @(#)wield.c    3.5     2005/04/15      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -608,8 +608,7 @@ boolean for_dip;
 {
        int erosion;
        struct monst *victim;
-       boolean vismon;
-       boolean visobj;
+       boolean vismon, visobj, chill;
        boolean ret = FALSE;
 
        if (!target)
@@ -639,6 +638,26 @@ boolean for_dip;
                target->spe = 0;
                ret = TRUE;
            }
+       } else if (target->oartifact &&
+               /* (no artifacts currently meet either of these criteria) */
+               arti_immune(target, acid_dmg ? AD_ACID : AD_RUST)) {
+           if (flags.verbose) {
+               if (victim == &youmonst)
+                   pline("%s.", Yobjnam2(target, "sizzle"));
+           }
+           /* no damage to object */
+       } else if (target->oartifact && !acid_dmg &&
+               /* cold and fire provide partial protection against rust */
+               ((chill = arti_immune(target, AD_COLD)) != 0 ||
+                arti_immune(target, AD_FIRE)) &&
+               /* once rusted, the chance for further rusting goes up */
+               rn2(2 * (MAX_ERODE + 1 - erosion))) {
+           if (flags.verbose && target->oclass == WEAPON_CLASS) {
+               if (victim == &youmonst || vismon || visobj)
+                   pline("%s some water.",
+                         Yobjnam2(target, chill ? "freeze" : "boil"));
+           }
+           /* no damage to object */
        } else if (target->oerodeproof ||
                (acid_dmg ? !is_corrodeable(target) : !is_rustprone(target))) {
            if (flags.verbose || !(target->oerodeproof && target->rknown)) {