1 /* @(#)com1.c 8.2 (Berkeley) 4/28/95 */
2 /* $NetBSD: command1.c,v 1.5 2012/06/19 05:46:08 dholland Exp $ */
5 * Copyright (c) 1983, 1993
6 * The Regents of the University of California. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 static void convert(int);
38 moveplayer(int thataway, int token)
41 if ((!notes[CANTMOVE] && !notes[LAUNCHED]) ||
42 testbit(location[position].objects, LAND) ||
43 (fuel > 0 && notes[LAUNCHED])) {
49 puts("You can't go this way.");
51 whichway(location[position]);
55 if (notes[CANTMOVE] && !notes[LAUNCHED]) {
56 printf("You aren't able to move; you better drop ");
59 printf("You are out of fuel; ");
60 puts("now you will rot in space forever!");
66 /* Converts day to night and vice versa. */
73 if (tothis == TONIGHT) {
74 for (i = 1; i <= NUMOFROOMS; i++)
75 for (j = 0; j < NUMOFWORDS; j++)
76 nightfile[i].objects[j] = dayfile[i].objects[j];
77 for (p = nightobjs; p->room != 0; p++)
78 setbit(nightfile[p->room].objects, p->obj);
81 for (i = 1; i <= NUMOFROOMS; i++)
82 for (j = 0; j < NUMOFWORDS; j++)
83 dayfile[i].objects[j] = nightfile[i].objects[j];
84 for (p = nightobjs; p->room != 0; p++)
85 clearbit(dayfile[p->room].objects, p->obj);
96 if (ourtime > 30 && position < 32) {
97 printf("An explosion of shuddering magnitude splinters ");
98 puts("bulkheads and");
99 printf("ruptures the battlestar's hull. You are sucked out ");
101 puts("frozen void of space and killed.");
104 if (ourtime > 20 && position < 32)
105 puts("Explosions rock the battlestar.");
106 if (ourtime > snooze) {
107 puts("You drop from exhaustion...");
110 if (ourtime > snooze - 5)
111 puts("You're getting tired.");
112 if (ourtime > (rythmn + CYCLE)) {
113 if (location == nightfile) {
115 if (OUTSIDE && ourtime - rythmn - CYCLE < 10) {
116 printf("Dew lit sunbeams stretch out from a ");
117 puts("watery sunrise and herald the dawn.");
118 printf("You awake from a misty dream-world ");
119 puts("into stark reality.");
124 clearbit(location[POOLS].objects, BATHGOD);
125 if (OUTSIDE && ourtime - rythmn - CYCLE < 10) {
126 printf("The dying sun sinks into the ocean, ");
127 puts("leaving a blood-stained sunset.");
128 printf("The sky slowly fades from orange to ");
129 puts("violet to black. A few stars");
130 puts("flicker on, and it is night.");
131 printf("The world seems completely different ");
135 rythmn = ourtime - ourtime % CYCLE;
137 if (!wiz && !tempwiz)
138 if ((testbit(inven, TALISMAN) || testbit(wear, TALISMAN)) &&
139 (testbit(inven, MEDALION) || testbit(wear, MEDALION)) &&
140 (testbit(inven, AMULET) || testbit(wear, AMULET))) {
142 printf("The three amulets glow and reenforce each ");
143 puts("other in power.\nYou are now a wizard.");
145 if (testbit(location[position].objects, ELF)) {
146 printf("%s\n", objdes[ELF]);
149 if (testbit(location[position].objects, DARK)) {
150 printf("%s\n", objdes[DARK]);
153 if (testbit(location[position].objects, WOODSMAN)) {
154 printf("%s\n", objdes[WOODSMAN]);
160 case 257: /* entering a cave */
166 case 216: /* leaving a cave */
173 if (testbit(location[position].objects, GIRL))
175 if (meetgirl && CYCLE * 1.5 - ourtime < 10) {
176 setbit(location[GARDEN].objects, GIRLTALK);
177 setbit(location[GARDEN].objects, LAMPON);
178 setbit(location[GARDEN].objects, ROPE);
180 if (position == DOCK && (beenthere[position] || ourtime > CYCLE)) {
181 clearbit(location[DOCK].objects, GIRL);
182 clearbit(location[DOCK].objects, MAN);
184 if (meetgirl && ourtime - CYCLE * 1.5 > 10) {
185 clearbit(location[GARDEN].objects, GIRLTALK);
186 clearbit(location[GARDEN].objects, LAMPON);
187 clearbit(location[GARDEN].objects, ROPE);
190 if (testbit(location[position].objects, CYLON)) {
191 puts("Oh my God, you're being shot at by an alien spacecraft!");
192 printf("The targeting computer says we have %d seconds ",
194 printf("to attack!\n");
198 hurt = rnd(NUMOFINJURIES);
200 printf("Laser blasts sear the cockpit, and the alien ");
201 puts("veers off in a victory roll.");
202 puts("The viper shudders under a terrible explosion.");
203 printf("I'm afraid you have suffered %s.\n",
206 clearbit(location[position].objects, CYLON);
208 if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]) {
209 puts("I'm afraid you have suffered fatal injuries.");
212 for (n = 0; n < NUMOFINJURIES; n++)
213 if (injuries[n] == 1) {
220 if (injuries[ARM] == 2) {
227 if (injuries[RIBS] == 2) {
234 if (injuries[SPINE] == 2) {
238 if (carrying > WEIGHT || encumber > CUMBER)
250 if (!location[position].flyhere ||
251 (testbit(location[position].objects, LAND) && fuel <= 0)) {
252 if (!location[position].flyhere)
253 puts("You're flying too low. We're going to crash!");
255 puts("You're out of fuel. We'll have to crash land!");
256 if (!location[position].down) {
257 printf("Your viper strikes the ground and ");
258 puts("explodes into fiery fragments.");
259 printf("Thick black smoke billows up from the");
263 position = location[position].down;
266 setbit(location[position].objects, CRASH);
267 ourtime += rnd(CYCLE / 4);
268 printf("The viper explodes into the ground and you lose ");
269 puts("consciousness...");
271 hurt1 = rnd(NUMOFINJURIES - 2) + 2;
272 hurt2 = rnd(NUMOFINJURIES - 2) + 2;
275 injuries[0] = 1;/* abrasions */
276 injuries[1] = 1;/* lacerations */
277 printf("I'm afraid you have suffered %s and %s.\n",
278 ouch[hurt1], ouch[hurt2]);