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