xref: /original-bsd/games/battlestar/com3.c (revision 4092c5cc)
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[] = "@(#)com3.c	8.1 (Berkeley) 05/31/93";
10 #endif /* not lint */
11 
12 #include "externs.h"
13 
14 dig()
15 {
16 	if (testbit(inven,SHOVEL)){
17 		puts("OK");
18 		time++;
19 		switch(position){
20 			case 144:		/* copse near beach */
21 				if (!notes[DUG]){
22 					setbit(location[position].objects,DEADWOOD);
23 					setbit(location[position].objects,COMPASS);
24 					setbit(location[position].objects,KNIFE);
25 					setbit(location[position].objects,MACE);
26 					notes[DUG] = 1;
27 				}
28 				break;
29 
30 			default:
31 				puts("Nothing happens.");
32 		}
33 	}
34 	else
35 		puts("You don't have a shovel.");
36 }
37 
38 jump()
39 {
40 	register int n;
41 
42 	switch(position){
43 		default:
44 			puts("Nothing happens.");
45 			return(-1);
46 
47 		case 242:
48 			position = 133;
49 			break;
50 		case 214:
51 		case 215:
52 		case 162:
53 		case 159:
54 			position = 145;
55 			break;
56 		case 232:
57 			position = 275;
58 			break;
59 		case 3:
60 			position = 1;
61 			break;
62 		case 172:
63 			position = 201;
64 	}
65 	puts("Ahhhhhhh...");
66 	injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1;
67 	for (n=0; n < NUMOFOBJECTS; n++)
68 		if (testbit(inven,n)){
69 			clearbit(inven,n);
70 			setbit(location[position].objects,n);
71 		}
72 	carrying = 0;
73 	encumber = 0;
74 	return(0);
75 }
76 
77 bury()
78 {
79 	int value;
80 
81 	if (testbit(inven,SHOVEL)){
82 		while(wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount);
83 		value = wordvalue[wordnumber];
84 		if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects,value) || value == BODY))
85 			switch(value){
86 				case BODY:
87 					wordtype[wordnumber] = OBJECT;
88 					if (testbit(inven,MAID) || testbit(location[position].objects,MAID))
89 						value = MAID;
90 					if (testbit(inven,DEADWOOD) || testbit(location[position].objects,DEADWOOD))
91 						value = DEADWOOD;
92 					if (testbit(inven,DEADGOD) || testbit(location[position].objects,DEADGOD))
93 						value = DEADGOD;
94 					if (testbit(inven,DEADTIME) || testbit(location[position].objects,DEADTIME))
95 						value = DEADTIME;
96 					if (testbit(inven,DEADNATIVE) || testbit(location[position].objects,DEADNATIVE))
97 						value = DEADNATIVE;
98 					break;
99 
100 				case NATIVE:
101 				case NORMGOD:
102 					puts("She screams as you wrestle her into the hole.");
103 				case TIMER:
104 					power += 7;
105 					ego -= 10;
106 				case AMULET:
107 				case MEDALION:
108 				case TALISMAN:
109 					wordtype[wordnumber] = OBJECT;
110 					break;
111 
112 				default:
113 					puts("Wha..?");
114 			}
115 		if (wordtype[wordnumber] == OBJECT && position > 88 && (testbit(inven,value) || testbit(location[position].objects,value))){
116 			puts("Buried.");
117 			if (testbit(inven,value)){
118 				clearbit(inven,value);
119 				carrying -= objwt[value];
120 				encumber -= objcumber[value];
121 			}
122 			clearbit(location[position].objects,value);
123 			switch(value){
124 				case MAID:
125 				case DEADWOOD:
126 				case DEADNATIVE:
127 				case DEADTIME:
128 				case DEADGOD:
129 					ego += 2;
130 					printf("The %s should rest easier now.\n",objsht[value]);
131 			}
132 		}
133 		else
134 			puts("It doesn't seem to work.");
135 	}
136 	else
137 		puts("You aren't holding a shovel.");
138 }
139 
140 drink()
141 {
142 	register int n;
143 
144 	if (testbit(inven,POTION)){
145 		puts("The cool liquid runs down your throat but turns to fire and you choke.");
146 		puts("The heat reaches your limbs and tingles your spirit.  You feel like falling");
147 		puts("asleep.");
148 		clearbit(inven, POTION);
149 		WEIGHT = MAXWEIGHT;
150 		CUMBER = MAXCUMBER;
151 		for (n=0; n < NUMOFINJURIES; n++)
152 			injuries[n] = 0;
153 		time++;
154 		zzz();
155 	}
156 	else
157 		puts("I'm not thirsty.");
158 }
159 
160 shoot()
161 {
162 	int firstnumber, value;
163 	register int n;
164 
165 	if (!testbit(inven,LASER))
166 		puts("You aren't holding a blaster.");
167 	else {
168 		firstnumber = wordnumber;
169 		while(wordtype[++wordnumber] == ADJS);
170 		while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
171 			value = wordvalue[wordnumber];
172 			printf("%s:\n", objsht[value]);
173 			for (n=0; objsht[value][n]; n++);
174 			if (testbit(location[position].objects,value)){
175 				clearbit(location[position].objects,value);
176 				time++;
177 				printf("The %s explode%s\n",objsht[value],(objsht[value][n-1]=='s' ? (objsht[value][n-2]=='s' ? "s." : ".") : "s."));
178 				if (value == BOMB)
179 					die();
180 			}
181 			else
182 				printf("I dont see any %s around here.\n", objsht[value]);
183 			if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
184 				wordnumber++;
185 			else
186 				return(firstnumber);
187 		}
188 			    /* special cases with their own return()'s */
189 
190 		if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS){
191 			time++;
192 			switch(wordvalue[wordnumber]){
193 
194 				case DOOR:
195 					switch(position){
196 						case 189:
197 						case 231:
198 							puts("The door is unhinged.");
199 							location[189].north = 231;
200 							location[231].south = 189;
201 							whichway(location[position]);
202 							break;
203 						case 30:
204 							puts("The wooden door splinters.");
205 							location[30].west = 25;
206 							whichway(location[position]);
207 							break;
208 						case 31:
209 							puts("The laser blast has no effect on the door.");
210 							break;
211 						case 20:
212 							puts("The blast hits the door and it explodes into flame.  The magnesium burns");
213 							puts("so rapidly that we have no chance to escape.");
214 							die();
215 						default:
216 							puts("Nothing happens.");
217 					}
218 					break;
219 
220 				case NORMGOD:
221 					if (testbit(location[position].objects,BATHGOD)){
222 						puts("The goddess is hit in the chest and splashes back against the rocks.");
223 						puts("Dark blood oozes from the charred blast hole.  Her naked body floats in the");
224 						puts("pools and then off downstream.");
225 						clearbit(location[position].objects,BATHGOD);
226 						setbit(location[180].objects,DEADGOD);
227 						power += 5;
228 						ego -= 10;
229 						notes[JINXED]++;
230 					} else if (testbit(location[position].objects,NORMGOD)){
231 						puts("The blast catches the goddess in the stomach, knocking her to the ground.");
232 						puts("She writhes in the dirt as the agony of death taunts her.");
233 						puts("She has stopped moving.");
234 						clearbit(location[position].objects,NORMGOD);
235 						setbit(location[position].objects,DEADGOD);
236 						power += 5;
237 						ego -= 10;
238 						notes[JINXED]++;
239 						if (wintime)
240 							live();
241 						break;
242 					} else
243 						puts("I don't see any goddess around here.");
244 					break;
245 
246 				case TIMER:
247 					if (testbit(location[position].objects,TIMER)){
248 						puts("The old man slumps over the bar.");
249 						power++;
250 						ego -= 2;
251 						notes[JINXED]++;
252 						clearbit(location[position].objects,TIMER);
253 						setbit(location[position].objects,DEADTIME);
254 					}
255 					else puts("What old timer?");
256 					break;
257 				case MAN:
258 					if (testbit(location[position].objects,MAN)){
259 						puts("The man falls to the ground with blood pouring all over his white suit.");
260 						puts("Your fantasy is over.");
261 						die();
262 					}
263 					else puts("What man?");
264 					break;
265 				case NATIVE:
266 					if (testbit(location[position].objects,NATIVE)){
267 						puts("The girl is blown backwards several feet and lies in a pool of blood.");
268 						clearbit(location[position].objects,NATIVE);
269 						setbit(location[position].objects,DEADNATIVE);
270 						power += 5;
271 						ego -= 2;
272 						notes[JINXED]++;
273 					} else puts("There is no girl here.");
274 					break;
275 				case -1:
276 					puts("Shoot what?");
277 					break;
278 
279 				default:
280 					printf("You can't shoot the %s.\n",objsht[wordvalue[wordnumber]]);
281 			}
282 		}
283 		else puts("You must be a looney.");
284 	}
285 	return(firstnumber);
286 }
287