]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.makemon.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$NetBSD: hack.makemon.c,v 1.3 1995/03/23 08:30:38 cgd Exp $";
10 extern char fut_geno
[];
12 extern struct obj
*mkobj_at();
13 struct monst zeromonst
;
16 * called with [x,y] = coordinates;
17 * [0,0] means anyplace
18 * [u.ux,u.uy] means: call mnexto (if !in_mklev)
20 * In case we make an Orc or killer bee, we make an entire horde (swarm);
21 * note that in this case we return only one of them (the one at [x,y]).
25 register struct permonst
*ptr
;
27 register struct monst
*mtmp
;
29 boolean anything
= (!ptr
);
30 extern boolean in_mklev
;
32 if(x
!= 0 || y
!= 0) if(m_at(x
,y
)) return((struct monst
*) 0);
34 if(index(fut_geno
, ptr
->mlet
)) return((struct monst
*) 0);
36 ct
= CMNUM
- strlen(fut_geno
);
37 if(index(fut_geno
, 'm')) ct
++; /* make only 1 minotaur */
38 if(index(fut_geno
, '@')) ct
++;
39 if(ct
<= 0) return(0); /* no more monsters! */
40 tmp
= rn2(ct
*dlevel
/24 + 7);
41 if(tmp
< dlevel
- 4) tmp
= rn2(ct
*dlevel
/24 + 12);
42 if(tmp
>= ct
) tmp
= rn1(ct
- ct
/2, ct
/2);
43 for(ct
= 0; ct
< CMNUM
; ct
++){
45 if(index(fut_geno
, ptr
->mlet
))
47 if(!tmp
--) goto gotmon
;
52 mtmp
= newmonst(ptr
->pxlth
);
53 *mtmp
= zeromonst
; /* clear all entries in structure */
54 for(ct
= 0; ct
< ptr
->pxlth
; ct
++)
55 ((char *) &(mtmp
->mextra
[0]))[ct
] = 0;
58 mtmp
->m_id
= flags
.ident
++;
60 mtmp
->mxlth
= ptr
->pxlth
;
61 if(ptr
->mlet
== 'D') mtmp
->mhpmax
= mtmp
->mhp
= 80;
62 else if(!ptr
->mlevel
) mtmp
->mhpmax
= mtmp
->mhp
= rnd(4);
63 else mtmp
->mhpmax
= mtmp
->mhp
= d(ptr
->mlevel
, 8);
69 mtmp
->mappearance
= ']';
72 if(x
== u
.ux
&& y
== u
.uy
&& ptr
->mlet
!= ' ')
77 if(ptr
->mlet
== 's' || ptr
->mlet
== 'S') {
78 mtmp
->mhide
= mtmp
->mundetected
= 1;
80 if(mtmp
->mx
&& mtmp
->my
)
81 (void) mkobj_at(0, mtmp
->mx
, mtmp
->my
);
83 if(ptr
->mlet
== ':') {
85 (void) newcham(mtmp
, &mons
[dlevel
+14+rn2(CMNUM
-14-dlevel
)]);
87 if(ptr
->mlet
== 'I' || ptr
->mlet
== ';')
89 if(ptr
->mlet
== 'L' || ptr
->mlet
== 'N'
90 || (in_mklev
&& index("&w;", ptr
->mlet
) && rn2(5))
94 if(ptr
->mlet
== 'w' && getwn(mtmp
))
98 if(anything
) if(ptr
->mlet
== 'O' || ptr
->mlet
== 'k') {
101 register int cnt
= rnd(10);
105 mm
= enexto(mm
.x
, mm
.y
);
106 (void) makemon(ptr
, mm
.x
, mm
.y
);
115 register xchar xx
,yy
;
118 coord foo
[15], *tfoo
;
123 do { /* full kludge action. */
124 for(x
= xx
-range
; x
<= xx
+range
; x
++)
125 if(goodpos(x
, yy
-range
)) {
127 tfoo
++->y
= yy
-range
;
128 if(tfoo
== &foo
[15]) goto foofull
;
130 for(x
= xx
-range
; x
<= xx
+range
; x
++)
131 if(goodpos(x
,yy
+range
)) {
133 tfoo
++->y
= yy
+range
;
134 if(tfoo
== &foo
[15]) goto foofull
;
136 for(y
= yy
+1-range
; y
< yy
+range
; y
++)
137 if(goodpos(xx
-range
,y
)) {
140 if(tfoo
== &foo
[15]) goto foofull
;
142 for(y
= yy
+1-range
; y
< yy
+range
; y
++)
143 if(goodpos(xx
+range
,y
)) {
146 if(tfoo
== &foo
[15]) goto foofull
;
149 } while(tfoo
== foo
);
151 return( foo
[rn2(tfoo
-foo
)] );
154 goodpos(x
,y
) /* used only in mnexto and rloc */
157 ! (x
< 1 || x
> COLNO
-2 || y
< 1 || y
> ROWNO
-2 ||
158 m_at(x
,y
) || !ACCESSIBLE(levl
[x
][y
].typ
)
159 || (x
== u
.ux
&& y
== u
.uy
)
160 || sobj_at(ENORMOUS_ROCK
, x
, y
)
168 register char ch
= mtmp
->data
->mlet
;
171 if(ch
== 'w' && mtmp
->mx
) return; /* do not relocate worms */
176 } while(!goodpos(tx
,ty
));
179 if(u
.ustuck
== mtmp
){
195 register struct permonst
*ptr
;
197 for(ct
= 0; ct
< CMNUM
; ct
++) {
200 return(makemon(ptr
,x
,y
));