[net.sources.games] sonic screwdriver patch for robots

bryan@utep-vaxa.UUCP (Bryan R. Davies) (06/12/85)

Well, here is the patch to install the "Sonic Screwdriver" option to robots.
Note that all the routines are surrounded by #ifdef's so you can easily turn
off the sonic screwdriver option by undefining the SCREWDRIVERS preprocessor
variable.

This patch can be installed easily using patch(1).

If you have any suggestions, comments, flames, or whatever, send them to:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Welcome to the machine."         Bryan R. Davies
             (Pink Floyd)         {whatever}!ihnp4!ut-sally!utep!bryan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: robots.c
*** robots.c.old	Fri Jun  7 14:43:54 1985
--- robots.c	Sun Jun  9 16:38:08 1985
***************
*** 10,15
  
  /* 1.7a modified by Stephen J. Muir at Lancaster University. */
  
  # include <curses.h>
  # include <signal.h>
  # include <pwd.h>

--- 10,19 -----
  
  /* 1.7a modified by Stephen J. Muir at Lancaster University. */
  
+ /*
+  *  Sonic Screwdriver added by Bryan R. Davies at the Univ. of Texas at El Paso
+  */
+ 
  # include <curses.h>
  # include <signal.h>
  # include <pwd.h>
***************
*** 21,26
  # define MIN_VALUE	10
  # define MAX_FREE	3
  
  # define VERT	'|'
  # define HORIZ	'-'
  # define ROBOT	'='

--- 25,35 -----
  # define MIN_VALUE	10
  # define MAX_FREE	3
  
+ # define SCREWDRIVERS
+ #ifdef SCREWDRIVERS
+ # define SSKEY			'z'
+ #endif SCREWDRIVERS
+ 
  # define VERT	'|'
  # define HORIZ	'-'
  # define ROBOT	'='
***************
*** 267,272
  			first_move = TRUE;
  		case 't':
  		case 'T':
  		case 's':
  		case 'S':
  		case 'm':

--- 270,281 -----
  			first_move = TRUE;
  		case 't':
  		case 'T':
+ 
+ #ifdef SCREWDRIVERS
+                 case SSKEY:
+                 case (SSKEY - 'a' + 'A'):
+ #endif SCREWDRIVERS
+ 
  		case 's':
  		case 'S':
  		case 'm':
***************
*** 291,296
  	case 'n':
  		do_move(cmd_ch);
  		break;
  	case 't':
  	case 'T':
  	teleport:

--- 300,318 -----
  	case 'n':
  		do_move(cmd_ch);
  		break;
+ 
+ #ifdef SCREWDRIVERS
+         case SSKEY:
+         case (SSKEY - 'a' + 'A'):
+                 if(free_teleports > 0) {
+                      sonic_screwdriver();
+                      free_teleports--;
+                      return;
+                 }
+                 bad_move = TRUE;
+                 break;
+ #endif SCREWDRIVERS
+ 
  	case 't':
  	case 'T':
  	teleport:
***************
*** 449,454
  		}
  	}
  }
  
  good_moves()
  {

--- 471,506 -----
  		}
  	}
  }
