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