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