changeset 13:ed82a42ba89d

Added code to cause missiles, fighters and plasmas to get confused in nebulous terrain. If it gets confused then it picks a random direction to go.
author darius
date Sat, 06 Dec 1997 06:27:03 +0000
parents 8f2256d473fb
children b7fe2e0e4b86
files src/weapons.c
diffstat 1 files changed, 300 insertions(+), 440 deletions(-) [+]
line wrap: on
line diff
--- a/src/weapons.c	Sat Dec 06 05:10:46 1997 +0000
+++ b/src/weapons.c	Sat Dec 06 06:27:03 1997 +0000
@@ -126,8 +126,6 @@
 }
 
 
-
-
 /*---------------------------------PEXPLODE-------------------------------*/
 /*
  * This function does the explosion of a plasma torp.  It goes through all
@@ -144,8 +142,6 @@
 }
 
 
-
-
 /*-------------------------------UDPHASER----------------------------------*/
 /*
  * This function goes through all players and calcs the damage from a phaser
@@ -216,46 +212,6 @@
   return 0;			/* return that it should continue */
 }
 
-
-#if 0				/* I think this is now unused */
-/*----------------------------------NEAR----------------------------------*/
-/*
- * This function checks to see if a player is close enough to a torp for the
- * torp to explode on.  This function returns a 1 if the torp should explode
- * and a zero if not.
- */
-
-int
-near(torp)
-  struct torp *torp;		/* the torp to check for */
-{
-#if 1
-  return near_player(&torp->t_base, EXPDIST);
-#else
-  register int i;		/* looping var */
-  int dx, dy;			/* to calc torp-player distance */
-  register struct player *j;	/* to point to players */
-
-  for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++)
-  {
-    if (j->p_status != PALIVE)
-      continue;			/* don't check players not alive */
-    if (j->p_no == torp->t_owner)
-      continue;			/* no exploding on self */
-    if (!hostile_to(torp->t_war, torp->t_team, j))
-      continue;			/* disregard if both teams not at war */
-    dx = torp->t_x - j->p_x;	/* calc delta coords */
-    dy = torp->t_y - j->p_y;
-    if (ABS(dx) > EXPDIST || ABS(dy) > EXPDIST)
-      continue;			/* disregard if obviously too far */
-    if (dx * dx + dy * dy < EXPDIST * EXPDIST)
-      return 1;			/* if close enough to explode then return 1 */
-  }
-  return 0;			/* return that torp should continue */
-#endif
-}
-#endif
-
 int
 near_player(torp, dist)
   struct basetorp *torp;	/* the torp to check for */
@@ -321,33 +277,7 @@
 pnear(plasmatorp)
   struct plasmatorp *plasmatorp;/* the plasma torp to check for */
 {
-#if 1
   return near_player(&plasmatorp->pt_base, EXPDIST);
-#else
-  register int i;		/* looping var */
-  int dx, dy;			/* to calc distances with */
-  register struct player *j;	/* to point to players */
-  /* fprintf(stderr, "ENTERING PNEAR\n"); */
-  for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++)
-  {
-    if (!(j->p_status == PALIVE))
-      continue;			/* don't check players not alive */
-    if (plasmatorp->pt_owner == j->p_no)
-      continue;			/* no exploding on self */
-    if (!hostile_to(plasmatorp->pt_war, plasmatorp->pt_team, j))
-      continue;			/* disregard if both teams not at war */
-    dx = plasmatorp->pt_x - j->p_x;	/* calc delta coords */
-    dy = plasmatorp->pt_y - j->p_y;
-    /* fprintf(stderr, "ENTERING UDORPS #1\n"); */
-    if (ABS(dx) > EXPDIST || ABS(dy) > EXPDIST)
-      continue;			/* disregard if obviously too far */
-    /* fprintf(stderr, "ENTERING UDORPS #2\n"); */
-    if (dx * dx + dy * dy < EXPDIST * EXPDIST)
-      return 1;			/* if close enough to explode then return 1 */
-    /* fprintf(stderr, "ENTERING UDORPS #3\n"); */
-  }
-  return 0;			/* return that plasma torp should continue */
-#endif
 }
 
 
