]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/command4.c
1 /* $NetBSD: command4.c,v 1.2 2003/08/07 09:37:00 agc 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. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)com4.c 8.2 (Berkeley) 4/28/95";
37 __RCSID("$NetBSD: command4.c,v 1.2 2003/08/07 09:37:00 agc Exp $");
47 int firstnumber
, heavy
, bulky
, value
;
49 firstnumber
= wordnumber
;
50 if (wordnumber
< wordcount
&& wordvalue
[wordnumber
+ 1] == OFF
) {
52 wordvalue
[wordnumber
] = TAKEOFF
;
53 wordtype
[wordnumber
] = VERB
;
57 while (wordnumber
<= wordcount
&& wordtype
[wordnumber
] == OBJECT
) {
58 value
= wordvalue
[wordnumber
];
59 printf("%s:\n", objsht
[value
]);
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");
71 clearbit(from
, value
);
72 if (value
== MEDALION
)
74 } else if (testbit(inven
, value
))
75 printf("You're already holding %s%s.\n",
76 A_OR_AN_OR_BLANK(value
),
78 else if (!testbit(from
, value
))
79 printf("I don't see any %s around here.\n", objsht
[value
]);
81 printf("The %s %stoo heavy.\n", objsht
[value
],
84 printf("The %s %stoo cumbersome to hold.\n",
85 objsht
[value
], IS_OR_ARE(value
));
86 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
92 /* special cases with their own return()'s */
94 if (wordnumber
<= wordcount
&& wordtype
[wordnumber
] == NOUNS
)
95 switch (wordvalue
[wordnumber
]) {
98 if (testbit(from
, SWORD
)) {
99 wordtype
[wordnumber
--] = OBJECT
;
102 if (testbit(from
, TWO_HANDED
)) {
103 wordvalue
[wordnumber
] = TWO_HANDED
;
104 wordtype
[wordnumber
--] = OBJECT
;
107 wordvalue
[wordnumber
] = BROAD
;
108 wordtype
[wordnumber
--] = OBJECT
;
112 if (testbit(from
, MAID
)) {
113 wordvalue
[wordnumber
] = MAID
;
114 wordtype
[wordnumber
--] = OBJECT
;
116 } else if (testbit(from
, DEADWOOD
)) {
117 wordvalue
[wordnumber
] = DEADWOOD
;
118 wordtype
[wordnumber
--] = OBJECT
;
120 } else if (testbit(from
, DEADNATIVE
)) {
121 wordvalue
[wordnumber
] = DEADNATIVE
;
122 wordtype
[wordnumber
--] = OBJECT
;
125 if (testbit(from
, DEADGOD
)) {
126 wordvalue
[wordnumber
] = DEADGOD
;
127 wordtype
[wordnumber
--] = OBJECT
;
130 wordvalue
[wordnumber
] = DEADTIME
;
131 wordtype
[wordnumber
--] = OBJECT
;
138 if (testbit(location
[position
].objects
, AMULET
)) {
139 puts("The amulet is warm to the touch, and its beauty catches your breath.");
140 puts("A mist falls over your eyes, but then it is gone. Sounds seem clearer");
141 puts("and sharper but far away as if in a dream. The sound of purling water");
142 puts("reaches you from afar. The mist falls again, and your heart leaps in horror.");
143 puts("The gold freezes your hands and fathomless darkness engulfs your soul.");
145 wordtype
[wordnumber
--] = OBJECT
;
149 if (testbit(location
[position
].objects
, MEDALION
)) {
150 puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
151 puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
153 wordtype
[wordnumber
--] = OBJECT
;
157 if (testbit(location
[position
].objects
, TALISMAN
)) {
158 puts("The talisman is cold to the touch, and it sends a chill down your spine.");
160 wordtype
[wordnumber
--] = OBJECT
;
164 if (testbit(location
[position
].objects
, BATHGOD
) && (testbit(wear
, AMULET
) || testbit(inven
, AMULET
))) {
165 puts("She offers a delicate hand, and you help her out of the sparkling springs.");
166 puts("Water droplets like liquid silver bedew her golden skin, but when they part");
167 puts("from her, they fall as teardrops. She wraps a single cloth around her and");
168 puts("ties it at the waist. Around her neck hangs a golden amulet.");
169 puts("She bids you to follow her, and walks away.");
172 clearbit(location
[position
].objects
, BATHGOD
);
174 if (!testbit(location
[position
].objects
, BATHGOD
))
175 puts("You're in no position to take her.");
177 puts("She moves away from you.");
181 puts("It doesn't seem to work.");
184 puts("You've got to be kidding.");
185 return (firstnumber
);
197 if (drop(name
) != -1) {
198 switch (wordvalue
[wordnumber
]) {
217 deposit
= location
[position
].up
* (location
[position
].access
|| position
== FINAL
);
221 deposit
= location
[position
].down
;
224 wordnumber
= first
+ 1;
225 while (wordnumber
<= wordcount
) {
226 value
= wordvalue
[wordnumber
];
227 if (deposit
&& testbit(location
[position
].objects
, value
)) {
228 clearbit(location
[position
].objects
, value
);
229 if (value
!= GRENADE
)
230 setbit(location
[deposit
].objects
, value
);
232 puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
233 for (n
= 0; n
< NUMOFWORDS
; n
++)
234 location
[deposit
].objects
[n
] = 0;
235 setbit(location
[deposit
].objects
, CHAR
);
237 if (value
== ROPE
&& position
== FINAL
)
238 location
[position
].access
= 1;
242 puts("The stone door is unhinged.");
243 location
[189].north
= 231;
244 location
[231].south
= 189;
247 puts("The wooden door is blown open.");
248 location
[30].west
= 25;
251 puts("The door is not damaged.");
254 if (value
== GRENADE
&& testbit(location
[position
].objects
, value
)) {
255 puts("You are blown into shreds when your grenade explodes.");
258 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
273 int firstnumber
, value
;
275 firstnumber
= wordnumber
;
277 while (wordnumber
<= wordcount
&& (wordtype
[wordnumber
] == OBJECT
|| wordtype
[wordnumber
] == NOUNS
)) {
278 value
= wordvalue
[wordnumber
];
279 if (value
== BODY
) { /* special case */
280 wordtype
[wordnumber
] = OBJECT
;
281 if (testbit(inven
, MAID
) || testbit(location
[position
].objects
, MAID
))
283 else if (testbit(inven
, DEADWOOD
) || testbit(location
[position
].objects
, DEADWOOD
))
285 else if (testbit(inven
, DEADGOD
) || testbit(location
[position
].objects
, DEADGOD
))
287 else if (testbit(inven
, DEADTIME
) || testbit(location
[position
].objects
, DEADTIME
))
289 else if (testbit(inven
, DEADNATIVE
) || testbit(location
[position
].objects
, DEADNATIVE
))
292 if (wordtype
[wordnumber
] == NOUNS
&& value
== DOOR
) {
294 puts("You hurt your foot.");
296 puts("You're not holding a door.");
297 } else if (objsht
[value
] == NULL
) {
299 puts("That's not for kicking!");
301 puts("You don't have that.");
303 printf("%s:\n", objsht
[value
]);
304 if (testbit(inven
, value
)) {
305 clearbit(inven
, value
);
306 carrying
-= objwt
[value
];
307 encumber
-= objcumber
[value
];
309 puts("The bomb explodes. A blinding white light and immense concussion obliterate us.");
312 if (value
!= AMULET
&& value
!= MEDALION
&& value
!= TALISMAN
)
313 setbit(location
[position
].objects
, value
);
318 puts("Drop kicked.");
320 printf("%s.\n", name
);
323 printf("You aren't holding the %s.\n", objsht
[value
]);
324 if (testbit(location
[position
].objects
, value
)) {
326 puts("Kicked instead.");
327 else if (*name
== 'G')
328 puts("Given anyway.");
330 } else if (testbit(location
[position
].objects
, value
))
332 else if (testbit(wear
, value
))
333 puts("Not while it's being worn.");
338 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
341 return (firstnumber
);
350 wordnumber
= take(wear
);
351 return (drop("Dropped"));
357 wordnumber
= take(location
[position
].objects
);
364 int firstnumber
, value
;
366 firstnumber
= wordnumber
;
368 while (wordnumber
<= wordcount
) {
369 value
= wordvalue
[wordnumber
];
370 if (wordtype
[wordnumber
] != OBJECT
|| objsht
[value
] == NULL
)
375 puts("You can't eat that!");
376 return (firstnumber
);
380 return (firstnumber
);
383 printf("You can't eat %s%s!\n",
384 A_OR_AN_OR_BLANK(value
), objsht
[value
]);
385 return (firstnumber
);
390 case COCONUTS
: /* eatable things */
393 printf("%s:\n", objsht
[value
]);
394 if (testbit(inven
, value
) &&
395 ourtime
> ate
- CYCLE
&&
396 testbit(inven
, KNIFE
)) {
397 clearbit(inven
, value
);
398 carrying
-= objwt
[value
];
399 encumber
-= objcumber
[value
];
400 ate
= max(ourtime
, ate
) + CYCLE
/ 3;
401 snooze
+= CYCLE
/ 10;
403 puts("Eaten. You can explore a little longer now.");
404 } else if (!testbit(inven
, value
))
405 printf("You aren't holding the %s.\n", objsht
[value
]);
406 else if (!testbit(inven
, KNIFE
))
407 puts("You need a knife.");
409 puts("You're stuffed.");
410 if (wordnumber
< wordcount
- 1 && wordvalue
[++wordnumber
] == AND
)
413 return (firstnumber
);
416 return (firstnumber
);