1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2: /* hack.bones.c - version 1.0.3 */
3:
4: #include "hack.h"
5: extern char plname[PL_NSIZ];
6: extern long somegold();
7: extern struct monst *makemon();
8: extern struct permonst pm_ghost;
9:
10: char bones[] = "bones_xx";
11:
12: /* save bones and possessions of a deceased adventurer */
13: savebones(){
14: register fd;
15: register struct obj *otmp;
16: register struct trap *ttmp;
17: register struct monst *mtmp;
18: if(dlevel <= 0 || dlevel > MAXLEVEL) return;
19: if(!rn2(1 + dlevel/2)) return; /* not so many ghosts on low levels */
20: bones[6] = '0' + (dlevel/10);
21: bones[7] = '0' + (dlevel%10);
22: if((fd = open(bones,0)) >= 0){
23: (void) close(fd);
24: return;
25: }
26: /* drop everything; the corpse's possessions are usually cursed */
27: otmp = invent;
28: while(otmp){
29: otmp->ox = u.ux;
30: otmp->oy = u.uy;
31: otmp->age = 0; /* very long ago */
32: otmp->owornmask = 0;
33: if(rn2(5)) otmp->cursed = 1;
34: if(!otmp->nobj){
35: otmp->nobj = fobj;
36: fobj = invent;
37: invent = 0; /* superfluous */
38: break;
39: }
40: otmp = otmp->nobj;
41: }
42: if(!(mtmp = makemon(PM_GHOST, u.ux, u.uy))) return;
43: mtmp->mx = u.ux;
44: mtmp->my = u.uy;
45: mtmp->msleep = 1;
46: (void) strcpy((char *) mtmp->mextra, plname);
47: mkgold(somegold() + d(dlevel,30), u.ux, u.uy);
48: for(mtmp = fmon; mtmp; mtmp = mtmp->nmon){
49: mtmp->m_id = 0;
50: if(mtmp->mtame) {
51: mtmp->mtame = 0;
52: mtmp->mpeaceful = 0;
53: }
54: mtmp->mlstmv = 0;
55: if(mtmp->mdispl) unpmon(mtmp);
56: }
57: for(ttmp = ftrap; ttmp; ttmp = ttmp->ntrap)
58: ttmp->tseen = 0;
59: for(otmp = fobj; otmp; otmp = otmp->nobj) {
60: otmp->o_id = 0;
61: /* otmp->o_cnt_id = 0; - superfluous */
62: otmp->onamelth = 0;
63: otmp->known = 0;
64: otmp->invlet = 0;
65: if(otmp->olet == AMULET_SYM && !otmp->spe) {
66: otmp->spe = -1; /* no longer the actual amulet */
67: otmp->cursed = 1; /* flag as gotten from a ghost */
68: }
69: }
70: if((fd = creat(bones, FMASK)) < 0) return;
71: savelev(fd,dlevel);
72: (void) close(fd);
73: }
74:
75: getbones(){
76: register fd,x,y,ok;
77: if(rn2(3)) return(0); /* only once in three times do we find bones */
78: bones[6] = '0' + dlevel/10;
79: bones[7] = '0' + dlevel%10;
80: if((fd = open(bones, 0)) < 0) return(0);
81: if((ok = uptodate(fd)) != 0){
82: getlev(fd, 0, dlevel);
83: for(x = 0; x < COLNO; x++) for(y = 0; y < ROWNO; y++)
84: levl[x][y].seen = levl[x][y].new = 0;
85: }
86: (void) close(fd);
87: #ifdef WIZARD
88: if(!wizard) /* duvel!frans: don't remove bones while debugging */
89: #endif WiZARD
90: if(unlink(bones) < 0){
91: pline("Cannot unlink %s .", bones);
92: return(0);
93: }
94: return(ok);
95: }
Defined functions
Defined variables
bones
defined in line
10; used 9 times