1 /*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8 #ifndef lint
9 static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 04/28/95";
10 #endif /* not lint */
11
12 #include "extern.h"
13 #include "pathnames.h"
14
launch()15 launch()
16 {
17 if (testbit(location[position].objects,VIPER) && !notes[CANTLAUNCH]){
18 if (fuel > 4){
19 clearbit(location[position].objects,VIPER);
20 position = location[position].up;
21 notes[LAUNCHED] = 1;
22 time++;
23 fuel -= 4;
24 puts("You climb into the viper and prepare for launch.");
25 puts("With a touch of your thumb the turbo engines ignite, thrusting you back into\nyour seat.");
26 return(1);
27 }
28 else
29 puts("Not enough fuel to launch.");
30 }
31 else
32 puts("Can't launch.");
33 return(0);
34 }
35
land()36 land()
37 {
38 if (notes[LAUNCHED] && testbit(location[position].objects,LAND) && location[position].down){
39 notes[LAUNCHED] = 0;
40 position = location[position].down;
41 setbit(location[position].objects,VIPER);
42 fuel -= 2;
43 time++;
44 puts("You are down.");
45 return(1);
46 }
47 else
48 puts("You can't land here.");
49 return(0);
50 }
51
die()52 die() /* endgame */
53 {
54 printf("bye.\nYour rating was %s.\n", rate());
55 post(' ');
56 exit(0);
57 }
58
live()59 live()
60 {
61 puts("\nYou win!");
62 post('!');
63 exit(0);
64 }
65
66 /*
67 * sigh -- this program thinks "time" is an int. It's easier to not load
68 * <time.h> than try and fix it.
69 */
70 #define KERNEL
71 #include <sys/time.h>
72 #undef KERNEL
73
post(ch)74 post(ch)
75 char ch;
76 {
77 FILE *fp;
78 struct timeval tv;
79 char *date, *ctime();
80 int s = sigblock(sigmask(SIGINT));
81
82 gettimeofday(&tv, (struct timezone *)0); /* can't call time */
83 date = ctime(&tv.tv_sec);
84 date[24] = '\0';
85 if (fp = fopen(_PATH_SCORE,"a")) {
86 fprintf(fp, "%s %8s %c%20s", date, uname, ch, rate());
87 if (wiz)
88 fprintf(fp, " wizard\n");
89 else if (tempwiz)
90 fprintf(fp, " WIZARD!\n");
91 else
92 fprintf(fp, "\n");
93 } else
94 perror(_PATH_SCORE);
95 sigsetmask(s);
96 }
97
98 char *
rate()99 rate()
100 {
101 int score;
102
103 score = max(max(pleasure,power),ego);
104 if (score == pleasure){
105 if (score < 5)
106 return("novice");
107 else if (score < 20)
108 return("junior voyeur");
109 else if (score < 35)
110 return("Don Juan");
111 else return("Marquis De Sade");
112 }
113 else if (score == power){
114 if (score < 5)
115 return("serf");
116 else if (score < 8)
117 return("Samurai");
118 else if (score < 13)
119 return("Klingon");
120 else if (score < 22)
121 return("Darth Vader");
122 else return("Sauron the Great");
123 }
124 else{
125 if (score < 5)
126 return("Polyanna");
127 else if (score < 10)
128 return("philanthropist");
129 else if (score < 20)
130 return("Tattoo");
131 else return("Mr. Roarke");
132 }
133 }
134
drive()135 drive()
136 {
137 if (testbit(location[position].objects,CAR)){
138 puts("You hop in the car and turn the key. There is a perceptible grating noise,");
139 puts("and an explosion knocks you unconscious...");
140 clearbit(location[position].objects,CAR);
141 setbit(location[position].objects,CRASH);
142 injuries[5] = injuries[6] = injuries[7] = injuries[8] = 1;
143 time += 15;
144 zzz();
145 return(0);
146 }
147 else
148 puts("There is nothing to drive here.");
149 return(-1);
150 }
151
ride()152 ride()
153 {
154 if (testbit(location[position].objects,HORSE)){
155 puts("You climb onto the stallion and kick it in the guts. The stupid steed launches");
156 puts("forward through bush and fern. You are thrown and the horse gallups off.");
157 clearbit(location[position].objects,HORSE);
158 while (!(position = rnd(NUMOFROOMS+1)) || !OUTSIDE || !beenthere[position] || location[position].flyhere);
159 setbit(location[position].objects,HORSE);
160 if (location[position].north)
161 position = location[position].north;
162 else if (location[position].south)
163 position = location[position].south;
164 else if (location[position].east)
165 position = location[position].east;
166 else
167 position = location[position].west;
168 return(0);
169 }
170 else puts("There is no horse here.");
171 return(-1);
172 }
173
light()174 light() /* synonyms = {strike, smoke} */
175 { /* for matches, cigars */
176 if (testbit(inven,MATCHES) && matchcount){
177 puts("Your match splutters to life.");
178 time++;
179 matchlight = 1;
180 matchcount--;
181 if (position == 217){
182 puts("The whole bungalow explodes with an intense blast.");
183 die();
184 }
185 }
186 else puts("You're out of matches.");
187 }
188