]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/object.c
1 /* $NetBSD: object.c,v 1.14 2008/02/04 01:07:01 dholland Exp $ */
3 /* object.c Larn is copyrighted 1986 by Noah Morgan. */
7 __RCSID("$NetBSD: object.c,v 1.14 2008/02/04 01:07:01 dholland Exp $");
15 subroutine to look for an object and give the player his options
16 if an object was found.
23 return; /* can't find objects if time is stopped */
24 i
= item
[playerx
][playery
];
27 showcell(playerx
, playery
);
35 lprcat("\n\nYou have found some gold!");
40 lprcat("\n\nYou have found a magic potion");
41 i
= iarg
[playerx
][playery
];
42 if (potionname
[i
][0] != 0)
43 lprintf(" of%s", potionname
[i
]);
48 lprcat("\n\nYou have found a magic scroll");
49 i
= iarg
[playerx
][playery
];
50 if (scrollname
[i
][0] != 0)
51 lprintf(" of%s", scrollname
[i
]);
58 lprcat("\n\nThere is a Holy Altar here!");
63 lprcat("\n\nYou have found a book.");
68 lprcat("\n\nYou have found a fortune cookie.");
75 lprintf("\n\nThere is %s here!", objectname
[i
]);
82 lprintf("\n\nThere is %s here!", objectname
[i
]);
87 lprintf("\n\nThere is %s here!", objectname
[i
]);
92 lprcat("\n\nYou have found the Orb!!!!!");
97 lprcat("\n\nYou're standing at the top of a pit.");
102 lprcat("\n\nThere is a circular staircase here");
107 lprcat("\n\nYou feel heavy for a moment, but the feeling disappears");
108 oelevator(1); /* up */
114 lprcat("\n\nThere is a fountain here");
121 lprcat("\n\nYou are standing in front of a statue");
126 lprcat("\n\nThere is a chest here");
133 item
[playerx
][playery
] = OTELEPORTER
;
134 know
[playerx
][playery
] = 1;
137 lprcat("\nZaaaappp! You've been teleported!\n");
146 lprcat("\n\nYou have found the College of Larn.");
147 lprcat("\nDo you (g) go inside, or (i) stay here? ");
149 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
152 oschool(); /* the college of larn */
154 lprcat(" stay here");
160 lprcat("\n\nThere is a mirror here");
169 lprcat("\n\nYou have found the bank of Larn.");
171 lprcat("\n\nYou have found a branch office of the bank of Larn.");
172 lprcat("\nDo you (g) go inside, or (i) stay here? ");
174 while ((j
!= 'g') && (j
!= 'i') && (j
!= '\33'))
180 obank2(); /* the bank of larn */
182 lprcat(" stay here");
188 lprcat("\n\nThere is a dead fountain here");
194 lprcat("\n\nThere is a DND store here.");
195 lprcat("\nDo you (g) go inside, or (i) stay here? ");
197 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
200 dndstore(); /* the dnd adventurers store */
202 lprcat(" stay here");
206 lprcat("\n\nThere is a circular staircase here");
207 ostairs(-1); /* down */
211 lprcat("\n\nYou feel light for a moment, but the feeling disappears");
212 oelevator(-1); /* down */
216 lprintf("\n\nYou have found %s", objectname
[i
]);
217 lprcat("\nDo you (c) close it");
220 while ((i
!= 'c') && (i
!= 'i') && (i
!= '\33'))
222 if ((i
== '\33') || (i
== 'i')) {
228 item
[playerx
][playery
] = OCLOSEDDOOR
;
229 iarg
[playerx
][playery
] = 0;
235 lprintf("\n\nYou have found %s", objectname
[i
]);
236 lprcat("\nDo you (o) try to open it");
239 while ((i
!= 'o') && (i
!= 'i') && (i
!= '\33'))
241 if ((i
== '\33') || (i
== 'i')) {
249 switch (iarg
[playerx
][playery
]) {
251 c
[AGGRAVATE
] += rnd(400);
255 lprcat("\nYou are jolted by an electric shock ");
266 lprcat("\nYou suddenly feel weaker ");
279 item
[playerx
][playery
] = OOPENDOOR
;
285 lprcat("\nYou have found ");
286 lprcat(objectname
[OENTRANCE
]);
287 lprcat("\nDo you (g) go inside");
290 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
296 item
[33][MAXY
- 1] = know
[33][MAXY
- 1] = mitem
[33][MAXY
- 1] = 0;
297 draws(0, MAXX
, 0, MAXY
);
305 lprcat("\nYou have found ");
306 lprcat(objectname
[OVOLDOWN
]);
307 lprcat("\nDo you (c) climb down");
310 while ((i
!= 'c') && (i
!= 'i') && (i
!= '\33'))
312 if ((i
== '\33') || (i
== 'i')) {
317 lprcat("\nThe shaft only extends 5 feet downward!");
320 if (packweight() > 45 + 3 * (c
[STRENGTH
] + c
[STREXTRA
])) {
321 lprcat("\nYou slip and fall down the shaft");
324 losehp(30 + rnd(20));
327 lprcat("climb down");
329 newcavelevel(MAXLEVEL
);
330 for (i
= 0; i
< MAXY
; i
++)
331 for (j
= 0; j
< MAXX
; j
++) /* put player near
333 if (item
[j
][i
] == OVOLUP
) {
340 draws(0, MAXX
, 0, MAXY
);
345 lprcat("\nYou have found ");
346 lprcat(objectname
[OVOLUP
]);
347 lprcat("\nDo you (c) climb up");
350 while ((i
!= 'c') && (i
!= 'i') && (i
!= '\33'))
352 if ((i
== '\33') || (i
== 'i')) {
357 lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!");
360 if (packweight() > 45 + 5 * (c
[STRENGTH
] + c
[STREXTRA
])) {
361 lprcat("\nYou slip and fall down the shaft");
364 losehp(15 + rnd(20));
372 for (i
= 0; i
< MAXY
; i
++)
373 for (j
= 0; j
< MAXX
; j
++) /* put player near
375 if (item
[j
][i
] == OVOLDOWN
) {
382 draws(0, MAXX
, 0, MAXY
);
388 return; /* for an arrow trap */
389 item
[playerx
][playery
] = OTRAPARROW
;
390 know
[playerx
][playery
] = 0;
393 lprcat("\nYou are hit by an arrow");
394 beep(); /* for an arrow trap */
396 losehp(rnd(10) + level
);
402 return; /* for a dart trap */
403 item
[playerx
][playery
] = ODARTRAP
;
404 know
[playerx
][playery
] = 0;
407 lprcat("\nYou are hit by a dart");
408 beep(); /* for a dart trap */
411 if ((--c
[STRENGTH
]) < 3)
418 return; /* for a trap door */
419 item
[playerx
][playery
] = OTRAPDOOR
;
420 know
[playerx
][playery
] = 1;
423 lastnum
= 272; /* a trap door */
424 if ((level
== MAXLEVEL
- 1) || (level
== MAXLEVEL
+ MAXVLEVEL
- 1)) {
425 lprcat("\nYou fell through a bottomless trap door!");
430 lprcat("\nYou fall through a trap door!");
431 beep(); /* for a trap door */
432 losehp(rnd(5 + level
));
434 newcavelevel(level
+ 1);
435 draws(0, MAXX
, 0, MAXY
);
443 lprcat("\nYou have found the Larn trading Post.");
444 lprcat("\nDo you (g) go inside, or (i) stay here? ");
446 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
457 lprcat("\nYou have found your way home.");
458 lprcat("\nDo you (g) go inside, or (i) stay here? ");
460 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
473 return; /* annihilated by sphere of annihilation */
478 lprcat("\n\nThere is an LRS office here.");
479 lprcat("\nDo you (g) go inside, or (i) stay here? ");
481 while ((i
!= 'g') && (i
!= 'i') && (i
!= '\33'))
484 olrs(); /* the larn revenue service */
486 lprcat(" stay here");
496 function to say what object we found and ask if player wants to take it
499 finditem(int theitem
)
502 lprintf("\n\nYou have found %s ", objectname
[theitem
]);
503 tmp
= iarg
[playerx
][playery
];
517 lprintf("+ %ld", (long) tmp
);
519 lprintf(" %ld", (long) tmp
);
521 lprcat("\nDo you want to (t) take it");
524 while (i
!= 't' && i
!= 'i' && i
!= '\33')
528 if (take(theitem
, tmp
) == 0)
538 subroutine to process the stair cases
539 if dir > 0 the up else down
546 lprcat("\nDo you (s) stay here ");
548 lprcat("(u) go up ");
550 lprcat("(d) go down ");
551 lprcat("or (f) kick stairs? ");
562 lprcat("kick stairs");
564 lprcat("\nI hope you feel better. Showing anger rids you of frustration.");
566 k
= rnd((level
+ 1) << 1);
567 lprintf("\nYou hurt your foot dumb dumb! You suffer %ld hit points", (long) k
);
577 lprcat("\nThe stairs don't go up!");
578 else if (level
>= 2 && level
!= 11) {
580 newcavelevel(level
- 1);
581 draws(0, MAXX
, 0, MAXY
);
584 lprcat("\nThe stairs lead to a dead end!");
590 lprcat("\nThe stairs don't go down!");
591 else if (level
!= 0 && level
!= 10 && level
!= 13) {
593 newcavelevel(level
+ 1);
594 draws(0, MAXX
, 0, MAXY
);
597 lprcat("\nThe stairs lead to a dead end!");
605 subroutine to handle a teleport trap +/- 1 level maximum
614 died(264); /* stuck in a rock */
615 c
[TELEFLAG
] = 1; /* show ?? on bottomline if been teleported */
618 else if (level
< MAXLEVEL
) {
619 tmp
= rnd(5) + level
- 3;
625 tmp
= rnd(3) + level
- 2;
626 if (tmp
>= MAXLEVEL
+ MAXVLEVEL
)
627 tmp
= MAXLEVEL
+ MAXVLEVEL
- 1;
631 playerx
= rnd(MAXX
- 2);
632 playery
= rnd(MAXY
- 2);
636 draws(0, MAXX
, 0, MAXY
);
642 function to process a potion
648 lprcat("\nDo you (d) drink it, (t) take it");
659 forget(); /* destroy potion */
665 if (take(OPOTION
, pot
) == 0)
672 function to drink a potion
679 if (pot
< 0 || pot
>= MAXPOTION
)
680 return; /* check for within bounds */
681 potionname
[pot
] = potionhide
[pot
];
684 lprcat("\nYou feel greedy . . .");
686 for (i
= 0; i
< MAXY
; i
++)
687 for (j
= 0; j
< MAXX
; j
++)
688 if ((item
[j
][i
] == OGOLDPILE
) || (item
[j
][i
] == OMAXGOLD
)) {
696 lprcat("\nYou feel greedy . . .");
698 for (i
= 0; i
< MAXY
; i
++)
699 for (j
= 0; j
< MAXX
; j
++) {
701 if ((k
== ODIAMOND
) || (k
== ORUBY
) || (k
== OEMERALD
) || (k
== OMAXGOLD
)
702 || (k
== OSAPPHIRE
) || (k
== OLARNEYE
) || (k
== OGOLDPILE
)) {
712 break; /* instant healing */
715 lprcat("\nYou feel better");
716 if (c
[HP
] == c
[HPMAX
])
718 else if ((c
[HP
] += rnd(20) + 20 + c
[LEVEL
]) > c
[HPMAX
])
723 lprcat("\nSuddenly, you feel much more skillful!");
729 lprcat("\nYou feel strange for a moment");
734 lprcat("\nYou feel more self confident!");
739 lprcat("\nWow! You feel great!");
740 if (c
[STRENGTH
] < 12)
747 lprcat("\nYour charm went up by one!");
752 lprcat("\nYour intelligence went up by one!");
757 for (i
= 0; i
< MAXY
; i
++)
758 for (j
= 0; j
< MAXX
; j
++)
763 /* monster detection */ return;
766 lprcat("\nThis potion has no taste to it");
770 lprcat("\nWOW!!! You feel Super-fantastic!!!");
772 for (i
= 0; i
< 6; i
++)
778 lprcat("\nYou have a greater intestinal constitude!");
783 lprcat("\nYou now have incredibly bulging muscles!!!");
784 if (c
[GIANTSTR
] == 0)
790 lprcat("\nYou feel a chill run up your spine!");
791 c
[FIRERESISTANCE
] += 1000;
795 lprcat("\nYou fall asleep. . .");
796 i
= rnd(11) - (c
[CONSTITUTION
] >> 2) + 2;
802 lprcat("\nYou woke up!");
806 lprcat("\nYou become dizzy!");
807 if (--c
[STRENGTH
] < 3)
812 lprcat("\nYou stagger for a moment . .");
813 for (i
= 0; i
< MAXY
; i
++)
814 for (j
= 0; j
< MAXX
; j
++)
817 draws(0, MAXX
, 0, MAXY
); /* potion of forgetfulness */
821 lprcat("\nYou can't see anything!"); /* blindness */
822 c
[BLINDCOUNT
] += 500;
826 lprcat("\nYou feel confused");
827 c
[CONFUSE
] += 20 + rnd(9);
831 lprcat("\nYou don't seem to be affected");
832 return; /* cure dianthroritis */
835 lprcat("\nYou feel a sickness engulf you"); /* poison */
836 c
[HALFDAM
] += 200 + rnd(200);
840 lprcat("\nYou feel your vision sharpen"); /* see invisible */
841 c
[SEEINVISIBLE
] += rnd(1000) + 400;
842 monstnamelist
[INVISIBLESTALKER
] = 'I';
845 bottomline(); /* show new stats */
851 function to process a magic scroll
858 if (c
[BLINDCOUNT
] == 0)
859 lprcat("(r) read it, ");
860 lprcat("(t) take it");
874 if (typ
== 2 || typ
== 15) {
875 show1cell(playerx
, playery
);
878 /* destroy it */ read_scroll(typ
);
883 if (take(OSCROLL
, typ
) == 0)
884 forget(); /* destroy it */
890 data for the function to read a scroll
892 static int xh
, yh
, yl
, xl
;
893 static u_char curse
[] = {
894 BLINDCOUNT
, CONFUSE
, AGGRAVATE
, HASTEMONST
, ITCHING
,
895 LAUGHING
, DRAINSTRENGTH
, CLUMSINESS
, INFEEBLEMENT
, HALFDAM
898 static u_char exten
[] = {
899 PROTECTIONTIME
, DEXCOUNT
, STRCOUNT
, CHARMCOUNT
, INVISIBILITY
,
900 CANCELLATION
, HASTESELF
, GLOBE
, SCAREMONST
, HOLDMONST
, TIMESTOP
903 u_char time_change
[] = {
904 HASTESELF
, HERO
, ALTPRO
, PROTECTIONTIME
, DEXCOUNT
, STRCOUNT
,
905 GIANTSTR
, CHARMCOUNT
, INVISIBILITY
, CANCELLATION
, HASTESELF
,
906 AGGRAVATE
, SCAREMONST
, STEALTH
, AWARENESS
, HOLDMONST
,
907 HASTEMONST
, FIRERESISTANCE
, GLOBE
, SPIRITPRO
, UNDEADPRO
,
908 HALFDAM
, SEEINVISIBLE
, ITCHING
, CLUMSINESS
, WTW
912 * function to adjust time when time warping and taking courses in school
919 for (j
= 0; j
< 26; j
++)/* adjust time related parameters */
920 if (c
[time_change
[j
]])
921 if ((c
[time_change
[j
]] -= tim
) < 1)
922 c
[time_change
[j
]] = 1;
927 function to read a scroll
934 if (typ
< 0 || typ
>= MAXSCROLL
)
935 return; /* be sure we are within bounds */
936 scrollname
[typ
] = scrollhide
[typ
];
939 lprcat("\nYour armor glows for a moment");
944 lprcat("\nYour weapon glows for a moment");
946 return; /* enchant weapon */
949 lprcat("\nYou have been granted enlightenment!");
950 yh
= min(playery
+ 7, MAXY
);
951 xh
= min(playerx
+ 25, MAXX
);
952 yl
= max(playery
- 7, 0);
953 xl
= max(playerx
- 25, 0);
954 for (i
= yl
; i
< yh
; i
++)
955 for (j
= xl
; j
< xh
; j
++)
958 draws(xl
, xh
, yl
, yh
);
962 lprcat("\nThis scroll seems to be blank");
966 createmonster(makemonst(level
+ 1));
967 return; /* this one creates a monster */
970 something(level
); /* create artifact */
975 return; /* aggravate monsters */
978 gltime
+= (i
= rnd(1000) - 850); /* time warp */
980 lprintf("\nYou went forward in time by %ld mobuls", (long) ((i
+ 99) / 100));
982 lprintf("\nYou went backward in time by %ld mobuls", (long) (-(i
+ 99) / 100));
983 adjusttime((long) i
); /* adjust time for time warping */
988 return; /* teleportation */
991 c
[AWARENESS
] += 1800;
992 return; /* expanded awareness */
995 c
[HASTEMONST
] += rnd(55) + 12;
996 return; /* haste monster */
999 for (i
= 0; i
< MAXY
; i
++)
1000 for (j
= 0; j
< MAXX
; j
++)
1002 hitp
[j
][i
] = monster
[mitem
[j
][i
]].hitpoints
;
1003 return; /* monster healing */
1005 c
[SPIRITPRO
] += 300 + rnd(200);
1007 return; /* spirit protection */
1010 c
[UNDEADPRO
] += 300 + rnd(200);
1012 return; /* undead protection */
1015 c
[STEALTH
] += 250 + rnd(250);
1017 return; /* stealth */
1020 lprcat("\nYou have been granted enlightenment!"); /* magic mapping */
1021 for (i
= 0; i
< MAXY
; i
++)
1022 for (j
= 0; j
< MAXX
; j
++)
1025 draws(0, MAXX
, 0, MAXY
);
1031 return; /* hold monster */
1034 for (i
= 0; i
< 26; i
++) /* gem perfection */
1044 j
= 255; /* double value */
1051 for (i
= 0; i
< 11; i
++)
1052 c
[exten
[i
]] <<= 1; /* spell extension */
1056 for (i
= 0; i
< 26; i
++) { /* identify */
1057 if (iven
[i
] == OPOTION
)
1058 potionname
[ivenarg
[i
]] = potionhide
[ivenarg
[i
]];
1059 if (iven
[i
] == OSCROLL
)
1060 scrollname
[ivenarg
[i
]] = scrollhide
[ivenarg
[i
]];
1065 for (i
= 0; i
< 10; i
++) /* remove curse */
1072 break; /* scroll of annihilation */
1075 godirect(22, 150, "The ray hits the %s", 0, ' '); /* pulverization */
1079 break; /* life protection */
1094 if (rnd(101) < 81) {
1095 if (rnd(70) > 9 * c
[DEXTERITY
] - packweight() || rnd(101) < 5) {
1096 if (level
== MAXLEVEL
- 1)
1098 else if (level
== MAXLEVEL
+ MAXVLEVEL
- 1)
1101 if (rnd(101) < 20) {
1103 lprcat("\nYou fell into a pit! Your fall is cushioned by an unknown force\n");
1105 i
= rnd(level
* 3 + 3);
1106 lprintf("\nYou fell into a pit! You suffer %ld hit points damage", (long) i
);
1107 lastnum
= 261; /* if he dies scoreboard
1112 newcavelevel(level
+ 1);
1113 draws(0, MAXX
, 0, MAXY
);
1122 lprcat("\nYou fell into a bottomless pit!");
1151 lprcat("\nDo you ");
1152 if (c
[BLINDCOUNT
] == 0)
1153 lprcat("(r) read it, ");
1154 lprcat("(t) take it");
1157 switch (ttgetch()) {
1167 /* no more book */ readbook(iarg
[playerx
][playery
]);
1173 if (take(OBOOK
, iarg
[playerx
][playery
]) == 0)
1174 forget(); /* no more book */
1180 function to read a book
1188 i
= rund((tmp
= splev
[lev
]) ? tmp
: 1);
1190 i
= rnd((tmp
= splev
[lev
] - 9) ? tmp
: 1) + 9;
1192 lprintf("\nSpell \"%s\": %s\n%s", spelcode
[i
], spelname
[i
], speldescript
[i
]);
1194 lprcat("\nYour int went up by one!");
1205 lprcat("\nDo you (e) eat it, (t) take it");
1208 switch (ttgetch()) {
1215 lprcat("eat\nThe cookie tasted good.");
1216 forget(); /* no more cookie */
1219 if (!(p
= fortune()))
1221 lprcat(" A message inside the cookie reads:\n");
1227 if (take(OCOOKIE
, 0) == 0)
1228 forget(); /* no more book */
1235 * routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth
1243 i
= iarg
[playerx
][playery
];
1244 if (arg
== OMAXGOLD
)
1246 else if (arg
== OKGOLD
)
1248 else if (arg
== ODGOLD
)
1250 lprintf("\nIt is worth %ld!", (long) i
);
1253 item
[playerx
][playery
] = know
[playerx
][playery
] = 0; /* destroy gold */
1260 nosignal
= 1; /* disable signals */
1261 for (i
= 0; i
< 26; i
++)
1262 if (iven
[i
] == OPOTION
)
1263 if (ivenarg
[i
] == 21) {
1264 iven
[i
] = 0; /* remove the potion of cure
1265 * dianthroritis from
1268 lprcat("Congratulations. You found a potion of cure dianthroritis.\n");
1269 lprcat("\nFrankly, No one thought you could do it. Boy! Did you surprise them!\n");
1270 if (gltime
> TIMELIMIT
) {
1271 lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
1272 lprcat("You didn't make it in time. In your agony, you kill the doctor,\nyour wife, and yourself! Too bad!\n");
1276 lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
1277 lprcat("Your daughter should be well on her way to recovery.\n");
1279 lprcat("\nThe potion is");
1281 lprcat(" working! The doctor thinks that\n");
1282 lprcat("your daughter will recover in a few days. Congratulations!\n");
1290 lprintf("Welcome home %s. Latest word from the doctor is not good.\n", logname
);
1292 if (gltime
> TIMELIMIT
) {
1293 lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
1294 lprcat("You didn't make it in time. In your agony, you kill the doctor,\nyour wife, and yourself! Too bad!\n");
1298 lprcat("\nThe diagnosis is confirmed as dianthroritis. He guesses that\n");
1299 lprintf("your daughter has only %ld mobuls left in this world. It's up to you,\n", (long) ((TIMELIMIT
- gltime
+ 99) / 100));
1300 lprintf("%s, to find the only hope for your daughter, the very rare\n", logname
);
1301 lprcat("potion of cure dianthroritis. It is rumored that only deep in the\n");
1302 lprcat("depths of the caves can this potion be found.\n\n\n");
1303 lprcat("\n ----- press ");
1305 lprcat(" to continue, ");
1307 lprcat(" to leave ----- ");
1309 while (i
!= '\33' && i
!= '\n')
1313 nosignal
= 0; /* enable signals */
1319 /* routine to save program space */
1323 lprcat(", or (i) ignore it? ");