7d3962116d885c92ed98eef0db236413e7bf06a6
2 * File for the fun ends
5 * @(#)rip.c 3.13 (Berkeley) 6/16/81
7 * Rogue: Exploring the Dungeons of Doom
8 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
11 * See the file LICENSE.TXT for full copyright and licensing information.
18 #include <sys/types.h>
24 static char *rip
[] = {
37 " ________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______",
45 * Do something really fun when he dies
51 register char **dp
= rip
, *killer
;
52 register struct tm
*lt
;
57 lt
= localtime(&date
);
61 printw("%s\n", *dp
++);
62 mvaddstr(14, 28-(((int)strlen(whoami
)+1)/2), whoami
);
64 sprintf(buf
, "%d Au", purse
);
65 mvaddstr(15, 28-(((int)strlen(buf
)+1)/2), buf
);
66 killer
= killname(monst
);
67 mvaddstr(17, 28-(((int)strlen(killer
)+1)/2), killer
);
68 mvaddstr(16, 33, vowelstr(killer
));
69 sprintf(prbuf
, "%4d", 1900+lt
->tm_year
);
70 mvaddstr(18, 26, prbuf
);
73 score(purse
, 0, monst
);
80 * score -- figure score and post it.
84 score(amount
, flags
, monst
)
87 static struct sc_ent
{
95 register struct sc_ent
*scp
;
97 register struct sc_ent
*sc2
;
99 register char *killer
;
100 register int prflags
= 0;
102 static char *reason
[] = {
107 "got the amulet and left"
110 char score_file
[PATH_MAX
];
111 int rogue_ver
= 0, scorefile_ver
= 0;
114 * Open file and read list
117 /* Get default score file */
118 strcpy(score_file
, md_getroguedir());
121 strcat(score_file
,"\\");
123 strcat(score_file
, "rogue36.scr");
125 if ((fd
= open(score_file
, O_RDWR
| O_CREAT
, 0666 )) < 0)
128 outf
= (FILE *) fdopen(fd
, "w");
130 for (scp
= top_ten
; scp
<= &top_ten
[9]; scp
++)
133 for (i
= 0; i
< 80; i
++)
134 scp
->sc_name
[i
] = rnd(255);
137 scp
->sc_monster
= RN
;
138 scp
->sc_login
[0] = '\0';
141 signal(SIGINT
, SIG_DFL
);
142 if ((flags
!= -1) && (flags
!= 1))
144 mvaddstr(LINES
-1, 0, "[Press return to continue]");
147 get_str(prbuf
, stdscr
);
151 if (strcmp(prbuf
, "names") == 0)
153 else if (strcmp(prbuf
, "edit") == 0)
156 encread((char *) scoreline
, 100, fd
);
157 sscanf(scoreline
, "R%d %d\n", &rogue_ver
, &scorefile_ver
);
159 if ((rogue_ver
== 36) && (scorefile_ver
== 2))
160 for(i
= 0; i
< 10; i
++)
163 encread((char *) &top_ten
[i
].sc_name
, 80, fd
);
164 encread((char *) &top_ten
[i
].sc_login
, 8, fd
);
165 encread((char *) scoreline
, 100, fd
);
166 sscanf(scoreline
, " %d %d %d %d \n",
167 &top_ten
[i
].sc_score
, &top_ten
[i
].sc_flags
,
168 &top_ten
[i
].sc_level
, &monster
);
169 top_ten
[i
].sc_monster
= monster
;
173 * Insert her in list if need be
177 for (scp
= top_ten
; scp
<= &top_ten
[9]; scp
++)
178 if (amount
> scp
->sc_score
)
180 if (scp
<= &top_ten
[9])
182 for (sc2
= &top_ten
[9]; sc2
> scp
; sc2
--)
184 scp
->sc_score
= amount
;
185 strcpy(scp
->sc_name
, whoami
);
186 scp
->sc_flags
= flags
;
188 scp
->sc_level
= max_level
;
190 scp
->sc_level
= level
;
191 scp
->sc_monster
= monst
;
192 strncpy(scp
->sc_login
, md_getusername(), 8);
200 printf("Top Ten Adventurers:\nRank\tScore\tName\n");
201 for (scp
= top_ten
; scp
<= &top_ten
[9]; scp
++) {
203 printf("%ld\t%d\t%s: %s on level %d", scp
- top_ten
+ 1,
204 scp
->sc_score
, scp
->sc_name
, reason
[scp
->sc_flags
],
206 if (scp
->sc_flags
== 0) {
208 killer
= killname(scp
->sc_monster
);
209 if (*killer
== 'a' || *killer
== 'e' || *killer
== 'i' ||
210 *killer
== 'o' || *killer
== 'u')
212 printf(" %s", killer
);
216 printf(" (%s)", scp
->sc_login
);
219 else if (prflags
== 2)
222 fgets(prbuf
,80,stdin
);
225 for (sc2
= scp
; sc2
< &top_ten
[9]; sc2
++)
227 top_ten
[9].sc_score
= 0;
228 for (i
= 0; i
< 80; i
++)
229 top_ten
[9].sc_name
[i
] = rnd(255);
230 top_ten
[9].sc_flags
= RN
;
231 top_ten
[9].sc_level
= RN
;
232 top_ten
[9].sc_monster
= RN
;
236 else if (prflags
>= 3)
239 killer
= killname(scp
->sc_monster
);
240 if (*killer
== 'a' || *killer
== 'e' || *killer
== 'i' ||
241 *killer
== 'o' || *killer
== 'u')
243 printf(" %s", killer
);
251 * Update the list file
253 strcpy(scoreline
, "R36 2\n");
254 encwrite(scoreline
, 100, outf
);
255 for(i
= 0; i
< 10; i
++)
257 encwrite((char *) &top_ten
[i
].sc_name
, 80, outf
);
258 encwrite((char *) &top_ten
[i
].sc_login
, 8, outf
);
259 sprintf(scoreline
, " %d %d %d %d \n",
260 top_ten
[i
].sc_score
, top_ten
[i
].sc_flags
,
261 top_ten
[i
].sc_level
, top_ten
[i
].sc_monster
);
262 encwrite((char *) scoreline
, 100, outf
);
273 addstr(" You escaped from the caverns, but alone. \n");
275 addstr("\nYou have joined the elite ranks of those who have escaped the\n");
276 addstr("Cavern of Cuties alive, but failed to meet anyone while there.\n");
277 addstr("You journey home and sell all your loot at a great profit and\n");
278 addstr("continue your life alone.\n");
279 total_something(2, 0);
282 total_winner(monster
)
288 addstr(" You got the amulet and a hot date. \n");
290 total_something(4, monster
);
293 mostly_winner(monster
)
299 addstr(" You got a hot date. \n");
301 total_something(3, monster
);
304 total_something(flags
, monster
)
308 register struct linked_list
*item
;
309 register struct object
*obj
;
312 register int oldpurse
;
314 mvaddstr(LINES
- 1, 0, "--Press space to continue--");
318 mvaddstr(0, 0, " Worth Item");
320 for (c
= 'a', item
= pack
; item
!= NULL
; c
++, item
= next(item
))
322 obj
= (struct object
*) ldata(item
);
326 worth
= 2 * obj
->o_count
;
328 switch (obj
->o_which
)
330 case MACE
: worth
= 8;
331 when SWORD
: worth
= 15;
332 when BOW
: worth
= 75;
333 when ARROW
: worth
= 1;
334 when DAGGER
: worth
= 2;
335 when ROCK
: worth
= 1;
336 when TWOSWORD
: worth
= 30;
337 when SLING
: worth
= 1;
338 when DART
: worth
= 1;
339 when CROSSBOW
: worth
= 15;
340 when BOLT
: worth
= 1;
341 when SPEAR
: worth
= 2;
342 otherwise
: worth
= 0;
344 worth
*= (1 + (10 * obj
->o_hplus
+ 10 * obj
->o_dplus
));
345 worth
*= obj
->o_count
;
346 obj
->o_flags
|= ISKNOW
;
348 switch (obj
->o_which
)
350 case LEATHER
: worth
= 5;
351 when RING_MAIL
: worth
= 30;
352 when STUDDED_LEATHER
: worth
= 15;
353 when SCALE_MAIL
: worth
= 3;
354 when CHAIN_MAIL
: worth
= 75;
355 when SPLINT_MAIL
: worth
= 80;
356 when BANDED_MAIL
: worth
= 90;
357 when PLATE_MAIL
: worth
= 400;
358 otherwise
: worth
= 0;
360 worth
*= (1 + (10 * (a_class
[obj
->o_which
] - obj
->o_ac
)));
361 obj
->o_flags
|= ISKNOW
;
363 s_know
[obj
->o_which
] = TRUE
;
364 worth
= s_magic
[obj
->o_which
].mi_worth
;
365 worth
*= obj
->o_count
;
367 p_know
[obj
->o_which
] = TRUE
;
368 worth
= p_magic
[obj
->o_which
].mi_worth
;
369 worth
*= obj
->o_count
;
371 obj
->o_flags
|= ISKNOW
;
372 r_know
[obj
->o_which
] = TRUE
;
373 worth
= r_magic
[obj
->o_which
].mi_worth
;
374 if (obj
->o_which
== R_ADDSTR
|| obj
->o_which
== R_ADDDAM
||
375 obj
->o_which
== R_PROTECT
|| obj
->o_which
== R_ADDHIT
)
377 worth
+= obj
->o_ac
* 20;
381 obj
->o_flags
|= ISKNOW
;
382 ws_know
[obj
->o_which
] = TRUE
;
383 worth
= ws_magic
[obj
->o_which
].mi_worth
;
384 worth
+= 20 * obj
->o_charges
;
388 mvprintw(c
- 'a' + 1, 0, "%c) %5d %s", c
, worth
, inv_name(obj
, FALSE
));
391 mvprintw(c
- 'a' + 1, 0," %5d Gold Peices ", oldpurse
);
393 score(purse
, flags
, monster
);
404 return monsters
[monst
-'A'].m_name
;