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