]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/com4.c
1 /* $NetBSD: com4.c,v 1.3 1995/03/21 15:07:04 cgd Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static char sccsid
[] = "@(#)com4.c 8.1 (Berkeley) 5/31/93";
40 static char rcsid
[] = "$NetBSD: com4.c,v 1.3 1995/03/21 15:07:04 cgd Exp $";
49 int firstnumber
, heavy
, bulky
, value
;
52 firstnumber
= wordnumber
;
53 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == OFF
){
55 wordvalue
[wordnumber
] = TAKEOFF
;
59 while(wordtype
[++wordnumber
] == ADJS
);
60 while(wordnumber
<=wordcount
&& wordtype
[wordnumber
] == OBJECT
){
61 value
= wordvalue
[wordnumber
];
62 printf("%s:\n", objsht
[value
]);
63 for (n
=0; objsht
[value
][n
]; n
++);
64 heavy
= (carrying
+ objwt
[value
]) <= WEIGHT
;
65 bulky
= (encumber
+ objcumber
[value
]) <= CUMBER
;
66 if ((testbit(from
,value
) || wiz
|| tempwiz
) && heavy
&& bulky
&& !testbit(inven
,value
)){
68 carrying
+= objwt
[value
];
69 encumber
+= objcumber
[value
];
71 if (testbit(from
,value
))
74 printf("Zap! Taken from thin air.\n");
76 if (value
== MEDALION
)
79 else if (testbit(inven
,value
))
80 printf("You're already holding%s%s.\n", (objsht
[value
][n
-1] == 's' ? " " : " a "),objsht
[value
]);
82 printf("The %s %s too heavy.\n", objsht
[value
],(objsht
[value
][n
-1] == 's' ? "are" : "is"));
84 printf("The %s %s too cumbersome to hold.\n", objsht
[value
],(objsht
[value
][n
-1] == 's' ? "are" : "is"));
86 printf("I dont see any %s around here.\n", objsht
[value
]);
87 if (wordnumber
< wordcount
-1 && wordvalue
[++wordnumber
] == AND
)
93 /* special cases with their own return()'s */
95 if (wordnumber
<= wordcount
&& wordtype
[wordnumber
] == NOUNS
)
96 switch(wordvalue
[wordnumber
]){
99 if (testbit(from
, SWORD
)){
100 wordtype
[wordnumber
--] = OBJECT
;
103 if (testbit(from
, TWO_HANDED
)){
104 wordvalue
[wordnumber
] = TWO_HANDED
;
105 wordtype
[wordnumber
--] = OBJECT
;
108 wordvalue
[wordnumber
] = BROAD
;
109 wordtype
[wordnumber
--] = OBJECT
;
113 if (testbit(from
,MAID
)){
114 wordvalue
[wordnumber
] = MAID
;
115 wordtype
[wordnumber
--] = OBJECT
;
118 else if (testbit(from
,DEADWOOD
)){
119 wordvalue
[wordnumber
] = DEADWOOD
;
120 wordtype
[wordnumber
--] = OBJECT
;
123 else if (testbit(from
,DEADNATIVE
)){
124 wordvalue
[wordnumber
] = DEADNATIVE
;
125 wordtype
[wordnumber
--] = OBJECT
;
128 else if (testbit(from
,DEADGOD
)){
129 wordvalue
[wordnumber
] = DEADGOD
;
130 wordtype
[wordnumber
--] = OBJECT
;
134 wordvalue
[wordnumber
] = DEADTIME
;
135 wordtype
[wordnumber
--] = OBJECT
;
141 if (testbit(location
[position
].objects
,AMULET
)){
142 puts("The amulet is warm to the touch, and its beauty catches your breath.");
143 puts("A mist falls over your eyes, but then it is gone. Sounds seem clearer");
144 puts("and sharper but far away as if in a dream. The sound of purling water reaches");
145 puts("you from afar. The mist falls again, and your heart leaps in horror. The gold");
146 puts("freezes your hands and fathomless darkness engulfs your soul.");
148 wordtype
[wordnumber
--] = OBJECT
;
152 if (testbit(location
[position
].objects
, MEDALION
)){
153 puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
154 puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
156 wordtype
[wordnumber
--] = OBJECT
;
160 if (testbit(location
[position
].objects
,TALISMAN
)){
161 puts("The talisman is cold to the touch, and it sends a chill down your spine.");
163 wordtype
[wordnumber
--] = OBJECT
;
167 if (testbit(location
[position
].objects
,BATHGOD
) && (testbit(wear
,AMULET
) || testbit(inven
,AMULET
))){
168 puts("She offers a delicate hand, and you help her out of the sparkling springs.");
169 puts("Water droplets like liquid silver bedew her golden skin, but when they part");
170 puts("from her, they fall as teardrops. She wraps a single cloth around her and");
171 puts("ties it at the waist. Around her neck hangs a golden amulet.");
172 puts("She bids you to follow her.");
175 clearbit(location
[position
].objects
,BATHGOD
);
176 } else if (!testbit(location
[position
].objects
,BATHGOD
))
177 puts("You're in no position to take her.");
179 puts("She moves away from you.");
183 puts("It doesn't seem to work.");
186 puts("You've got to be kidding.");
198 if (drop(name
) != -1){
199 switch(wordvalue
[wordnumber
]){
218 deposit
= location
[position
].up
* (location
[position
].access
|| position
== FINAL
);
222 deposit
= location
[position
].down
;
226 while (wordtype
[++wordnumber
] == ADJS
);
227 while (wordnumber
<= wordcount
){
228 value
= wordvalue
[wordnumber
];
229 if (deposit
&& testbit(location
[position
].objects
,value
)){
230 clearbit(location
[position
].objects
,value
);
231 if (value
!= GRENADE
)
232 setbit(location
[deposit
].objects
,value
);
234 puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
235 for (n
= 0; n
< NUMOFWORDS
; n
++)
236 location
[deposit
].objects
[n
] = 0;
237 setbit(location
[deposit
].objects
,CHAR
);
239 if (value
== ROPE
&& position
== FINAL
)
240 location
[position
].access
= 1;
244 puts("The stone door is unhinged.");
245 location
[189].north
= 231;
246 location
[231].south
= 189;
249 puts("The wooden door is blown open.");
250 location
[30].west
= 25;
253 puts("The door is not damaged.");
256 else if (value
== GRENADE
&& testbit(location
[position
].objects
,value
)){
257 puts("You are blown into shreds when your grenade explodes.");
260 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
274 int firstnumber
, value
;
276 firstnumber
= wordnumber
;
277 while (wordtype
[++wordnumber
] == ADJS
)
279 while (wordnumber
<=wordcount
&& (wordtype
[wordnumber
] == OBJECT
|| wordtype
[wordnumber
] == NOUNS
)) {
280 value
= wordvalue
[wordnumber
];
281 printf("%s:\n", objsht
[value
]);
282 if (testbit(inven
,value
)){
283 clearbit(inven
,value
);
284 carrying
-= objwt
[value
];
285 encumber
-= objcumber
[value
];
287 puts("The bomb explodes. A blinding white light and immense concussion obliterate us.");
290 if (value
!= AMULET
&& value
!= MEDALION
&& value
!= TALISMAN
)
291 setbit(location
[position
].objects
,value
);
296 puts("Drop kicked.");
298 printf("%s.\n", name
);
302 printf("You aren't holding the %s.\n", objsht
[value
]);
303 if (testbit(location
[position
].objects
,value
)) {
305 puts("Kicked instead.");
306 else if (*name
== 'G')
307 puts("Given anyway.");
312 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
323 wordnumber
= take(wear
);
324 return(drop("Dropped"));
329 wordnumber
= take(location
[position
].objects
);
335 int firstnumber
, value
;
337 firstnumber
= wordnumber
;
338 while(wordtype
[++wordnumber
] == ADJS
);
339 while(wordnumber
<= wordcount
){
340 value
= wordvalue
[wordnumber
];
348 printf("You can't eat%s%s!\n",
349 wordtype
[wordnumber
] == OBJECT
&&
351 [strlen(objsht
[value
]) - 1] == 's' ?
359 case COCONUTS
: /* eatable things */
362 printf("%s:\n",objsht
[value
]);
363 if (testbit(inven
,value
) && time
> ate
- CYCLE
&& testbit(inven
,KNIFE
)){
364 clearbit(inven
,value
);
365 carrying
-= objwt
[value
];
366 encumber
-= objcumber
[value
];
367 ate
= max(time
,ate
) + CYCLE
/3;
370 puts("Eaten. You can explore a little longer now.");
372 else if (time
< ate
- CYCLE
)
373 puts("You're stuffed.");
374 else if (!testbit(inven
,KNIFE
))
375 puts("You need a knife.");
377 printf("You aren't holding the %s.\n", objsht
[value
]);
378 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)