1 /* @(#)com5.c 8.2 (Berkeley) 4/28/95 */ 2 /* $NetBSD: command5.c,v 1.5 2014/03/22 23:31:28 dholland 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 "extern.h" 34 35 void 36 kiss(void) 37 { 38 while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount) 39 continue; 40 /* The goddess must be "taken" first if bathing. */ 41 if (wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] == NORMGOD 42 && testbit(location[position].objects, BATHGOD)) { 43 wordvalue[--wordnumber] = TAKE; 44 cypher(); 45 return; 46 } 47 if (wordtype[wordnumber] == NOUNS) { 48 if (testbit(location[position].objects, 49 wordvalue[wordnumber])) { 50 pleasure++; 51 printf("Kissed.\n"); 52 switch (wordvalue[wordnumber]) { 53 case NORMGOD: 54 switch (godready++) { 55 case 0: 56 printf("She squirms and avoids your "); 57 puts("advances."); 58 break; 59 case 1: 60 puts("She is coming around; she "); 61 puts("didn't fight it as much."); 62 break; 63 case 2: 64 puts("She's beginning to like it."); 65 break; 66 default: 67 puts("She's gone limp."); 68 69 } 70 break; 71 case NATIVE: 72 printf("Her lips are warm and her body "); 73 printf("robust. She pulls you down to "); 74 puts("the ground."); 75 break; 76 case TIMER: 77 puts("The old man blushes."); 78 break; 79 case MAN: 80 puts("The dwarf punches you in the kneecap."); 81 break; 82 default: 83 pleasure--; 84 } 85 } else 86 puts("I see nothing like that here."); 87 } else 88 puts("I'd prefer not to."); 89 } 90 91 void 92 love(void) 93 { 94 int n; 95 96 while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount) 97 continue; 98 if (wordtype[wordnumber] == NOUNS) { 99 if ((testbit(location[position].objects, BATHGOD) || 100 testbit(location[position].objects, NORMGOD)) && 101 wordvalue[wordnumber] == NORMGOD) { 102 if (loved) { 103 printf("Loved.\n"); 104 return; 105 } 106 if (godready >= 2) { 107 printf("She cuddles up to you, and her mouth "); 108 printf("starts to work:\n'That was my "); 109 printf("sister's amulet. The lovely "); 110 printf("goddess, Purl, was she. The Empire\n"); 111 printf("captured her just after the Darkness "); 112 printf("came. My other sister, Vert, was "); 113 printf("killed\nby the Dark Lord himself. "); 114 printf("He took her amulet and warped its "); 115 printf("power.\nYour quest was foretold by "); 116 printf("my father before he died, but to get "); 117 printf("the Dark Lord's\namulet you must use "); 118 printf("cunning and skill. I will leave you "); 119 puts("my amulet,"); 120 printf("which you may use as you wish. As "); 121 printf("for me, I am the last goddess of "); 122 printf("the\nwaters. My father was the "); 123 printf("Island King, and the rule is "); 124 printf("rightfully mine.'\n\nShe pulls the "); 125 puts("throne out into a large bed."); 126 power++; 127 pleasure += 15; 128 ego++; 129 if (card(injuries, NUMOFINJURIES)) { 130 printf("Her kisses revive you; your "); 131 printf("wounds are healed.\n"); 132 for (n = 0; n < NUMOFINJURIES; n++) 133 injuries[n] = 0; 134 WEIGHT = MAXWEIGHT; 135 CUMBER = MAXCUMBER; 136 } 137 printf("Goddess:\n"); 138 if (!loved) 139 setbit(location[position].objects, 140 MEDALION); 141 loved = 1; 142 ourtime += 10; 143 printf("Loved.\n"); 144 zzz(); 145 return; 146 } else { 147 puts("You wish!"); 148 return; 149 } 150 } 151 if (testbit(location[position].objects, 152 wordvalue[wordnumber])) { 153 if (wordvalue[wordnumber] == NATIVE) { 154 printf("The girl is easy prey. She peels "); 155 puts("off her sarong and indulges you."); 156 power++; 157 pleasure += 5; 158 printf("Girl:\n"); 159 ourtime += 10; 160 printf("Loved.\n"); 161 zzz(); 162 } 163 if (wordvalue[wordnumber] == MAN || 164 wordvalue[wordnumber] == BODY || 165 wordvalue[wordnumber] == ELF || 166 wordvalue[wordnumber] == TIMER) 167 puts("Kinky!"); 168 else 169 puts("It doesn't seem to work."); 170 } else 171 puts("Where's your lover?"); 172 } else 173 puts("It doesn't seem to work."); 174 } 175 176 int 177 zzz(void) 178 { 179 int oldtime; 180 int n; 181 int zzztime; 182 183 zzztime = (3 * CYCLE) / 4; 184 185 oldtime = ourtime; 186 if ((snooze - ourtime) < zzztime) { 187 ourtime += zzztime - (snooze - ourtime); 188 printf("<zzz>"); 189 for (n = 0; n < ourtime - oldtime; n++) 190 printf("."); 191 printf("\n"); 192 snooze += 3 * (ourtime - oldtime); 193 if (notes[LAUNCHED]) { 194 fuel -= (ourtime - oldtime); 195 if (location[position].down) { 196 position = location[position].down; 197 crash(); 198 } else 199 notes[LAUNCHED] = 0; 200 } 201 if (OUTSIDE && rnd(100) < 50) { 202 printf("You are awakened abruptly by the sound "); 203 puts("of someone nearby."); 204 switch (rnd(4)) { 205 case 0: 206 if (ucard(inven)) { 207 n = rnd(NUMOFOBJECTS); 208 while (!testbit(inven, n)) 209 n = rnd(NUMOFOBJECTS); 210 clearbit(inven, n); 211 if (n != AMULET && n != MEDALION && 212 n != TALISMAN) 213 setbit( 214 location[position].objects, 215 n); 216 carrying -= objwt[n]; 217 encumber -= objcumber[n]; 218 } 219 printf("A fiendish little Elf is stealing "); 220 puts("your treasures!"); 221 fight(ELF, 10); 222 break; 223 case 1: 224 setbit(location[position].objects, DEADWOOD); 225 break; 226 case 2: 227 setbit(location[position].objects, HALBERD); 228 break; 229 default: 230 break; 231 } 232 } 233 } else 234 return (0); 235 return (1); 236 } 237 238 void 239 chime(void) 240 { 241 if ((ourtime / CYCLE + 1) % 2 && OUTSIDE) 242 switch ((ourtime % CYCLE) / (CYCLE / 7)) { 243 case 0: 244 puts("It is just after sunrise."); 245 break; 246 case 1: 247 puts("It is early morning."); 248 break; 249 case 2: 250 puts("It is late morning."); 251 break; 252 case 3: 253 puts("It is near noon."); 254 break; 255 case 4: 256 puts("It is early afternoon."); 257 break; 258 case 5: 259 puts("It is late afternoon."); 260 break; 261 case 6: 262 puts("It is near sunset."); 263 break; 264 } 265 else if (OUTSIDE) 266 switch ((ourtime % CYCLE) / (CYCLE / 7)) { 267 case 0: 268 puts("It is just after sunset."); 269 break; 270 case 1: 271 puts("It is early evening."); 272 break; 273 case 2: 274 puts("The evening is getting old."); 275 break; 276 case 3: 277 puts("It is near midnight."); 278 break; 279 case 4: 280 puts("These are the wee hours of the morning."); 281 break; 282 case 5: 283 puts("The night is waning."); 284 break; 285 case 6: 286 puts("It is almost morning."); 287 break; 288 } 289 else 290 puts("I can't tell the time in here."); 291 } 292 293 int 294 give(void) 295 { 296 int obj = -1, result = -1, person = 0, firstnumber, last1, last2; 297 298 last1 = last2 = 0; 299 firstnumber = wordnumber; 300 while (wordtype[++wordnumber] != OBJECT && 301 wordvalue[wordnumber] != AMULET && 302 wordvalue[wordnumber] != MEDALION && 303 wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount) 304 continue; 305 if (wordnumber <= wordcount) { 306 obj = wordvalue[wordnumber]; 307 if (obj == EVERYTHING) 308 wordtype[wordnumber] = -1; 309 last1 = wordnumber; 310 } 311 wordnumber = firstnumber; 312 while ((wordtype[++wordnumber] != NOUNS || 313 wordvalue[wordnumber] == obj) && wordnumber <= wordcount); 314 if (wordtype[wordnumber] == NOUNS) { 315 person = wordvalue[wordnumber]; 316 last2 = wordnumber; 317 } 318 /* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g., 319 * plain `give'. However, detecting this case is liable to detect 320 * `give foo' as well, which would give a confusing error. We 321 * need to make sure the -1 value can cause no problems if it arises. 322 * If in the below we get to the drop("Given") then drop will look 323 * at word 0 for an object to give, and fail, which is OK; then 324 * result will be -1 and we get to the end, where wordnumber gets 325 * set to something more sensible. If we get to "I don't think 326 * that is possible" then again wordnumber is set to something 327 * sensible. The wordnumber we leave with still isn't right if 328 * you include words the game doesn't know in your command, but 329 * that's no worse than what other commands than give do in 330 * the same place. */ 331 wordnumber = last1 - 1; 332 if (person && testbit(location[position].objects, person)) { 333 if (person == NORMGOD && godready < 2 && 334 !(obj == RING || obj == BRACELET)) 335 puts("The goddess won't look at you."); 336 else 337 result = drop("Given"); 338 } else { 339 puts("I don't think that is possible."); 340 wordnumber = max(last1, last2) + 1; 341 return (0); 342 } 343 if (result != -1 && (testbit(location[position].objects, obj) || 344 obj == AMULET || obj == MEDALION || obj == TALISMAN)) { 345 clearbit(location[position].objects, obj); 346 ourtime++; 347 ego++; 348 switch (person) { 349 case NATIVE: 350 puts("She accepts it shyly."); 351 ego += 2; 352 break; 353 case NORMGOD: 354 if (obj == RING || obj == BRACELET) { 355 printf("She takes the charm and puts it on."); 356 puts(" A little kiss on the cheek is"); 357 puts("your reward."); 358 ego += 5; 359 godready += 3; 360 } 361 if (obj == AMULET || obj == MEDALION || 362 obj == TALISMAN) { 363 win++; 364 ego += 5; 365 power -= 5; 366 if (win >= 3) { 367 printf("The powers of the earth are "); 368 printf("now legitimate. You have "); 369 puts("destroyed the Darkness"); 370 printf("and restored the goddess to "); 371 printf("her throne. The entire "); 372 puts("island celebrates with"); 373 printf("dancing and spring feasts. "); 374 printf("As a measure of her "); 375 puts("gratitude, the goddess weds you"); 376 printf("in the late summer and "); 377 printf("crowns you Prince Liverwort, "); 378 puts("Lord of Fungus."); 379 printf("\nBut, as the year wears on "); 380 printf("and autumn comes along, you "); 381 puts("become restless and"); 382 printf("yearn for adventure. The "); 383 printf("goddess, too, realizes that "); 384 puts("the marriage can't last."); 385 printf("She becomes bored and takes "); 386 printf("several more natives as "); 387 puts("husbands. One evening,"); 388 printf("after having been out "); 389 printf("drinking with the girls, she "); 390 puts("kicks the throne particularly"); 391 printf("hard and wakes you up. (If "); 392 printf("you want to win this game, "); 393 printf("you're going to have to\n"); 394 puts("shoot her!)"); 395 clearbit(location[position].objects, 396 MEDALION); 397 wintime = ourtime; 398 } 399 } 400 break; 401 case TIMER: 402 if (obj == COINS) { 403 printf("He fingers the coins for a moment "); 404 printf("and then looks up agape. `Kind you "); 405 puts("are and"); 406 printf("I mean to repay you as best I can.' "); 407 printf("Grabbing a pencil and cocktail "); 408 puts("napkin...\n"); 409 printf("+-----------------------------------"); 410 printf("------------------------------------"); 411 printf("------+\n"); 412 printf("| xxxxxxxx\\ |\n"); 413 printf("| xxxxx\\ CLIFFS |\n"); 414 printf("| FOREST xxx\\ |\n"); 415 printf("| \\\\ x\\ OCEAN |\n"); 416 printf("| || x\\ |\n"); 417 printf("| || ROAD x\\ |\n"); 418 printf("| || x\\ |\n"); 419 printf("| SECRET || ......... |\n"); 420 printf("| - + - || ........ |\n"); 421 printf("| ENTRANCE || ... BEACH |\n"); 422 printf("| || ... E |\n"); 423 printf("| || ... | |\n"); 424 printf("| // ... N <-- + --- S |\n"); 425 printf("| PALM GROVE // ... | |\n"); 426 printf("| // ... W |\n"); 427 printf("+"); 428 printf("---------------------------------"); 429 printf("---------------------------------"); 430 printf("-----------+\n"); 431 printf("\n`This map shows a secret entrance "); 432 puts("to the catacombs."); 433 printf("You will know when you arrive "); 434 printf("because I left an old pair of shoes "); 435 puts("there.'"); 436 } 437 break; 438 } 439 } 440 wordnumber = max(last1, last2) + 1; 441 return (firstnumber); 442 } 443