add Berkeley header; yank to 5.1
[unix-history] / usr / src / games / battlestar / com2.c
CommitLineData
fdc7d56f 1/*
e95fc82a
KB
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
fdc7d56f
EW
11 */
12
354f3094 13#ifndef lint
e95fc82a
KB
14static char sccsid[] = "@(#)com2.c 5.1 (Berkeley) %G%";
15#endif /* not lint */
354f3094
EW
16
17#include "externs.h"
18
19wearit() /* synonyms = {sheathe, sheath} */
20{
21 register int n;
22 int firstnumber, value;
23
24 firstnumber = wordnumber;
25 while(wordtype[++wordnumber] == ADJS);
26 while(wordnumber <= wordcount){
27 value = wordvalue[wordnumber];
28 for (n=0; objsht[value][n]; n++);
29 switch(value){
30
31 case -1:
32 puts("Wear what?");
33 return(firstnumber);
34
35 default:
36 printf("You can't wear%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
37 return(firstnumber);
38
39 case KNIFE:
40 /* case SHIRT: */
41 case ROBE:
42 case LEVIS: /* wearable things */
43 case SWORD:
44 case MAIL:
45 case HELM:
46 case SHOES:
47 case PAJAMAS:
48 case COMPASS:
49 case LASER:
50 case AMULET:
51 case TALISMAN:
52 case MEDALION:
53 case ROPE:
54 case RING:
55 case BRACELET:
56 case GRENADE:
57
58 if (testbit(inven,value)){
59 clearbit(inven,value);
60 setbit(wear,value);
61 carrying -= objwt[value];
62 encumber -= objcumber[value];
63 time++;
64 printf("You are now wearing %s %s.\n",(objsht[value][n-1] == 's' ? "the" : "a"), objsht[value]);
65 }
66 else if (testbit(wear,value))
67 printf("You are already wearing the %s.\n", objsht[value]);
68 else
69 printf("You aren't holding the %s.\n", objsht[value]);
70 if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
71 wordnumber++;
72 else
73 return(firstnumber);
74 } /* end switch */
75 } /* end while */
76 puts("Don't be ridiculous.");
77 return(firstnumber);
78}
79
80put() /* synonyms = {buckle, strap, tie} */
81{
82 if (wordvalue[wordnumber + 1] == ON){
83 wordvalue[++wordnumber] = PUTON;
84 return(cypher());
85 }
86 if (wordvalue[wordnumber + 1] == DOWN){
87 wordvalue[++wordnumber] = DROP;
88 return(cypher());
89 }
90 puts("I don't understand what you want to put.");
91 return(-1);
92
93}
94
95draw() /* synonyms = {pull, carry} */
96{
97 return(take(wear));
98}
99
100use()
101{
102 while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount);
103 if (wordvalue[wordnumber] == AMULET && testbit(inven,AMULET) && position != FINAL){
104 puts("The amulet begins to glow.");
105 if (testbit(inven,MEDALION)){
106 puts("The medallion comes to life too.");
107 if (position == 114){
108 location[position].down = 160;
109 whichway(location[position]);
110 puts("The waves subside and it is possible to descend to the sea cave now.");
111 time++;
112 return(-1);
113 }
114 }
115 puts("A light mist falls over your eyes and the sound of purling water trickles in");
116 puts("your ears. When the mist lifts you are standing beside a cool stream.");
117 if (position == 229)
118 position = 224;
119 else
120 position = 229;
121 time++;
122 return(0);
123 }
124 else if (position == FINAL)
125 puts("The amulet won't work in here.");
126 else if (wordvalue[wordnumber] == COMPASS && testbit(inven,COMPASS))
127 printf("Your compass points %s.\n",truedirec(NORTH,'-'));
128 else if (wordvalue[wordnumber] == COMPASS)
129 puts("You aren't holding the compass.");
130 else if (wordvalue[wordnumber] == AMULET)
131 puts("You aren't holding the amulet.");
132 else
133 puts("There is no apparent use.");
134 return(-1);
135}
136
137murder()
138{
139 register int n;
140
141 for (n=0; !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || n == HALBERD) && testbit(inven,n)) && n < NUMOFOBJECTS; n++);
142 if (n == NUMOFOBJECTS)
143 puts("You don't have suitable weapons to kill.");
144 else {
145 printf("Your %s should do the trick.\n",objsht[n]);
146 while (wordtype[++wordnumber] == ADJS);
147 switch(wordvalue[wordnumber]){
148
149 case NORMGOD:
150 if (testbit(location[position].objects,BATHGOD)){
151 puts("The goddess's head slices off. Her corpse floats in the water.");
152 clearbit(location[position].objects,BATHGOD);
153 setbit(location[position].objects,DEADGOD);
154 power += 5;
155 notes[JINXED]++;
156 } else if (testbit(location[position].objects,NORMGOD)){
157 puts("The goddess pleads but you strike her mercilessly. Her broken body lies in a\npool of blood.");
158 clearbit(location[position].objects,NORMGOD);
159 setbit(location[position].objects,DEADGOD);
160 power += 5;
161 notes[JINXED]++;
162 if (wintime)
163 live();
164 } else puts("I dont see her anywhere.");
165 break;
166 case TIMER:
167 if (testbit(location[position].objects,TIMER)){
168 puts("The old man offers no resistance.");
169 clearbit(location[position].objects,TIMER);
170 setbit(location[position].objects,DEADTIME);
171 power++;
172 notes[JINXED]++;
173 } else puts("Who?");
174 break;
175 case NATIVE:
176 if (testbit(location[position].objects,NATIVE)){
177 puts("The girl screams as you cut her body to shreds. She is dead.");
178 clearbit(location[position].objects,NATIVE);
179 setbit(location[position].objects,DEADNATIVE);
180 power += 5;
181 notes[JINXED]++;
182 } else puts("What girl?");
183 break;
184 case MAN:
185 if (testbit(location[position].objects,MAN)){
a7c71d1e 186 puts("You strike him to the ground, and he coughs up blood.");
354f3094
EW
187 puts("Your fantasy is over.");
188 die();
189 }
190 case -1:
191 puts("Kill what?");
192 break;
193
194 default:
195 if (wordtype[wordnumber] != NOUNS)
196 puts("Kill what?");
197 else
198 printf("You can't kill the %s!\n",objsht[wordvalue[wordnumber]]);
199 }
200 }
201}
202
203ravage()
204{
205 while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
206 if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
207 time++;
208 switch(wordvalue[wordnumber]){
209 case NORMGOD:
a7c71d1e 210 puts("You attack the goddess, and she screams as you beat her. She falls down");
354f3094
EW
211 puts("crying and tries to hold her torn and bloodied dress around her.");
212 power += 5;
213 pleasure += 8;
214 ego -= 10;
215 wordnumber--;
216 godready = -30000;
217 murder();
218 win = -30000;
219 break;
220 case NATIVE:
a7c71d1e
EW
221 puts("The girl tries to run, but you catch her and throw her down. Her face is");
222 puts("bleeding, and she screams as you tear off her clothes.");
354f3094
EW
223 power += 3;
224 pleasure += 5;
225 ego -= 10;
226 wordnumber--;
227 murder();
a7c71d1e 228 if (rnd(100) < 50){
354f3094
EW
229 puts("Her screams have attracted attention. I think we are surrounded.");
230 setbit(location[ahead].objects,WOODSMAN);
231 setbit(location[ahead].objects,DEADWOOD);
232 setbit(location[ahead].objects,MALLET);
233 setbit(location[back].objects,WOODSMAN);
234 setbit(location[back].objects,DEADWOOD);
235 setbit(location[back].objects,MALLET);
236 setbit(location[left].objects,WOODSMAN);
237 setbit(location[left].objects,DEADWOOD);
238 setbit(location[left].objects,MALLET);
239 setbit(location[right].objects,WOODSMAN);
240 setbit(location[right].objects,DEADWOOD);
241 setbit(location[right].objects,MALLET);
242 }
243 break;
244 default:
245 puts("You are perverted.");
246 }
247 }
248 else
249 puts("Who?");
250}
251
252follow()
253{
254 if (followfight == time){
a7c71d1e
EW
255 puts("The Dark Lord leaps away and runs down secret tunnels and corridoors.");
256 puts("You chase him through the darkness and splash in pools of water.");
257 puts("You have cornered him. His laser sword extends as he steps forward.");
354f3094
EW
258 position = FINAL;
259 fight(DARK,75);
260 setbit(location[position].objects,TALISMAN);
261 setbit(location[position].objects,AMULET);
262 return(0);
263 }
264 else if (followgod == time){
265 puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
266 puts("She sits down on a throne.");
267 position = 268;
268 setbit(location[position].objects,NORMGOD);
269 notes[CANTSEE] = 1;
270 return(0);
271 }
272 else
273 puts("There is no one to follow.");
274 return(-1);
275}