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
);
78 * score -- figure score and post it.
82 score(amount
, flags
, monst
)
85 static struct sc_ent
{
93 register struct sc_ent
*scp
;
95 register struct sc_ent
*sc2
;
97 register char *killer
;
98 register int prflags
= 0;
100 static char *reason
[] = {
106 char score_file
[PATH_MAX
];
107 int rogue_ver
= 0, scorefile_ver
= 0;
110 * Open file and read list
113 /* Get default score file */
114 strcpy(score_file
, md_getroguedir());
117 strcat(score_file
,"\\");
119 strcat(score_file
, "rogue36.scr");
121 if ((fd
= open(score_file
, O_RDWR
| O_CREAT
, 0666 )) < 0)
124 outf
= (FILE *) fdopen(fd
, "w");
126 for (scp
= top_ten
; scp
<= &top_ten
[9]; scp
++)
129 for (i
= 0; i
< 80; i
++)
130 scp
->sc_name
[i
] = rnd(255);
133 scp
->sc_monster
= RN
;
134 scp
->sc_login
[0] = '\0';
137 signal(SIGINT
, SIG_DFL
);
138 if ((flags
!= -1) && (flags
!= 1))
140 mvaddstr(LINES
-1, 0, "[Press return to continue]");
143 get_str(prbuf
, stdscr
);
147 if (strcmp(prbuf
, "names") == 0)
149 else if (strcmp(prbuf
, "edit") == 0)
152 encread((char *) scoreline
, 100, fd
);
153 sscanf(scoreline
, "R%d %d\n", &rogue_ver
, &scorefile_ver
);
155 if ((rogue_ver
== 36) && (scorefile_ver
== 2))
156 for(i
= 0; i
< 10; i
++)
158 encread((char *) &top_ten
[i
].sc_name
, 80, fd
);
159 encread((char *) &top_ten
[i
].sc_login
, 8, fd
);
160 encread((char *) scoreline
, 100, fd
);
161 sscanf(scoreline
, " %d %d %d %d \n",
162 &top_ten
[i
].sc_score
, &top_ten
[i
].sc_flags
,
163 &top_ten
[i
].sc_level
, &top_ten
[i
].sc_monster
);
167 * Insert her in list if need be
171 for (scp
= top_ten
; scp
<= &top_ten
[9]; scp
++)
172 if (amount
> scp
->sc_score
)
174 if (scp
<= &top_ten
[9])
176 for (sc2
= &top_ten
[9]; sc2
> scp
; sc2
--)
178 scp
->sc_score
= amount
;
179 strcpy(scp
->sc_name
, whoami
);
180 scp
->sc_flags
= flags
;
182 scp
->sc_level
= max_level
;
184 scp
->sc_level
= level
;
185 scp
->sc_monster
= monst
;
186 strncpy(scp
->sc_login
, md_getusername(), 8);
194 printf("Top Ten Adventurers:\nRank\tScore\tName\n");
195 for (scp
= top_ten
; scp
<= &top_ten
[9]; scp
++) {
197 printf("%d\t%d\t%s: %s on level %d", scp
- top_ten
+ 1,
198 scp
->sc_score
, scp
->sc_name
, reason
[scp
->sc_flags
],
200 if (scp
->sc_flags
== 0) {
202 killer
= killname(scp
->sc_monster
);
203 if (*killer
== 'a' || *killer
== 'e' || *killer
== 'i' ||
204 *killer
== 'o' || *killer
== 'u')
206 printf(" %s", killer
);
210 printf(" (%s)", scp
->sc_login
);
213 else if (prflags
== 2)
216 fgets(prbuf
,80,stdin
);
219 for (sc2
= scp
; sc2
< &top_ten
[9]; sc2
++)
221 top_ten
[9].sc_score
= 0;
222 for (i
= 0; i
< 80; i
++)
223 top_ten
[9].sc_name
[i
] = rnd(255);
224 top_ten
[9].sc_flags
= RN
;
225 top_ten
[9].sc_level
= RN
;
226 top_ten
[9].sc_monster
= RN
;
236 * Update the list file
238 strcpy(scoreline
, "R36 2\n");
239 encwrite(scoreline
, 100, outf
);
240 for(i
= 0; i
< 10; i
++)
242 encwrite((char *) &top_ten
[i
].sc_name
, 80, outf
);
243 encwrite((char *) &top_ten
[i
].sc_login
, 8, outf
);
244 sprintf(scoreline
, " %d %d %d %d \n",
245 top_ten
[i
].sc_score
, top_ten
[i
].sc_flags
,
246 top_ten
[i
].sc_level
, top_ten
[i
].sc_monster
);
247 encwrite((char *) scoreline
, 100, outf
);
254 register struct linked_list
*item
;
255 register struct object
*obj
;
258 register int oldpurse
;
263 addstr(" @ @ @ @ @ @@@ @ @ \n");
264 addstr(" @ @ @@ @@ @ @ @ @ \n");
265 addstr(" @ @ @@@ @ @ @ @ @ @@@ @@@@ @@@ @ @@@ @ \n");
266 addstr(" @@@@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ \n");
267 addstr(" @ @ @ @ @ @ @ @@@@ @ @ @@@@@ @ @ @ \n");
268 addstr(" @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @ \n");
269 addstr(" @@@ @@@ @@ @ @ @ @@@@ @@@@ @@@ @@@ @@ @ \n");
271 addstr(" Congratulations, you have made it to the light of day! \n");
273 addstr("\nYou have joined the elite ranks of those who have escaped the\n");
274 addstr("Dungeons of Doom alive. You journey home and sell all your loot at\n");
275 addstr("a great profit and are admitted to the fighters guild.\n");
276 mvaddstr(LINES
- 1, 0, "--Press space to continue--");
280 mvaddstr(0, 0, " Worth Item");
282 for (c
= 'a', item
= pack
; item
!= NULL
; c
++, item
= next(item
))
284 obj
= (struct object
*) ldata(item
);
288 worth
= 2 * obj
->o_count
;
290 switch (obj
->o_which
)
292 case MACE
: worth
= 8;
293 when SWORD
: worth
= 15;
294 when BOW
: worth
= 75;
295 when ARROW
: worth
= 1;
296 when DAGGER
: worth
= 2;
297 when ROCK
: worth
= 1;
298 when TWOSWORD
: worth
= 30;
299 when SLING
: worth
= 1;
300 when DART
: worth
= 1;
301 when CROSSBOW
: worth
= 15;
302 when BOLT
: worth
= 1;
303 when SPEAR
: worth
= 2;
304 otherwise
: worth
= 0;
306 worth
*= (1 + (10 * obj
->o_hplus
+ 10 * obj
->o_dplus
));
307 worth
*= obj
->o_count
;
308 obj
->o_flags
|= ISKNOW
;
310 switch (obj
->o_which
)
312 case LEATHER
: worth
= 5;
313 when RING_MAIL
: worth
= 30;
314 when STUDDED_LEATHER
: worth
= 15;
315 when SCALE_MAIL
: worth
= 3;
316 when CHAIN_MAIL
: worth
= 75;
317 when SPLINT_MAIL
: worth
= 80;
318 when BANDED_MAIL
: worth
= 90;
319 when PLATE_MAIL
: worth
= 400;
320 otherwise
: worth
= 0;
322 worth
*= (1 + (10 * (a_class
[obj
->o_which
] - obj
->o_ac
)));
323 obj
->o_flags
|= ISKNOW
;
325 s_know
[obj
->o_which
] = TRUE
;
326 worth
= s_magic
[obj
->o_which
].mi_worth
;
327 worth
*= obj
->o_count
;
329 p_know
[obj
->o_which
] = TRUE
;
330 worth
= p_magic
[obj
->o_which
].mi_worth
;
331 worth
*= obj
->o_count
;
333 obj
->o_flags
|= ISKNOW
;
334 r_know
[obj
->o_which
] = TRUE
;
335 worth
= r_magic
[obj
->o_which
].mi_worth
;
336 if (obj
->o_which
== R_ADDSTR
|| obj
->o_which
== R_ADDDAM
||
337 obj
->o_which
== R_PROTECT
|| obj
->o_which
== R_ADDHIT
)
339 worth
+= obj
->o_ac
* 20;
343 obj
->o_flags
|= ISKNOW
;
344 ws_know
[obj
->o_which
] = TRUE
;
345 worth
= ws_magic
[obj
->o_which
].mi_worth
;
346 worth
+= 20 * obj
->o_charges
;
350 mvprintw(c
- 'a' + 1, 0, "%c) %5d %s", c
, worth
, inv_name(obj
, FALSE
));
353 mvprintw(c
- 'a' + 1, 0," %5d Gold Peices ", oldpurse
);
364 return monsters
[monst
-'A'].m_name
;