1 /* $NetBSD: command1.c,v 1.3 2005/07/01 06:04:54 jmc Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)com1.c 8.2 (Berkeley) 4/28/95";
37 __RCSID("$NetBSD: command1.c,v 1.3 2005/07/01 06:04:54 jmc Exp $");
43 static void convert(int);
46 moveplayer(int thataway
, int token
)
49 if ((!notes
[CANTMOVE
] && !notes
[LAUNCHED
]) ||
50 testbit(location
[position
].objects
, LAND
) ||
51 (fuel
> 0 && notes
[LAUNCHED
])) {
57 puts("You can't go this way.");
59 whichway(location
[position
]);
63 if (notes
[CANTMOVE
] && !notes
[LAUNCHED
]) {
64 printf("You aren't able to move; you better drop ");
67 printf("You are out of fuel; ");
68 puts("now you will rot in space forever!");
74 /* Converts day to night and vice versa. */
81 if (tothis
== TONIGHT
) {
82 for (i
= 1; i
<= NUMOFROOMS
; i
++)
83 for (j
= 0; j
< NUMOFWORDS
; j
++)
84 nightfile
[i
].objects
[j
] = dayfile
[i
].objects
[j
];
85 for (p
= nightobjs
; p
->room
!= 0; p
++)
86 setbit(nightfile
[p
->room
].objects
, p
->obj
);
89 for (i
= 1; i
<= NUMOFROOMS
; i
++)
90 for (j
= 0; j
< NUMOFWORDS
; j
++)
91 dayfile
[i
].objects
[j
] = nightfile
[i
].objects
[j
];
92 for (p
= nightobjs
; p
->room
!= 0; p
++)
93 clearbit(dayfile
[p
->room
].objects
, p
->obj
);
104 if (ourtime
> 30 && position
< 32) {
105 printf("An explosion of shuddering magnitude splinters ");
106 puts("bulkheads and");
107 printf("ruptures the battlestar's hull. You are sucked out ");
109 puts("frozen void of space and killed.");
112 if (ourtime
> 20 && position
< 32)
113 puts("Explosions rock the battlestar.");
114 if (ourtime
> snooze
) {
115 puts("You drop from exhaustion...");
118 if (ourtime
> snooze
- 5)
119 puts("You're getting tired.");
120 if (ourtime
> (rythmn
+ CYCLE
)) {
121 if (location
== nightfile
) {
123 if (OUTSIDE
&& ourtime
- rythmn
- CYCLE
< 10) {
124 printf("Dew lit sunbeams stretch out from a ");
125 puts("watery sunrise and herald the dawn.");
126 printf("You awake from a misty dream-world ");
127 puts("into stark reality.");
132 clearbit(location
[POOLS
].objects
, BATHGOD
);
133 if (OUTSIDE
&& ourtime
- rythmn
- CYCLE
< 10) {
134 printf("The dying sun sinks into the ocean, ");
135 puts("leaving a blood-stained sunset.");
136 printf("The sky slowly fades from orange to ");
137 puts("violet to black. A few stars");
138 puts("flicker on, and it is night.");
139 printf("The world seems completely different ");
143 rythmn
= ourtime
- ourtime
% CYCLE
;
145 if (!wiz
&& !tempwiz
)
146 if ((testbit(inven
, TALISMAN
) || testbit(wear
, TALISMAN
)) &&
147 (testbit(inven
, MEDALION
) || testbit(wear
, MEDALION
)) &&
148 (testbit(inven
, AMULET
) || testbit(wear
, AMULET
))) {
150 printf("The three amulets glow and reenforce each ");
151 puts("other in power.\nYou are now a wizard.");
153 if (testbit(location
[position
].objects
, ELF
)) {
154 printf("%s\n", objdes
[ELF
]);
157 if (testbit(location
[position
].objects
, DARK
)) {
158 printf("%s\n", objdes
[DARK
]);
161 if (testbit(location
[position
].objects
, WOODSMAN
)) {
162 printf("%s\n", objdes
[WOODSMAN
]);
168 case 257: /* entering a cave */
174 case 216: /* leaving a cave */
181 if (testbit(location
[position
].objects
, GIRL
))
183 if (meetgirl
&& CYCLE
* 1.5 - ourtime
< 10) {
184 setbit(location
[GARDEN
].objects
, GIRLTALK
);
185 setbit(location
[GARDEN
].objects
, LAMPON
);
186 setbit(location
[GARDEN
].objects
, ROPE
);
188 if (position
== DOCK
&& (beenthere
[position
] || ourtime
> CYCLE
)) {
189 clearbit(location
[DOCK
].objects
, GIRL
);
190 clearbit(location
[DOCK
].objects
, MAN
);
192 if (meetgirl
&& ourtime
- CYCLE
* 1.5 > 10) {
193 clearbit(location
[GARDEN
].objects
, GIRLTALK
);
194 clearbit(location
[GARDEN
].objects
, LAMPON
);
195 clearbit(location
[GARDEN
].objects
, ROPE
);
198 if (testbit(location
[position
].objects
, CYLON
)) {
199 puts("Oh my God, you're being shot at by an alien spacecraft!");
200 printf("The targeting computer says we have %d seconds ",
202 printf("to attack!\n");
206 hurt
= rnd(NUMOFINJURIES
);
208 printf("Laser blasts sear the cockpit, and the alien ");
209 puts("veers off in a victory roll.");
210 puts("The viper shudders under a terrible explosion.");
211 printf("I'm afraid you have suffered %s.\n",
214 clearbit(location
[position
].objects
, CYLON
);
216 if (injuries
[SKULL
] && injuries
[INCISE
] && injuries
[NECK
]) {
217 puts("I'm afraid you have suffered fatal injuries.");
220 for (n
= 0; n
< NUMOFINJURIES
; n
++)
221 if (injuries
[n
] == 1) {
228 if (injuries
[ARM
] == 2) {
235 if (injuries
[RIBS
] == 2) {
242 if (injuries
[SPINE
] == 2) {
246 if (carrying
> WEIGHT
|| encumber
> CUMBER
)
258 if (!location
[position
].flyhere
||
259 (testbit(location
[position
].objects
, LAND
) && fuel
<= 0)) {
260 if (!location
[position
].flyhere
)
261 puts("You're flying too low. We're going to crash!");
263 puts("You're out of fuel. We'll have to crash land!");
264 if (!location
[position
].down
) {
265 printf("Your viper strikes the ground and ");
266 puts("explodes into fiery fragments.");
267 printf("Thick black smoke billows up from the");
271 position
= location
[position
].down
;
274 setbit(location
[position
].objects
, CRASH
);
275 ourtime
+= rnd(CYCLE
/ 4);
276 printf("The viper explodes into the ground and you lose ");
277 puts("consciousness...");
279 hurt1
= rnd(NUMOFINJURIES
- 2) + 2;
280 hurt2
= rnd(NUMOFINJURIES
- 2) + 2;
283 injuries
[0] = 1;/* abrasions */
284 injuries
[1] = 1;/* lacerations */
285 printf("I'm afraid you have suffered %s and %s.\n",
286 ouch
[hurt1
], ouch
[hurt2
]);