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