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