BSD 4_3_Net_2 release
[unix-history] / usr / src / games / battlestar / com5.c
CommitLineData
fdc7d56f 1/*
e95fc82a
KB
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
af359dea
C
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
fdc7d56f
EW
32 */
33
f0462800 34#ifndef lint
1c15e888 35static char sccsid[] = "@(#)com5.c 5.3 (Berkeley) 6/1/90";
e95fc82a 36#endif /* not lint */
f0462800
EW
37
38#include "externs.h"
39
40kiss()
41{
42 while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
43 if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
44 pleasure++;
45 printf("Kissed.\n");
46 switch (wordvalue[wordnumber]){
47 case NORMGOD:
48 switch(godready++){
49 case 0:
50 puts("She squirms and avoids your advances.");
51 break;
52 case 1:
53 puts("She is coming around; she didn't fight it as much.");
54 break;
55 case 2:
56 puts("She's begining to like it.");
57 break;
58 default:
59 puts("She's gone limp.");
60
61 }
62 break;
63 case NATIVE:
64 puts("The lips are warm and her body robust. She pulls you down to the ground.");
65 break;
66 case TIMER:
67 puts("The old man blushes.");
68 break;
69 case MAN:
70 puts("The dwarf punches you in the kneecap.");
71 break;
72 default:
73 pleasure--;
74 }
75 }
76 else puts("I'd prefer not to.");
77}
78
79love()
80{
81 register int n;
82
83 while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
84 if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
85 if (wordvalue[wordnumber] == NORMGOD && !loved)
86 if (godready >= 2){
87 puts("She cuddles up to you, and her mouth starts to work:\n'That was my sister's amulet. The lovely goddess, Purl, was she. The Empire\ncaptured her just after the Darkness came. My other sister, Vert, was killed\nby the Dark Lord himself. He took her amulet and warped its power.\nYour quest was foretold by my father before he died, but to get the Dark Lord's\namulet you must use cunning and skill. I will leave you my amulet.");
88 puts("which you may use as you wish. As for me, I am the last goddess of the\nwaters. My father was the Island King, and the rule is rightfully mine.'\n\nShe pulls the throne out into a large bed.");
89 power++;
90 pleasure += 15;
91 ego++;
92 if (card(injuries, NUMOFINJURIES)){
93 puts("Her kisses revive you; your wounds are healed.\n");
94 for (n=0; n < NUMOFINJURIES; n++)
95 injuries[n] = 0;
96 WEIGHT = MAXWEIGHT;
97 CUMBER = MAXCUMBER;
98 }
99 printf("Goddess:\n");
100 if (!loved)
101 setbit(location[position].objects,MEDALION);
102 loved = 1;
103 time += 10;
104 zzz();
105 }
106 else {
107 puts("You wish!");
108 return;
109 }
110 if (wordvalue[wordnumber] == NATIVE){
111 puts("The girl is easy prey. She peals off her sarong and indulges you.");
112 power++;
113 pleasure += 5;
114 printf("Girl:\n");
115 time += 10;
116 zzz();
117 }
118 printf("Loved.\n");
119 }
120 else puts("I't doesn't seem to work.");
121}
122
123zzz()
124{
125 int oldtime;
126 register int n;
127
128 oldtime = time;
129 if ((snooze - time) < (0.75 * CYCLE)){
130 time += 0.75 * CYCLE - (snooze - time);
131 printf("<zzz>");
132 for (n = 0; n < time - oldtime; n++)
133 printf(".");
134 printf("\n");
135 snooze += 3 * (time - oldtime);
136 if (notes[LAUNCHED]){
137 fuel -= (time - oldtime);
138 if (location[position].down){
139 position = location[position].down;
140 crash();
141 }
142 else
143 notes[LAUNCHED] = 0;
144 }
a7c71d1e 145 if (OUTSIDE && rnd(100) < 50){
f0462800 146 puts("You are awakened abruptly by the sound of someone nearby.");
a7c71d1e 147 switch(rnd(4)){
f0462800
EW
148 case 0:
149 if (ucard(inven)){
150 n = rnd(NUMOFOBJECTS);
151 while(!testbit(inven,n))
152 n = rnd(NUMOFOBJECTS);
153 clearbit(inven,n);
154 if (n != AMULET && n != MEDALION && n != TALISMAN)
155 setbit(location[position].objects,n);
156 carrying -= objwt[n];
157 encumber -= objcumber[n];
158 }
159 puts("A fiendish little Elf is stealing your treasures!");
160 fight(ELF,10);
161 break;
162 case 1:
163 setbit(location[position].objects,DEADWOOD);
164 break;
165 case 2:
166 setbit(location[position].objects,HALBERD);
167 break;
a7c71d1e
EW
168 default:
169 break;
f0462800
EW
170 }
171 }
172 }
173 else
174 return(0);
175 return(1);
176}
177
178chime()
179{
180 if ((time / CYCLE + 1) % 2 && OUTSIDE)
181 switch((time % CYCLE)/(CYCLE / 7)){
182 case 0:
183 puts("It is just after sunrise.");
184 break;
185 case 1:
186 puts("It is early morning.");
187 break;
188 case 2:
189 puts("It is late morning.");
190 break;
191 case 3:
192 puts("It is near noon.");
193 break;
194 case 4:
195 puts("It is early afternoon.");
196 break;
197 case 5:
198 puts("It is late afternoon.");
199 break;
200 case 6:
201 puts("It is near sunset.");
202 break;
203 }
204 else if (OUTSIDE)
205 switch((time % CYCLE)/(CYCLE / 7)){
206 case 0:
207 puts("It is just after sunset.");
208 break;
209 case 1:
210 puts("It is early evening.");
211 break;
212 case 2:
213 puts("The evening is getting old.");
214 break;
215 case 3:
216 puts("It is near midnight.");
217 break;
218 case 4:
219 puts("These are the wee hours of the morning.");
220 break;
221 case 5:
222 puts("The night is waning.");
223 break;
224 case 6:
225 puts("It is almost morning.");
226 break;
227 }
228 else
229 puts("I can't tell the time in here.");
230}
231
232give()
233{
234 int obj = -1, result = -1, person = 0, firstnumber, last1, last2;
235
236 firstnumber = wordnumber;
237 while (wordtype[++wordnumber] != OBJECT && wordvalue[wordnumber] != AMULET && wordvalue[wordnumber] != MEDALION && wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount);
238 if (wordnumber <= wordcount){
239 obj = wordvalue[wordnumber];
240 if (obj == EVERYTHING)
241 wordtype[wordnumber] = -1;
242 last1 = wordnumber;
243 }
244 wordnumber = firstnumber;
245 while ((wordtype[++wordnumber] != NOUNS || wordvalue[wordnumber] == obj) && wordnumber <= wordcount);
246 if (wordtype[wordnumber] == NOUNS){
247 person = wordvalue[wordnumber];
248 last2 = wordnumber;
249 }
250 wordnumber = last1 - 1;
251 if (person && testbit(location[position].objects,person))
252 if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET))
253 puts("The goddess won't look at you.");
254 else
255 result = drop("Given");
256 else {
257 puts("I don't think that is possible.");
258 return(0);
259 }
260 if (result != -1 && (testbit(location[position].objects,obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)){
261 clearbit(location[position].objects,obj);
262 time++;
263 ego++;
264 switch(person){
265 case NATIVE:
266 puts("She accepts it shyly.");
267 ego += 2;
268 break;
269 case NORMGOD:
270 if (obj == RING || obj == BRACELET){
271 puts("She takes the charm and puts it on. A little kiss on the cheek is");
272 puts("your reward.");
273 ego += 5;
274 godready += 3;
275 }
276 if (obj == AMULET || obj == MEDALION || obj == TALISMAN){
277 win++;
278 ego += 5;
279 power -= 5;
280 if (win >= 3){
281 puts("The powers of the earth are now legitimate. You have destroyed the Darkness");
282 puts("and restored the goddess to her thrown. The entire island celebrates with");
283 puts("dancing and spring feasts. As a measure of her gratitude, the goddess weds you");
284 puts("in the late summer and crowns you Prince Liverwort, Lord of Fungus.");
285 puts("\nBut, as the year wears on and autumn comes along, you become restless and");
286 puts("yearn for adventure. The goddess, too, realizes that the marriage can't last.");
287 puts("She becomes bored and takes several more natives as husbands. One evening,");
288 puts("after having been out drinking with the girls, she kicks the throne particulary");
289 puts("hard and wakes you up. (If you want to win this game, you're going to have to\nshoot her!)");
290 clearbit(location[position].objects,MEDALION);
291 wintime = time;
292 }
293 }
294 break;
295 case TIMER:
296 if (obj == COINS){
a7c71d1e
EW
297 puts("He fingers the coins for a moment and then looks up agape. `Kind you are and");
298 puts("I mean to repay you as best I can.' Grabbing a pencil and cocktail napkin...\n");
299 printf( "+-----------------------------------------------------------------------------+\n");
300 printf( "| xxxxxxxx\\ |\n");
301 printf( "| xxxxx\\ CLIFFS |\n");
302 printf( "| FOREST xxx\\ |\n");
f0462800
EW
303 printf( "| \\\\ x\\ OCEAN |\n");
304 printf( "| || x\\ |\n");
305 printf( "| || ROAD x\\ |\n");
306 printf( "| || x\\ |\n");
307 printf( "| SECRET || ......... |\n");
308 printf( "| - + - || ........ |\n");
309 printf( "| ENTRANCE || ... BEACH |\n");
310 printf( "| || ... E |\n");
311 printf( "| || ... | |\n");
a7c71d1e 312 printf( "| // ... N <-- + --- S |\n");
f0462800
EW
313 printf( "| PALM GROVE // ... | |\n");
314 printf( "| // ... W |\n");
a7c71d1e
EW
315 printf( "+-----------------------------------------------------------------------------+\n");
316 puts("\n`This map shows a secret entrance to the catacombs.");
f0462800
EW
317 puts("You will know when you arrive because I left an old pair of shoes there.'");
318 }
319 break;
320 }
321 }
322 wordnumber = max(last1,last2);
323 return(firstnumber);
324}