home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / games / battlestar / com3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-08  |  8.9 KB  |  313 lines

  1. /*
  2.  * Copyright (c) 1983 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  */
  33.  
  34. #ifndef lint
  35. static char sccsid[] = "@(#)com3.c    5.3 (Berkeley) 6/1/90";
  36. #endif /* not lint */
  37.  
  38. #include "externs.h"
  39.  
  40. dig()
  41. {
  42.     if (testbit(inven,SHOVEL)){
  43.         puts("OK");
  44.         time++;
  45.         switch(position){
  46.             case 144:        /* copse near beach */
  47.                 if (!notes[DUG]){
  48.                     setbit(location[position].objects,DEADWOOD);
  49.                     setbit(location[position].objects,COMPASS);
  50.                     setbit(location[position].objects,KNIFE);
  51.                     setbit(location[position].objects,MACE);
  52.                     notes[DUG] = 1;
  53.                 }
  54.                 break;
  55.  
  56.             default:
  57.                 puts("Nothing happens.");
  58.         }
  59.     }
  60.     else    
  61.         puts("You don't have a shovel.");
  62. }
  63.  
  64. jump()
  65. {
  66.     register int n;
  67.  
  68.     switch(position){
  69.         default:
  70.             puts("Nothing happens.");
  71.             return(-1);
  72.  
  73.         case 242:
  74.             position = 133;
  75.             break;
  76.         case 214:
  77.         case 215:
  78.         case 162:
  79.         case 159:
  80.             position = 145;
  81.             break;
  82.         case 232:
  83.             position = 275;
  84.             break;
  85.         case 3:
  86.             position = 1;
  87.             break;
  88.         case 172:
  89.             position = 201;
  90.     }
  91.     puts("Ahhhhhhh...");
  92.     injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1;
  93.     for (n=0; n < NUMOFOBJECTS; n++)
  94.         if (testbit(inven,n)){
  95.             clearbit(inven,n);
  96.             setbit(location[position].objects,n);
  97.         }
  98.     carrying = 0;
  99.     encumber = 0;
  100.     return(0);
  101. }
  102.  
  103. bury()
  104. {
  105.     int value;
  106.  
  107.     if (testbit(inven,SHOVEL)){
  108.         while(wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount);
  109.         value = wordvalue[wordnumber];
  110.         if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects,value) || value == BODY))
  111.             switch(value){
  112.                 case BODY:
  113.                     wordtype[wordnumber] = OBJECT;
  114.                     if (testbit(inven,MAID) || testbit(location[position].objects,MAID))
  115.                         value = MAID;
  116.                     if (testbit(inven,DEADWOOD) || testbit(location[position].objects,DEADWOOD))
  117.                         value = DEADWOOD;
  118.                     if (testbit(inven,DEADGOD) || testbit(location[position].objects,DEADGOD))
  119.                         value = DEADGOD;
  120.                     if (testbit(inven,DEADTIME) || testbit(location[position].objects,DEADTIME))
  121.                         value = DEADTIME;
  122.                     if (testbit(inven,DEADNATIVE) || testbit(location[position].objects,DEADNATIVE))
  123.                         value = DEADNATIVE;
  124.                     break;
  125.  
  126.                 case NATIVE:
  127.                 case NORMGOD:
  128.                     puts("She screams as you wrestle her into the hole.");
  129.                 case TIMER:
  130.                     power += 7;
  131.                     ego -= 10;
  132.                 case AMULET:
  133.                 case MEDALION:
  134.                 case TALISMAN:
  135.                     wordtype[wordnumber] = OBJECT;
  136.                     break;
  137.  
  138.                 default:
  139.                     puts("Wha..?");
  140.             }
  141.         if (wordtype[wordnumber] == OBJECT && position > 88 && (testbit(inven,value) || testbit(location[position].objects,value))){
  142.             puts("Buried.");
  143.             if (testbit(inven,value)){
  144.                 clearbit(inven,value);
  145.                 carrying -= objwt[value];
  146.                 encumber -= objcumber[value];
  147.             }
  148.             clearbit(location[position].objects,value);
  149.             switch(value){
  150.                 case MAID:
  151.                 case DEADWOOD:
  152.                 case DEADNATIVE:
  153.                 case DEADTIME:
  154.                 case DEADGOD:
  155.                     ego += 2;
  156.                     printf("The %s should rest easier now.\n",objsht[value]);
  157.             }
  158.         }
  159.         else
  160.             puts("It doesn't seem to work.");
  161.     }
  162.     else
  163.         puts("You aren't holding a shovel.");
  164. }
  165.  
  166. drink()
  167. {
  168.     register int n;
  169.  
  170.     if (testbit(inven,POTION)){
  171.         puts("The cool liquid runs down your throat but turns to fire and you choke.");
  172.         puts("The heat reaches your limbs and tingles your spirit.  You feel like falling");
  173.         puts("asleep.");
  174.         clearbit(inven, POTION);
  175.         WEIGHT = MAXWEIGHT;
  176.         CUMBER = MAXCUMBER;
  177.         for (n=0; n < NUMOFINJURIES; n++)
  178.             injuries[n] = 0;
  179.         time++;
  180.         zzz();
  181.     }
  182.     else
  183.         puts("I'm not thirsty.");
  184. }
  185.  
  186. shoot()
  187. {
  188.     int firstnumber, value;
  189.     register int n;
  190.  
  191.     if (!testbit(inven,LASER))
  192.         puts("You aren't holding a blaster.");
  193.     else {
  194.         firstnumber = wordnumber;
  195.         while(wordtype[++wordnumber] == ADJS);
  196.         while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
  197.             value = wordvalue[wordnumber];
  198.             printf("%s:\n", objsht[value]);
  199.             for (n=0; objsht[value][n]; n++);
  200.             if (testbit(location[position].objects,value)){
  201.                 clearbit(location[position].objects,value);
  202.                 time++;
  203.                 printf("The %s explode%s\n",objsht[value],(objsht[value][n-1]=='s' ? (objsht[value][n-2]=='s' ? "s." : ".") : "s."));
  204.                 if (value == BOMB)
  205.                     die();
  206.             }
  207.             else
  208.                 printf("I dont see any %s around here.\n", objsht[value]);
  209.             if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
  210.                 wordnumber++;
  211.             else
  212.                 return(firstnumber);
  213.         }
  214.                 /* special cases with their own return()'s */
  215.  
  216.         if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS){
  217.             time++;
  218.             switch(wordvalue[wordnumber]){
  219.             
  220.                 case DOOR:
  221.                     switch(position){
  222.                         case 189:
  223.                         case 231:
  224.                             puts("The door is unhinged.");
  225.                             location[189].north = 231;
  226.                             location[231].south = 189;
  227.                             whichway(location[position]);
  228.                             break;
  229.                         case 30:
  230.                             puts("The wooden door splinters.");
  231.                             location[30].west = 25;
  232.                             whichway(location[position]);
  233.                             break;
  234.                         case 31:
  235.                             puts("The laser blast has no effect on the door.");
  236.                             break;
  237.                         case 20:
  238.                             puts("The blast hits the door and it explodes into flame.  The magnesium burns");
  239.                             puts("so rapidly that we have no chance to escape.");
  240.                             die();
  241.                         default:
  242.                             puts("Nothing happens.");
  243.                     }
  244.                     break;
  245.  
  246.                 case NORMGOD:
  247.                     if (testbit(location[position].objects,BATHGOD)){
  248.                         puts("The goddess is hit in the chest and splashes back against the rocks.");
  249.                         puts("Dark blood oozes from the charred blast hole.  Her naked body floats in the");
  250.                         puts("pools and then off downstream.");
  251.                         clearbit(location[position].objects,BATHGOD);
  252.                         setbit(location[180].objects,DEADGOD);
  253.                         power += 5;
  254.                         ego -= 10;
  255.                         notes[JINXED]++;
  256.                     } else if (testbit(location[position].objects,NORMGOD)){
  257.                         puts("The blast catches the goddess in the stomach, knocking her to the ground.");
  258.                         puts("She writhes in the dirt as the agony of death taunts her.");
  259.                         puts("She has stopped moving.");
  260.                         clearbit(location[position].objects,NORMGOD);
  261.                         setbit(location[position].objects,DEADGOD);
  262.                         power += 5;
  263.                         ego -= 10;
  264.                         notes[JINXED]++;
  265.                         if (wintime)
  266.                             live();
  267.                         break;
  268.                     } else
  269.                         puts("I don't see any goddess around here.");
  270.                     break;
  271.  
  272.                 case TIMER:
  273.                     if (testbit(location[position].objects,TIMER)){
  274.                         puts("The old man slumps over the bar.");
  275.                         power++;
  276.                         ego -= 2;
  277.                         notes[JINXED]++;
  278.                         clearbit(location[position].objects,TIMER);
  279.                         setbit(location[position].objects,DEADTIME);
  280.                     }
  281.                     else puts("What old timer?");
  282.                     break;
  283.                 case MAN:
  284.                     if (testbit(location[position].objects,MAN)){
  285.                         puts("The man falls to the ground with blood pouring all over his white suit.");
  286.                         puts("Your fantasy is over.");
  287.                         die();
  288.                     }
  289.                     else puts("What man?");
  290.                     break;
  291.                 case NATIVE:
  292.                     if (testbit(location[position].objects,NATIVE)){
  293.                         puts("The girl is blown backwards several feet and lies in a pool of blood.");
  294.                         clearbit(location[position].objects,NATIVE);
  295.                         setbit(location[position].objects,DEADNATIVE);
  296.                         power += 5;
  297.                         ego -= 2;
  298.                         notes[JINXED]++;
  299.                     } else puts("There is no girl here.");
  300.                     break;
  301.                 case -1:
  302.                     puts("Shoot what?");
  303.                     break;
  304.  
  305.                 default:
  306.                     printf("You can't shoot the %s.\n",objsht[wordvalue[wordnumber]]);
  307.             }
  308.         }
  309.         else puts("You must be a looney.");
  310.     }
  311.     return(firstnumber);
  312. }
  313.