]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.makemon.c
1 /* $NetBSD: hack.makemon.c,v 1.4 1997/10/19 16:58:17 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.makemon.c,v 1.4 1997/10/19 16:58:17 christos Exp $");
15 struct monst zeromonst
;
18 * called with [x,y] = coordinates;
19 * [0,0] means anyplace
20 * [u.ux,u.uy] means: call mnexto (if !in_mklev)
22 * In case we make an Orc or killer bee, we make an entire horde (swarm);
23 * note that in this case we return only one of them (the one at [x,y]).
31 boolean anything
= (!ptr
);
35 return ((struct monst
*) 0);
37 if (strchr(fut_geno
, ptr
->mlet
))
38 return ((struct monst
*) 0);
40 ct
= CMNUM
- strlen(fut_geno
);
41 if (strchr(fut_geno
, 'm'))
42 ct
++; /* make only 1 minotaur */
43 if (strchr(fut_geno
, '@'))
46 return (0); /* no more monsters! */
47 tmp
= rn2(ct
* dlevel
/ 24 + 7);
49 tmp
= rn2(ct
* dlevel
/ 24 + 12);
51 tmp
= rn1(ct
- ct
/ 2, ct
/ 2);
52 for (ct
= 0; ct
< CMNUM
; ct
++) {
54 if (strchr(fut_geno
, ptr
->mlet
))
62 mtmp
= newmonst(ptr
->pxlth
);
63 *mtmp
= zeromonst
; /* clear all entries in structure */
64 for (ct
= 0; ct
< ptr
->pxlth
; ct
++)
65 ((char *) &(mtmp
->mextra
[0]))[ct
] = 0;
68 mtmp
->m_id
= flags
.ident
++;
70 mtmp
->mxlth
= ptr
->pxlth
;
72 mtmp
->mhpmax
= mtmp
->mhp
= 80;
73 else if (!ptr
->mlevel
)
74 mtmp
->mhpmax
= mtmp
->mhp
= rnd(4);
76 mtmp
->mhpmax
= mtmp
->mhp
= d(ptr
->mlevel
, 8);
80 if (ptr
->mlet
== 'M') {
82 mtmp
->mappearance
= ']';
85 if (x
== u
.ux
&& y
== u
.uy
&& ptr
->mlet
!= ' ')
90 if (ptr
->mlet
== 's' || ptr
->mlet
== 'S') {
91 mtmp
->mhide
= mtmp
->mundetected
= 1;
93 if (mtmp
->mx
&& mtmp
->my
)
94 (void) mkobj_at(0, mtmp
->mx
, mtmp
->my
);
96 if (ptr
->mlet
== ':') {
98 (void) newcham(mtmp
, &mons
[dlevel
+ 14 + rn2(CMNUM
- 14 - dlevel
)]);
100 if (ptr
->mlet
== 'I' || ptr
->mlet
== ';')
102 if (ptr
->mlet
== 'L' || ptr
->mlet
== 'N'
103 || (in_mklev
&& strchr("&w;", ptr
->mlet
) && rn2(5))
108 if (ptr
->mlet
== 'w' && getwn(mtmp
))
113 if (ptr
->mlet
== 'O' || ptr
->mlet
== 'k') {
119 mm
= enexto(mm
.x
, mm
.y
);
120 (void) makemon(ptr
, mm
.x
, mm
.y
);
131 coord foo
[15], *tfoo
;
136 do { /* full kludge action. */
137 for (x
= xx
- range
; x
<= xx
+ range
; x
++)
138 if (goodpos(x
, yy
- range
)) {
140 tfoo
++->y
= yy
- range
;
141 if (tfoo
== &foo
[15])
144 for (x
= xx
- range
; x
<= xx
+ range
; x
++)
145 if (goodpos(x
, yy
+ range
)) {
147 tfoo
++->y
= yy
+ range
;
148 if (tfoo
== &foo
[15])
151 for (y
= yy
+ 1 - range
; y
< yy
+ range
; y
++)
152 if (goodpos(xx
- range
, y
)) {
153 tfoo
->x
= xx
- range
;
155 if (tfoo
== &foo
[15])
158 for (y
= yy
+ 1 - range
; y
< yy
+ range
; y
++)
159 if (goodpos(xx
+ range
, y
)) {
160 tfoo
->x
= xx
+ range
;
162 if (tfoo
== &foo
[15])
166 } while (tfoo
== foo
);
168 return (foo
[rn2(tfoo
- foo
)]);
173 { /* used only in mnexto and rloc */
175 !(x
< 1 || x
> COLNO
- 2 || y
< 1 || y
> ROWNO
- 2 ||
176 m_at(x
, y
) || !ACCESSIBLE(levl
[x
][y
].typ
)
177 || (x
== u
.ux
&& y
== u
.uy
)
178 || sobj_at(ENORMOUS_ROCK
, x
, y
)
187 char ch
= mtmp
->data
->mlet
;
190 if (ch
== 'w' && mtmp
->mx
)
191 return; /* do not relocate worms */
194 tx
= rn1(COLNO
- 3, 2);
196 } while (!goodpos(tx
, ty
));
199 if (u
.ustuck
== mtmp
) {
216 struct permonst
*ptr
;
218 for (ct
= 0; ct
< CMNUM
; ct
++) {
220 if (ptr
->mlet
== let
)
221 return (makemon(ptr
, x
, y
));