home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / games / battlestar / com2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-08  |  9.1 KB  |  297 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[] = "@(#)com2.c    5.3 (Berkeley) 6/1/90";
  36. #endif /* not lint */
  37.  
  38. #include "externs.h"
  39.  
  40. wearit()        /* synonyms = {sheathe, sheath} */
  41. {
  42.     register int n;
  43.     int firstnumber, value;
  44.  
  45.     firstnumber = wordnumber;
  46.     while(wordtype[++wordnumber] == ADJS);
  47.     while(wordnumber <= wordcount){
  48.         value = wordvalue[wordnumber];
  49.         for (n=0; objsht[value][n]; n++);
  50.         switch(value){
  51.             
  52.             case -1:
  53.                 puts("Wear what?");
  54.                 return(firstnumber);
  55.  
  56.             default:
  57.                 printf("You can't wear%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
  58.                 return(firstnumber);
  59.  
  60.             case KNIFE:
  61.         /*    case SHIRT:    */
  62.             case ROBE:
  63.             case LEVIS:    /* wearable things */
  64.             case SWORD:
  65.             case MAIL:
  66.             case HELM:
  67.             case SHOES:
  68.             case PAJAMAS:
  69.             case COMPASS:
  70.             case LASER:
  71.             case AMULET:
  72.             case TALISMAN:
  73.             case MEDALION:
  74.             case ROPE:
  75.             case RING:
  76.             case BRACELET:
  77.             case GRENADE:
  78.  
  79.                 if (testbit(inven,value)){
  80.                     clearbit(inven,value);
  81.                     setbit(wear,value);
  82.                     carrying -= objwt[value];
  83.                     encumber -= objcumber[value];
  84.                     time++;
  85.                     printf("You are now wearing %s %s.\n",(objsht[value][n-1] == 's' ? "the" : "a"), objsht[value]);
  86.                 }
  87.                 else if (testbit(wear,value))
  88.                     printf("You are already wearing the %s.\n", objsht[value]);
  89.                 else 
  90.                     printf("You aren't holding the %s.\n", objsht[value]);
  91.                 if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
  92.                     wordnumber++;
  93.                 else 
  94.                     return(firstnumber);
  95.         } /* end switch */
  96.     } /* end while */
  97.     puts("Don't be ridiculous.");
  98.     return(firstnumber);
  99. }
  100.  
  101. put()        /* synonyms = {buckle, strap, tie} */
  102. {
  103.     if (wordvalue[wordnumber + 1] == ON){
  104.         wordvalue[++wordnumber] = PUTON;
  105.         return(cypher());
  106.     }
  107.     if (wordvalue[wordnumber + 1] == DOWN){
  108.         wordvalue[++wordnumber] = DROP;
  109.         return(cypher());
  110.     }
  111.     puts("I don't understand what you want to put.");
  112.     return(-1);
  113.  
  114. }
  115.  
  116. draw()             /* synonyms = {pull, carry} */
  117. {
  118.     return(take(wear));
  119. }
  120.  
  121. use()
  122. {
  123.     while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount);
  124.     if (wordvalue[wordnumber] == AMULET && testbit(inven,AMULET) && position != FINAL){
  125.         puts("The amulet begins to glow.");
  126.         if (testbit(inven,MEDALION)){
  127.             puts("The medallion comes to life too.");
  128.             if (position == 114){
  129.                 location[position].down = 160;
  130.                 whichway(location[position]);
  131.                 puts("The waves subside and it is possible to descend to the sea cave now.");
  132.                 time++;
  133.                 return(-1);
  134.             }
  135.         }
  136.         puts("A light mist falls over your eyes and the sound of purling water trickles in");
  137.         puts("your ears.   When the mist lifts you are standing beside a cool stream.");
  138.         if (position == 229)
  139.             position = 224;
  140.         else
  141.             position = 229;
  142.         time++;
  143.         return(0);
  144.     }
  145.     else if (position == FINAL)
  146.         puts("The amulet won't work in here.");
  147.     else if (wordvalue[wordnumber] == COMPASS && testbit(inven,COMPASS))
  148.         printf("Your compass points %s.\n",truedirec(NORTH,'-'));
  149.     else if (wordvalue[wordnumber] == COMPASS)
  150.         puts("You aren't holding the compass.");
  151.     else if (wordvalue[wordnumber] == AMULET)
  152.         puts("You aren't holding the amulet.");
  153.     else
  154.         puts("There is no apparent use.");
  155.     return(-1);
  156. }
  157.  
  158. murder()
  159. {
  160.     register int n;
  161.  
  162.     for (n=0; !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || n == HALBERD) && testbit(inven,n)) && n < NUMOFOBJECTS; n++);
  163.     if (n == NUMOFOBJECTS)
  164.         puts("You don't have suitable weapons to kill.");
  165.     else {
  166.         printf("Your %s should do the trick.\n",objsht[n]);
  167.         while (wordtype[++wordnumber] == ADJS);
  168.         switch(wordvalue[wordnumber]){
  169.             
  170.             case NORMGOD:
  171.                 if (testbit(location[position].objects,BATHGOD)){
  172.                     puts("The goddess's head slices off.  Her corpse floats in the water.");
  173.                     clearbit(location[position].objects,BATHGOD);
  174.                     setbit(location[position].objects,DEADGOD);
  175.                     power += 5;
  176.                     notes[JINXED]++;
  177.                 } else if (testbit(location[position].objects,NORMGOD)){
  178.                     puts("The goddess pleads but you strike her mercilessly.  Her broken body lies in a\npool of blood.");
  179.                     clearbit(location[position].objects,NORMGOD);
  180.                     setbit(location[position].objects,DEADGOD);
  181.                     power += 5;
  182.                     notes[JINXED]++;
  183.                     if (wintime)
  184.                         live();
  185.                 } else puts("I dont see her anywhere.");
  186.                 break;
  187.             case TIMER:
  188.                 if (testbit(location[position].objects,TIMER)){
  189.                     puts("The old man offers no resistance.");
  190.                     clearbit(location[position].objects,TIMER);
  191.                     setbit(location[position].objects,DEADTIME);
  192.                     power++;
  193.                     notes[JINXED]++;
  194.                 } else puts("Who?");
  195.                 break;
  196.             case NATIVE:
  197.                 if (testbit(location[position].objects,NATIVE)){
  198.                     puts("The girl screams as you cut her body to shreds.  She is dead.");
  199.                     clearbit(location[position].objects,NATIVE);
  200.                     setbit(location[position].objects,DEADNATIVE);
  201.                     power += 5;
  202.                     notes[JINXED]++;
  203.                 } else puts("What girl?");
  204.                 break;
  205.             case MAN:
  206.                 if (testbit(location[position].objects,MAN)){
  207.                     puts("You strike him to the ground, and he coughs up blood.");
  208.                     puts("Your fantasy is over.");
  209.                     die();
  210.                 }
  211.             case -1:
  212.                 puts("Kill what?");
  213.                 break;
  214.  
  215.             default:
  216.                 if (wordtype[wordnumber] != NOUNS)
  217.                     puts("Kill what?");
  218.                 else
  219.                     printf("You can't kill the %s!\n",objsht[wordvalue[wordnumber]]);
  220.         }
  221.     }
  222. }
  223.  
  224. ravage()
  225. {
  226.     while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
  227.     if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
  228.         time++;
  229.         switch(wordvalue[wordnumber]){
  230.             case NORMGOD:
  231.                 puts("You attack the goddess, and she screams as you beat her.  She falls down");
  232.                 puts("crying and tries to hold her torn and bloodied dress around her.");
  233.                 power += 5;
  234.                 pleasure += 8;
  235.                 ego -= 10;
  236.                 wordnumber--;
  237.                 godready = -30000;
  238.                 murder();
  239.                 win = -30000;
  240.                 break;
  241.             case NATIVE:
  242.                 puts("The girl tries to run, but you catch her and throw her down.  Her face is");
  243.                 puts("bleeding, and she screams as you tear off her clothes.");
  244.                 power += 3;
  245.                 pleasure += 5;
  246.                 ego -= 10;
  247.                 wordnumber--;
  248.                 murder();
  249.                 if (rnd(100) < 50){
  250.                     puts("Her screams have attracted attention.  I think we are surrounded.");
  251.                     setbit(location[ahead].objects,WOODSMAN);
  252.                     setbit(location[ahead].objects,DEADWOOD);
  253.                     setbit(location[ahead].objects,MALLET);
  254.                     setbit(location[back].objects,WOODSMAN);
  255.                     setbit(location[back].objects,DEADWOOD);
  256.                     setbit(location[back].objects,MALLET);
  257.                     setbit(location[left].objects,WOODSMAN);
  258.                     setbit(location[left].objects,DEADWOOD);
  259.                     setbit(location[left].objects,MALLET);
  260.                     setbit(location[right].objects,WOODSMAN);
  261.                     setbit(location[right].objects,DEADWOOD);
  262.                     setbit(location[right].objects,MALLET);
  263.                 }
  264.                 break;
  265.             default:
  266.                 puts("You are perverted.");
  267.         }
  268.     }
  269.     else
  270.         puts("Who?");
  271. }
  272.  
  273. follow()
  274. {
  275.     if (followfight == time){
  276.         puts("The Dark Lord leaps away and runs down secret tunnels and corridoors.");
  277.         puts("You chase him through the darkness and splash in pools of water.");
  278.         puts("You have cornered him.  His laser sword extends as he steps forward.");
  279.         position = FINAL;
  280.         fight(DARK,75);
  281.         setbit(location[position].objects,TALISMAN);
  282.         setbit(location[position].objects,AMULET);
  283.         return(0);
  284.     }
  285.     else if (followgod == time){
  286.         puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
  287.         puts("She sits down on a throne.");
  288.         position = 268;
  289.         setbit(location[position].objects,NORMGOD);
  290.         notes[CANTSEE] = 1;
  291.         return(0);
  292.     }
  293.     else 
  294.         puts("There is no one to follow.");
  295.     return(-1);
  296. }
  297.