+ 
+ #ifdef SCREWDRIVERS
+ sonic_screwdriver()
+ {
+         int xtemp, ytemp;
+         struct robot	*r, *end;
+ 
+         end = &robot_list[max_robots];
+ 
+ 	for(r = robot_list; r < end; r++) {
+ 		if(r->alive) {
+ 		xtemp =	( r->x + sign(my_x-r->x) ) - my_x;
+ 		ytemp =	( r->y + sign(my_y-r->y) ) - my_y;
+ 
+                 xtemp = ( xtemp < 0 ) ? -xtemp : xtemp;
+                 ytemp = ( ytemp < 0 ) ? -ytemp : ytemp;
+ 
+ 
+                      if( ( xtemp <= 0 ) && ( ytemp <= 0 ) ) {
+ 		          r->alive = FALSE;
+                           if ( free_per_level > 1 ) free_per_level--;
+ 			  robots_alive--;
+ 			  move(r->y,r->x);
+ 			  winch(stdscr);
+                           addch(SCRAP);
+                      }
+ 		}
+ 	}
+ }
+ #endif SCREWDRIVERS
  
  good_moves()
  {

Index: robots.6
*** robots.6.old	Thu Jun  6 11:16:41 1985
--- robots.6	Sun Jun  9 16:40:13 1985
***************
*** 37,42
  Move down and right.
  .IP .
  Do nothing.
  .IP t
  Teleport.
  .IP s

--- 37,44 -----
  Move down and right.
  .IP .
  Do nothing.
+ .IP z
+ Zap robots with sonic screwdriver.
  .IP t
  Teleport using sonic screwdriver.
  .IP s
***************
*** 38,44
  .IP .
  Do nothing.
  .IP t
! Teleport.
  .IP s
  Sit and watch.
  .IP d

--- 40,46 -----
  .IP z
  Zap robots with sonic screwdriver.
  .IP t
! Teleport using sonic screwdriver.
  .IP s
  Sit and watch.
  .IP d
***************
*** 65,73
  Scores are printed out at the end of the game.
  The scores can be printed out with the '\-s' argument.
  .SH NOTES
! At the start of each level, you have a number of
! .I free teleports.
! These are teleports which are
  .I guaranteed
  not to land you next to a robot.
  The number you have remaining is shown at the bottom left-hand corner

--- 67,87 -----
  Scores are printed out at the end of the game.
  The scores can be printed out with the '\-s' argument.
  .SH NOTES
! You posses a
! .I sonic screwdriver
! which, at the start of each level, has a number of charges.
! The sonic screwdriver can be used to
! .I zap
! robots immediately
! next to you into scrap heaps.  This takes a "turn" so all
! robots not affected will move one step toward you.  You can
! also
! .I teleport
! with the sonic screwdriver at any time, regardless of how many
! charges are left.  If the screwdriver is charged, the teleport
! is a
! .I free teleport,
! which means that it is
  .I guaranteed
  not to land you next to a robot.  Otherwise, you take your chances.
  .PP
***************
*** 69,87
  .I free teleports.
  These are teleports which are
  .I guaranteed
! not to land you next to a robot.
! The number you have remaining is shown at the bottom left-hand corner
! of the screen within angled brakets.
! At the start of the level, you are given one, two or three free teleports.
! This number starts off as one and increases as follows.
! If you have one free teleport per level, and you save it,
! you will get two per level.
! If you have two (or more) free teleports, and you save them both,
! you will get three per level.
! If you have two free teleports, and you save one of them,
! you have a 50% chance of getting three per level.
! Where there are two numbers, the second indicates free teleports saved from
! the previous level.
  .SH FILES
  .nf
  /usr/games/lib/robots_tmp	this week's best scores

--- 83,100 -----
  .I free teleport,
  which means that it is
  .I guaranteed
! not to land you next to a robot.  Otherwise, you take your chances.
! .PP
! The number of charges your sonic screwdriver has remaining is shown
! at the bottom of the screen within angled brackets.  At the start
! of each level, you are given one, two, or three charges.  This number
! starts off as one and increases as follows:  If you have one charge
! per level, and you save it, you will get two per level.  If you have
! two (or more) charges, and you save them both, you will get three
! per level.  If you have two charges, and you save one of them, you
! have a 50% chance of getting three per level.  Where there are two
! numbers within the angled brackets, the second indicates charges
! saved from the previous level.
  .SH FILES
  .nf
  /usr/games/lib/robots_tmp	this week's best scores
-- 

"Welcome to the machine."         Bryan R. Davies
             (Pink Floyd)         {whatever}!ihnp4!ut-sally!utep!bryan

twb@hoqam.UUCP (BEATTIE) (06/13/85)

> Well, here is the patch to install the "Sonic Screwdriver" option to robots.
> 
> This patch can be installed easily using patch(1).
> 
I don't know what patch(1) is, can someone post it or mail it??
Please.
Thanks,
Tom.
..!hou2g!hoqam!twb
Slurm - n. The slime that accumulates on the underside of a soap bar
when it sits in the dish too long.