]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/object.c
1 /* $NetBSD: object.c,v 1.11 2008/01/28 03:39:31 dholland Exp $ */
3 /* object.c Larn is copyrighted 1986 by Noah Morgan. */
7 __RCSID("$NetBSD: object.c,v 1.11 2008/01/28 03:39:31 dholland Exp $");
17 subroutine to look for an object and give the player his options
18 if an object was found.
25 return; /* can't find objects is time is stopped */
26 i
= item
[playerx
][playery
];
29 showcell(playerx
, playery
);
37 lprcat("\n\nYou have found some gold!");
42 lprcat("\n\nYou have found a magic potion");
43 i
= iarg
[playerx
][playery
];
44 if (potionname
[i
][0] != 0)
45 lprintf(" of%s", potionname
[i
]);
50 lprcat("\n\nYou have found a magic scroll");
51 i
= iarg
[playerx
][playery
];
52 if (scrollname
[i
][0] != 0)
53 lprintf(" of%s", scrollname
[i
]);
60 lprcat("\n\nThere is a Holy Altar here!");
65 lprcat("\n\nYou have found a book.");
70 lprcat("\n\nYou have found a fortune cookie.");
77 lprintf("\n\nThere is %s here!", objectname
[i
]);
84 lprintf("\n\nThere is %s here!", objectname
[i
]);
89 lprintf("\n\nThere is %s here!", objectname
[i
]);
94 lprcat("\n\nYou have found the Orb!!!!!");
99 lprcat("\n\nYou're standing at the top of a pit.");
104 lprcat("\n\nThere is a circular staircase here");
109 lprcat("\n\nYou feel heavy for a moment, but the feeling disappears");
110 oelevator(1); /* up */
116 lprcat("\n\nThere is a fountain here");
123 lprcat("\n\nYou are standing in front of a statue");
128 lprcat("\n\nThere is a chest here");
135 item
[playerx
][playery
] = OTELEPORTER
;
136 know
[playerx
][playery
] = 1;
139 lprcat("\nZaaaappp! You've been teleported!\n");
148 lprcat("\n\nYou have found the College of Larn.");
149 lprcat("\nDo you (g) go inside, or (i) stay here? ");
151 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
154 oschool(); /* the college of larn */
156 lprcat(" stay here");
162 lprcat("\n\nThere is a mirror here");
171 lprcat("\n\nYou have found the bank of Larn.");
173 lprcat("\n\nYou have found a branch office of the bank of Larn.");
174 lprcat("\nDo you (g) go inside, or (i) stay here? ");
176 while ((j
!= 'g') && (j
!= 'i') && (j
!= '\33'))
182 obank2(); /* the bank of larn */
184 lprcat(" stay here");
190 lprcat("\n\nThere is a dead fountain here");
196 lprcat("\n\nThere is a DND store here.");
197 lprcat("\nDo you (g) go inside, or (i) stay here? ");
199 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
202 dndstore(); /* the dnd adventurers store */
204 lprcat(" stay here");
208 lprcat("\n\nThere is a circular staircase here");
209 ostairs(-1); /* down */
213 lprcat("\n\nYou feel light for a moment, but the feeling disappears");
214 oelevator(-1); /* down */
218 lprintf("\n\nYou have found %s", objectname
[i
]);
219 lprcat("\nDo you (c) close it");
222 while ((i
!= 'c') && (i
!= 'i') && (i
!= '\33'))
224 if ((i
== '\33') || (i
== 'i')) {
230 item
[playerx
][playery
] = OCLOSEDDOOR
;
231 iarg
[playerx
][playery
] = 0;
237 lprintf("\n\nYou have found %s", objectname
[i
]);
238 lprcat("\nDo you (o) try to open it");
241 while ((i
!= 'o') && (i
!= 'i') && (i
!= '\33'))
243 if ((i
== '\33') || (i
== 'i')) {
251 switch (iarg
[playerx
][playery
]) {
253 c
[AGGRAVATE
] += rnd(400);
257 lprcat("\nYou are jolted by an electric shock ");
268 lprcat("\nYou suddenly feel weaker ");
281 item
[playerx
][playery
] = OOPENDOOR
;
287 lprcat("\nYou have found ");
288 lprcat(objectname
[OENTRANCE
]);
289 lprcat("\nDo you (g) go inside");
292 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
298 item
[33][MAXY
- 1] = know
[33][MAXY
- 1] = mitem
[33][MAXY
- 1] = 0;
299 draws(0, MAXX
, 0, MAXY
);
307 lprcat("\nYou have found ");
308 lprcat(objectname
[OVOLDOWN
]);
309 lprcat("\nDo you (c) climb down");
312 while ((i
!= 'c') && (i
!= 'i') && (i
!= '\33'))
314 if ((i
== '\33') || (i
== 'i')) {
319 lprcat("\nThe shaft only extends 5 feet downward!");
322 if (packweight() > 45 + 3 * (c
[STRENGTH
] + c
[STREXTRA
])) {
323 lprcat("\nYou slip and fall down the shaft");
326 losehp(30 + rnd(20));
329 lprcat("climb down");
331 newcavelevel(MAXLEVEL
);
332 for (i
= 0; i
< MAXY
; i
++)
333 for (j
= 0; j
< MAXX
; j
++) /* put player near
335 if (item
[j
][i
] == OVOLUP
) {
342 draws(0, MAXX
, 0, MAXY
);
347 lprcat("\nYou have found ");
348 lprcat(objectname
[OVOLUP
]);
349 lprcat("\nDo you (c) climb up");
352 while ((i
!= 'c') && (i
!= 'i') && (i
!= '\33'))
354 if ((i
== '\33') || (i
== 'i')) {
359 lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!");
362 if (packweight() > 45 + 5 * (c
[STRENGTH
] + c
[STREXTRA
])) {
363 lprcat("\nYou slip and fall down the shaft");
366 losehp(15 + rnd(20));
374 for (i
= 0; i
< MAXY
; i
++)
375 for (j
= 0; j
< MAXX
; j
++) /* put player near
377 if (item
[j
][i
] == OVOLDOWN
) {
384 draws(0, MAXX
, 0, MAXY
);
390 return; /* for an arrow trap */
391 item
[playerx
][playery
] = OTRAPARROW
;
392 know
[playerx
][playery
] = 0;
395 lprcat("\nYou are hit by an arrow");
396 beep(); /* for an arrow trap */
398 losehp(rnd(10) + level
);
404 return; /* for a dart trap */
405 item
[playerx
][playery
] = ODARTRAP
;
406 know
[playerx
][playery
] = 0;
409 lprcat("\nYou are hit by a dart");
410 beep(); /* for a dart trap */
413 if ((--c
[STRENGTH
]) < 3)
420 return; /* for a trap door */
421 item
[playerx
][playery
] = OTRAPDOOR
;
422 know
[playerx
][playery
] = 1;
425 lastnum
= 272; /* a trap door */
426 if ((level
== MAXLEVEL
- 1) || (level
== MAXLEVEL
+ MAXVLEVEL
- 1)) {
427 lprcat("\nYou fell through a bottomless trap door!");
432 lprcat("\nYou fall through a trap door!");
433 beep(); /* for a trap door */
434 losehp(rnd(5 + level
));
436 newcavelevel(level
+ 1);
437 draws(0, MAXX
, 0, MAXY
);
445 lprcat("\nYou have found the Larn trading Post.");
446 lprcat("\nDo you (g) go inside, or (i) stay here? ");
448 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
459 lprcat("\nYou have found your way home.");
460 lprcat("\nDo you (g) go inside, or (i) stay here? ");
462 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
475 return; /* annihilated by sphere of annihilation */
480 lprcat("\n\nThere is an LRS office here.");
481 lprcat("\nDo you (g) go inside, or (i) stay here? ");
483 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
486 olrs(); /* the larn revenue service */
488 lprcat(" stay here");
498 function to say what object we found and ask if player wants to take it
505 lprintf("\n\nYou have found %s ", objectname
[itm
]);
506 tmp
= iarg
[playerx
][playery
];
520 lprintf("+ %ld", (long) tmp
);
522 lprintf(" %ld", (long) tmp
);
524 lprcat("\nDo you want to (t) take it");
527 while (i
!= 't' && i
!= 'i' && i
!= '\33')
531 if (take(itm
, tmp
) == 0)
545 subroutine to process the stair cases
546 if dir > 0 the up else down
553 lprcat("\nDo you (s) stay here ");
555 lprcat("(u) go up ");
557 lprcat("(d) go down ");
558 lprcat("or (f) kick stairs? ");
561 switch (lgetchar()) {
569 lprcat("kick stairs");
571 lprcat("\nI hope you feel better. Showing anger rids you of frustration.");
573 k
= rnd((level
+ 1) << 1);
574 lprintf("\nYou hurt your foot dumb dumb! You suffer %ld hit points", (long) k
);
584 lprcat("\nThe stairs don't go up!");
585 else if (level
>= 2 && level
!= 11) {
587 newcavelevel(level
- 1);
588 draws(0, MAXX
, 0, MAXY
);
591 lprcat("\nThe stairs lead to a dead end!");
597 lprcat("\nThe stairs don't go down!");
598 else if (level
!= 0 && level
!= 10 && level
!= 13) {
600 newcavelevel(level
+ 1);
601 draws(0, MAXX
, 0, MAXY
);
604 lprcat("\nThe stairs lead to a dead end!");
616 subroutine to handle a teleport trap +/- 1 level maximum
625 died(264); /* stuck in a rock */
626 c
[TELEFLAG
] = 1; /* show ?? on bottomline if been teleported */
629 else if (level
< MAXLEVEL
) {
630 tmp
= rnd(5) + level
- 3;
636 tmp
= rnd(3) + level
- 2;
637 if (tmp
>= MAXLEVEL
+ MAXVLEVEL
)
638 tmp
= MAXLEVEL
+ MAXVLEVEL
- 1;
642 playerx
= rnd(MAXX
- 2);
643 playery
= rnd(MAXY
- 2);
647 draws(0, MAXX
, 0, MAXY
);
657 function to process a potion
663 lprcat("\nDo you (d) drink it, (t) take it");
666 switch (lgetchar()) {
674 forget(); /* destroy potion */
680 if (take(OPOTION
, pot
) == 0)
687 function to drink a potion
694 if (pot
< 0 || pot
>= MAXPOTION
)
695 return; /* check for within bounds */
696 potionname
[pot
] = potionhide
[pot
];
699 lprcat("\nYou feel greedy . . .");
701 for (i
= 0; i
< MAXY
; i
++)
702 for (j
= 0; j
< MAXX
; j
++)
703 if ((item
[j
][i
] == OGOLDPILE
) || (item
[j
][i
] == OMAXGOLD
)) {
711 lprcat("\nYou feel greedy . . .");
713 for (i
= 0; i
< MAXY
; i
++)
714 for (j
= 0; j
< MAXX
; j
++) {
716 if ((k
== ODIAMOND
) || (k
== ORUBY
) || (k
== OEMERALD
) || (k
== OMAXGOLD
)
717 || (k
== OSAPPHIRE
) || (k
== OLARNEYE
) || (k
== OGOLDPILE
)) {
727 break; /* instant healing */
730 lprcat("\nYou feel better");
731 if (c
[HP
] == c
[HPMAX
])
733 else if ((c
[HP
] += rnd(20) + 20 + c
[LEVEL
]) > c
[HPMAX
])
738 lprcat("\nSuddenly, you feel much more skillful!");
744 lprcat("\nYou feel strange for a moment");
749 lprcat("\nYou feel more self confident!");
754 lprcat("\nWow! You feel great!");
755 if (c
[STRENGTH
] < 12)
762 lprcat("\nYour charm went up by one!");
767 lprcat("\nYour intelligence went up by one!");
772 for (i
= 0; i
< MAXY
; i
++)
773 for (j
= 0; j
< MAXX
; j
++)
778 /* monster detection */ return;
781 lprcat("\nThis potion has no taste to it");
785 lprcat("\nWOW!!! You feel Super-fantastic!!!");
787 for (i
= 0; i
< 6; i
++)
793 lprcat("\nYou have a greater intestinal constitude!");
798 lprcat("\nYou now have incredibly bulging muscles!!!");
799 if (c
[GIANTSTR
] == 0)
805 lprcat("\nYou feel a chill run up your spine!");
806 c
[FIRERESISTANCE
] += 1000;
810 lprcat("\nYou fall asleep. . .");
811 i
= rnd(11) - (c
[CONSTITUTION
] >> 2) + 2;
817 lprcat("\nYou woke up!");
821 lprcat("\nYou become dizzy!");
822 if (--c
[STRENGTH
] < 3)
827 lprcat("\nYou stagger for a moment . .");
828 for (i
= 0; i
< MAXY
; i
++)
829 for (j
= 0; j
< MAXX
; j
++)
832 draws(0, MAXX
, 0, MAXY
); /* potion of forgetfulness */
836 lprcat("\nYou can't see anything!"); /* blindness */
837 c
[BLINDCOUNT
] += 500;
841 lprcat("\nYou feel confused");
842 c
[CONFUSE
] += 20 + rnd(9);
846 lprcat("\nYou don't seem to be affected");
847 return; /* cure dianthroritis */
850 lprcat("\nYou feel a sickness engulf you"); /* poison */
851 c
[HALFDAM
] += 200 + rnd(200);
855 lprcat("\nYou feel your vision sharpen"); /* see invisible */
856 c
[SEEINVISIBLE
] += rnd(1000) + 400;
857 monstnamelist
[INVISIBLESTALKER
] = 'I';
860 bottomline(); /* show new stats */
870 function to process a magic scroll
877 if (c
[BLINDCOUNT
] == 0)
878 lprcat("(r) read it, ");
879 lprcat("(t) take it");
882 switch (lgetchar()) {
893 if (typ
== 2 || typ
== 15) {
894 show1cell(playerx
, playery
);
897 /* destroy it */ read_scroll(typ
);
902 if (take(OSCROLL
, typ
) == 0)
903 forget(); /* destroy it */
909 data for the function to read a scroll
911 static int xh
, yh
, yl
, xl
;
912 static u_char curse
[] = {
913 BLINDCOUNT
, CONFUSE
, AGGRAVATE
, HASTEMONST
, ITCHING
,
914 LAUGHING
, DRAINSTRENGTH
, CLUMSINESS
, INFEEBLEMENT
, HALFDAM
917 static u_char exten
[] = {
918 PROTECTIONTIME
, DEXCOUNT
, STRCOUNT
, CHARMCOUNT
, INVISIBILITY
,
919 CANCELLATION
, HASTESELF
, GLOBE
, SCAREMONST
, HOLDMONST
, TIMESTOP
922 u_char time_change
[] = {
923 HASTESELF
, HERO
, ALTPRO
, PROTECTIONTIME
, DEXCOUNT
, STRCOUNT
,
924 GIANTSTR
, CHARMCOUNT
, INVISIBILITY
, CANCELLATION
, HASTESELF
,
925 AGGRAVATE
, SCAREMONST
, STEALTH
, AWARENESS
, HOLDMONST
,
926 HASTEMONST
, FIRERESISTANCE
, GLOBE
, SPIRITPRO
, UNDEADPRO
,
927 HALFDAM
, SEEINVISIBLE
, ITCHING
, CLUMSINESS
, WTW
931 * function to adjust time when time warping and taking courses in school
938 for (j
= 0; j
< 26; j
++)/* adjust time related parameters */
939 if (c
[time_change
[j
]])
940 if ((c
[time_change
[j
]] -= tim
) < 1)
941 c
[time_change
[j
]] = 1;
946 function to read a scroll
953 if (typ
< 0 || typ
>= MAXSCROLL
)
954 return; /* be sure we are within bounds */
955 scrollname
[typ
] = scrollhide
[typ
];
958 lprcat("\nYour armor glows for a moment");
963 lprcat("\nYour weapon glows for a moment");
965 return; /* enchant weapon */
968 lprcat("\nYou have been granted enlightenment!");
969 yh
= min(playery
+ 7, MAXY
);
970 xh
= min(playerx
+ 25, MAXX
);
971 yl
= max(playery
- 7, 0);
972 xl
= max(playerx
- 25, 0);
973 for (i
= yl
; i
< yh
; i
++)
974 for (j
= xl
; j
< xh
; j
++)
977 draws(xl
, xh
, yl
, yh
);
981 lprcat("\nThis scroll seems to be blank");
985 createmonster(makemonst(level
+ 1));
986 return; /* this one creates a monster */
989 something(level
); /* create artifact */
994 return; /* aggravate monsters */
997 gltime
+= (i
= rnd(1000) - 850); /* time warp */
999 lprintf("\nYou went forward in time by %ld mobuls", (long) ((i
+ 99) / 100));
1001 lprintf("\nYou went backward in time by %ld mobuls", (long) (-(i
+ 99) / 100));
1002 adjusttime((long) i
); /* adjust time for time warping */
1007 return; /* teleportation */
1010 c
[AWARENESS
] += 1800;
1011 return; /* expanded awareness */
1014 c
[HASTEMONST
] += rnd(55) + 12;
1015 return; /* haste monster */
1018 for (i
= 0; i
< MAXY
; i
++)
1019 for (j
= 0; j
< MAXX
; j
++)
1021 hitp
[j
][i
] = monster
[mitem
[j
][i
]].hitpoints
;
1022 return; /* monster healing */
1024 c
[SPIRITPRO
] += 300 + rnd(200);
1026 return; /* spirit protection */
1029 c
[UNDEADPRO
] += 300 + rnd(200);
1031 return; /* undead protection */
1034 c
[STEALTH
] += 250 + rnd(250);
1036 return; /* stealth */
1039 lprcat("\nYou have been granted enlightenment!"); /* magic mapping */
1040 for (i
= 0; i
< MAXY
; i
++)
1041 for (j
= 0; j
< MAXX
; j
++)
1044 draws(0, MAXX
, 0, MAXY
);
1050 return; /* hold monster */
1053 for (i
= 0; i
< 26; i
++) /* gem perfection */
1063 j
= 255; /* double value */
1070 for (i
= 0; i
< 11; i
++)
1071 c
[exten
[i
]] <<= 1; /* spell extension */
1075 for (i
= 0; i
< 26; i
++) { /* identify */
1076 if (iven
[i
] == OPOTION
)
1077 potionname
[ivenarg
[i
]] = potionhide
[ivenarg
[i
]];
1078 if (iven
[i
] == OSCROLL
)
1079 scrollname
[ivenarg
[i
]] = scrollhide
[ivenarg
[i
]];
1084 for (i
= 0; i
< 10; i
++) /* remove curse */
1091 break; /* scroll of annihilation */
1094 godirect(22, 150, "The ray hits the %s", 0, ' '); /* pulverization */
1098 break; /* life protection */
1113 if (rnd(101) < 81) {
1114 if (rnd(70) > 9 * c
[DEXTERITY
] - packweight() || rnd(101) < 5) {
1115 if (level
== MAXLEVEL
- 1)
1117 else if (level
== MAXLEVEL
+ MAXVLEVEL
- 1)
1120 if (rnd(101) < 20) {
1122 lprcat("\nYou fell into a pit! Your fall is cushioned by an unknown force\n");
1124 i
= rnd(level
* 3 + 3);
1125 lprintf("\nYou fell into a pit! You suffer %ld hit points damage", (long) i
);
1126 lastnum
= 261; /* if he dies scoreboard
1131 newcavelevel(level
+ 1);
1132 draws(0, MAXX
, 0, MAXY
);
1141 lprcat("\nYou fell into a bottomless pit!");
1170 lprcat("\nDo you ");
1171 if (c
[BLINDCOUNT
] == 0)
1172 lprcat("(r) read it, ");
1173 lprcat("(t) take it");
1176 switch (lgetchar()) {
1186 /* no more book */ readbook(iarg
[playerx
][playery
]);
1192 if (take(OBOOK
, iarg
[playerx
][playery
]) == 0)
1193 forget(); /* no more book */
1199 function to read a book
1207 i
= rund((tmp
= splev
[lev
]) ? tmp
: 1);
1209 i
= rnd((tmp
= splev
[lev
] - 9) ? tmp
: 1) + 9;
1211 lprintf("\nSpell \"%s\": %s\n%s", spelcode
[i
], spelname
[i
], speldescript
[i
]);
1213 lprcat("\nYour int went up by one!");
1223 lprcat("\nDo you (e) eat it, (t) take it");
1226 switch (lgetchar()) {
1233 lprcat("eat\nThe cookie tasted good.");
1234 forget(); /* no more cookie */
1237 if (!(p
= fortune()))
1239 lprcat(" A message inside the cookie reads:\n");
1245 if (take(OCOOKIE
, 0) == 0)
1246 forget(); /* no more book */
1253 * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth
1261 i
= iarg
[playerx
][playery
];
1262 if (arg
== OMAXGOLD
)
1264 else if (arg
== OKGOLD
)
1266 else if (arg
== ODGOLD
)
1268 lprintf("\nIt is worth %ld!", (long) i
);
1271 item
[playerx
][playery
] = know
[playerx
][playery
] = 0; /* destroy gold */
1278 nosignal
= 1; /* disable signals */
1279 for (i
= 0; i
< 26; i
++)
1280 if (iven
[i
] == OPOTION
)
1281 if (ivenarg
[i
] == 21) {
1282 iven
[i
] = 0; /* remove the potion of cure
1283 * dianthroritis from
1286 lprcat("Congratulations. You found a potion of cure dianthroritis.\n");
1287 lprcat("\nFrankly, No one thought you could do it. Boy! Did you surprise them!\n");
1288 if (gltime
> TIMELIMIT
) {
1289 lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
1290 lprcat("You didn't make it in time. In your agony, you kill the doctor,\nyour wife, and yourself! Too bad!\n");
1294 lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
1295 lprcat("Your daughter should be well on her way to recovery.\n");
1297 lprcat("\nThe potion is");
1299 lprcat(" working! The doctor thinks that\n");
1300 lprcat("your daughter will recover in a few days. Congratulations!\n");
1308 lprintf("Welcome home %s. Latest word from the doctor is not good.\n", logname
);
1310 if (gltime
> TIMELIMIT
) {
1311 lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
1312 lprcat("You didn't make it in time. In your agony, you kill the doctor,\nyour wife, and yourself! Too bad!\n");
1316 lprcat("\nThe diagnosis is confirmed as dianthroritis. He guesses that\n");
1317 lprintf("your daughter has only %ld mobuls left in this world. It's up to you,\n", (long) ((TIMELIMIT
- gltime
+ 99) / 100));
1318 lprintf("%s, to find the only hope for your daughter, the very rare\n", logname
);
1319 lprcat("potion of cure dianthroritis. It is rumored that only deep in the\n");
1320 lprcat("depths of the caves can this potion be found.\n\n\n");
1321 lprcat("\n ----- press ");
1323 lprcat(" to continue, ");
1325 lprcat(" to leave ----- ");
1327 while (i
!= '\33' && i
!= '\n')
1331 nosignal
= 0; /* enable signals */
1337 /* routine to save program space */
1341 lprcat(", or (i) ignore it? ");