1/* $OpenBSD: command2.c,v 1.1 2020/12/15 00:38:18 daniel Exp $ */ 2/* $NetBSD: com2.c,v 1.3 1995/03/21 15:06:55 cgd Exp $ */ 3 4/* 5 * Copyright (c) 1983, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#include <stdio.h> 34#include <stdlib.h> 35 36#include "extern.h" 37 38int 39wearit(void) 40{ /* synonyms = {sheathe, sheath} */ 41 int firstnumber, value; 42 43 firstnumber = wordnumber; 44 wordnumber++; 45 while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT || 46 (wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] != DOOR))) { 47 value = wordvalue[wordnumber]; 48 if (value >= 0 && objsht[value] == NULL) 49 break; 50 switch (value) { 51 52 case -1: 53 puts("Wear what?"); 54 return (firstnumber); 55 56 default: 57 printf("You can't wear %s%s!\n", 58 A_OR_AN_OR_BLANK(value), objsht[value]); 59 return (firstnumber); 60 61 case KNIFE: 62 /* case SHIRT: */ 63 case ROBE: 64 case LEVIS: /* wearable things */ 65 case SWORD: 66 case MAIL: 67 case HELM: 68 case SHOES: 69 case PAJAMAS: 70 case COMPASS: 71 case LASER: 72 case AMULET: 73 case TALISMAN: 74 case MEDALION: 75 case ROPE: 76 case RING: 77 case BRACELET: 78 case GRENADE: 79 80 if (TestBit(inven, value)) { 81 ClearBit(inven, value); 82 SetBit(wear, value); 83 carrying -= objwt[value]; 84 encumber -= objcumber[value]; 85 ourtime++; 86 printf("You are now wearing %s%s.\n", 87 A_OR_AN_OR_THE(value), objsht[value]); 88 } else 89 if (TestBit(wear, value)) 90 printf("You are already wearing the %s.\n", 91 objsht[value]); 92 else 93 printf("You aren't holding the %s.\n", 94 objsht[value]); 95 if (wordnumber < wordcount - 1 && 96 wordvalue[++wordnumber] == AND) 97 wordnumber++; 98 else 99 return (firstnumber); 100 } /* end switch */ 101 } /* end while */ 102 puts("Don't be ridiculous."); 103 return (firstnumber); 104} 105 106int 107put(void) 108{ /* synonyms = {buckle, strap, tie} */ 109 if (inc_wordnumber(words[wordnumber], "what")) 110 return(-1); 111 if (wordvalue[wordnumber] == ON) { 112 wordvalue[wordnumber] = PUTON; 113 wordtype[wordnumber] = VERB; 114 return (cypher() - 1); 115 } 116 if (wordvalue[wordnumber] == DOWN) { 117 wordvalue[wordnumber] = DROP; 118 wordtype[wordnumber] = VERB; 119 return (cypher() - 1); 120 } 121 puts("I don't understand what you want to put."); 122 return (-1); 123} 124 125int 126draw(void) 127{ /* synonyms = {pull, carry} */ 128 return (take(wear)); 129} 130 131int 132use(void) 133{ 134 if (inc_wordnumber(words[wordnumber], "what")) 135 return(-1); 136 if (wordvalue[wordnumber] == AMULET && TestBit(inven, AMULET) && 137 position != FINAL) { 138 puts("The amulet begins to glow."); 139 if (TestBit(inven, MEDALION)) { 140 puts("The medallion comes to life too."); 141 if (position == 114) { 142 location[position].down = 160; 143 whichway(location[position]); 144 puts("The waves subside and it is possible to descend to the sea cave now."); 145 ourtime++; 146 wordnumber++; 147 return (-1); 148 } 149 } 150 puts("A light mist falls over your eyes and the sound of purling water trickles in"); 151 puts("your ears. When the mist lifts you are standing beside a cool stream."); 152 if (position == 229) 153 position = 224; 154 else 155 position = 229; 156 ourtime++; 157 notes[CANTSEE] = 0; 158 wordnumber++; 159 return (0); 160 } 161 else if (position == FINAL) 162 puts("The amulet won't work in here."); 163 else if (wordvalue[wordnumber] == COMPASS && TestBit(inven, COMPASS)) 164 printf("Your compass points %s.\n", truedirec(NORTH,'-')); 165 else if (wordvalue[wordnumber] == COMPASS) 166 puts("You aren't holding the compass."); 167 else if (wordvalue[wordnumber] == AMULET) 168 puts("You aren't holding the amulet."); 169 else 170 puts("There is no apparent use."); 171 wordnumber++; 172 return (-1); 173} 174 175void 176murder(void) 177{ 178 int n; 179 180 if (inc_wordnumber(words[wordnumber], "whom")) 181 return; 182 for (n = 0; n < NUMOFOBJECTS && 183 !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || 184 n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || 185 n == HALBERD) && TestBit(inven, n)); n++) 186 continue; 187 if (n == NUMOFOBJECTS) { 188 if (TestBit(inven, LASER)) { 189 printf("Your laser should do the trick.\n"); 190 switch(wordvalue[wordnumber]) { 191 case NORMGOD: 192 case TIMER: 193 case NATIVE: 194 case MAN: 195 wordvalue[--wordnumber] = SHOOT; 196 cypher(); 197 break; 198 case -1: 199 puts("Kill what?"); 200 break; 201 default: 202 if (wordtype[wordnumber] != OBJECT || 203 wordvalue[wordnumber] == EVERYTHING) 204 puts("You can't kill that!"); 205 else 206 printf("You can't kill %s%s!\n", 207 A_OR_AN_OR_BLANK(wordvalue[wordnumber]), 208 objsht[wordvalue[wordnumber]]); 209 break; 210 } 211 } else 212 puts("You don't have suitable weapons to kill."); 213 } else { 214 printf("Your %s should do the trick.\n", objsht[n]); 215 switch (wordvalue[wordnumber]) { 216 217 case NORMGOD: 218 if (TestBit(location[position].objects, BATHGOD)) { 219 puts("The goddess's head slices off. Her corpse floats in the water."); 220 ClearBit(location[position].objects, BATHGOD); 221 SetBit(location[position].objects, DEADGOD); 222 power += 5; 223 notes[JINXED]++; 224 } else 225 if (TestBit(location[position].objects, NORMGOD)) { 226 puts("The goddess pleads but you strike her mercilessly. Her broken body lies in a\npool of blood."); 227 ClearBit(location[position].objects, NORMGOD); 228 SetBit(location[position].objects, DEADGOD); 229 power += 5; 230 notes[JINXED]++; 231 if (wintime) 232 live(); 233 } else 234 puts("I don't see her anywhere."); 235 break; 236 case TIMER: 237 if (TestBit(location[position].objects, TIMER)) { 238 puts("The old man offers no resistance."); 239 ClearBit(location[position].objects, TIMER); 240 SetBit(location[position].objects, DEADTIME); 241 power++; 242 notes[JINXED]++; 243 } else 244 puts("Who?"); 245 break; 246 case NATIVE: 247 if (TestBit(location[position].objects, NATIVE)) { 248 puts("The girl screams as you cut her body to shreds. She is dead."); 249 ClearBit(location[position].objects, NATIVE); 250 SetBit(location[position].objects, DEADNATIVE); 251 power += 5; 252 notes[JINXED]++; 253 } else 254 puts("What girl?"); 255 break; 256 case MAN: 257 if (TestBit(location[position].objects, MAN)) { 258 puts("You strike him to the ground, and he coughs up blood."); 259 puts("Your fantasy is over."); 260 die(0); 261 } 262 case -1: 263 puts("Kill what?"); 264 break; 265 266 default: 267 if (wordtype[wordnumber] != OBJECT || 268 wordvalue[wordnumber] == EVERYTHING) 269 puts("You can't kill that!"); 270 else 271 printf("You can't kill the %s!\n", 272 objsht[wordvalue[wordnumber]]); 273 } 274 } 275 wordnumber++; 276} 277 278void 279ravage(void) 280{ 281 if (inc_wordnumber(words[wordnumber], "whom")) 282 return; 283 if (wordtype[wordnumber] == NOUNS && (TestBit(location[position].objects, wordvalue[wordnumber]) 284 || (wordvalue[wordnumber] == NORMGOD && TestBit(location[position].objects, BATHGOD)))) { 285 ourtime++; 286 switch (wordvalue[wordnumber]) { 287 case NORMGOD: 288 puts("You attack the goddess, and she screams as you beat her. She falls down"); 289 if (TestBit(location[position].objects, BATHGOD)) 290 puts("crying and tries to cover her nakedness."); 291 else 292 puts("crying and tries to hold her torn and bloodied dress around her."); 293 power += 5; 294 pleasure += 8; 295 ego -= 10; 296 wordnumber--; 297 godready = -30000; 298 murder(); 299 win = -30000; 300 break; 301 case NATIVE: 302 puts("The girl tries to run, but you catch her and throw her down. Her face is"); 303 puts("bleeding, and she screams as you tear off her clothes."); 304 power += 3; 305 pleasure += 5; 306 ego -= 10; 307 wordnumber--; 308 murder(); 309 if (rnd(100) < 50) { 310 puts("Her screams have attracted attention. I think we are surrounded."); 311 SetBit(location[ahead].objects, WOODSMAN); 312 SetBit(location[ahead].objects, DEADWOOD); 313 SetBit(location[ahead].objects, MALLET); 314 SetBit(location[back].objects, WOODSMAN); 315 SetBit(location[back].objects, DEADWOOD); 316 SetBit(location[back].objects, MALLET); 317 SetBit(location[left].objects, WOODSMAN); 318 SetBit(location[left].objects, DEADWOOD); 319 SetBit(location[left].objects, MALLET); 320 SetBit(location[right].objects, WOODSMAN); 321 SetBit(location[right].objects, DEADWOOD); 322 SetBit(location[right].objects, MALLET); 323 } 324 break; 325 default: 326 puts("You are perverted."); 327 wordnumber++; 328 } 329 } else { 330 printf("%s: Who?\n", words[wordnumber]); 331 wordnumber++; 332 } 333} 334 335int 336follow(void) 337{ 338 if (followfight == ourtime) { 339 puts("The Dark Lord leaps away and runs down secret tunnels and corridors."); 340 puts("You chase him through the darkness and splash in pools of water."); 341 puts("You have cornered him. His laser sword extends as he steps forward."); 342 position = FINAL; 343 fight(DARK, 75); 344 SetBit(location[position].objects, TALISMAN); 345 SetBit(location[position].objects, AMULET); 346 return (0); 347 } else 348 if (followgod == ourtime) { 349 puts("The goddess leads you down a steamy tunnel and into a high, wide chamber."); 350 puts("She sits down on a throne."); 351 position = 268; 352 SetBit(location[position].objects, NORMGOD); 353 notes[CANTSEE] = 1; 354 return (0); 355 } else 356 puts("There is no one to follow."); 357 return (-1); 358} 359 360void 361undress(void) 362{ 363 if (inc_wordnumber(words[wordnumber], "whom")) 364 return; 365 if (wordvalue[wordnumber] == NORMGOD && 366 (TestBit(location[position].objects, NORMGOD)) && godready >= 2) { 367 wordnumber--; 368 love(); 369 } else { 370 wordnumber--; 371 ravage(); 372 } 373} 374