|
|
1.1 root 1: /*
2: * File for the fun ends
3: * Death or a total win
4: *
5: * @(#)rip.c 3.13 (Berkeley) 6/16/81
6: */
7:
8: #include <curses.h>
9: #include <time.h>
10: #include <signal.h>
11: #include <ctype.h>
12: #include <sys/types.h>
13: #include <pwd.h>
14: #include "mach_dep.h"
15: #include "rogue.h"
16:
17: static char *rip[] = {
18: " __________",
19: " / \\",
20: " / REST \\",
21: " / IN \\",
22: " / PEACE \\",
23: " / \\",
24: " | |",
25: " | |",
26: " | killed by a |",
27: " | |",
28: " | 1980 |",
29: " *| * * * | *",
30: " ________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______",
31: 0
32: };
33:
34: char *killname();
35:
36: /*
37: * death:
38: * Do something really fun when he dies
39: */
40:
41: death(monst)
42: register char monst;
43: {
44: register char **dp = rip, *killer;
45: register struct tm *lt;
46: time_t date;
47: char buf[80];
48: struct tm *localtime();
49:
50: time(&date);
51: lt = localtime(&date);
52: clear();
53: move(8, 0);
54: while (*dp)
55: printw("%s\n", *dp++);
56: mvaddstr(14, 28-((strlen(whoami)+1)/2), whoami);
57: purse -= purse/10;
58: sprintf(buf, "%d Au", purse);
59: mvaddstr(15, 28-((strlen(buf)+1)/2), buf);
60: killer = killname(monst);
61: mvaddstr(17, 28-((strlen(killer)+1)/2), killer);
62: mvaddstr(16, 33, vowelstr(killer));
63: mvaddstr(18, 28, sprintf(prbuf, "%2d", lt->tm_year));
64: move(LINES-1, 0);
65: draw(stdscr);
66: score(purse, 0, monst);
67: endwin();
68: exit(0);
69: }
70:
71: /*
72: * score -- figure score and post it.
73: */
74:
75: /* VARARGS2 */
76: score(amount, flags, monst)
77: char monst;
78: {
79: static struct sc_ent {
80: int sc_score;
81: char sc_name[80];
82: int sc_flags;
83: int sc_level;
84: int sc_uid;
85: char sc_monster;
86: } top_ten[10];
87: register struct sc_ent *scp;
88: register int i;
89: register struct sc_ent *sc2;
90: register FILE *outf;
91: register char *killer;
92: register int prflags = 0;
93: register int fd;
94: static char *reason[] = {
95: "killed",
96: "quit",
97: "A total winner",
98: };
99: int endit();
100:
101: if (flags != -1)
102: endwin();
103: /*
104: * Open file and read list
105: */
106:
107: if ((fd = open(cheating?"/usr/games/lib/cheat_roll":SCOREFILE, 2)) < 0)
108: return;
109: outf = fdopen(fd, "w");
110:
111: for (scp = top_ten; scp < &top_ten[10]; scp++)
112: {
113: scp->sc_score = 0;
114: for (i = 0; i < 80; i++)
115: scp->sc_name[i] = rnd(255);
116: scp->sc_flags = RN;
117: scp->sc_level = RN;
118: scp->sc_monster = RN;
119: scp->sc_uid = RN;
120: }
121:
122: signal(SIGINT, SIG_DFL);
123: if (flags != -1)
124: {
125: printf("[Press return to continue]");
126: fflush(stdout);
127: gets(prbuf);
128: }
129: if (wizard)
130: if (strcmp(prbuf, "names") == 0)
131: prflags = 1;
132: else if (strcmp(prbuf, "edit") == 0)
133: prflags = 2;
134: encread((char *) top_ten, sizeof top_ten, fd);
135: /*
136: * Insert her in list if need be
137: */
138: if (!waswizard)
139: {
140: for (scp = top_ten; scp < &top_ten[10]; scp++)
141: if (amount > scp->sc_score)
142: break;
143: if (scp < &top_ten[10])
144: {
145: for (sc2 = &top_ten[9]; sc2 > scp; sc2--)
146: *sc2 = *(sc2-1);
147: scp->sc_score = amount;
148: strcpy(scp->sc_name, whoami);
149: scp->sc_flags = flags;
150: if (flags == 2)
151: scp->sc_level = max_level;
152: else
153: scp->sc_level = level;
154: scp->sc_monster = monst;
155: scp->sc_uid = getuid();
156: }
157: }
158: /*
159: * Print the list
160: */
161: printf("\nTop Ten Adventurers:\nRank\tScore\tName\n");
162: for (scp = top_ten; scp < &top_ten[10]; scp++) {
163: if (scp->sc_score) {
164: printf("%d\t%d\t%s: %s on level %d", scp - top_ten + 1,
165: scp->sc_score, scp->sc_name, reason[scp->sc_flags],
166: scp->sc_level);
167: if (scp->sc_flags == 0) {
168: printf(" by a");
169: killer = killname(scp->sc_monster);
170: if (*killer == 'a' || *killer == 'e' || *killer == 'i' ||
171: *killer == 'o' || *killer == 'u')
172: putchar('n');
173: printf(" %s", killer);
174: }
175: if (prflags == 1)
176: {
177: struct passwd *pp, *getpwuid();
178:
179: if ((pp = getpwuid(scp->sc_uid)) == NULL)
180: printf(" (%d)", scp->sc_uid);
181: else
182: printf(" (%s)", pp->pw_name);
183: putchar('\n');
184: }
185: else if (prflags == 2)
186: {
187: fflush(stdout);
188: gets(prbuf);
189: if (prbuf[0] == 'd')
190: {
191: for (sc2 = scp; sc2 < &top_ten[9]; sc2++)
192: *sc2 = *(sc2 + 1);
193: top_ten[9].sc_score = 0;
194: for (i = 0; i < 80; i++)
195: top_ten[9].sc_name[i] = rnd(255);
196: top_ten[9].sc_flags = RN;
197: top_ten[9].sc_level = RN;
198: top_ten[9].sc_monster = RN;
199: scp--;
200: }
201: }
202: else
203: printf(".\n");
204: }
205: }
206: fseek(outf, 0L, 0);
207: /*
208: * Update the list file
209: */
210: encwrite((char *) top_ten, sizeof top_ten, outf);
211: fclose(outf);
212: }
213:
214: total_winner()
215: {
216: register struct linked_list *item;
217: register struct object *obj;
218: register int worth;
219: register char c;
220: register int oldpurse;
221:
222: clear();
223: standout();
224: addstr(" \n");
225: addstr(" @ @ @ @ @ @@@ @ @ \n");
226: addstr(" @ @ @@ @@ @ @ @ @ \n");
227: addstr(" @ @ @@@ @ @ @ @ @ @@@ @@@@ @@@ @ @@@ @ \n");
228: addstr(" @@@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ \n");
229: addstr(" @ @ @ @ @ @ @ @@@@ @ @ @@@@@ @ @ @ \n");
230: addstr(" @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @ \n");
231: addstr(" @@@ @@@ @@ @ @ @ @@@@ @@@@ @@@ @@@ @@ @ \n");
232: addstr(" \n");
233: addstr(" Congratulations, you have made it to the light of day! \n");
234: standend();
235: addstr("\nYou have joined the elite ranks of those who have escaped the\n");
236: addstr("Dungeons of Doom alive. You journey home and sell all your loot at\n");
237: addstr("a great profit and are admitted to the fighters guild.\n");
238: mvaddstr(LINES - 1, 0, "--Press space to continue--");
239: refresh();
240: wait_for(' ');
241: clear();
242: mvaddstr(0, 0, " Worth Item");
243: oldpurse = purse;
244: for (c = 'a', item = pack; item != NULL; c++, item = next(item))
245: {
246: obj = (struct object *) ldata(item);
247: switch (obj->o_type)
248: {
249: when FOOD:
250: worth = 2 * obj->o_count;
251: when WEAPON:
252: switch (obj->o_which)
253: {
254: when MACE: worth = 8;
255: when SWORD: worth = 15;
256: when BOW: worth = 75;
257: when ARROW: worth = 1;
258: when DAGGER: worth = 2;
259: when ROCK: worth = 1;
260: when TWOSWORD: worth = 30;
261: when SLING: worth = 1;
262: when DART: worth = 1;
263: when CROSSBOW: worth = 15;
264: when BOLT: worth = 1;
265: when SPEAR: worth = 2;
266: otherwise: worth = 0;
267: }
268: worth *= (1 + (10 * obj->o_hplus + 10 * obj->o_dplus));
269: worth *= obj->o_count;
270: obj->o_flags |= ISKNOW;
271: when ARMOR:
272: switch (obj->o_which)
273: {
274: when LEATHER: worth = 5;
275: when RING_MAIL: worth = 30;
276: when STUDDED_LEATHER: worth = 15;
277: when SCALE_MAIL: worth = 3;
278: when CHAIN_MAIL: worth = 75;
279: when SPLINT_MAIL: worth = 80;
280: when BANDED_MAIL: worth = 90;
281: when PLATE_MAIL: worth = 400;
282: otherwise: worth = 0;
283: }
284: worth *= (1 + (10 * (a_class[obj->o_which] - obj->o_ac)));
285: obj->o_flags |= ISKNOW;
286: when SCROLL:
287: s_know[obj->o_which] = TRUE;
288: worth = s_magic[obj->o_which].mi_worth;
289: worth *= obj->o_count;
290: when POTION:
291: p_know[obj->o_which] = TRUE;
292: worth = p_magic[obj->o_which].mi_worth;
293: worth *= obj->o_count;
294: when RING:
295: obj->o_flags |= ISKNOW;
296: r_know[obj->o_which] = TRUE;
297: worth = r_magic[obj->o_which].mi_worth;
298: if (obj->o_which == R_ADDSTR || obj->o_which == R_ADDDAM ||
299: obj->o_which == R_PROTECT || obj->o_which == R_ADDHIT)
300: if (obj->o_ac > 0)
301: worth += obj->o_ac * 20;
302: else
303: worth = 50;
304: when STICK:
305: obj->o_flags |= ISKNOW;
306: ws_know[obj->o_which] = TRUE;
307: worth = ws_magic[obj->o_which].mi_worth;
308: worth += 20 * obj->o_charges;
309: when AMULET:
310: worth = 1000;
311: }
312: mvprintw(c - 'a' + 1, 0, "%c) %5d %s", c, worth, inv_name(obj, FALSE));
313: purse += worth;
314: }
315: mvprintw(c - 'a' + 1, 0," %5d Gold Peices ", oldpurse);
316: refresh();
317: score(purse, 2);
318: exit(0);
319: }
320:
321: char *
322: killname(monst)
323: register char monst;
324: {
325: if (isupper(monst))
326: return monsters[monst-'A'].m_name;
327: else
328: switch (monst)
329: {
330: case 'a':
331: return "arrow";
332: case 'd':
333: return "dart";
334: case 'b':
335: return "bolt";
336: }
337: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.