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.2 2003/06/17 04:25:22 dillon Exp $
45 int firstnumber
, heavy
, bulky
, value
;
48 firstnumber
= wordnumber
;
49 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+1] == OFF
){
51 wordvalue
[wordnumber
] = TAKEOFF
;
55 while(wordtype
[++wordnumber
] == ADJS
);
56 while(wordnumber
<=wordcount
&& wordtype
[wordnumber
] == OBJECT
){
57 value
= wordvalue
[wordnumber
];
58 printf("%s:\n", objsht
[value
]);
59 for (n
=0; objsht
[value
][n
]; n
++);
60 heavy
= (carrying
+ objwt
[value
]) <= WEIGHT
;
61 bulky
= (encumber
+ objcumber
[value
]) <= CUMBER
;
62 if ((testbit(from
,value
) || wiz
|| tempwiz
) && heavy
&& bulky
&& !testbit(inven
,value
)){
64 carrying
+= objwt
[value
];
65 encumber
+= objcumber
[value
];
67 if (testbit(from
,value
))
70 printf("Zap! Taken from thin air.\n");
72 if (value
== MEDALION
)
75 else if (testbit(inven
,value
))
76 printf("You're already holding%s%s.\n", (objsht
[value
][n
-1] == 's' ? " " : " a "),objsht
[value
]);
78 printf("The %s %s too heavy.\n", objsht
[value
],(objsht
[value
][n
-1] == 's' ? "are" : "is"));
80 printf("The %s %s too cumbersome to hold.\n", objsht
[value
],(objsht
[value
][n
-1] == 's' ? "are" : "is"));
82 printf("I dont see any %s around here.\n", objsht
[value
]);
83 if (wordnumber
< wordcount
-1 && wordvalue
[++wordnumber
] == AND
)
89 /* special cases with their own return()'s */
91 if (wordnumber
<= wordcount
&& wordtype
[wordnumber
] == NOUNS
)
92 switch(wordvalue
[wordnumber
]){
95 if (testbit(from
, SWORD
)){
96 wordtype
[wordnumber
--] = OBJECT
;
99 if (testbit(from
, TWO_HANDED
)){
100 wordvalue
[wordnumber
] = TWO_HANDED
;
101 wordtype
[wordnumber
--] = OBJECT
;
104 wordvalue
[wordnumber
] = BROAD
;
105 wordtype
[wordnumber
--] = OBJECT
;
109 if (testbit(from
,MAID
)){
110 wordvalue
[wordnumber
] = MAID
;
111 wordtype
[wordnumber
--] = OBJECT
;
114 else if (testbit(from
,DEADWOOD
)){
115 wordvalue
[wordnumber
] = DEADWOOD
;
116 wordtype
[wordnumber
--] = OBJECT
;
119 else if (testbit(from
,DEADNATIVE
)){
120 wordvalue
[wordnumber
] = DEADNATIVE
;
121 wordtype
[wordnumber
--] = OBJECT
;
124 else if (testbit(from
,DEADGOD
)){
125 wordvalue
[wordnumber
] = DEADGOD
;
126 wordtype
[wordnumber
--] = OBJECT
;
130 wordvalue
[wordnumber
] = DEADTIME
;
131 wordtype
[wordnumber
--] = OBJECT
;
137 if (testbit(location
[position
].objects
,AMULET
)){
138 puts("The amulet is warm to the touch, and its beauty catches your breath.");
139 puts("A mist falls over your eyes, but then it is gone. Sounds seem clearer");
140 puts("and sharper but far away as if in a dream. The sound of purling water reaches");
141 puts("you from afar. The mist falls again, and your heart leaps in horror. The gold");
142 puts("freezes your hands and fathomless darkness engulfs your soul.");
144 wordtype
[wordnumber
--] = OBJECT
;
148 if (testbit(location
[position
].objects
, MEDALION
)){
149 puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
150 puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
152 wordtype
[wordnumber
--] = OBJECT
;
156 if (testbit(location
[position
].objects
,TALISMAN
)){
157 puts("The talisman is cold to the touch, and it sends a chill down your spine.");
159 wordtype
[wordnumber
--] = OBJECT
;
163 if (testbit(location
[position
].objects
,BATHGOD
) && (testbit(wear
,AMULET
) || testbit(inven
,AMULET
))){
164 puts("She offers a delicate hand, and you help her out of the sparkling springs.");
165 puts("Water droplets like liquid silver bedew her golden skin, but when they part");
166 puts("from her, they fall as teardrops. She wraps a single cloth around her and");
167 puts("ties it at the waist. Around her neck hangs a golden amulet.");
168 puts("She bids you to follow her.");
171 clearbit(location
[position
].objects
,BATHGOD
);
172 } else if (!testbit(location
[position
].objects
,BATHGOD
))
173 puts("You're in no position to take her.");
175 puts("She moves away from you.");
179 puts("It doesn't seem to work.");
182 puts("You've got to be kidding.");
195 if (drop(name
) != -1){
196 switch(wordvalue
[wordnumber
]){
215 deposit
= location
[position
].up
* (location
[position
].access
|| position
== FINAL
);
219 deposit
= location
[position
].down
;
223 while (wordtype
[++wordnumber
] == ADJS
);
224 while (wordnumber
<= wordcount
){
225 value
= wordvalue
[wordnumber
];
226 if (deposit
&& testbit(location
[position
].objects
,value
)){
227 clearbit(location
[position
].objects
,value
);
228 if (value
!= GRENADE
)
229 setbit(location
[deposit
].objects
,value
);
231 puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
232 for (n
= 0; n
< NUMOFWORDS
; n
++)
233 location
[deposit
].objects
[n
] = 0;
234 setbit(location
[deposit
].objects
,CHAR
);
236 if (value
== ROPE
&& position
== FINAL
)
237 location
[position
].access
= 1;
241 puts("The stone door is unhinged.");
242 location
[189].north
= 231;
243 location
[231].south
= 189;
246 puts("The wooden door is blown open.");
247 location
[30].west
= 25;
250 puts("The door is not damaged.");
253 else if (value
== GRENADE
&& testbit(location
[position
].objects
,value
)){
254 puts("You are blown into shreds when your grenade explodes.");
257 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
272 int firstnumber
, value
;
274 firstnumber
= wordnumber
;
275 while (wordtype
[++wordnumber
] == ADJS
)
277 while (wordnumber
<=wordcount
&& (wordtype
[wordnumber
] == OBJECT
|| wordtype
[wordnumber
] == NOUNS
)) {
278 value
= wordvalue
[wordnumber
];
279 printf("%s:\n", objsht
[value
]);
280 if (testbit(inven
,value
)){
281 clearbit(inven
,value
);
282 carrying
-= objwt
[value
];
283 encumber
-= objcumber
[value
];
285 puts("The bomb explodes. A blinding white light and immense concussion obliterate us.");
288 if (value
!= AMULET
&& value
!= MEDALION
&& value
!= TALISMAN
)
289 setbit(location
[position
].objects
,value
);
294 puts("Drop kicked.");
296 printf("%s.\n", name
);
300 printf("You aren't holding the %s.\n", objsht
[value
]);
301 if (testbit(location
[position
].objects
,value
)) {
303 puts("Kicked instead.");
304 else if (*name
== 'G')
305 puts("Given anyway.");
310 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
322 wordnumber
= take(wear
);
323 return(drop("Dropped"));
329 wordnumber
= take(location
[position
].objects
);
336 int firstnumber
, value
;
338 firstnumber
= wordnumber
;
339 while(wordtype
[++wordnumber
] == ADJS
);
340 while(wordnumber
<= wordcount
){
341 value
= wordvalue
[wordnumber
];
349 printf("You can't eat%s%s!\n",
350 wordtype
[wordnumber
] == OBJECT
&&
352 [strlen(objsht
[value
]) - 1] == 's' ?
360 case COCONUTS
: /* eatable things */
363 printf("%s:\n",objsht
[value
]);
364 if (testbit(inven
,value
) && gtime
> ate
- CYCLE
&& testbit(inven
,KNIFE
)){
365 clearbit(inven
,value
);
366 carrying
-= objwt
[value
];
367 encumber
-= objcumber
[value
];
368 ate
= max(gtime
,ate
) + CYCLE
/3;
371 puts("Eaten. You can explore a little longer now.");
373 else if (gtime
< ate
- CYCLE
)
374 puts("You're stuffed.");
375 else if (!testbit(inven
,KNIFE
))
376 puts("You need a knife.");
378 printf("You aren't holding the %s.\n", objsht
[value
]);
379 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)