Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / games / battlestar / com2.c
blob211535ac3bf8061eaf6bf235bc96746db3d12e36
1 /*
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
7 * are met:
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
31 * SUCH DAMAGE.
33 * @(#)com2.c 8.1 (Berkeley) 5/31/93
34 * $FreeBSD: src/games/battlestar/com2.c,v 1.8.2.2 2002/05/01 09:17:16 roam Exp $
35 * $DragonFly: src/games/battlestar/com2.c,v 1.3 2006/08/08 16:47:20 pavalos Exp $
38 #include "externs.h"
40 int
41 wearit(void) /* synonyms = {sheathe, sheath} */
43 int n;
44 int firstnumber, value;
46 firstnumber = wordnumber;
47 while(wordtype[++wordnumber] == ADJS);
48 while(wordnumber <= wordcount){
49 value = wordvalue[wordnumber];
50 if (value == -1) {
51 puts("Wear what?");
52 return (firstnumber);
54 for (n=0; objsht[value][n]; n++);
55 switch(value){
56 default:
57 printf("You can't wear%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
58 return(firstnumber);
60 case KNIFE:
61 /* case SHIRT: */
62 case ROBE:
63 case LEVIS: /* wearable things */
64 case SWORD:
65 case MAIL:
66 case HELM:
67 case SHOES:
68 case PAJAMAS:
69 case COMPASS:
70 case LASER:
71 case AMULET:
72 case TALISMAN:
73 case MEDALION:
74 case ROPE:
75 case RING:
76 case BRACELET:
77 case GRENADE:
79 if (testbit(inven,value)){
80 clearbit(inven,value);
81 setbit(wear,value);
82 carrying -= objwt[value];
83 encumber -= objcumber[value];
84 gtime++;
85 printf("You are now wearing %s %s.\n",(objsht[value][n-1] == 's' ? "the" : "a"), objsht[value]);
87 else if (testbit(wear,value))
88 printf("You are already wearing the %s.\n", objsht[value]);
89 else
90 printf("You aren't holding the %s.\n", objsht[value]);
91 if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
92 wordnumber++;
93 else
94 return(firstnumber);
95 } /* end switch */
96 } /* end while */
97 puts("Don't be ridiculous.");
98 return(firstnumber);
102 put(void) /* synonyms = {buckle, strap, tie} */
104 if (wordvalue[wordnumber + 1] == ON){
105 wordvalue[++wordnumber] = PUTON;
106 return(cypher());
108 if (wordvalue[wordnumber + 1] == DOWN){
109 wordvalue[++wordnumber] = DROP;
110 return(cypher());
112 puts("I don't understand what you want to put.");
113 return(-1);
118 draw(void) /* synonyms = {pull, carry} */
120 return(take(wear));
124 use(void)
126 while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount);
127 if (wordvalue[wordnumber] == AMULET && testbit(inven,AMULET) && position != FINAL){
128 puts("The amulet begins to glow.");
129 if (testbit(inven,MEDALION)){
130 puts("The medallion comes to life too.");
131 if (position == 114){
132 location[position].down = 160;
133 whichway(location[position]);
134 puts("The waves subside and it is possible to descend to the sea cave now.");
135 gtime++;
136 return(-1);
139 puts("A light mist falls over your eyes and the sound of purling water trickles in");
140 puts("your ears. When the mist lifts you are standing beside a cool stream.");
141 if (position == 229)
142 position = 224;
143 else
144 position = 229;
145 gtime++;
146 notes[CANTSEE] = 0;
147 return(0);
149 else if (position == FINAL)
150 puts("The amulet won't work in here.");
151 else if (wordvalue[wordnumber] == COMPASS && testbit(inven,COMPASS))
152 printf("Your compass points %s.\n",truedirec(NORTH,'-'));
153 else if (wordvalue[wordnumber] == COMPASS)
154 puts("You aren't holding the compass.");
155 else if (wordvalue[wordnumber] == AMULET)
156 puts("You aren't holding the amulet.");
157 else
158 puts("There is no apparent use.");
159 return(-1);
162 void
163 murder(void)
165 int n;
167 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++);
168 if (n == NUMOFOBJECTS)
169 puts("You don't have suitable weapons to kill.");
170 else {
171 printf("Your %s should do the trick.\n",objsht[n]);
172 while (wordtype[++wordnumber] == ADJS);
173 switch(wordvalue[wordnumber]){
175 case NORMGOD:
176 if (testbit(location[position].objects,BATHGOD)){
177 puts("The goddess's head slices off. Her corpse floats in the water.");
178 clearbit(location[position].objects,BATHGOD);
179 setbit(location[position].objects,DEADGOD);
180 power += 5;
181 notes[JINXED]++;
182 } else if (testbit(location[position].objects,NORMGOD)){
183 puts("The goddess pleads but you strike her mercilessly. Her broken body lies in a\npool of blood.");
184 clearbit(location[position].objects,NORMGOD);
185 setbit(location[position].objects,DEADGOD);
186 power += 5;
187 notes[JINXED]++;
188 if (wintime)
189 live();
190 } else puts("I dont see her anywhere.");
191 break;
192 case TIMER:
193 if (testbit(location[position].objects,TIMER)){
194 puts("The old man offers no resistance.");
195 clearbit(location[position].objects,TIMER);
196 setbit(location[position].objects,DEADTIME);
197 power++;
198 notes[JINXED]++;
199 } else puts("Who?");
200 break;
201 case NATIVE:
202 if (testbit(location[position].objects,NATIVE)){
203 puts("The girl screams as you cut her body to shreds. She is dead.");
204 clearbit(location[position].objects,NATIVE);
205 setbit(location[position].objects,DEADNATIVE);
206 power += 5;
207 notes[JINXED]++;
208 } else puts("What girl?");
209 break;
210 case MAN:
211 if (testbit(location[position].objects,MAN)){
212 puts("You strike him to the ground, and he coughs up blood.");
213 puts("Your fantasy is over.");
214 die(0);
216 case -1:
217 puts("Kill what?");
218 break;
220 default:
221 if (wordtype[wordnumber] != NOUNS)
222 puts("Kill what?");
223 else
224 printf("You can't kill the %s!\n",objsht[wordvalue[wordnumber]]);
229 void
230 ravage(void)
232 while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
233 if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
234 gtime++;
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 bs_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);
270 break;
271 default:
272 puts("You are perverted.");
275 else
276 puts("Who?");
280 follow(void)
282 if (followfight == gtime){
283 puts("The Dark Lord leaps away and runs down secret tunnels and corridors.");
284 puts("You chase him through the darkness and splash in pools of water.");
285 puts("You have cornered him. His laser sword extends as he steps forward.");
286 position = FINAL;
287 fight(DARK,75);
288 setbit(location[position].objects,TALISMAN);
289 setbit(location[position].objects,AMULET);
290 return(0);
292 else if (followgod == gtime){
293 puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
294 puts("She sits down on a throne.");
295 position = 268;
296 setbit(location[position].objects,NORMGOD);
297 notes[CANTSEE] = 1;
298 return(0);
300 else
301 puts("There is no one to follow.");
302 return(-1);