]> granicus.if.org Git - nethack/commitdiff
Spiders will occasionally spin webs
authorPasi Kallinen <paxed@alt.org>
Fri, 7 Sep 2018 17:26:14 +0000 (20:26 +0300)
committerPasi Kallinen <paxed@alt.org>
Fri, 7 Sep 2018 17:26:18 +0000 (20:26 +0300)
Idea and code inspired by aosdict

doc/fixes36.2
src/monmove.c

index 949691dadd2d7c31dd9a2b187b535a03855c40d3..ccaa24f4bf5a76755a941b9aed6b7bb2705e7f59 100644 (file)
@@ -114,6 +114,7 @@ add window port status_update() value BL_RESET to use as a flag to
 for hilite_status of string status fields (title, dungeon-level, alignment),
        the types value-goes-up and -down aren't meaningful; treat them as
        value-changed if from config file and don't offer as choices with 'O'
+spiders will occasionally spin webs when moving around
 
 
 Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
index 0abf63b6d873b94ee0a8f271ed26d8543ededd89..c6babe5ca42330bb5cdc8475396c0cf682d14cb2 100644 (file)
@@ -742,6 +742,18 @@ xchar nix,niy;
     return FALSE;
 }
 
+/* returns the number of walls in the four cardinal directions that could hold up a web */
+int
+count_webbing_walls(x,y)
+xchar x,y;
+{
+#define holds_up_web(x,y) ((!isok((x),(y)) \
+                            || IS_ROCK(levl[(x)][(y)].typ) \
+                            || levl[(x)][(y)].typ == IRONBARS) ? 1 : 0)
+    return holds_up_web(x, y-1) + holds_up_web(x+1, y) + holds_up_web(x, y+1) + holds_up_web(x-1, y);
+#undef holds_up_web
+}
+
 /* Return values:
  * 0: did not move, but can still attack and do other stuff.
  * 1: moved, possibly can attack.
@@ -1436,6 +1448,19 @@ postmov:
             }
         }
 
+        /* maybe a spider spun a web */
+        if (webmaker(ptr) && !t_at(mtmp->mx, mtmp->my)) {
+            int prob = ((ptr == &mons[PM_GIANT_SPIDER]) ? 15 : 5) *
+                (count_webbing_walls(mtmp->mx, mtmp->my) + 1);
+            if (rn2(1000) < prob) {
+                struct trap* trap = maketrap(mtmp->mx, mtmp->my, WEB);
+                if (trap && canspotmon(mtmp)) {
+                    pline("%s spins a web.", upstart(y_monnam(mtmp)));
+                    trap->tseen = 1;
+                }
+            }
+        }
+
         if (hides_under(ptr) || ptr->mlet == S_EEL) {
             /* Always set--or reset--mundetected if it's already hidden
                (just in case the object it was hiding under went away);