Thursday, September 22, 2016

Wounding

So, I've implemented the new WOUNDING feature for slashem and included a new chaotic artifact long sword named Nightblood (taken from some book).  The patch is for SlashTHEM.

The gist is that if you "wound" a monster, it will continue to take damage until you kill it or until it bleeds out.  Just apply this patch and add #define WOUNDING to includ/config.h and you should be good to go.

greg@viper:~/src/SlashTHEM$ git diffdiff --git a/include/artilist.h b/include/artilist.h
index 172a20f..522a74b 100644
--- a/include/artilist.h
+++ b/include/artilist.h
@@ -28,6 +28,9 @@ static const char *artifact_names[] = {
 #define     ELEC(a,b)    {0,AD_ELEC,a,b}        /* electrical shock */
 #define     STUN(a,b)    {0,AD_STUN,a,b}        /* magical attack */
 #define     ACID(a,b)    {0,AD_ACID,a,b}
+#ifdef WOUNDING
+#define     WOUN(a,b)   {0,AD_WOUN,a,b}
+#endif

 STATIC_OVL NEARDATA struct artifact artilist[] = {
 #endif    /* MAKEDEFS_C */
@@ -355,7 +358,11 @@ A("Cat's Claw",        DAGGER,
     (SPFX_RESTR|SPFX_DCLAS), 0, S_RODENT,
     PHYS(5,7),    NO_DFNS,    NO_CARY,    0, A_NEUTRAL, NON_PM, NON_PM, 1000L ),
 #endif /* NEWHON_ARTIFACTS */
-
+#ifdef WOUNDING
+A("Nightblood", LONG_SWORD,
+  (SPFX_NOGEN | SPFX_RESTR | SPFX_INTEL), 0, 0,
+  WOUN(5, 10), NO_DFNS, NO_CARY, 0, A_CHAOTIC, NON_PM, NON_PM, 4000L),
+#endif
 #ifdef TOURIST
 A("Whisperfeet",               SPEED_BOOTS,
     (SPFX_RESTR|SPFX_STLTH|SPFX_LUCK), 0, 0,
@@ -898,6 +905,9 @@ A(0, 0, 0, 0, 0, NO_ATTK, NO_DFNS, NO_CARY, 0, A_NONE, NON_PM, NON_PM, 0L )
 #undef    FIRE
 #undef    ELEC
 #undef    STUN
+#ifdef WOUNDING
+#undef  WOUN
+#endif /* WOUNDING */
 #endif

 /*artilist.h*/
diff --git a/include/attk.h b/include/attk.h
index a52a9ce..dee4dcc 100644
--- a/include/attk.h
+++ b/include/attk.h
@@ -141,7 +141,12 @@ extern char *attk_dname(Attk);
 #define AD_POLY        43    /* RJ -- polymorphs (genetic engineer) */
 #define AD_CORR        44    /* corrode armor (black pudding) */
 #define AD_TCKL        45    /* Tickle (Nightgaunts) */
-#define AD_ENDS        46    /* placeholder */
+#ifdef WOUNDING
+#define AD_WOUN     46  /* Wounding attack */
+#define AD_ENDS        47    /* placeholder */
+#else
+#define AD_ENDS     46  /* placeholder */
+#endif

 #define AD_CLRC        240        /* random clerical spell */
 #define AD_SPEL        241        /* random magic spell */
diff --git a/src/artifact.c b/src/artifact.c
index 69b0add..d37b396 100644
--- a/src/artifact.c
+++ b/src/artifact.c
@@ -1281,6 +1281,18 @@ int dieroll; /* needed for Magicbane and vorpal blades */
         return Mb_hit(magr, mdef, otmp, dmgptr, dieroll, vis, hittee);
     }

+#ifdef WOUNDING
+    if (attacks(AD_WOUN, otmp)) {
+        if (realizes_damage) {
+            if (rnd(5)==1) {
+                mdef->wounding += rnd(10);
+                pline_The("sharp blade wounds %s.", hittee);
+            }
+        }
+        return realizes_damage;
+    }
+#endif
+
     if (!spec_dbon_applies && !spec_ability(otmp, SPFX_BEHEAD) ||
         !special_applies) {
         /* since damage bonus didn't apply, nothing more to do;
diff --git a/src/mon.c b/src/mon.c
index 1bb6a87..36c2fa2 100644
--- a/src/mon.c
+++ b/src/mon.c
@@ -808,6 +808,18 @@ mcalcdistress()
     struct monst *mtmp;

     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
+
+#ifdef WOUNDING
+    if (mtmp->wounding) {
+        mtmp->mhp -= rnd(mtmp->wounding);
+        if (mtmp->mhp < 1) {
+            pline_The("%s dies from its wounds.", Monnam(mtmp));
+            mon_xkilled(mtmp, NULL, AD_WOUN);
+        } else {
+            pline_The("%s suffers from its wounds.", Monnam(mtmp));
+        }
+    }
+#endif
     if (DEADMONSTER(mtmp)) continue;

     /* must check non-moving monsters once/turn in case
diff --git a/src/monmove.c b/src/monmove.c
index a6d1d32..ec22bf8 100644
--- a/src/monmove.c
+++ b/src/monmove.c
@@ -858,6 +858,19 @@ register int after;
         if(i == 1) return(0);    /* still in trap, so didn't move */
     }

+#ifdef WOUNDING
+    if (mtmp->wounding) {
+        mtmp->mhp -= rnd(mtmp->wounding);
+        if (mtmp->mhp < 1) {
+            pline_The("%s dies from its wounds.", Monnam(mtmp));
+            return 2;
+        } else {
+            pline_The("%s suffers from its wounds.", Monnam(mtmp));
+            return 1;
+        }
+    }
+#endif
+
     ptr = mtmp->data; /* mintrap() can change mtmp->data -dlc */

     if (mtmp->meating) {

Tuesday, September 20, 2016

"Just a fleshwound."

I'm working on a patch for slashem (tends to be the version of nethack I tinker with the most) to add a weapon feature called "Wounding".  Basically, when you hit a monster with a weapon that has the "wounding" feature, there's a chance you will create—you guessed it—a wound.  A wounded monster will take a random amount of extra damage every turn regardless of whether its hit.




What good is wounding without a nice artifact to carry out the message?  I've added Nightblood, a chaotic long sword that can wound.



I still need to test this to make sure it all works, at which point, I'll make the patch available.  Also, I think it's important to mention how much I love CPP.  I'm not talking about C++, but the C Pre-Processor.  All languages should have one.

Thursday, September 15, 2016

Starting to get back into it

I was looking through the Slashem, and then SlashTHEM code, pondering adding some new artifacts, when I decided to do something nice and fix all the indentation problems in the code.  A lot of the issues stem from mixing of Tabs and Spaces.  I personally prefer spaces since tab-sizes can be changed depending on the text editor you're using, so I changed all tabs to spaces.  Whatever your preference, tabs or spaces, I think we can all agree they shouldn't be mixed.

Fortunately, this who process was as simple as running indent -nut -kr on all the source files.  I discovered this very old, simple tool when working for a company that used the GNU indentation style, which if you're not familiar with it, is a steaming pile of horse shit that should never have been invented (Thanks Stallman!).

You can clone the SlashTHEM git repository here: https://github.com/Soviet5lo/SlashTHEM

Then just download and apply my patch to fix all the indentation to use indentation of four spaces per indentation level: https://drive.google.com/open?id=0B7oiSGh7Lg0lWEJKVmRwQzlHN0E

Enjoy.