2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)com6.c 8.1 (Berkeley) 5/31/93
30 * $FreeBSD: src/games/battlestar/com6.c,v 1.9.2.1 2001/03/05 11:45:35 kris Exp $
31 * $DragonFly: src/games/battlestar/com6.c,v 1.4 2006/08/08 16:47:20 pavalos Exp $
37 #include "pathnames.h"
39 static FILE *score_fp;
40 static void post(unsigned int ch);
45 if (testbit(location[position].objects, VIPER) && !notes[CANTLAUNCH]) {
47 clearbit(location[position].objects, VIPER);
48 position = location[position].up;
52 puts("You climb into the viper and prepare for launch.");
53 puts("With a touch of your thumb the turbo engines ignite, thrusting you back into\nyour seat.");
56 puts("Not enough fuel to launch.");
58 puts("Can't launch.");
65 if (notes[LAUNCHED] && testbit(location[position].objects, LAND) &&
66 location[position].down) {
68 position = location[position].down;
69 setbit(location[position].objects, VIPER);
72 puts("You are down.");
75 puts("You can't land here.");
80 die(int sig __unused) /* endgame */
82 printf("bye.\nYour rating was %s.\n", rate());
98 if ((score_fp = fopen(_PATH_SCORE, "a")) == NULL)
103 post(unsigned int ch)
110 if (score_fp == NULL)
113 s = sigblock(sigmask(SIGINT));
115 gettimeofday(&tv, NULL); /* can't call time */
116 tvsec = (time_t)tv.tv_sec;
117 date = ctime(&tvsec);
120 fprintf(score_fp, "%s %8s %c%20s", date, uname, ch, rate());
122 fprintf(score_fp, " wizard\n");
124 fprintf(score_fp, " WIZARD!\n");
126 fprintf(score_fp, "\n");
136 score = max(max(pleasure, power), ego);
137 if (score == pleasure) {
141 return ("junior voyeur");
145 return ("Marquis De Sade");
146 } else if (score == power) {
154 return ("Darth Vader");
156 return ("Sauron the Great");
161 return ("philanthropist");
165 return ("Mr. Roarke");
172 if (testbit(location[position].objects, CAR)) {
173 puts("You hop in the car and turn the key. There is a perceptible grating noise,");
174 puts("and an explosion knocks you unconscious...");
175 clearbit(location[position].objects, CAR);
176 setbit(location[position].objects, CRASH);
177 injuries[5] = injuries[6] = injuries[7] = injuries[8] = 1;
182 puts("There is nothing to drive here.");
189 if (testbit(location[position].objects, HORSE)) {
190 puts("You climb onto the stallion and kick it in the guts. The stupid steed launches");
191 puts("forward through bush and fern. You are thrown and the horse gallups off.");
192 clearbit(location[position].objects, HORSE);
193 while (!(position = rnd(NUMOFROOMS + 1)) || !OUTSIDE ||
194 !beenthere[position] || location[position].flyhere)
196 setbit(location[position].objects, HORSE);
197 if (location[position].north)
198 position = location[position].north;
199 else if (location[position].south)
200 position = location[position].south;
201 else if (location[position].east)
202 position = location[position].east;
204 position = location[position].west;
207 puts("There is no horse here.");
212 light(void) /* synonyms = {strike, smoke} */
213 { /* for matches, cigars */
214 if (testbit(inven, MATCHES) && matchcount) {
215 puts("Your match splutters to life.");
219 if (position == 217) {
220 puts("The whole bungalow explodes with an intense blast.");
224 puts("You're out of matches.");