1 /* $NetBSD: command2.c,v 1.3 2005/07/01 06:04:54 jmc 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. 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. 18 * 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 29 * SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 #ifndef lint 34 #if 0 35 static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95"; 36 #else 37 __RCSID("$NetBSD: command2.c,v 1.3 2005/07/01 06:04:54 jmc Exp $"); 38 #endif 39 #endif /* not lint */ 40 41 #include "extern.h" 42 43 int 44 wearit(void) 45 { /* synonyms = {sheathe, sheath} */ 46 int firstnumber, value; 47 48 firstnumber = wordnumber; 49 wordnumber++; 50 while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || 51 wordtype[wordnumber] == NOUNS) && wordvalue[wordnumber] != DOOR) { 52 value = wordvalue[wordnumber]; 53 if (value >= 0 && objsht[value] == NULL) 54 break; 55 switch (value) { 56 57 case -1: 58 puts("Wear what?"); 59 return (firstnumber); 60 61 default: 62 printf("You can't wear %s%s!\n", 63 A_OR_AN_OR_BLANK(value), 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 ourtime++; 91 printf("You are now wearing %s%s.\n", 92 A_OR_AN_OR_THE(value), objsht[value]); 93 } else 94 if (testbit(wear, value)) { 95 printf("You are already wearing the %s", 96 objsht[value]); 97 printf(".\n"); 98 } else 99 printf("You aren't holding the %s.\n", 100 objsht[value]); 101 if (wordnumber < wordcount - 1 && 102 wordvalue[++wordnumber] == AND) 103 wordnumber++; 104 else 105 return (firstnumber); 106 } /* end switch */ 107 } /* end while */ 108 puts("Don't be ridiculous."); 109 return (firstnumber); 110 } 111 112 int 113 put(void) 114 { /* synonyms = {buckle, strap, tie} */ 115 if (wordvalue[wordnumber + 1] == ON) { 116 wordvalue[++wordnumber] = PUTON; 117 wordtype[wordnumber] = VERB; 118 return (cypher()); 119 } 120 if (wordvalue[wordnumber + 1] == DOWN) { 121 wordvalue[++wordnumber] = DROP; 122 wordtype[wordnumber] = VERB; 123 return (cypher()); 124 } 125 puts("I don't understand what you want to put."); 126 return (-1); 127 128 } 129 130 int 131 draw(void) 132 { /* synonyms = {pull, carry} */ 133 return (take(wear)); 134 } 135 136 int 137 use(void) 138 { 139 wordnumber++; 140 if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) && 141 position != FINAL) { 142 puts("The amulet begins to glow."); 143 if (testbit(inven, MEDALION)) { 144 puts("The medallion comes to life too."); 145 if (position == 114) { 146 location[position].down = 160; 147 whichway(location[position]); 148 printf("The waves subside and it is possible "); 149 puts("to descend to the sea cave now."); 150 ourtime++; 151 return (-1); 152 } 153 } 154 printf("A light mist falls over your eyes and the sound of "); 155 puts("purling water trickles in"); 156 printf("your ears. When the mist lifts you are standing "); 157 puts("beside a cool stream."); 158 if (position == 229) 159 position = 224; 160 else 161 position = 229; 162 ourtime++; 163 notes[CANTSEE] = 0; 164 return (0); 165 } else if (position == FINAL) 166 puts("The amulet won't work in here."); 167 else if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS)) 168 printf("Your compass points %s.\n", truedirec(NORTH, '-')); 169 else if (wordvalue[wordnumber] == COMPASS) 170 puts("You aren't holding the compass."); 171 else if (wordvalue[wordnumber] == AMULET) 172 puts("You aren't holding the amulet."); 173 else 174 puts("There is no apparent use."); 175 return (-1); 176 } 177 178 void 179 murder(void) 180 { 181 int n; 182 183 for (n = 0; 184 !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || 185 n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || 186 n == HALBERD) && testbit(inven, n)) && n < NUMOFOBJECTS; 187 n++); 188 if (n == NUMOFOBJECTS) { 189 if (testbit(inven, LASER)) { 190 printf("Your laser should do the trick.\n"); 191 wordnumber++; 192 switch(wordvalue[wordnumber]) { 193 case NORMGOD: 194 case TIMER: 195 case NATIVE: 196 case MAN: 197 wordvalue[--wordnumber] = SHOOT; 198 cypher(); 199 break; 200 case -1: 201 puts("Kill what?"); 202 break; 203 default: 204 if (wordtype[wordnumber] != OBJECT || 205 wordvalue[wordnumber] == EVERYTHING) 206 puts("You can't kill that!"); 207 else 208 printf("You can't kill %s%s!\n", 209 A_OR_AN_OR_BLANK(wordvalue[wordnumber]), 210 objsht[wordvalue[wordnumber]]); 211 break; 212 } 213 } else 214 puts("You don't have suitable weapons to kill."); 215 } else { 216 printf("Your %s should do the trick.\n", objsht[n]); 217 wordnumber++; 218 switch (wordvalue[wordnumber]) { 219 220 case NORMGOD: 221 if (testbit(location[position].objects, BATHGOD)) { 222 printf("The goddess's head slices off. Her "); 223 puts("corpse floats in the water."); 224 clearbit(location[position].objects, BATHGOD); 225 setbit(location[position].objects, DEADGOD); 226 power += 5; 227 notes[JINXED]++; 228 } else 229 if (testbit(location[position].objects, 230 NORMGOD)) { 231 printf("The goddess pleads but you "); 232 printf("strike her mercilessly. Her "); 233 printf("broken body lies in a\n"); 234 puts("pool of blood."); 235 clearbit(location[position].objects, 236 NORMGOD); 237 setbit(location[position].objects, 238 DEADGOD); 239 power += 5; 240 notes[JINXED]++; 241 if (wintime) 242 live(); 243 } else 244 puts("I don't see her anywhere."); 245 break; 246 case TIMER: 247 if (testbit(location[position].objects, TIMER)) { 248 puts("The old man offers no resistance."); 249 clearbit(location[position].objects, TIMER); 250 setbit(location[position].objects, DEADTIME); 251 power++; 252 notes[JINXED]++; 253 } else 254 puts("Who?"); 255 break; 256 case NATIVE: 257 if (testbit(location[position].objects, NATIVE)) { 258 printf("The girl screams as you cut her "); 259 puts("body to shreds. She is dead."); 260 clearbit(location[position].objects, NATIVE); 261 setbit(location[position].objects, DEADNATIVE); 262 power += 5; 263 notes[JINXED]++; 264 } else 265 puts("What girl?"); 266 break; 267 case MAN: 268 if (testbit(location[position].objects, MAN)) { 269 printf("You strike him to the ground, and "); 270 puts("he coughs up blood."); 271 puts("Your fantasy is over."); 272 die(); 273 } 274 case -1: 275 puts("Kill what?"); 276 break; 277 278 default: 279 if (wordtype[wordnumber] != OBJECT || 280 wordvalue[wordnumber] == EVERYTHING) 281 puts("You can't kill that!"); 282 else 283 printf("You can't kill the %s!\n", 284 objsht[wordvalue[wordnumber]]); 285 } 286 } 287 } 288 289 void 290 ravage(void) 291 { 292 while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount) 293 continue; 294 if (wordtype[wordnumber] == NOUNS && 295 (testbit(location[position].objects, wordvalue[wordnumber]) 296 || (wordvalue[wordnumber] == NORMGOD && 297 testbit(location[position].objects, BATHGOD)))) { 298 ourtime++; 299 switch (wordvalue[wordnumber]) { 300 case NORMGOD: 301 printf("You attack the goddess, and she screams as "); 302 puts("you beat her. She falls down"); 303 if (testbit(location[position].objects, BATHGOD)) { 304 printf("crying and tries to cover her "); 305 puts("nakedness."); 306 } else { 307 printf("crying and tries to hold her torn "); 308 puts("and bloodied dress around her."); 309 } 310 power += 5; 311 pleasure += 8; 312 ego -= 10; 313 wordnumber--; 314 godready = -30000; 315 murder(); 316 win = -30000; 317 break; 318 case NATIVE: 319 printf("The girl tries to run, but you catch her and "); 320 puts("throw her down. Her face is"); 321 printf("bleeding, and she screams as you tear off "); 322 puts("her clothes."); 323 power += 3; 324 pleasure += 5; 325 ego -= 10; 326 wordnumber--; 327 murder(); 328 if (rnd(100) < 50) { 329 printf("Her screams have attracted "); 330 puts("attention. I think we are surrounded."); 331 setbit(location[ahead].objects, WOODSMAN); 332 setbit(location[ahead].objects, DEADWOOD); 333 setbit(location[ahead].objects, MALLET); 334 setbit(location[back].objects, WOODSMAN); 335 setbit(location[back].objects, DEADWOOD); 336 setbit(location[back].objects, MALLET); 337 setbit(location[left].objects, WOODSMAN); 338 setbit(location[left].objects, DEADWOOD); 339 setbit(location[left].objects, MALLET); 340 setbit(location[right].objects, WOODSMAN); 341 setbit(location[right].objects, DEADWOOD); 342 setbit(location[right].objects, MALLET); 343 } 344 break; 345 default: 346 puts("You are perverted."); 347 } 348 } else 349 puts("Who?"); 350 } 351 352 int 353 follow(void) 354 { 355 if (followfight == ourtime) { 356 printf("The Dark Lord leaps away and runs down secret "); 357 puts("tunnels and corridors."); 358 printf("You chase him through the darkness and splash in "); 359 puts("pools of water."); 360 printf("You have cornered him. His laser sword extends "); 361 puts("as he steps forward."); 362 position = FINAL; 363 fight(DARK, 75); 364 setbit(location[position].objects, TALISMAN); 365 setbit(location[position].objects, AMULET); 366 return (0); 367 } else 368 if (followgod == ourtime) { 369 printf("The goddess leads you down a steamy tunnel "); 370 puts("and into a high, wide chamber."); 371 puts("She sits down on a throne."); 372 position = 268; 373 setbit(location[position].objects, NORMGOD); 374 notes[CANTSEE] = 1; 375 return (0); 376 } else 377 puts("There is no one to follow."); 378 return (-1); 379 } 380