]> granicus.if.org Git - nethack/commitdiff
fix github issue #170 - stacks of non-missiles
authorPatR <rankin@nethack.org>
Fri, 28 Dec 2018 02:36:26 +0000 (18:36 -0800)
committerPatR <rankin@nethack.org>
Fri, 28 Dec 2018 02:36:26 +0000 (18:36 -0800)
Fixes #170

Monsters never throw athames or scalpels but some fake player monsters
on the Astral Plane are given those.  Since they're stackable the
quantity usually gets boosted but there's no point in having more than
one if they won't be thrown.

This could have been fixed by letting monsters throw those two items,
but I prevented the quantity from being boosted instead.

doc/fixes36.2
include/extern.h
src/mplayer.c
src/weapon.c

index d4fb99cec508827e25b69795d8ed935cf228f244..fed918d0fd953cad252ab6bcefd35c59c9424383 100644 (file)
@@ -317,6 +317,8 @@ when splitting a stack where internal ID is used to make adjustment to
 when merging a stack where internal ID is used to adjust shop prices, always
        keep the ID which induces the higher price (only matters when buying
        from shop, not when selling; doesn't affect items already on bill)
+since knives became stackable in 3.6.0, fake player monsters could be given
+       multi-quantity stacks for weapons (scalpel, athame) they never throw
 
 
 Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
index 28f671b1d30f1dc06fbd7a8e94c39378b60ed9d9..99107019455b57bfc6f4f40056b81d5c15b46239 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1545948751 2018/12/27 22:12:31 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.677 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1545964581 2018/12/28 02:36:21 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.678 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2730,6 +2730,7 @@ E const char *FDECL(weapon_descr, (struct obj *));
 E int FDECL(hitval, (struct obj *, struct monst *));
 E int FDECL(dmgval, (struct obj *, struct monst *));
 E struct obj *FDECL(select_rwep, (struct monst *));
+E boolean FDECL(monmightthrowwep, (struct obj *));
 E struct obj *FDECL(select_hwep, (struct monst *));
 E void FDECL(possibly_unwield, (struct monst *, BOOLEAN_P));
 E void FDECL(mwepgone, (struct monst *));
index dfb97ab854b211dcdae878f5b86cd3ebd04baacb..e0526be6ac12193d3b2510a33adc19e0f392a9a2 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mplayer.c       $NHDT-Date: 1458949461 2016/03/25 23:44:21 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.21 $ */
+/* NetHack 3.6 mplayer.c       $NHDT-Date: 1545964576 2018/12/28 02:36:16 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.25 $ */
 /*      Copyright (c) Izchak Miller, 1992.                        */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -270,7 +270,8 @@ register boolean special;
             if (special && rn2(2))
                 otmp = mk_artifact(otmp, A_NONE);
             /* usually increase stack size if stackable weapon */
-            if (objects[otmp->otyp].oc_merge && !otmp->oartifact)
+            if (objects[otmp->otyp].oc_merge && !otmp->oartifact
+                && monmightthrowwep(otmp))
                 otmp->quan += (long) rn2(is_spear(otmp) ? 4 : 8);
             /* mplayers knew better than to overenchant Magicbane */
             if (otmp->oartifact == ART_MAGICBANE)
index a590366bb131bcfa1d3b7c55f3705c7df1cd1169..567aa9578ab535e6a2d708dc57fcf5d075812690 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 weapon.c        $NHDT-Date: 1541145518 2018/11/02 07:58:38 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.60 $ */
+/* NetHack 3.6 weapon.c        $NHDT-Date: 1545964580 2018/12/28 02:36:20 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.67 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2011. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -373,6 +373,7 @@ int x;
     return (struct obj *) 0;
 }
 
+/* TODO: have monsters use aklys' throw-and-return */
 static NEARDATA const int rwep[] = {
     DWARVISH_SPEAR, SILVER_SPEAR, ELVEN_SPEAR, SPEAR, ORCISH_SPEAR, JAVELIN,
     SHURIKEN, YA, SILVER_ARROW, ELVEN_ARROW, ARROW, ORCISH_ARROW,
@@ -510,6 +511,19 @@ register struct monst *mtmp;
     return (struct obj *) 0;
 }
 
+/* is 'obj' a type of weapon that any monster knows how to throw? */
+boolean
+monmightthrowwep(obj)
+struct obj *obj;
+{
+    short idx;
+
+    for (idx = 0; idx < SIZE(rwep); ++idx)
+        if (obj->otyp == rwep[idx])
+            return TRUE;
+    return FALSE;
+}
+
 /* Weapons in order of preference */
 static const NEARDATA short hwep[] = {
     CORPSE, /* cockatrice corpse */