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: #if !defined(lint) && !defined(pdp11)
   8: static char sccsid[] = "@(#)com1.c	1.3.1 1996/10/26";
   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: #ifdef pdp11
 105:         strprt(ELF);
 106: #else
 107:         printf("%s\n",objdes[ELF]);
 108: #endif
 109:         fight(ELF,rnd(30));
 110:     }
 111:     if (testbit(location[position].objects,DARK)){
 112: #ifdef pdp11
 113:         strprt(DARK);
 114: #else
 115:         printf("%s\n",objdes[DARK]);
 116: #endif
 117:         fight(DARK,100);
 118:     }
 119:     if (testbit(location[position].objects,WOODSMAN)){
 120: #ifdef pdp11
 121:         strprt(WOODSMAN);
 122: #else
 123:         printf("%s\n",objdes[WOODSMAN]);
 124: #endif
 125:         fight(WOODSMAN,50);
 126:     }
 127:     switch(position){
 128: 
 129:         case 267:
 130:         case 257:   /* entering a cave */
 131:         case 274:
 132:         case 246:
 133:             notes[CANTSEE] = 1;
 134:             break;
 135:         case 160:
 136:         case 216:   /* leaving a cave */
 137:         case 230:
 138:         case 231:
 139:         case 232:
 140:             notes[CANTSEE] = 0;
 141:             break;
 142:     }
 143:     if (testbit(location[position].objects, GIRL))
 144:         meetgirl = 1;
 145:     if (meetgirl && CYCLE * 1.5 - Time < 10){
 146:         setbit(location[GARDEN].objects,GIRLTALK);
 147:         setbit(location[GARDEN].objects,LAMPON);
 148:         setbit(location[GARDEN].objects,ROPE);
 149:     }
 150:     if (position == DOCK && (beenthere[position] || Time > CYCLE)){
 151:         clearbit(location[DOCK].objects, GIRL);
 152:         clearbit(location[DOCK].objects,MAN);
 153:     }
 154:     if (meetgirl && Time - CYCLE * 1.5 > 10){
 155:         clearbit(location[GARDEN].objects,GIRLTALK);
 156:         clearbit(location[GARDEN].objects,LAMPON);
 157:         clearbit(location[GARDEN].objects,ROPE);
 158:         meetgirl = 0;
 159:     }
 160:     if (testbit(location[position].objects,CYLON)){
 161:         puts("Oh my God, you're being shot at by an alien spacecraft!");
 162:         printf("The targeting computer says we have %d seconds to attack!\n",clock);
 163:         fflush(stdout);
 164:         sleep(1);
 165:         if (!visual()){
 166:             hurt = rnd(NUMOFINJURIES);
 167:             injuries[hurt] = 1;
 168:             puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll.");
 169:             puts("The viper shudders under a terrible explosion.");
 170:             printf("I'm afraid you have suffered %s.\n", ouch[hurt]);
 171:         }
 172:         else
 173:             clearbit(location[position].objects,CYLON);
 174:     }
 175:     if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){
 176:         puts("I'm afraid you have suffered fatal injuries.");
 177:         die();
 178:     }
 179:     for (n=0; n < NUMOFINJURIES; n++)
 180:         if (injuries[n] == 1){
 181:             injuries[n] = 2;
 182:             if (WEIGHT > 5)
 183:                 WEIGHT -= 5;
 184:             else
 185:                 WEIGHT = 0;
 186:         }
 187:     if (injuries[ARM] == 2){
 188:         CUMBER -= 5;
 189:         injuries[ARM]++;
 190:     }
 191:     if (injuries[RIBS] == 2){
 192:         CUMBER -= 2;
 193:         injuries[RIBS]++;
 194:     }
 195:     if (injuries[SPINE] == 2){
 196:         WEIGHT = 0;
 197:         injuries[SPINE]++;
 198:     }
 199:     if (carrying > WEIGHT || encumber > CUMBER)
 200:         notes[CANTMOVE] = 1;
 201:     else
 202:         notes[CANTMOVE] = 0;
 203: }
 204: 
 205: crash()
 206: {
 207:     int hurt1,hurt2;
 208: 
 209:     fuel--;
 210:     if (!location[position].flyhere || (testbit(location[position].objects,LAND) && fuel <= 0)){
 211:         if (!location[position].flyhere)
 212:             puts("You're flying too low.  We're going to crash!");
 213:         else{
 214:             puts("You're out of fuel.  We'll have to crash land!");
 215:             if (!location[position].down){
 216:                 puts("Your viper strikes the ground and explodes into firey fragments.");
 217:                 puts("Thick black smoke billows up from the wreckage.");
 218:                 die();
 219:             }
 220:             position = location[position].down;
 221:         }
 222:         notes[LAUNCHED] = 0;
 223:         setbit(location[position].objects,CRASH);
 224:         Time += rnd(CYCLE/4);
 225:         puts("The viper explodes into the ground and you lose consciousness...");
 226:         zzz();
 227:         hurt1 = rnd(NUMOFINJURIES - 2) + 2;
 228:         hurt2 = rnd(NUMOFINJURIES - 2) + 2;
 229:         injuries[hurt1] = 1;
 230:         injuries[hurt2] = 1;
 231:         injuries[0] = 1;    /* abrasions */
 232:         injuries[1] = 1;    /* lacerations */
 233:         printf("I'm afraid you have suffered %s and %s.\n",ouch[hurt1],ouch[hurt2]);
 234:     }
 235: }

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: 1996-10-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3764
Valid CSS Valid XHTML 1.0 Strict