1 /* @(#)com6.c 8.2 (Berkeley) 4/28/95 */
2 /* $NetBSD: command6.c,v 1.8 2010/04/24 00:38:30 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
34 #include "pathnames.h"
36 static void post(int);
41 if (testbit(location[position].objects, VIPER) && !notes[CANTLAUNCH]) {
43 clearbit(location[position].objects, VIPER);
44 position = location[position].up;
48 printf("You climb into the viper and prepare for ");
50 printf("With a touch of your thumb the turbo engines ");
51 printf("ignite, thrusting you back into\nyour seat.\n");
54 puts("Not enough fuel to launch.");
56 puts("Can't launch.");
63 if (notes[LAUNCHED] && testbit(location[position].objects, LAND) &&
64 location[position].down) {
66 position = location[position].down;
67 setbit(location[position].objects, VIPER);
70 puts("You are down.");
73 puts("You can't land here.");
80 printf("bye.\nYour rating was %s.\n", rate());
86 diesig(int dummy __unused)
99 static FILE *score_fp;
102 open_score_file(void)
104 score_fp = fopen(_PATH_SCORE, "a");
105 if (score_fp == NULL)
106 warn("open %s for append", _PATH_SCORE);
107 if (score_fp != NULL && fileno(score_fp) < 3)
115 sigset_t isigset, osigset;
117 sigemptyset(&isigset);
118 sigaddset(&isigset, SIGINT);
119 sigprocmask(SIG_BLOCK, &isigset, &osigset);
121 if (score_fp != NULL) {
122 fprintf(score_fp, "%24.24s %8s %c%20s", ctime(&tv), username,
125 fprintf(score_fp, " wizard\n");
128 fprintf(score_fp, " WIZARD!\n");
130 fprintf(score_fp, "\n");
133 sigprocmask(SIG_SETMASK, &osigset, (sigset_t *) 0);
141 score = max(max(pleasure, power), ego);
142 if (score == pleasure) {
146 return ("junior voyeur");
150 return ("Marquis De Sade");
151 } else if (score == power) {
159 return ("Darth Vader");
161 return ("Sauron the Great");
166 return ("philanthropist");
170 return ("Mr. Roarke");
177 if (testbit(location[position].objects, CAR)) {
178 printf("You hop in the car and turn the key. There is ");
179 puts("a perceptible grating noise,");
180 puts("and an explosion knocks you unconscious...");
181 clearbit(location[position].objects, CAR);
182 setbit(location[position].objects, CRASH);
183 injuries[5] = injuries[6] = injuries[7] = injuries[8] = 1;
188 puts("There is nothing to drive here.");
195 if (testbit(location[position].objects, HORSE)) {
196 printf("You climb onto the stallion and kick it in the guts.");
197 puts(" The stupid steed launches");
198 printf("forward through bush and fern. You are thrown and ");
199 puts("the horse gallops off.");
200 clearbit(location[position].objects, HORSE);
201 while (!(position = rnd(NUMOFROOMS + 1)) || !OUTSIDE ||
202 !beenthere[position] || location[position].flyhere)
204 setbit(location[position].objects, HORSE);
205 if (location[position].north)
206 position = location[position].north;
207 else if (location[position].south)
208 position = location[position].south;
209 else if (location[position].east)
210 position = location[position].east;
212 position = location[position].west;
215 puts("There is no horse here.");
221 { /* synonyms = {strike, smoke} *//* for
223 if (testbit(inven, MATCHES) && matchcount) {
224 puts("Your match splutters to life.");
228 if (position == 217) {
229 printf("The whole bungalow explodes with an ");
230 puts("intense blast.");
234 puts("You're out of matches.");
239 { /* synonyms = {open, unlock} */
241 if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS
242 && wordvalue[wordnumber] == DOOR) {
246 if (location[189].north == 231)
247 puts("The door is already open.");
249 puts("The door does not budge.");
252 if (location[30].west == 25)
253 puts("The door is gone.");
255 puts("The door is locked tight.");
258 puts("That's one immovable door.");
261 puts("The door is already ajar.");
267 puts("That doesn't open.");