1 /*- 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 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. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)com3.c 8.1 (Berkeley) 5/31/93 30 * $FreeBSD: src/games/battlestar/com3.c,v 1.8.2.1 2001/03/05 11:45:35 kris Exp $ 31 * $DragonFly: src/games/battlestar/com3.c,v 1.3 2006/08/08 16:47:20 pavalos Exp $ 32 */ 33 34 #include "externs.h" 35 36 void 37 dig(void) 38 { 39 if (testbit(inven, SHOVEL)) { 40 puts("OK"); 41 gtime++; 42 switch (position) { 43 case 144: /* copse near beach */ 44 if (!notes[DUG]) { 45 setbit(location[position].objects, DEADWOOD); 46 setbit(location[position].objects, COMPASS); 47 setbit(location[position].objects, KNIFE); 48 setbit(location[position].objects, MACE); 49 notes[DUG] = 1; 50 } 51 break; 52 53 default: 54 puts("Nothing happens."); 55 } 56 } else 57 puts("You don't have a shovel."); 58 } 59 60 int 61 jump(void) 62 { 63 int n; 64 65 switch (position) { 66 default: 67 puts("Nothing happens."); 68 return (-1); 69 70 case 242: 71 position = 133; 72 break; 73 case 214: 74 case 215: 75 case 162: 76 case 159: 77 position = 145; 78 break; 79 case 232: 80 position = 275; 81 break; 82 case 3: 83 position = 1; 84 break; 85 case 172: 86 position = 201; 87 } 88 puts("Ahhhhhhh..."); 89 injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1; 90 for (n = 0; n < NUMOFOBJECTS; n++) 91 if (testbit(inven, n)) { 92 clearbit(inven, n); 93 setbit(location[position].objects, n); 94 } 95 carrying = 0; 96 encumber = 0; 97 return (0); 98 } 99 100 void 101 bury(void) 102 { 103 int value; 104 105 if (testbit(inven, SHOVEL)) { 106 while (wordtype[++wordnumber] != OBJECT && 107 wordtype[wordnumber] != NOUNS && wordnumber < wordcount) 108 ; /* nothing */ 109 value = wordvalue[wordnumber]; 110 if (wordtype[wordnumber] == NOUNS && 111 (testbit(location[position].objects, value) || 112 value == BODY)) 113 switch (value) { 114 case BODY: 115 wordtype[wordnumber] = OBJECT; 116 if (testbit(inven, MAID) || 117 testbit(location[position].objects, MAID)) 118 value = MAID; 119 if (testbit(inven, DEADWOOD) || 120 testbit(location[position].objects, 121 DEADWOOD)) 122 value = DEADWOOD; 123 if (testbit(inven, DEADGOD) || 124 testbit(location[position].objects, 125 DEADGOD)) 126 value = DEADGOD; 127 if (testbit(inven, DEADTIME) || 128 testbit(location[position].objects, 129 DEADTIME)) 130 value = DEADTIME; 131 if (testbit(inven, DEADNATIVE) || 132 testbit(location[position].objects, 133 DEADNATIVE)) 134 value = DEADNATIVE; 135 break; 136 137 case NATIVE: 138 case NORMGOD: 139 puts("She screams as you wrestle her into the hole."); 140 case TIMER: 141 power += 7; 142 ego -= 10; 143 case AMULET: 144 case MEDALION: 145 case TALISMAN: 146 wordtype[wordnumber] = OBJECT; 147 break; 148 149 default: 150 puts("Wha..?"); 151 } 152 if (wordtype[wordnumber] == OBJECT && position > 88 && 153 (testbit(inven, value) || 154 testbit(location[position].objects, value))) { 155 puts("Buried."); 156 if (testbit(inven, value)) { 157 clearbit(inven, value); 158 carrying -= objwt[value]; 159 encumber -= objcumber[value]; 160 } 161 clearbit(location[position].objects, value); 162 switch (value) { 163 case MAID: 164 case DEADWOOD: 165 case DEADNATIVE: 166 case DEADTIME: 167 case DEADGOD: 168 ego += 2; 169 printf("The %s should rest easier now.\n", 170 objsht[value]); 171 } 172 } else 173 puts("It doesn't seem to work."); 174 } else 175 puts("You aren't holding a shovel."); 176 } 177 178 void 179 drink(void) 180 { 181 int n; 182 183 if (testbit(inven, POTION)) { 184 puts("The cool liquid runs down your throat but turns to fire and you choke."); 185 puts("The heat reaches your limbs and tingles your spirit. You feel like falling"); 186 puts("asleep."); 187 clearbit(inven, POTION); 188 WEIGHT = MAXWEIGHT; 189 CUMBER = MAXCUMBER; 190 for (n = 0; n < NUMOFINJURIES; n++) 191 injuries[n] = 0; 192 gtime++; 193 zzz(); 194 } else 195 puts("I'm not thirsty."); 196 } 197 198 int 199 shoot(void) 200 { 201 int firstnumber, value; 202 int n; 203 204 firstnumber = wordnumber; 205 if (!testbit(inven, LASER)) 206 puts("You aren't holding a blaster."); 207 else { 208 while (wordtype[++wordnumber] == ADJS) 209 ; /* nothing */ 210 while (wordnumber <= wordcount && 211 wordtype[wordnumber] == OBJECT) { 212 value = wordvalue[wordnumber]; 213 printf("%s:\n", objsht[value]); 214 for (n = 0; objsht[value][n]; n++) 215 ; /* nothing */ 216 if (testbit(location[position].objects, value)) { 217 clearbit(location[position].objects, value); 218 gtime++; 219 printf("The %s explode%s\n", objsht[value], 220 (objsht[value][n - 1] == 221 's' ? (objsht[value][n - 2] == 222 's' ? "s." : ".") : "s.")); 223 if (value == BOMB) 224 die(0); 225 } else 226 printf("I dont see any %s around here.\n", 227 objsht[value]); 228 if (wordnumber < wordcount - 1 && 229 wordvalue[++wordnumber] == AND) 230 wordnumber++; 231 else 232 return (firstnumber); 233 } 234 /* special cases with their own return()'s */ 235 236 if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) { 237 gtime++; 238 switch (wordvalue[wordnumber]) { 239 case DOOR: 240 switch (position) { 241 case 189: 242 case 231: 243 puts("The door is unhinged."); 244 location[189].north = 231; 245 location[231].south = 189; 246 whichway(location[position]); 247 break; 248 case 30: 249 puts("The wooden door splinters."); 250 location[30].west = 25; 251 whichway(location[position]); 252 break; 253 case 31: 254 puts("The laser blast has no effect on the door."); 255 break; 256 case 20: 257 puts("The blast hits the door and it explodes into flame. The magnesium burns"); 258 puts("so rapidly that we have no chance to escape."); 259 die(0); 260 default: 261 puts("Nothing happens."); 262 } 263 break; 264 265 case NORMGOD: 266 if (testbit(location[position].objects, 267 BATHGOD)) { 268 puts("The goddess is hit in the chest and splashes back against the rocks."); 269 puts("Dark blood oozes from the charred blast hole. Her naked body floats in the"); 270 puts("pools and then off downstream."); 271 clearbit(location[position].objects, 272 BATHGOD); 273 setbit(location[180].objects, DEADGOD); 274 power += 5; 275 ego -= 10; 276 notes[JINXED]++; 277 } else 278 if (testbit(location[position].objects, 279 NORMGOD)) { 280 puts("The blast catches the goddess in the stomach, knocking her to the ground."); 281 puts("She writhes in the dirt as the agony of death taunts her."); 282 puts("She has stopped moving."); 283 clearbit(location[position].objects, NORMGOD); 284 setbit(location[position].objects, DEADGOD); 285 power += 5; 286 ego -= 10; 287 notes[JINXED]++; 288 if (wintime) 289 live(); 290 break; 291 } else 292 puts("I don't see any goddess around here."); 293 break; 294 295 case TIMER: 296 if (testbit(location[position].objects, 297 TIMER)) { 298 puts("The old man slumps over the bar."); 299 power++; 300 ego -= 2; 301 notes[JINXED]++; 302 clearbit(location[position].objects, 303 TIMER); 304 setbit(location[position].objects, 305 DEADTIME); 306 } else 307 puts("What old timer?"); 308 break; 309 case MAN: 310 if (testbit(location[position].objects, MAN)) { 311 puts("The man falls to the ground with blood pouring all over his white suit."); 312 puts("Your fantasy is over."); 313 die(0); 314 } else 315 puts("What man?"); 316 break; 317 case NATIVE: 318 if (testbit(location[position].objects, 319 NATIVE)) { 320 puts("The girl is blown backwards several feet and lies in a pool of blood."); 321 clearbit(location[position].objects, 322 NATIVE); 323 setbit(location[position].objects, 324 DEADNATIVE); 325 power += 5; 326 ego -= 2; 327 notes[JINXED]++; 328 } else 329 puts("There is no girl here."); 330 break; 331 case -1: 332 puts("Shoot what?"); 333 break; 334 335 default: 336 printf("You can't shoot the %s.\n", 337 objsht[wordvalue[wordnumber]]); 338 } 339 } else 340 puts("You must be a looney."); 341 } 342 return (firstnumber); 343 } 344