@@ -378,107 +308,103 @@
   {
     switch (j->t_status)
     {				/* check status of torp */
-     case TFREE:		/* if torp not active then */
-      continue;			/* go on to next torp */
-     case TMOVE:
-     case TSTRAIGHT:		/* if torp moving then */
-      if (j->t_turns > 0)
-      {				/* if torp can turn then */
-	turn = torp_track_opportunity
-	  (&j->t_base, j->t_turns,
-	   configvals->improved_tracking[SS_PHOTON]);
-	/* should we go right or left */
-	if (turn < 0)
-	{			/* we will go left */
-	  heading = ((int) j->t_dir) - j->t_turns;	/* turn left */
-	  if (heading < 0)
-	    j->t_dir = heading + 256;
-	  /*
-	   * j->t_dir = ((heading < 0) ? ((unsigned char) (256 + heading)) :
-	   * ((unsigned char) heading));	* no underflow
-	   */
-	}
-	else if (turn > 0)
-	{			/* we will go right */
-	  heading = ((int) j->t_dir) + j->t_turns;	/* turn right */
-	  if (heading > 255)
-	    j->t_dir = heading - 256;
-	  /*
-	   * j->t_dir = ((heading > 255) ? ((unsigned char) (heading - 256))
-	   * : ((unsigned char) heading));	* no overflow
-	   */
-	}
-      }
-      j->t_x += (double) j->t_speed * Cos[j->t_dir] * WARP1;
-      j->t_y += (double) j->t_speed * Sin[j->t_dir] * WARP1;
+			case TFREE:		/* if torp not active then */
+				continue;			/* go on to next torp */
+			case TMOVE:
+			case TSTRAIGHT:		/* if torp moving then */
+				if (j->t_turns > 0)
+				{				/* if torp can turn then */
+					turn = torp_track_opportunity
+					(&j->t_base, j->t_turns,
+					 configvals->improved_tracking[SS_PHOTON]);
+					/* should we go right or left */
 
-#if 0
-      if (outofbounds(j->t_x, j->t_y))
-      {				/* hit top wall? */
-	j->t_status = TEXPLODE;	/* so you cannot wall kill */
-	j->t_whodet = j->t_owner;
-	/* explode(&j->t_base);	eliminate self wallkills */
-	break;			/* done with this torp */
-      }
-#endif
+				if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE +
+												 (int) (j->t_y) / TGRID_GRANULARITY].types
+						 & T_NEBULA) &&	neb_effect[SS_PHOTON])
+					if(TORP_NEB_EFF > (lrand48() % 100)) /* Is torp affected? */
+						turn = (lrand48() % 2); /* Yes */
+				
+					if (turn < 0)
+					{			/* we will go left */
+						heading = ((int) j->t_dir) - j->t_turns;	/* turn left */
+						if (heading < 0)
+							j->t_dir = heading + 256;
+						/*
+						 * j->t_dir = ((heading < 0) ? ((unsigned char) (256 + heading)) :
+						 * ((unsigned char) heading));	* no underflow
+						 */
+					}
+					else if (turn > 0)
+					{			/* we will go right */
+						heading = ((int) j->t_dir) + j->t_turns;	/* turn right */
+						if (heading > 255)
+							j->t_dir = heading - 256;
+						/*
+						 * j->t_dir = ((heading > 255) ? ((unsigned char) (heading - 256))
+						 * : ((unsigned char) heading));	* no overflow
+						 */
+					}
+				}
+				j->t_x += (double) j->t_speed * Cos[j->t_dir] * WARP1;
+				j->t_y += (double) j->t_speed * Sin[j->t_dir] * WARP1;
 
-      move_torp(i, j->t_x, j->t_y, 1);
+				move_torp(i, j->t_x, j->t_y, 1);
 
