1 /* $NetBSD: command6.c,v 1.4 2007/12/15 19:44:39 perry 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
[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95";
37 __RCSID("$NetBSD: command6.c,v 1.4 2007/12/15 19:44:39 perry Exp $");
42 #include "pathnames.h"
44 static void post(int);
49 if (testbit(location
[position
].objects
, VIPER
) && !notes
[CANTLAUNCH
]) {
51 clearbit(location
[position
].objects
, VIPER
);
52 position
= location
[position
].up
;
56 printf("You climb into the viper and prepare for ");
58 printf("With a touch of your thumb the turbo engines ");
59 printf("ignite, thrusting you back into\nyour seat.\n");
62 puts("Not enough fuel to launch.");
64 puts("Can't launch.");
71 if (notes
[LAUNCHED
] && testbit(location
[position
].objects
, LAND
) &&
72 location
[position
].down
) {
74 position
= location
[position
].down
;
75 setbit(location
[position
].objects
, VIPER
);
78 puts("You are down.");
81 puts("You can't land here.");
88 printf("bye.\nYour rating was %s.\n", rate());
94 diesig(int dummy __unused
)
107 static FILE *score_fp
;
110 open_score_file(void)
112 score_fp
= fopen(_PATH_SCORE
, "a");
113 if (score_fp
== NULL
)
114 warn("open %s for append", _PATH_SCORE
);
115 if (score_fp
!= NULL
&& fileno(score_fp
) < 3)
124 sigset_t isigset
, osigset
;
126 sigemptyset(&isigset
);
127 sigaddset(&isigset
, SIGINT
);
128 sigprocmask(SIG_BLOCK
, &isigset
, &osigset
);
132 if (score_fp
!= NULL
) {
133 fprintf(score_fp
, "%s %8s %c%20s", date
, username
,
136 fprintf(score_fp
, " wizard\n");
139 fprintf(score_fp
, " WIZARD!\n");
141 fprintf(score_fp
, "\n");
143 sigprocmask(SIG_SETMASK
, &osigset
, (sigset_t
*) 0);
151 score
= max(max(pleasure
, power
), ego
);
152 if (score
== pleasure
) {
156 return ("junior voyeur");
160 return ("Marquis De Sade");
161 } else if (score
== power
) {
169 return ("Darth Vader");
171 return ("Sauron the Great");
176 return ("philanthropist");
180 return ("Mr. Roarke");
187 if (testbit(location
[position
].objects
, CAR
)) {
188 printf("You hop in the car and turn the key. There is ");
189 puts("a perceptible grating noise,");
190 puts("and an explosion knocks you unconscious...");
191 clearbit(location
[position
].objects
, CAR
);
192 setbit(location
[position
].objects
, CRASH
);
193 injuries
[5] = injuries
[6] = injuries
[7] = injuries
[8] = 1;
198 puts("There is nothing to drive here.");
205 if (testbit(location
[position
].objects
, HORSE
)) {
206 printf("You climb onto the stallion and kick it in the guts.");
207 puts(" The stupid steed launches");
208 printf("forward through bush and fern. You are thrown and ");
209 puts("the horse gallops off.");
210 clearbit(location
[position
].objects
, HORSE
);
211 while (!(position
= rnd(NUMOFROOMS
+ 1)) || !OUTSIDE
||
212 !beenthere
[position
] || location
[position
].flyhere
)
214 setbit(location
[position
].objects
, HORSE
);
215 if (location
[position
].north
)
216 position
= location
[position
].north
;
217 else if (location
[position
].south
)
218 position
= location
[position
].south
;
219 else if (location
[position
].east
)
220 position
= location
[position
].east
;
222 position
= location
[position
].west
;
225 puts("There is no horse here.");
231 { /* synonyms = {strike, smoke} *//* for
233 if (testbit(inven
, MATCHES
) && matchcount
) {
234 puts("Your match splutters to life.");
238 if (position
== 217) {
239 printf("The whole bungalow explodes with an ");
240 puts("intense blast.");
244 puts("You're out of matches.");
249 { /* synonyms = {open, unlock} */
251 if (wordnumber
<= wordcount
&& wordtype
[wordnumber
] == NOUNS
252 && wordvalue
[wordnumber
] == DOOR
) {
256 if (location
[189].north
== 231)
257 puts("The door is already open.");
259 puts("The door does not budge.");
262 if (location
[30].west
== 25)
263 puts("The door is gone.");
265 puts("The door is locked tight.");
268 puts("That's one immovable door.");
271 puts("The door is already ajar.");
277 puts("That doesn't open.");