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