-      if (j->t_status == TMOVE)	/* if a TMOVE torp then */
-	j->t_dir += (lrand48() % 3) - 1;	/* make the torp wobble */
-      if (j->t_fuse-- <= 0)
-      {				/* dec torp's life and see if dead */
-	j->t_status = TFREE;	/* dead, free the torp */
-	move_torp(i, -1, -1, 1);
-	players[j->t_owner].p_ntorp--;	/* let player fire another */
-	break;			/* no more torp processing */
-      }
-      if ((sun_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLSTAR, ORBDIST))
-	  ||
-	  (wh_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLWHOLE, ORBDIST)))
-      {
-	/* did it hit a star or wormhole? */
-	j->t_whodet = j->t_owner;
-	explode(&j->t_base);
-	break;
-      }
+				if (j->t_status == TMOVE)	/* if a TMOVE torp then */
+					j->t_dir += (lrand48() % 3) - 1;	/* make the torp wobble */
+				if (j->t_fuse-- <= 0)
+				{				/* dec torp's life and see if dead */
+					j->t_status = TFREE;	/* dead, free the torp */
+					move_torp(i, -1, -1, 1);
+					players[j->t_owner].p_ntorp--;	/* let player fire another */
+					break;			/* no more torp processing */
+				}
+				if ((sun_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLSTAR, ORBDIST))
+						||
+						(wh_effect[SS_PHOTON] && weap_near_object(&j->t_base, PLWHOLE, ORBDIST)))
+				{
+					/* did it hit a star or wormhole? */
+					j->t_whodet = j->t_owner;
+					explode(&j->t_base);
+					break;
+				}
 
-      if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE +
-			(int) (j->t_y) / TGRID_GRANULARITY].types
-	   & T_ASTEROIDS) &&
-	  ast_effect[SS_PHOTON])
-	if (TORP_HIT_AST > (lrand48() % 100))
-	{
-	  explode(&j->t_base);
-	  break;
-	}
+				if ((terrain_grid[(int) (j->t_x) / TGRID_GRANULARITY * TGRID_SIZE +
+												 (int) (j->t_y) / TGRID_GRANULARITY].types
+						 & T_ASTEROIDS) && ast_effect[SS_PHOTON])
+					if (TORP_HIT_AST > (lrand48() % 100))
+					{
+						explode(&j->t_base);
+						break;
+					}
 
-      if (near_player(&j->t_base, EXPDIST))
-      {
-	/* if torp near enough to hit */
-	explode(&j->t_base);	/* let torp explode on player */
-      }
+				if (near_player(&j->t_base, EXPDIST))
+				{
+					/* if torp near enough to hit */
+					explode(&j->t_base);	/* let torp explode on player */
+				}
 
-      break;
-     case TDET:		/* if torp was detted */
-      explode(&j->t_base);	/* make it explode */
-      break;			/* on to next torp */
-     case TEXPLODE:		/* if torp exploding */
-      if (j->t_fuse-- <= 0)
-      {				/* dec explosion timer */
-	j->t_status = TFREE;	/* if torp done, free it up */
-	move_torp(i, -1, -1, 1);
-	players[j->t_owner].p_ntorp--;	/* let player fire another */
-      }
-      break;			/* on to next torp */
-     case TOFF:
-      j->t_status = TFREE;
-      move_torp(i, -1, -1, 1);
-      players[j->t_owner].p_ntorp--;
-      break;
-     default:			/* Shouldn't happen */
-      j->t_status = TFREE;
-      break;
+				break;
+			case TDET:		/* if torp was detted */
+				explode(&j->t_base);	/* make it explode */
+				break;			/* on to next torp */
+			case TEXPLODE:		/* if torp exploding */
+				if (j->t_fuse-- <= 0)
+				{				/* dec explosion timer */
+					j->t_status = TFREE;	/* if torp done, free it up */
+					move_torp(i, -1, -1, 1);
+					players[j->t_owner].p_ntorp--;	/* let player fire another */
+				}
+				break;			/* on to next torp */
+			case TOFF:
+				j->t_status = TFREE;
+				move_torp(i, -1, -1, 1);
+				players[j->t_owner].p_ntorp--;
+				break;
+			default:			/* Shouldn't happen */
+				j->t_status = TFREE;
+				break;
     }				/* end of switch */
   }				/* end of for */
 }
