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