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