@@ -496,193 +422,150 @@
     mis = &missiles[i];
     switch (mis->ms_status)
     {
-     case TFREE:
-      break;
-     case TLAND:
-      j = &players[mis->ms_owner];
-      j->p_ship.s_missilestored++;
-      j->p_armies = (int) (j->p_ship.s_missilestored / FAE_RATE);
-      mis->ms_status = TFREE;
-      j->p_nthingys--;
-      break;
-#if 0
-     case TRETURN:
-      j = &players[mis->ms_owner];
-      if (!(j->p_ship.s_nflags & SFNHASFIGHTERS))
-      {
-	mis->ms_type = MISSILETHINGY;	/* If the player no longer has em, */
-	mis->ms_status = TMOVE;	/* make his fighters kamikazes */
-	mis->fi_hasfired = 0;
-	break;
-      }
-
-
-      if (mis->ms_fuse-- <= 0)
-      {
-	mis->ms_status = TFREE;
-	move_missile(i, -1, -1, 1);
-	break;
-      }
-
-      if (((sun_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY
-	    || sun_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY)
-	   && weap_near_object(&mis->ms_base, PLSTAR, ORBDIST)) ||
-	  ((wh_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY
-	    || wh_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY)
-	   && weap_near_object(&mis->ms_base, PLWHOLE, ORBDIST)))
-      {
-	/* did it hit a star or wormhole? */
-	explode(&mis->ms_base);
-	break;
-      }
-      if (mis->ms_turns > 0)
-      {
-	turn = fighter_track_target(&mis->ms_base, mis->ms_turns);
-	mis->ms_dir = (unsigned char) (mis->ms_dir + turn * mis->ms_turns);
-      }
-      x = mis->ms_x + mis->ms_speed * Cos[mis->ms_dir] * WARP1;
-      y = mis->ms_y + mis->ms_speed * Sin[mis->ms_dir] * WARP1;
-      move_missile(i, x, y, 1);
-
-      if (mis->ms_fuse-- <= 0)
-      {
-	mis->ms_status = TFREE;
-	move_missile(i, -1, -1, 1);
-      }
-      else if (f_land(mis))
-      {
-	mis->ms_status = TLAND;
-	move_missile(i, -1, -1, 1);
-      }
-      break;
-#endif
-     case TRETURN:
-     case TMOVE:
-     case TSTRAIGHT:
-
-      if (mis->ms_fuse-- <= 0)
-      {
-	mis->ms_status = TFREE;
-	move_missile(i, -1, -1, 1);
-	break;
-      }
-
-      if (terrain_grid[(int) (mis->ms_x) / TGRID_GRANULARITY * TGRID_SIZE +
-		       (int) (mis->ms_y) / TGRID_GRANULARITY].types
-	  & T_ASTEROIDS)
-	if ((mis->ms_type == FIGHTERTHINGY) &&
-	    ast_effect[SS_FIGHTER] &&
-	    (FIGHTER_HIT_AST > (lrand48() % 100)))
-	{
-	  mis->ms_whodet = mis->ms_owner;
-	  explode(&mis->ms_base);
-	  break;
-	}
-	else if ((MISSILE_HIT_AST > (lrand48() % 100)) &&
-		 ast_effect[SS_MISSILE])
-	{
-	  mis->ms_whodet = mis->ms_owner;
-	  explode(&mis->ms_base);
-	  break;
-	}
+			case TFREE:
+				break;
+			case TLAND:
+				j = &players[mis->ms_owner];
+				j->p_ship.s_missilestored++;
+				j->p_armies = (int) (j->p_ship.s_missilestored / FAE_RATE);
+				mis->ms_status = TFREE;
+				j->p_nthingys--;
+				break;
+			case TRETURN:
+			case TMOVE:
+			case TSTRAIGHT:
+				
+				if (mis->ms_fuse-- <= 0)
+				{
+					mis->ms_status = TFREE;
+					move_missile(i, -1, -1, 1);
+					break;
+				}
+				
+				if (terrain_grid[(int) (mis->ms_x) / TGRID_GRANULARITY * TGRID_SIZE +
+												(int) (mis->ms_y) / TGRID_GRANULARITY].types
+						& T_ASTEROIDS)
+					if ((mis->ms_type == FIGHTERTHINGY) &&
+							ast_effect[SS_FIGHTER] &&
+							(FIGHTER_HIT_AST > (lrand48() % 100)))
+					{
+						mis->ms_whodet = mis->ms_owner;
+						explode(&mis->ms_base);
+						break;
+					}
+					else if ((MISSILE_HIT_AST > (lrand48() % 100)) &&
+									 ast_effect[SS_MISSILE])
+					{
+						mis->ms_whodet = mis->ms_owner;
+						explode(&mis->ms_base);
+						break;
+					}
+				
+				if ((((sun_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY)
+							|| (sun_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY))
+						 && weap_near_object(&mis->ms_base, PLSTAR, ORBDIST))
+						||
+						(((wh_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY)
+							|| (wh_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY))
+						 && weap_near_object(&mis->ms_base, PLWHOLE, ORBDIST)))
+				{
+					/* did it hit a star? */
+					explode(&mis->ms_base);
+					break;
+				}
+				
+				j = &players[mis->ms_owner];
+				
+				if (mis->ms_type == FIGHTERTHINGY &&
+						!(j->p_ship.s_nflags & SFNHASFIGHTERS))
+				{
+					mis->ms_type = MISSILETHINGY;	/* If the player no longer has em, */
+					mis->ms_status = TMOVE;	/* make his fighters kamikazes */
+					mis->fi_hasfired = 0;
+					break;
+				}
+				
+				if ((mis->ms_type == FIGHTERTHINGY)
+						&& ((mis->ms_fuse < .6 * j->p_ship.s_missile.fuse)
+								|| (mis->fi_hasfired))
+						&& mis->ms_status != TRETURN)
+					mis->ms_status = TRETURN;
+				
+				if (mis->ms_turns > 0)
+				{
+					if (mis->ms_type == FIGHTERTHINGY)
+					{
+						turn = fighter_track_target(&mis->ms_base, mis->ms_turns);
+					}
+					else
+					{
+						turn = torp_track_opportunity
+						(&mis->ms_base, mis->ms_turns,
+						 configvals->improved_tracking[SS_MISSILE]);
+					}
 
-      if ((((sun_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY)
-	    || (sun_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY))
-	   && weap_near_object(&mis->ms_base, PLSTAR, ORBDIST))
-	  ||
-	  (((wh_effect[SS_MISSILE] && mis->ms_type == MISSILETHINGY)
-	    || (wh_effect[SS_FIGHTER] && mis->ms_type == FIGHTERTHINGY))
-	   && weap_near_object(&mis->ms_base, PLWHOLE, ORBDIST)))
-      {
-	/* did it hit a star? */
-	explode(&mis->ms_base);
-	break;
-      }
-
-      j = &players[mis->ms_owner];
-
-      if (mis->ms_type == FIGHTERTHINGY &&
-	  !(j->p_ship.s_nflags & SFNHASFIGHTERS))
-      {
-	mis->ms_type = MISSILETHINGY;	/* If the player no longer has em, */
-	mis->ms_status = TMOVE;	/* make his fighters kamikazes */
-	mis->fi_hasfired = 0;
-	break;
-      }
-
-      if ((mis->ms_type == FIGHTERTHINGY)
-	  && ((mis->ms_fuse < .6 * j->p_ship.s_missile.fuse)
-	      || (mis->fi_hasfired))
-	  && mis->ms_status != TRETURN)
-	mis->ms_status = TRETURN;
-
-      if (mis->ms_turns > 0)
-      {
-	if (mis->ms_type == FIGHTERTHINGY)
-	{
-	  turn = fighter_track_target(&mis->ms_base, mis->ms_turns);
-	}
-	else
-	{
-	  turn = torp_track_opportunity
-	    (&mis->ms_base, mis->ms_turns,
-	     configvals->improved_tracking[SS_MISSILE]);
-	}
-	mis->ms_dir = (unsigned char) (mis->ms_dir + turn * mis->ms_turns);
-      }
-      x = mis->ms_x + mis->ms_speed * Cos[mis->ms_dir] * WARP1;
-      y = mis->ms_y + mis->ms_speed * Sin[mis->ms_dir] * WARP1;
+					if ((terrain_grid[(int) (mis->ms_x) / TGRID_GRANULARITY * TGRID_SIZE +
+													 (int) (mis->ms_y) / TGRID_GRANULARITY].types
+							 & T_NEBULA))
+							
+						if((mis->ms_type == FIGHTERTHINGY) && neb_effect[SS_FIGHTER])
+						{
+							if(FIGHTER_NEB_EFF > (lrand48() % 100)) /* Is fighter affected? */
+								turn = (lrand48() % 2); /* Yes */
+						}
+						else
+							if(neb_effect[SS_MISSILE])
+								if(MISSILE_NEB_EFF > (lrand48() % 100)) /* Is missile affected? */
+									turn = (lrand48() % 2); /* Yes */
+							
 
-#if 0
-      if (outofbounds(x, y))
-      {
-	explode(&mis->ms_base);
-	break;
-      }
-#endif
-
-      move_missile(i, x, y, 1);
-
-      if (mis->ms_status != TSTRAIGHT)
-	mis->ms_dir += (lrand48() % 3) - 1;
-
-      if (mis->ms_type == MISSILETHINGY
-	  && near_player(&mis->ms_base, EXPDIST))
-      {
-	explode(&mis->ms_base);
-      }
-      else if (mis->ms_type == FIGHTERTHINGY
-	       && near_player(&mis->ms_base, FSTRIKEDIST)
-	       && !mis->fi_hasfired)
-      {
-	if (f_torp(mis))
-	  mis->fi_hasfired = 1;	/* if within strike range, fire a torp */
-      }
-
-      if (mis->ms_status == TRETURN &&
-	  f_land(mis))
-      {
-	mis->ms_status = TLAND;
-	move_missile(i, -1, -1, 1);
-      }
-
-      break;
-
-     case TDET:
-      explode(&mis->ms_base);
-      break;
-
-     case TEXPLODE:
-      if (mis->ms_fuse-- <= 0)
-      {
-	mis->ms_status = TFREE;
-	players[mis->ms_owner].p_nthingys--;
-	move_missile(i, -1, -1, 1);
-      }
-      break;
-     default:
-      mis->ms_status = TFREE;
-      break;
+					mis->ms_dir = (unsigned char) (mis->ms_dir + turn * mis->ms_turns);
+				}
+				x = mis->ms_x + mis->ms_speed * Cos[mis->ms_dir] * WARP1;
+				y = mis->ms_y + mis->ms_speed * Sin[mis->ms_dir] * WARP1;
+				
+				move_missile(i, x, y, 1);
+				
+				if (mis->ms_status != TSTRAIGHT)
+					mis->ms_dir += (lrand48() % 3) - 1;
+				
+				if (mis->ms_type == MISSILETHINGY
+						&& near_player(&mis->ms_base, EXPDIST))
+				{
+					explode(&mis->ms_base);
+				}
+				else if (mis->ms_type == FIGHTERTHINGY
+								 && near_player(&mis->ms_base, FSTRIKEDIST)
+								 && !mis->fi_hasfired)
+				{
+					if (f_torp(mis))
+						mis->fi_hasfired = 1;	/* if within strike range, fire a torp */
+				}
+				
+				if (mis->ms_status == TRETURN &&
+						f_land(mis))
+				{
+					mis->ms_status = TLAND;
+					move_missile(i, -1, -1, 1);
+				}
+				
+				break;
+				
+			case TDET:
+				explode(&mis->ms_base);
+				break;
+				
+			case TEXPLODE:
+				if (mis->ms_fuse-- <= 0)
+				{
+					mis->ms_status = TFREE;
+					players[mis->ms_owner].p_nthingys--;
+					move_missile(i, -1, -1, 1);
+				}
+				break;
+			default:
+				mis->ms_status = TFREE;
+				break;
     }
   }
 }
