1 /* $NetBSD: command3.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[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95"; 36 #else 37 __RCSID("$NetBSD: command3.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 void 44 dig(void) 45 { 46 if (testbit(inven, SHOVEL)) { 47 puts("OK"); 48 ourtime++; 49 switch (position) { 50 case 144: /* copse near beach */ 51 if (!notes[DUG]) { 52 setbit(location[position].objects, DEADWOOD); 53 setbit(location[position].objects, COMPASS); 54 setbit(location[position].objects, KNIFE); 55 setbit(location[position].objects, MACE); 56 notes[DUG] = 1; 57 } 58 break; 59 60 default: 61 puts("Nothing happens."); 62 } 63 } else 64 puts("You don't have a shovel."); 65 } 66 67 int 68 jump(void) 69 { 70 int n; 71 72 switch (position) { 73 default: 74 puts("Nothing happens."); 75 return (-1); 76 77 case 242: 78 position = 133; 79 break; 80 case 214: 81 case 215: 82 case 162: 83 case 159: 84 position = 145; 85 break; 86 case 232: 87 position = FINAL; 88 break; 89 case 3: 90 position = 1; 91 break; 92 case 172: 93 position = 201; 94 } 95 puts("Ahhhhhhh..."); 96 injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1; 97 for (n = 0; n < NUMOFOBJECTS; n++) 98 if (testbit(inven, n)) { 99 clearbit(inven, n); 100 setbit(location[position].objects, n); 101 } 102 carrying = 0; 103 encumber = 0; 104 return (0); 105 } 106 107 void 108 bury(void) 109 { 110 int value; 111 112 if (testbit(inven, SHOVEL)) { 113 while (wordtype[++wordnumber] != OBJECT && 114 wordtype[wordnumber] != NOUNS && wordnumber < wordcount) 115 continue; 116 value = wordvalue[wordnumber]; 117 if (wordtype[wordnumber] == NOUNS && 118 (testbit(location[position].objects, value) || 119 value == BODY)) 120 switch (value) { 121 case BODY: 122 wordtype[wordnumber] = OBJECT; 123 if (testbit(inven, MAID) || 124 testbit(location[position].objects, MAID)) 125 value = MAID; 126 if (testbit(inven, DEADWOOD) || 127 testbit(location[position].objects, 128 DEADWOOD)) 129 value = DEADWOOD; 130 if (testbit(inven, DEADGOD) || 131 testbit(location[position].objects, 132 DEADGOD)) 133 value = DEADGOD; 134 if (testbit(inven, DEADTIME) || 135 testbit(location[position].objects, 136 DEADTIME)) 137 value = DEADTIME; 138 if (testbit(inven, DEADNATIVE) || 139 testbit(location[position].objects, 140 DEADNATIVE)) 141 value = DEADNATIVE; 142 break; 143 144 case NATIVE: 145 case NORMGOD: 146 printf("She screams as you wrestle her into "); 147 puts("the hole."); 148 case TIMER: 149 power += 7; 150 ego -= 10; 151 case AMULET: 152 case MEDALION: 153 case TALISMAN: 154 wordtype[wordnumber] = OBJECT; 155 break; 156 157 default: 158 puts("Wha..?"); 159 } 160 if (wordtype[wordnumber] == OBJECT && position > 88 && 161 (testbit(inven, value) || 162 testbit(location[position].objects, value))) { 163 puts("Buried."); 164 if (testbit(inven, value)) { 165 clearbit(inven, value); 166 carrying -= objwt[value]; 167 encumber -= objcumber[value]; 168 } 169 clearbit(location[position].objects, value); 170 switch (value) { 171 case MAID: 172 case DEADWOOD: 173 case DEADNATIVE: 174 case DEADTIME: 175 case DEADGOD: 176 ego += 2; 177 printf("The %s should rest easier now.\n", 178 objsht[value]); 179 } 180 } else 181 puts("It doesn't seem to work."); 182 } else 183 puts("You aren't holding a shovel."); 184 } 185 186 void 187 drink(void) 188 { 189 int n; 190 191 if (testbit(inven, POTION)) { 192 printf("The cool liquid runs down your throat but turns to "); 193 puts("fire and you choke."); 194 printf("The heat reaches your limbs and tingles your spirit."); 195 puts(" You feel like falling"); 196 puts("asleep."); 197 clearbit(inven, POTION); 198 WEIGHT = MAXWEIGHT; 199 CUMBER = MAXCUMBER; 200 for (n = 0; n < NUMOFINJURIES; n++) 201 injuries[n] = 0; 202 ourtime++; 203 zzz(); 204 } else 205 puts("I'm not thirsty."); 206 } 207 208 int 209 shoot(void) 210 { 211 int firstnumber, value; 212 213 firstnumber = wordnumber; 214 if (!testbit(inven, LASER)) 215 puts("You aren't holding a blaster."); 216 else { 217 wordnumber++; 218 while (wordnumber <= wordcount && 219 wordtype[wordnumber] == OBJECT) { 220 value = wordvalue[wordnumber]; 221 printf("%s:\n", objsht[value]); 222 if (testbit(location[position].objects, value)) { 223 clearbit(location[position].objects, value); 224 ourtime++; 225 printf("The %s explode%s\n", objsht[value], 226 (is_plural_object(value) ? "." : "s.")); 227 if (value == BOMB) 228 die(); 229 } else 230 printf("I don't see any %s around here.\n", 231 objsht[value]); 232 if (wordnumber < wordcount - 1 && 233 wordvalue[++wordnumber] == AND) 234 wordnumber++; 235 else 236 return (firstnumber); 237 } 238 /* special cases with their own return()'s */ 239 240 if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) { 241 ourtime++; 242 switch (wordvalue[wordnumber]) { 243 244 case DOOR: 245 switch (position) { 246 case 189: 247 case 231: 248 puts("The door is unhinged."); 249 location[189].north = 231; 250 location[231].south = 189; 251 whichway(location[position]); 252 break; 253 case 30: 254 puts("The wooden door splinters."); 255 location[30].west = 25; 256 whichway(location[position]); 257 break; 258 case 31: 259 printf("The laser blast has no "); 260 puts("effect on the door."); 261 break; 262 case 20: 263 printf("The blast hits the door and "); 264 printf("it explodes into flame. The "); 265 puts("magnesium burns"); 266 printf("so rapidly that we have no "); 267 puts("chance to escape."); 268 die(); 269 default: 270 puts("Nothing happens."); 271 } 272 break; 273 274 case NORMGOD: 275 if (testbit(location[position].objects, 276 BATHGOD)) { 277 printf("The goddess is hit in the "); 278 printf("chest and splashes back "); 279 puts("against the rocks."); 280 printf("Dark blood oozes from the "); 281 printf("charred blast hole. Her "); 282 puts("naked body floats in the"); 283 puts("pools and then off downstream."); 284 clearbit(location[position].objects, 285 BATHGOD); 286 setbit(location[180].objects, DEADGOD); 287 power += 5; 288 ego -= 10; 289 notes[JINXED]++; 290 } else 291 if (testbit(location[position].objects, 292 NORMGOD)) { 293 printf("The blast catches "); 294 printf("the goddess in the "); 295 printf("stomach, knocking "); 296 puts("her to the ground."); 297 printf("She writhes in the "); 298 printf("dirt as the agony of "); 299 puts("death taunts her."); 300 puts("She has stopped moving."); 301 clearbit(location[position].objects, NORMGOD); 302 setbit(location[position].objects, DEADGOD); 303 power += 5; 304 ego -= 10; 305 notes[JINXED]++; 306 if (wintime) 307 live(); 308 break; 309 } else 310 printf("I don't see any "); 311 puts("goddess around here."); 312 break; 313 314 case TIMER: 315 if (testbit(location[position].objects, 316 TIMER)) { 317 printf("The old man slumps over "); 318 puts("the bar."); 319 power++; 320 ego -= 2; 321 notes[JINXED]++; 322 clearbit(location[position].objects, 323 TIMER); 324 setbit(location[position].objects, 325 DEADTIME); 326 } else 327 puts("What old-timer?"); 328 break; 329 case MAN: 330 if (testbit(location[position].objects, MAN)) { 331 printf("The man falls to the ground "); 332 printf("with blood pouring all over "); 333 puts("his white suit."); 334 puts("Your fantasy is over."); 335 die(); 336 } else 337 puts("What man?"); 338 break; 339 case NATIVE: 340 if (testbit(location[position].objects, 341 NATIVE)) { 342 printf("The girl is blown backwards "); 343 printf("several feet and lies in a "); 344 puts("pool of blood."); 345 clearbit(location[position].objects, 346 NATIVE); 347 setbit(location[position].objects, 348 DEADNATIVE); 349 power += 5; 350 ego -= 2; 351 notes[JINXED]++; 352 } else 353 puts("There is no girl here."); 354 break; 355 case -1: 356 puts("Shoot what?"); 357 break; 358 359 default: 360 printf("You can't shoot the %s.\n", 361 objsht[wordvalue[wordnumber]]); 362 } 363 } else 364 puts("You must be a looney."); 365 } 366 return (firstnumber); 367 } 368