1: /*
   2:  * Copyright (c) 1983 Regents of the University of California,
   3:  * All rights reserved.  Redistribution permitted subject to
   4:  * the terms of the Berkeley Software License Agreement.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)com1.c	1.3 4/24/85";
   9: #endif
  10: 
  11: #include "externs.h"
  12: 
  13: move(thataway, token)
  14: int thataway, token;
  15: {
  16:     wordnumber++;
  17:     if ((!notes[CANTMOVE] && !notes[LAUNCHED]) || testbit(location[position].objects, LAND) || fuel > 0 && notes[LAUNCHED])
  18:         if (thataway) {
  19:             position = thataway;
  20:             newway(token);
  21:             time++;
  22:         }
  23:         else {
  24:             puts("You can't go this way.");
  25:             newway(token);
  26:             whichway(location[position]);
  27:             return(0);
  28:         }
  29:     else if (notes[CANTMOVE] && !notes[LAUNCHED])
  30:         puts("You aren't able to move; you better drop something.");
  31:     else
  32:         puts("You are out of fuel; now you will rot in space forever!");
  33:     return(1);
  34: }
  35: 
  36: convert(tothis)     /* Converts day to night and vice versa. 	    */
  37: int tothis;     /* Day objects are permanent.  Night objects are added*/
  38: {           /* at dusk, and subtracted at dawn.		*/
  39:     register struct objs *p;
  40:     register i, j;
  41: 
  42:     if (tothis == TONIGHT) {
  43:         for (i = 1; i <= NUMOFROOMS; i++)
  44:             for (j = 0; j < NUMOFWORDS; j++)
  45:                 nightfile[i].objects[j] = dayfile[i].objects[j];
  46:         for (p = nightobjs; p->room != 0; p++)
  47:             setbit(nightfile[p->room].objects, p->obj);
  48:         location = nightfile;
  49:     } else {
  50:         for (i = 1; i <= NUMOFROOMS; i++)
  51:             for (j = 0; j < NUMOFWORDS; j++)
  52:                 dayfile[i].objects[j] = nightfile[i].objects[j];
  53:         for (p = nightobjs; p->room != 0; p++)
  54:             clearbit(dayfile[p->room].objects, p->obj);
  55:         location = dayfile;
  56:     }
  57: }
  58: 
  59: news()
  60: {
  61:     register int n;
  62:     int hurt;
  63: 
  64:     if (time > 30 && position < 32){
  65:         puts("An explosion of shuddering magnitude splinters bulkheads and");
  66:         puts("ruptures the battlestar's hull.  You are sucked out into the");
  67:         puts("frozen void of space and killed.");
  68:         die();
  69:     }
  70:     if (time > 20 && position < 32)
  71:         puts("Explosions rock the battlestar.");
  72:     if (time > snooze){
  73:         puts("You drop from exhaustion...");
  74:         zzz();
  75:     }
  76:     if (time > snooze - 5)
  77:         puts("You're getting tired.");
  78:     if (time > (rythmn + CYCLE)) {
  79:         if (location == nightfile) {
  80:             convert(TODAY);
  81:             if (OUTSIDE && time - rythmn - CYCLE < 10) {
  82:                 puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn.");
  83:                 puts("You awake from a misty dream-world into stark reality.");
  84:                 puts("It is day.");
  85:             }
  86:         } else {
  87:             convert(TONIGHT);
  88:             clearbit(location[POOLS].objects, BATHGOD);
  89:             if (OUTSIDE && time - rythmn - CYCLE < 10) {
  90:                 puts("The dying sun sinks into the ocean, leaving a blood stained sunset.");
  91:                 puts("The sky slowly fades from orange to violet to black.  A few stars");
  92:                 puts("flicker on, and it is night.");
  93:                 puts("The world seems completly different at night.");
  94:             }
  95:         }
  96:         rythmn = time - time % CYCLE;
  97:     }
  98:     if (!wiz && !tempwiz)
  99:         if ((testbit(inven,TALISMAN) || testbit(wear,TALISMAN)) && (testbit(inven,MEDALION) || testbit(wear,MEDALION)) && (testbit(inven,AMULET) || testbit(wear,AMULET))){
 100:             tempwiz = 1;
 101:             puts("The three amulets glow and reenforce each other in power.\nYou are now a wizard.");
 102:     }
 103:     if (testbit(location[position].objects,ELF)){
 104:         printf("%s\n",objdes[ELF]);
 105:         fight(ELF,rnd(30));
 106:     }
 107:     if (testbit(location[position].objects,DARK)){
 108:         printf("%s\n",objdes[DARK]);
 109:         fight(DARK,100);
 110:     }
 111:     if (testbit(location[position].objects,WOODSMAN)){
 112:         printf("%s\n",objdes[WOODSMAN]);
 113:         fight(WOODSMAN,50);
 114:     }
 115:     switch(position){
 116: 
 117:         case 267:
 118:         case 257:   /* entering a cave */
 119:         case 274:
 120:         case 246:
 121:             notes[CANTSEE] = 1;
 122:             break;
 123:         case 160:
 124:         case 216:   /* leaving a cave */
 125:         case 230:
 126:         case 231:
 127:         case 232:
 128:             notes[CANTSEE] = 0;
 129:             break;
 130:     }
 131:     if (testbit(location[position].objects, GIRL))
 132:         meetgirl = 1;
 133:     if (meetgirl && CYCLE * 1.5 - time < 10){
 134:         setbit(location[GARDEN].objects,GIRLTALK);
 135:         setbit(location[GARDEN].objects,LAMPON);
 136:         setbit(location[GARDEN].objects,ROPE);
 137:     }
 138:     if (position == DOCK && (beenthere[position] || time > CYCLE)){
 139:         clearbit(location[DOCK].objects, GIRL);
 140:         clearbit(location[DOCK].objects,MAN);
 141:     }
 142:     if (meetgirl && time - CYCLE * 1.5 > 10){
 143:         clearbit(location[GARDEN].objects,GIRLTALK);
 144:         clearbit(location[GARDEN].objects,LAMPON);
 145:         clearbit(location[GARDEN].objects,ROPE);
 146:         meetgirl = 0;
 147:     }
 148:     if (testbit(location[position].objects,CYLON)){
 149:         puts("Oh my God, you're being shot at by an alien spacecraft!");
 150:         printf("The targeting computer says we have %d seconds to attack!\n",clock);
 151:         fflush(stdout);
 152:         sleep(1);
 153:         if (!visual()){
 154:             hurt = rnd(NUMOFINJURIES);
 155:             injuries[hurt] = 1;
 156:             puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll.");
 157:             puts("The viper shudders under a terrible explosion.");
 158:             printf("I'm afraid you have suffered %s.\n", ouch[hurt]);
 159:         }
 160:         else
 161:             clearbit(location[position].objects,CYLON);
 162:     }
 163:     if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){
 164:         puts("I'm afraid you have suffered fatal injuries.");
 165:         die();
 166:     }
 167:     for (n=0; n < NUMOFINJURIES; n++)
 168:         if (injuries[n] == 1){
 169:             injuries[n] = 2;
 170:             if (WEIGHT > 5)
 171:                 WEIGHT -= 5;
 172:             else
 173:                 WEIGHT = 0;
 174:         }
 175:     if (injuries[ARM] == 2){
 176:         CUMBER -= 5;
 177:         injuries[ARM]++;
 178:     }
 179:     if (injuries[RIBS] == 2){
 180:         CUMBER -= 2;
 181:         injuries[RIBS]++;
 182:     }
 183:     if (injuries[SPINE] == 2){
 184:         WEIGHT = 0;
 185:         injuries[SPINE]++;
 186:     }
 187:     if (carrying > WEIGHT || encumber > CUMBER)
 188:         notes[CANTMOVE] = 1;
 189:     else
 190:         notes[CANTMOVE] = 0;
 191: }
 192: 
 193: crash()
 194: {
 195:     int hurt1,hurt2;
 196: 
 197:     fuel--;
 198:     if (!location[position].flyhere || (testbit(location[position].objects,LAND) && fuel <= 0)){
 199:         if (!location[position].flyhere)
 200:             puts("You're flying too low.  We're going to crash!");
 201:         else{
 202:             puts("You're out of fuel.  We'll have to crash land!");
 203:             if (!location[position].down){
 204:                 puts("Your viper strikes the ground and explodes into firey fragments.");
 205:                 puts("Thick black smoke billows up from the wreckage.");
 206:                 die();
 207:             }
 208:             position = location[position].down;
 209:         }
 210:         notes[LAUNCHED] = 0;
 211:         setbit(location[position].objects,CRASH);
 212:         time += rnd(CYCLE/4);
 213:         puts("The viper explodes into the ground and you lose consciousness...");
 214:         zzz();
 215:         hurt1 = rnd(NUMOFINJURIES - 2) + 2;
 216:         hurt2 = rnd(NUMOFINJURIES - 2) + 2;
 217:         injuries[hurt1] = 1;
 218:         injuries[hurt2] = 1;
 219:         injuries[0] = 1;    /* abrasions */
 220:         injuries[1] = 1;    /* lacerations */
 221:         printf("I'm afraid you have suffered %s and %s.\n",ouch[hurt1],ouch[hurt2]);
 222:     }
 223: }

Defined functions

convert defined in line 36; used 2 times
move defined in line 13; used 11 times
news defined in line 59; used 1 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-04-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1526
Valid CSS Valid XHTML 1.0 Strict