@@ -699,11 +582,10 @@
   float tdx, tdy;
   float theta;
 
-#if 1				/* mathematically, these affect t, but not
+				/* mathematically, these affect t, but not
 				 * the return value */
   s *= WARP1 * TICKSPERSEC;
   w *= WARP1 * TICKSPERSEC;
-#endif
 
   sdx = s * Cos[dir];
   sdy = s * Sin[dir];
@@ -859,96 +741,74 @@
   {
     switch (j->pt_status)
     {				/* check torp's status */
-     case PTFREE:		/* if plasma not being fired */
-      continue;			/* go to next plasma */
-     case PTMOVE:		/* if plasma moving */
-      turn = torp_track_opportunity
-	(&j->pt_base, j->pt_turns,
-	 configvals->improved_tracking[SS_PLASMA]);
-      /* should we go right or left */
-      if (turn < 0)
-      {				/* if left then */
-	heading = ((int) j->pt_dir) - j->pt_turns;
-	j->pt_dir = ((heading < 0) ? ((unsigned char) (256 + heading)) :
-		     ((unsigned char) heading));	/* no rollunder */
-      }
-      else if (turn > 0)
-      {				/* else if right */
-	heading = ((int) j->pt_dir) + j->pt_turns;
-	j->pt_dir = ((heading > 255) ? ((unsigned char) (heading - 256)) :
-		     ((unsigned char) heading));	/* no rollover */
-      }
-      j->pt_x += (double) j->pt_speed * Cos[j->pt_dir] * WARP1;
+			case PTFREE:		/* if plasma not being fired */
+				continue;			/* go to next plasma */
+			case PTMOVE:		/* if plasma moving */
+				turn = torp_track_opportunity
+				(&j->pt_base, j->pt_turns,
+				 configvals->improved_tracking[SS_PLASMA]);
+
+				if ((terrain_grid[(int) (j->pt_x) / TGRID_GRANULARITY * TGRID_SIZE +
+												 (int) (j->pt_y) / TGRID_GRANULARITY].types
+						 & T_NEBULA) && neb_effect[SS_PLASMA])
+					if(PLASMA_NEB_EFF > (lrand48() % 100)) /* Is plasma affected? */
+						turn = (lrand48() % 2); /* Yes */
+
+				/* should we go right or left */
+				if (turn < 0)
+				{				/* if left then */
+					heading = ((int) j->pt_dir) - j->pt_turns;
+					j->pt_dir = ((heading < 0) ? ((unsigned char) (256 + heading)) :
+											 ((unsigned char) heading));	/* no rollunder */
+				}
+				else if (turn > 0)
+				{				/* else if right */
+					heading = ((int) j->pt_dir) + j->pt_turns;
+					j->pt_dir = ((heading > 255) ? ((unsigned char) (heading - 256)) :
+											 ((unsigned char) heading));	/* no rollover */
+				}
+				j->pt_x += (double) j->pt_speed * Cos[j->pt_dir] * WARP1;
 
-#if 0
-      if (j->pt_x < 0)
-      {				/* if torp at left edge */
-	j->pt_x = 0;		/* set x to left edge */
-	pexplode(j);		/* make torp explode */
-	break;			/* go to next torp */
-      }
-      else if (j->pt_x > GWIDTH)
-      {				/* if torp is at right edge */
-	j->pt_x = GWIDTH;	/* set x to right edge */
-	pexplode(j);		/* make torp explode */
-	break;			/* on to next torp */
-      }
-#endif
-      j->pt_y += (double) j->pt_speed * Sin[j->pt_dir] * WARP1;
-#if 0
-      if (j->pt_y < 0)
-      {				/* if torp at top */
-	j->pt_y = 0;		/* set torp to top edge */
-	pexplode(j);		/* make torp explode */
-	break;			/* on to next torp */
-      }
-      else if (j->pt_y > GWIDTH)
-      {				/* if torp is at bottom */
-	j->pt_y = GWIDTH;	/* set y to bottom */
-	pexplode(j);		/* make torp explode */
-	break;			/* on to next torp */
-      }
-#endif
+				j->pt_y += (double) j->pt_speed * Sin[j->pt_dir] * WARP1;
+				if (j->pt_fuse-- <= 0)
+				{				/* dec the torp fuse. if torp done */
+					j->pt_status = PTFREE;	/* free it up */
+					players[j->pt_owner].p_nplasmatorp--;	/* dec p-torps fired */
+					break;
+				}
+
+				if ((terrain_grid[(int) (j->pt_x) / TGRID_GRANULARITY * TGRID_SIZE +
+												 (int) (j->pt_y) / TGRID_GRANULARITY].types
+						 & T_ASTEROIDS) &&
+						ast_effect[SS_PLASMA])
+					if (PLASMA_HIT_AST > (lrand48() % 100))
+					{
+						pexplode(j);
+						break;
+					}
 
-      if (j->pt_fuse-- <= 0)
-      {				/* dec the torp fuse. if torp done */
-	j->pt_status = PTFREE;	/* free it up */
-	players[j->pt_owner].p_nplasmatorp--;	/* dec p-torps fired */
-	break;
-      }
-
-      if ((terrain_grid[(int) (j->pt_x) / TGRID_GRANULARITY * TGRID_SIZE +
-			(int) (j->pt_y) / TGRID_GRANULARITY].types
-	   & T_ASTEROIDS) &&
-	  ast_effect[SS_PLASMA])
-	if (PLASMA_HIT_AST > (lrand48() % 100))
-	{
-	  pexplode(j);
-	  break;
-	}
-
-      if ((sun_effect[SS_PLASMA] && weap_near_object(&j->pt_base, PLSTAR, ORBDIST))
-	  ||
-	  (sun_effect[SS_PLASMA] && weap_near_object(&j->pt_base, PLWHOLE, ORBDIST))
-      /* did it hit a star? */
-	  || pnear(j) /* or a player */ )
-      {
-	pexplode(j);
-      }
-      break;			/* on to next torp */
-     case PTDET:		/* if torp was detted */
-      pexplode(j);		/* make it explode */
-      break;			/* on to next torp */
-     case PTEXPLODE:		/* if torp is exploding */
-      if (j->pt_fuse-- <= 0)
-      {				/* dec the timer until torp dead */
-	j->pt_status = PTFREE;	/* set the torp free is timer zero */
-	players[j->pt_owner].p_nplasmatorp--;	/* dec ptorps fired by player */
-      }
-      break;
-     default:			/* Shouldn't happen */
-      j->pt_status = PTFREE;	/* free torp if it got screwed */
-      break;			/* on to next torp */
+				if ((sun_effect[SS_PLASMA] && weap_near_object(&j->pt_base, PLSTAR, ORBDIST))
+						||
+						(sun_effect[SS_PLASMA] && weap_near_object(&j->pt_base, PLWHOLE, ORBDIST))
+						/* did it hit a star? */
+						|| pnear(j) /* or a player */ )
+				{
+					pexplode(j);
+				}
+				break;			/* on to next torp */
+			case PTDET:		/* if torp was detted */
+				pexplode(j);		/* make it explode */
+				break;			/* on to next torp */
+			case PTEXPLODE:		/* if torp is exploding */
+				if (j->pt_fuse-- <= 0)
+				{				/* dec the timer until torp dead */
+					j->pt_status = PTFREE;	/* set the torp free is timer zero */
+					players[j->pt_owner].p_nplasmatorp--;	/* dec ptorps fired by player */
+				}
+				break;
+			default:			/* Shouldn't happen */
+				j->pt_status = PTFREE;	/* free torp if it got screwed */
+				break;			/* on to next torp */
     }
   }
 }