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
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
33 * @(#)com4.c 8.1 (Berkeley) 5/31/93
34 * $FreeBSD: src/games/battlestar/com4.c,v 1.8.2.1 2001/03/05 11:45:35 kris Exp $
35 * $DragonFly: src/games/battlestar/com4.c,v 1.3 2006/08/08 16:47:20 pavalos Exp $
41 take(unsigned int from
[])
43 int firstnumber
, heavy
, bulky
, value
;
46 firstnumber
= wordnumber
;
47 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == OFF
){
49 wordvalue
[wordnumber
] = TAKEOFF
;
53 while(wordtype
[++wordnumber
] == ADJS
);
54 while(wordnumber
<=wordcount
&& wordtype
[wordnumber
] == OBJECT
){
55 value
= wordvalue
[wordnumber
];
56 printf("%s:\n", objsht
[value
]);
57 for (n
=0; objsht
[value
][n
]; n
++);
58 heavy
= (carrying
+ objwt
[value
]) <= WEIGHT
;
59 bulky
= (encumber
+ objcumber
[value
]) <= CUMBER
;
60 if ((testbit(from
,value
) || wiz
|| tempwiz
) && heavy
&& bulky
&& !testbit(inven
,value
)){
62 carrying
+= objwt
[value
];
63 encumber
+= objcumber
[value
];
65 if (testbit(from
,value
))
68 printf("Zap! Taken from thin air.\n");
70 if (value
== MEDALION
)
73 else if (testbit(inven
,value
))
74 printf("You're already holding%s%s.\n", (objsht
[value
][n
-1] == 's' ? " " : " a "),objsht
[value
]);
76 printf("The %s %s too heavy.\n", objsht
[value
],(objsht
[value
][n
-1] == 's' ? "are" : "is"));
78 printf("The %s %s too cumbersome to hold.\n", objsht
[value
],(objsht
[value
][n
-1] == 's' ? "are" : "is"));
80 printf("I dont see any %s around here.\n", objsht
[value
]);
81 if (wordnumber
< wordcount
-1 && wordvalue
[++wordnumber
] == AND
)
87 /* special cases with their own return()'s */
89 if (wordnumber
<= wordcount
&& wordtype
[wordnumber
] == NOUNS
)
90 switch(wordvalue
[wordnumber
]){
93 if (testbit(from
, SWORD
)){
94 wordtype
[wordnumber
--] = OBJECT
;
97 if (testbit(from
, TWO_HANDED
)){
98 wordvalue
[wordnumber
] = TWO_HANDED
;
99 wordtype
[wordnumber
--] = OBJECT
;
102 wordvalue
[wordnumber
] = BROAD
;
103 wordtype
[wordnumber
--] = OBJECT
;
107 if (testbit(from
,MAID
)){
108 wordvalue
[wordnumber
] = MAID
;
109 wordtype
[wordnumber
--] = OBJECT
;
112 else if (testbit(from
,DEADWOOD
)){
113 wordvalue
[wordnumber
] = DEADWOOD
;
114 wordtype
[wordnumber
--] = OBJECT
;
117 else if (testbit(from
,DEADNATIVE
)){
118 wordvalue
[wordnumber
] = DEADNATIVE
;
119 wordtype
[wordnumber
--] = OBJECT
;
122 else if (testbit(from
,DEADGOD
)){
123 wordvalue
[wordnumber
] = DEADGOD
;
124 wordtype
[wordnumber
--] = OBJECT
;
128 wordvalue
[wordnumber
] = DEADTIME
;
129 wordtype
[wordnumber
--] = OBJECT
;
135 if (testbit(location
[position
].objects
,AMULET
)){
136 puts("The amulet is warm to the touch, and its beauty catches your breath.");
137 puts("A mist falls over your eyes, but then it is gone. Sounds seem clearer");
138 puts("and sharper but far away as if in a dream. The sound of purling water reaches");
139 puts("you from afar. The mist falls again, and your heart leaps in horror. The gold");
140 puts("freezes your hands and fathomless darkness engulfs your soul.");
142 wordtype
[wordnumber
--] = OBJECT
;
146 if (testbit(location
[position
].objects
, MEDALION
)){
147 puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
148 puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
150 wordtype
[wordnumber
--] = OBJECT
;
154 if (testbit(location
[position
].objects
,TALISMAN
)){
155 puts("The talisman is cold to the touch, and it sends a chill down your spine.");
157 wordtype
[wordnumber
--] = OBJECT
;
161 if (testbit(location
[position
].objects
,BATHGOD
) && (testbit(wear
,AMULET
) || testbit(inven
,AMULET
))){
162 puts("She offers a delicate hand, and you help her out of the sparkling springs.");
163 puts("Water droplets like liquid silver bedew her golden skin, but when they part");
164 puts("from her, they fall as teardrops. She wraps a single cloth around her and");
165 puts("ties it at the waist. Around her neck hangs a golden amulet.");
166 puts("She bids you to follow her.");
169 clearbit(location
[position
].objects
,BATHGOD
);
170 } else if (!testbit(location
[position
].objects
,BATHGOD
))
171 puts("You're in no position to take her.");
173 puts("She moves away from you.");
177 puts("It doesn't seem to work.");
180 puts("You've got to be kidding.");
185 throw(const char *name
)
192 if (drop(name
) != -1){
193 switch(wordvalue
[wordnumber
]){
212 deposit
= location
[position
].up
* (location
[position
].access
|| position
== FINAL
);
216 deposit
= location
[position
].down
;
220 while (wordtype
[++wordnumber
] == ADJS
);
221 while (wordnumber
<= wordcount
){
222 value
= wordvalue
[wordnumber
];
223 if (deposit
&& testbit(location
[position
].objects
,value
)){
224 clearbit(location
[position
].objects
,value
);
225 if (value
!= GRENADE
)
226 setbit(location
[deposit
].objects
,value
);
228 puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
229 for (n
= 0; n
< NUMOFWORDS
; n
++)
230 location
[deposit
].objects
[n
] = 0;
231 setbit(location
[deposit
].objects
,CHAR
);
233 if (value
== ROPE
&& position
== FINAL
)
234 location
[position
].access
= 1;
238 puts("The stone door is unhinged.");
239 location
[189].north
= 231;
240 location
[231].south
= 189;
243 puts("The wooden door is blown open.");
244 location
[30].west
= 25;
247 puts("The door is not damaged.");
250 else if (value
== GRENADE
&& testbit(location
[position
].objects
,value
)){
251 puts("You are blown into shreds when your grenade explodes.");
254 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
265 drop(const char *name
)
268 int firstnumber
, value
;
270 firstnumber
= wordnumber
;
271 while (wordtype
[++wordnumber
] == ADJS
)
273 while (wordnumber
<=wordcount
&& (wordtype
[wordnumber
] == OBJECT
|| wordtype
[wordnumber
] == NOUNS
)) {
274 value
= wordvalue
[wordnumber
];
275 printf("%s:\n", objsht
[value
]);
276 if (testbit(inven
,value
)){
277 clearbit(inven
,value
);
278 carrying
-= objwt
[value
];
279 encumber
-= objcumber
[value
];
281 puts("The bomb explodes. A blinding white light and immense concussion obliterate us.");
284 if (value
!= AMULET
&& value
!= MEDALION
&& value
!= TALISMAN
)
285 setbit(location
[position
].objects
,value
);
290 puts("Drop kicked.");
292 printf("%s.\n", name
);
296 printf("You aren't holding the %s.\n", objsht
[value
]);
297 if (testbit(location
[position
].objects
,value
)) {
299 puts("Kicked instead.");
300 else if (*name
== 'G')
301 puts("Given anyway.");
306 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
318 wordnumber
= take(wear
);
319 return(drop("Dropped"));
325 wordnumber
= take(location
[position
].objects
);
332 int firstnumber
, value
;
334 firstnumber
= wordnumber
;
335 while(wordtype
[++wordnumber
] == ADJS
);
336 while(wordnumber
<= wordcount
){
337 value
= wordvalue
[wordnumber
];
345 printf("You can't eat%s%s!\n",
346 wordtype
[wordnumber
] == OBJECT
&&
348 [strlen(objsht
[value
]) - 1] == 's' ?
356 case COCONUTS
: /* eatable things */
359 printf("%s:\n",objsht
[value
]);
360 if (testbit(inven
,value
) && gtime
> ate
- CYCLE
&& testbit(inven
,KNIFE
)){
361 clearbit(inven
,value
);
362 carrying
-= objwt
[value
];
363 encumber
-= objcumber
[value
];
364 ate
= max(gtime
,ate
) + CYCLE
/3;
367 puts("Eaten. You can explore a little longer now.");
369 else if (gtime
< ate
- CYCLE
)
370 puts("You're stuffed.");
371 else if (!testbit(inven
,KNIFE
))
372 puts("You need a knife.");
374 printf("You aren't holding the %s.\n", objsht
[value
]);
375 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)