]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.bones.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$NetBSD: hack.bones.c,v 1.3 1995/03/23 08:29:48 cgd Exp $";
10 extern char plname
[PL_NSIZ
];
11 extern long somegold();
12 extern struct monst
*makemon();
13 extern struct permonst pm_ghost
;
15 char bones
[] = "bones_xx";
17 /* save bones and possessions of a deceased adventurer */
20 register struct obj
*otmp
;
21 register struct trap
*ttmp
;
22 register struct monst
*mtmp
;
23 if(dlevel
<= 0 || dlevel
> MAXLEVEL
) return;
24 if(!rn2(1 + dlevel
/2)) return; /* not so many ghosts on low levels */
25 bones
[6] = '0' + (dlevel
/10);
26 bones
[7] = '0' + (dlevel%10
);
27 if((fd
= open(bones
,0)) >= 0){
31 /* drop everything; the corpse's possessions are usually cursed */
36 otmp
->age
= 0; /* very long ago */
38 if(rn2(5)) otmp
->cursed
= 1;
42 invent
= 0; /* superfluous */
47 if(!(mtmp
= makemon(PM_GHOST
, u
.ux
, u
.uy
))) return;
51 (void) strcpy((char *) mtmp
->mextra
, plname
);
52 mkgold(somegold() + d(dlevel
,30), u
.ux
, u
.uy
);
53 for(mtmp
= fmon
; mtmp
; mtmp
= mtmp
->nmon
){
60 if(mtmp
->mdispl
) unpmon(mtmp
);
62 for(ttmp
= ftrap
; ttmp
; ttmp
= ttmp
->ntrap
)
64 for(otmp
= fobj
; otmp
; otmp
= otmp
->nobj
) {
66 /* otmp->o_cnt_id = 0; - superfluous */
70 if(otmp
->olet
== AMULET_SYM
&& !otmp
->spe
) {
71 otmp
->spe
= -1; /* no longer the actual amulet */
72 otmp
->cursed
= 1; /* flag as gotten from a ghost */
75 if((fd
= creat(bones
, FMASK
)) < 0) return;
82 if(rn2(3)) return(0); /* only once in three times do we find bones */
83 bones
[6] = '0' + dlevel
/10;
84 bones
[7] = '0' + dlevel%10
;
85 if((fd
= open(bones
, 0)) < 0) return(0);
86 if((ok
= uptodate(fd
)) != 0){
87 getlev(fd
, 0, dlevel
);
88 for(x
= 0; x
< COLNO
; x
++) for(y
= 0; y
< ROWNO
; y
++)
89 levl
[x
][y
].seen
= levl
[x
][y
].new = 0;
93 if(!wizard
) /* duvel!frans: don't remove bones while debugging */
95 if(unlink(bones
) < 0){
96 pline("Cannot unlink %s .", bones
);