]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/com2.c
curses needs termcap
[bsdgames-darwin.git] / battlestar / com2.c
1 /* $NetBSD: com2.c,v 1.4 1997/01/07 11:56:35 tls Exp $ */
2
3 /*
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
22 *
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
33 * SUCH DAMAGE.
34 */
35
36 #ifndef lint
37 #if 0
38 static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95";
39 #else
40 static char rcsid[] = "$NetBSD: com2.c,v 1.4 1997/01/07 11:56:35 tls Exp $";
41 #endif
42 #endif /* not lint */
43
44 #include "extern.h"
45
46 wearit() /* synonyms = {sheathe, sheath} */
47 {
48 register int n;
49 int firstnumber, value;
50
51 firstnumber = wordnumber;
52 while(wordtype[++wordnumber] == ADJS);
53 while(wordnumber <= wordcount){
54 value = wordvalue[wordnumber];
55 for (n=0; objsht[value][n]; n++);
56 switch(value){
57
58 case -1:
59 puts("Wear what?");
60 return(firstnumber);
61
62 default:
63 printf("You can't wear%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
64 return(firstnumber);
65
66 case KNIFE:
67 /* case SHIRT: */
68 case ROBE:
69 case LEVIS: /* wearable things */
70 case SWORD:
71 case MAIL:
72 case HELM:
73 case SHOES:
74 case PAJAMAS:
75 case COMPASS:
76 case LASER:
77 case AMULET:
78 case TALISMAN:
79 case MEDALION:
80 case ROPE:
81 case RING:
82 case BRACELET:
83 case GRENADE:
84
85 if (testbit(inven,value)){
86 clearbit(inven,value);
87 setbit(wear,value);
88 carrying -= objwt[value];
89 encumber -= objcumber[value];
90 time++;
91 printf("You are now wearing %s %s.\n",(objsht[value][n-1] == 's' ? "the" : "a"), objsht[value]);
92 }
93 else if (testbit(wear,value))
94 printf("You are already wearing the %s.\n", objsht[value]);
95 else
96 printf("You aren't holding the %s.\n", objsht[value]);
97 if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
98 wordnumber++;
99 else
100 return(firstnumber);
101 } /* end switch */
102 } /* end while */
103 puts("Don't be ridiculous.");
104 return(firstnumber);
105 }
106
107 put() /* synonyms = {buckle, strap, tie} */
108 {
109 if (wordvalue[wordnumber + 1] == ON){
110 wordvalue[++wordnumber] = PUTON;
111 return(cypher());
112 }
113 if (wordvalue[wordnumber + 1] == DOWN){
114 wordvalue[++wordnumber] = DROP;
115 return(cypher());
116 }
117 puts("I don't understand what you want to put.");
118 return(-1);
119
120 }
121
122 draw() /* synonyms = {pull, carry} */
123 {
124 return(take(wear));
125 }
126
127 use()
128 {
129 while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount);
130 if (wordvalue[wordnumber] == AMULET && testbit(inven,AMULET) && position != FINAL){
131 puts("The amulet begins to glow.");
132 if (testbit(inven,MEDALION)){
133 puts("The medallion comes to life too.");
134 if (position == 114){
135 location[position].down = 160;
136 whichway(location[position]);
137 puts("The waves subside and it is possible to descend to the sea cave now.");
138 time++;
139 return(-1);
140 }
141 }
142 puts("A light mist falls over your eyes and the sound of purling water trickles in");
143 puts("your ears. When the mist lifts you are standing beside a cool stream.");
144 if (position == 229)
145 position = 224;
146 else
147 position = 229;
148 time++;
149 return(0);
150 }
151 else if (position == FINAL)
152 puts("The amulet won't work in here.");
153 else if (wordvalue[wordnumber] == COMPASS && testbit(inven,COMPASS))
154 printf("Your compass points %s.\n",truedirec(NORTH,'-'));
155 else if (wordvalue[wordnumber] == COMPASS)
156 puts("You aren't holding the compass.");
157 else if (wordvalue[wordnumber] == AMULET)
158 puts("You aren't holding the amulet.");
159 else
160 puts("There is no apparent use.");
161 return(-1);
162 }
163
164 murder()
165 {
166 register int n;
167
168 for (n=0; !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || n == HALBERD) && testbit(inven,n)) && n < NUMOFOBJECTS; n++);
169 if (n == NUMOFOBJECTS)
170 puts("You don't have suitable weapons to kill.");
171 else {
172 printf("Your %s should do the trick.\n",objsht[n]);
173 while (wordtype[++wordnumber] == ADJS);
174 switch(wordvalue[wordnumber]){
175
176 case NORMGOD:
177 if (testbit(location[position].objects,BATHGOD)){
178 puts("The goddess's head slices off. Her corpse floats in the water.");
179 clearbit(location[position].objects,BATHGOD);
180 setbit(location[position].objects,DEADGOD);
181 power += 5;
182 notes[JINXED]++;
183 } else if (testbit(location[position].objects,NORMGOD)){
184 puts("The goddess pleads but you strike her mercilessly. Her broken body lies in a\npool of blood.");
185 clearbit(location[position].objects,NORMGOD);
186 setbit(location[position].objects,DEADGOD);
187 power += 5;
188 notes[JINXED]++;
189 if (wintime)
190 live();
191 } else puts("I dont see her anywhere.");
192 break;
193 case TIMER:
194 if (testbit(location[position].objects,TIMER)){
195 puts("The old man offers no resistance.");
196 clearbit(location[position].objects,TIMER);
197 setbit(location[position].objects,DEADTIME);
198 power++;
199 notes[JINXED]++;
200 } else puts("Who?");
201 break;
202 case NATIVE:
203 if (testbit(location[position].objects,NATIVE)){
204 puts("The girl screams as you cut her body to shreds. She is dead.");
205 clearbit(location[position].objects,NATIVE);
206 setbit(location[position].objects,DEADNATIVE);
207 power += 5;
208 notes[JINXED]++;
209 } else puts("What girl?");
210 break;
211 case MAN:
212 if (testbit(location[position].objects,MAN)){
213 puts("You strike him to the ground, and he coughs up blood.");
214 puts("Your fantasy is over.");
215 die();
216 }
217 case -1:
218 puts("Kill what?");
219 break;
220
221 default:
222 if (wordtype[wordnumber] != NOUNS)
223 puts("Kill what?");
224 else
225 printf("You can't kill the %s!\n",objsht[wordvalue[wordnumber]]);
226 }
227 }
228 }
229
230 ravage()
231 {
232 while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
233 if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
234 time++;
235 switch(wordvalue[wordnumber]){
236 case NORMGOD:
237 puts("You attack the goddess, and she screams as you beat her. She falls down");
238 puts("crying and tries to hold her torn and bloodied dress around her.");
239 power += 5;
240 pleasure += 8;
241 ego -= 10;
242 wordnumber--;
243 godready = -30000;
244 murder();
245 win = -30000;
246 break;
247 case NATIVE:
248 puts("The girl tries to run, but you catch her and throw her down. Her face is");
249 puts("bleeding, and she screams as you tear off her clothes.");
250 power += 3;
251 pleasure += 5;
252 ego -= 10;
253 wordnumber--;
254 murder();
255 if (rnd(100) < 50){
256 puts("Her screams have attracted attention. I think we are surrounded.");
257 setbit(location[ahead].objects,WOODSMAN);
258 setbit(location[ahead].objects,DEADWOOD);
259 setbit(location[ahead].objects,MALLET);
260 setbit(location[back].objects,WOODSMAN);
261 setbit(location[back].objects,DEADWOOD);
262 setbit(location[back].objects,MALLET);
263 setbit(location[left].objects,WOODSMAN);
264 setbit(location[left].objects,DEADWOOD);
265 setbit(location[left].objects,MALLET);
266 setbit(location[right].objects,WOODSMAN);
267 setbit(location[right].objects,DEADWOOD);
268 setbit(location[right].objects,MALLET);
269 }
270 break;
271 default:
272 puts("You are perverted.");
273 }
274 }
275 else
276 puts("Who?");
277 }
278
279 follow()
280 {
281 if (followfight == time){
282 puts("The Dark Lord leaps away and runs down secret tunnels and corridoors.");
283 puts("You chase him through the darkness and splash in pools of water.");
284 puts("You have cornered him. His laser sword extends as he steps forward.");
285 position = FINAL;
286 fight(DARK,75);
287 setbit(location[position].objects,TALISMAN);
288 setbit(location[position].objects,AMULET);
289 return(0);
290 }
291 else if (followgod == time){
292 puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
293 puts("She sits down on a throne.");
294 position = 268;
295 setbit(location[position].objects,NORMGOD);
296 notes[CANTSEE] = 1;
297 return(0);
298 }
299 else
300 puts("There is no one to follow.");
301 return(-1);
302 }