The "Ultimate" monster infighting patch.

Monsters now hate other monsters as much as they hate you. If
there's a big monster they'll gang up on it to kill it. They also
hate barrels and will destroy them at all costs. Hilariy ensues.
===================================================================
--- p_enemy.c	(revision 2755)
+++ p_enemy.c	(working copy)
@@ -501,58 +501,78 @@
 ( mobj_t*	actor,
   boolean	allaround )
 {
-    int		c;
-    int		stop;
-    player_t*	player;
-    angle_t	an;
-    fixed_t	dist;
-
-    c = 0;
-    stop = (actor->lastlook-1)&3;
-	
-    for ( ; ; actor->lastlook = (actor->lastlook+1)&3 )
+    thinker_t *rover;
+    angle_t an;
+    fixed_t dist;
+    mobj_t *best;
+
+    best = NULL;
+
+    for (rover=thinkercap.next; rover != &thinkercap; rover=rover->next)
     {
-	if (!playeringame[actor->lastlook])
-	    continue;
-			
-	if (c++ == 2
-	    || actor->lastlook == stop)
-	{
-	    // done looking
-	    return false;	
-	}
-	
-	player = &players[actor->lastlook];
+        mobj_t *mo;
 
-	if (player->health <= 0)
+        if (rover->function.acp1 != (actionf_p1) P_MobjThinker)
+            continue;
+
+        mo = (mobj_t *) rover;
+
+        if (mo == actor)
+            continue;
+
+        if ((mo->flags & MF_SHOOTABLE) == 0)
+            continue;
+
+	if (mo->health <= 0)
 	    continue;		// dead
 
-	if (!P_CheckSight (actor, player->mo))
+	if (!P_CheckSight (actor, mo))
 	    continue;		// out of sight
-			
+
 	if (!allaround)
 	{
 	    an = R_PointToAngle2 (actor->x,
 				  actor->y, 
-				  player->mo->x,
-				  player->mo->y)
+				  mo->x,
+				  mo->y)
 		- actor->angle;
-	    
+
 	    if (an > ANG90 && an < ANG270)
 	    {
-		dist = P_AproxDistance (player->mo->x - actor->x,
-					player->mo->y - actor->y);
+		dist = P_AproxDistance (mo->x - actor->x,
+					mo->y - actor->y);
 		// if real close, react anyway
 		if (dist > MELEERANGE)
 		    continue;	// behind back
 	    }
 	}
-		
-	actor->target = player->mo;
-	return true;
+
+        // HATE BARRELS
+
+        if (mo->type == MT_BARREL)
+        {
+            best = mo;
+            break;
+        }
+
+        // Make monsters gang up on big monsters that have lots 
+        // of health
+
+        if (best == NULL || mo->health > best->health)
+        {
+            best = mo;
+        }
     }
 
-    return false;
+    if (best != NULL)
+    {
+        actor->target = best;
+        return true;
+    }
+    else
+    {
+        return false;
+    }
 }
 
 
