]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.worm.c
1 /* $NetBSD: hack.worm.c,v 1.4 1997/10/19 16:59:30 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.worm.c,v 1.4 1997/10/19 16:59:30 christos Exp $");
18 struct wseg
*wsegs
[32]; /* linked list, tail first */
19 struct wseg
*wheads
[32];
27 for (tmp
= 1; tmp
< 32; tmp
++)
32 return (0); /* level infested with worms */
35 /* called to initialize a worm unless cut in half */
41 int tmp
= mtmp
->wormno
;
44 wheads
[tmp
] = wsegs
[tmp
] = wtmp
= newseg();
48 /* wtmp->wdispl = 0; */
56 struct wseg
*wtmp
, *whd
= NULL
;
57 int tmp
= mtmp
->wormno
;
62 /* wtmp->wdispl = 0; */
63 (whd
= wheads
[tmp
])->nseg
= wtmp
;
65 if (cansee(whd
->wx
, whd
->wy
)) {
67 atl(whd
->wx
, whd
->wy
, '~');
71 if (wgrowtime
[tmp
] <= moves
) {
73 wgrowtime
[tmp
] = moves
+ rnd(5);
75 wgrowtime
[tmp
] += 2 + rnd(15);
81 wsegs
[tmp
] = whd
->nseg
;
93 if (wtmp
== wheads
[tmp
])
95 if (wtmp
== 0 || wtmp
->nseg
== 0)
96 panic("worm_nomove?");
97 wsegs
[tmp
] = wtmp
->nseg
;
99 mtmp
->mhp
-= 3; /* mhpmax not changed ! */
106 int tmp
= mtmp
->wormno
;
107 struct wseg
*wtmp
, *wtmp2
;
111 for (wtmp
= wsegs
[tmp
]; wtmp
; wtmp
= wtmp2
) {
122 int tmp
= mtmp
->wormno
;
125 return; /* worm without tail */
126 for (wtmp
= wsegs
[tmp
]; wtmp
; wtmp
= wtmp
->nseg
)
127 (void) hitu(mtmp
, 1);
134 struct wseg
*wtmp
= wsegs
[tmp
];
136 panic("wormsee: wtmp==0");
137 for (; wtmp
->nseg
; wtmp
= wtmp
->nseg
)
138 if (!cansee(wtmp
->wx
, wtmp
->wy
) && wtmp
->wdispl
) {
139 newsym(wtmp
->wx
, wtmp
->wy
);
149 atl(wtmp
->wx
, wtmp
->wy
, '~');
155 cutworm(mtmp
, x
, y
, weptyp
)
158 uchar weptyp
; /* uwep->otyp or 0 */
160 struct wseg
*wtmp
, *wtmp2
;
163 if (mtmp
->mx
== x
&& mtmp
->my
== y
)
164 return; /* hit headon */
166 /* cutting goes best with axe or sword */
168 if (weptyp
== LONG_SWORD
|| weptyp
== TWO_HANDED_SWORD
||
174 /* if tail then worm just loses a tail segment */
177 if (wtmp
->wx
== x
&& wtmp
->wy
== y
) {
178 wsegs
[tmp
] = wtmp
->nseg
;
182 /* cut the worm in two halves */
185 mtmp2
->mxlth
= mtmp2
->mnamelth
= 0;
187 /* sometimes the tail end dies */
188 if (rn2(3) || !getwn(mtmp2
)) {
192 tmp2
= mtmp2
->wormno
;
193 wsegs
[tmp2
] = wsegs
[tmp
];
197 if (wtmp
->nseg
->wx
== x
&& wtmp
->nseg
->wy
== y
) {
200 wsegs
[tmp
] = wtmp
->nseg
->nseg
;
204 pline("You cut the worm in half.");
205 mtmp2
->mhpmax
= mtmp2
->mhp
=
206 d(mtmp2
->data
->mlevel
, 8);
207 mtmp2
->mx
= wtmp
->wx
;
208 mtmp2
->my
= wtmp
->wy
;
213 pline("You cut off part of the worm's tail.");
223 } while (wtmp
->nseg
);
224 panic("Cannot find worm segment");
232 newsym(wtmp
->wx
, wtmp
->wy
);