foxygit / doom Log in
commit 1fa73503eff445004d4eee2112017c25c42aeba1
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Mon Oct 17 22:07:26 2005 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Mon Oct 17 22:07:26 2005 +0000

    Fix "Monsters Infight"

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 212
---
 src/deh_misc.c | 36 ++++++++++++++++++++++++++----------
 src/deh_misc.h |  7 +++++--
 src/p_map.c    | 19 ++++++++++++++-----
 3 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/src/deh_misc.c b/src/deh_misc.c
index af0536c8..dcfe998e 100644
--- a/src/deh_misc.c
+++ b/src/deh_misc.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: deh_misc.c 211 2005-10-17 21:20:27Z fraggle $
+// $Id: deh_misc.c 212 2005-10-17 22:07:26Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.8  2005/10/17 22:07:25  fraggle
+// Fix "Monsters Infight"
+//
 // Revision 1.7  2005/10/17 21:20:27  fraggle
 // Add note that the "Monsters Infight" setting is not supported.
 //
@@ -161,13 +164,15 @@ int deh_idkfa_armor_class = 2;

 int deh_bfg_cells_per_shot = 40;

-// BROKEN:
 // Dehacked: "Monsters infight"
-// This presumably controls monster infighting.  However, it is not clear
-// what the values here are supposed to be.  In dehacked, this appears
-// off by default, and turning it on sets the value of this to "221".
+// This controls whether monsters can harm other monsters of the same
+// species.  For example, whether an imp fireball will damage other
+// imps.  The value of this in dehacked patches is weird - '202' means
+// off, while '221' means on.
+//
+// See PIT_CheckThing in p_map.c

-//int deh_monsters_infight;
+int deh_species_infighting = 0;

 static struct
 {
@@ -210,18 +215,29 @@ static void DEH_MiscParseLine(deh_context_t *context, char *line, void *tag)
         return;
     }

-    // Monsters infighting does not work
+    ivalue = atoi(value);

     if (!strcasecmp(variable_name, "Monsters Infight"))
     {
         // See notes above.

-        DEH_Warning(context, "The Misc setting 'Monsters Infight' is not supported.");
+        if (ivalue == 202)
+        {
+            deh_species_infighting = 0;
+        }
+        else if (ivalue == 221)
+        {
+            deh_species_infighting = 1;
+        }
+        else
+        {
+            DEH_Warning(context,
+                        "Invalid value for 'Monsters Infight': %i", ivalue);
+        }
+
         return;
     }

-    ivalue = atoi(value);
-
     for (i=0; i<sizeof(misc_settings) / sizeof(*misc_settings); ++i)
     {
         if (!strcasecmp(variable_name, misc_settings[i].deh_name))
diff --git a/src/deh_misc.h b/src/deh_misc.h
index 5e5a70d9..616ad761 100644
--- a/src/deh_misc.h
+++ b/src/deh_misc.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: deh_misc.h 206 2005-10-17 20:27:05Z fraggle $
+// $Id: deh_misc.h 212 2005-10-17 22:07:26Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.2  2005/10/17 22:07:26  fraggle
+// Fix "Monsters Infight"
+//
 // Revision 1.1  2005/10/17 20:27:05  fraggle
 // Start of Dehacked 'Misc' section support.  Initial Health+Bullets,
 // and bfg cells/shot are supported.
@@ -56,7 +59,7 @@ extern int deh_idfa_armor_class;
 extern int deh_idkfa_armor;
 extern int deh_idkfa_armor_class;
 extern int deh_bfg_cells_per_shot;
-extern int deh_monsters_infight;
+extern int deh_species_infighting;

 #endif /* #ifndef DEH_MISC_H */

diff --git a/src/p_map.c b/src/p_map.c
index 0def9ed5..f31bf152 100644
--- a/src/p_map.c
+++ b/src/p_map.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: p_map.c 8 2005-07-23 16:44:57Z fraggle $
+// $Id: p_map.c 212 2005-10-17 22:07:26Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.3  2005/10/17 22:07:26  fraggle
+// Fix "Monsters Infight"
+//
 // Revision 1.2  2005/07/23 16:44:56  fraggle
 // Update copyright to GNU GPL
 //
@@ -36,10 +39,12 @@
 //-----------------------------------------------------------------------------

 static const char
-rcsid[] = "$Id: p_map.c 8 2005-07-23 16:44:57Z fraggle $";
+rcsid[] = "$Id: p_map.c 212 2005-10-17 22:07:26Z fraggle $";

 #include <stdlib.h>

+#include "deh_misc.h"
+
 #include "m_bbox.h"
 #include "m_random.h"
 #include "i_system.h"
@@ -309,8 +314,8 @@ boolean PIT_CheckThing (mobj_t* thing)
 	if (tmthing->z+tmthing->height < thing->z)
 	    return true;		// underneath

-	if (tmthing->target && (
-	    tmthing->target->type == thing->type ||
+	if (tmthing->target
+         && (tmthing->target->type == thing->type ||
 	    (tmthing->target->type == MT_KNIGHT && thing->type == MT_BRUISER)||
 	    (tmthing->target->type == MT_BRUISER && thing->type == MT_KNIGHT) ) )
 	{
@@ -318,7 +323,11 @@ boolean PIT_CheckThing (mobj_t* thing)
 	    if (thing == tmthing->target)
 		return true;

-	    if (thing->type != MT_PLAYER)
+            // sdh: Add deh_species_infighting here.  We can override the
+            // "monsters of the same species cant hurt each other" behavior
+            // through dehacked patches
+
+	    if (thing->type != MT_PLAYER && !deh_species_infighting)
 	    {
 		// Explode, but do no damage.
 		// Let players missile other players.