]> granicus.if.org Git - nethack/commitdiff
Make monsters trigger landmines based on weight
authorMichael Meyer <me@entrez.cc>
Wed, 15 Jun 2022 21:40:56 +0000 (17:40 -0400)
committerPatR <rankin@nethack.org>
Sat, 2 Jul 2022 22:02:32 +0000 (15:02 -0700)
The 1/3 likelihood of a monster setting off a landmine seemed a little
arbitrary to me, especially in that it applied equally to all monsters,
from giants to insects.  Change the flat 33% chance to one based on the
monster's body weight, so that lightweight monsters have little to no
chance of setting off a mine, with the likelihood increasing from there
with the monster's weight.

With a trigger weight of 400, as it is in this commit, a dingo has a 0%
chance of setting off a landmine, a gelatinous cube the same 33% chance
as before, an elf a 50% chance, a human a 72% chance, and something the
size of a dragon (ignoring the reduced likelihood for flying monsters) a
91% chance.

src/trap.c

index 0b86e33c32c8ceec34ec4a547cd7c3ee1480ba0c..0663dbc4c39b046c8ec9581260a8c76bc829ab29 100644 (file)
@@ -2243,8 +2243,11 @@ trapeffect_landmine(
         struct permonst *mptr = mtmp->data;
         coordxy tx = trap->tx, ty = trap->ty;
 
-        if (rn2(3))
-            return Trap_Effect_Finished; /* monsters usually don't set it off */
+        /* heavier monsters are more likely to set off a land mine; on the
+           other hand, any mon lighter than the trigger weight is immune. */
+#define MINE_TRIGGER_WT (WT_ELF / 2)
+        if (rn2(mtmp->data->cwt + 1) < MINE_TRIGGER_WT)
+            return Trap_Effect_Finished;
         if (is_flyer(mptr)) {
             boolean already_seen = trap->tseen;
 
@@ -2293,6 +2296,7 @@ trapeffect_landmine(
     }
     return Trap_Effect_Finished;
 }
+#undef MINE_TRIGGER_WT
 
 static int
 trapeffect_rolling_boulder_trap(