hack.apply.c revision 1.7 1 1.7 jsm /* $NetBSD: hack.apply.c,v 1.7 2003/04/02 18:36:35 jsm Exp $ */
2 1.5 christos
3 1.3 mycroft /*
4 1.7 jsm * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
5 1.7 jsm * Amsterdam
6 1.7 jsm * All rights reserved.
7 1.7 jsm *
8 1.7 jsm * Redistribution and use in source and binary forms, with or without
9 1.7 jsm * modification, are permitted provided that the following conditions are
10 1.7 jsm * met:
11 1.7 jsm *
12 1.7 jsm * - Redistributions of source code must retain the above copyright notice,
13 1.7 jsm * this list of conditions and the following disclaimer.
14 1.7 jsm *
15 1.7 jsm * - Redistributions in binary form must reproduce the above copyright
16 1.7 jsm * notice, this list of conditions and the following disclaimer in the
17 1.7 jsm * documentation and/or other materials provided with the distribution.
18 1.7 jsm *
19 1.7 jsm * - Neither the name of the Stichting Centrum voor Wiskunde en
20 1.7 jsm * Informatica, nor the names of its contributors may be used to endorse or
21 1.7 jsm * promote products derived from this software without specific prior
22 1.7 jsm * written permission.
23 1.7 jsm *
24 1.7 jsm * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
25 1.7 jsm * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 1.7 jsm * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27 1.7 jsm * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
28 1.7 jsm * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 1.7 jsm * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 1.7 jsm * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 1.7 jsm * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 1.7 jsm * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 1.7 jsm * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 1.7 jsm * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 1.7 jsm */
36 1.7 jsm
37 1.7 jsm /*
38 1.7 jsm * Copyright (c) 1982 Jay Fenlason <hack (at) gnu.org>
39 1.7 jsm * All rights reserved.
40 1.7 jsm *
41 1.7 jsm * Redistribution and use in source and binary forms, with or without
42 1.7 jsm * modification, are permitted provided that the following conditions
43 1.7 jsm * are met:
44 1.7 jsm * 1. Redistributions of source code must retain the above copyright
45 1.7 jsm * notice, this list of conditions and the following disclaimer.
46 1.7 jsm * 2. Redistributions in binary form must reproduce the above copyright
47 1.7 jsm * notice, this list of conditions and the following disclaimer in the
48 1.7 jsm * documentation and/or other materials provided with the distribution.
49 1.7 jsm * 3. The name of the author may not be used to endorse or promote products
50 1.7 jsm * derived from this software without specific prior written permission.
51 1.7 jsm *
52 1.7 jsm * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
53 1.7 jsm * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
54 1.7 jsm * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
55 1.7 jsm * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56 1.7 jsm * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57 1.7 jsm * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
58 1.7 jsm * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
59 1.7 jsm * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
60 1.7 jsm * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
61 1.7 jsm * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 1.3 mycroft */
63 1.3 mycroft
64 1.5 christos #include <sys/cdefs.h>
65 1.3 mycroft #ifndef lint
66 1.7 jsm __RCSID("$NetBSD: hack.apply.c,v 1.7 2003/04/02 18:36:35 jsm Exp $");
67 1.5 christos #endif /* not lint */
68 1.1 cgd
69 1.1 cgd #include "hack.h"
70 1.5 christos #include "extern.h"
71 1.1 cgd #include "def.edog.h"
72 1.1 cgd #include "def.mkroom.h"
73 1.5 christos
74 1.5 christos static void use_camera __P((struct obj *));
75 1.5 christos static int in_ice_box __P((struct obj *));
76 1.5 christos static int ck_ice_box __P((struct obj *));
77 1.5 christos static int out_ice_box __P((struct obj *));
78 1.5 christos static void use_ice_box __P((struct obj *));
79 1.5 christos static struct monst *bchit __P((int, int , int , int));
80 1.5 christos static void use_whistle __P((struct obj *));
81 1.5 christos static void use_magic_whistle __P((struct obj *));
82 1.5 christos static int dig __P((void));
83 1.5 christos static int use_pick_axe __P((struct obj *));
84 1.5 christos
85 1.5 christos int
86 1.5 christos doapply()
87 1.5 christos {
88 1.5 christos struct obj *obj;
89 1.5 christos int res = 1;
90 1.1 cgd
91 1.1 cgd obj = getobj("(", "use or apply");
92 1.5 christos if (!obj)
93 1.5 christos return (0);
94 1.1 cgd
95 1.5 christos switch (obj->otyp) {
96 1.1 cgd case EXPENSIVE_CAMERA:
97 1.5 christos use_camera(obj);
98 1.5 christos break;
99 1.1 cgd case ICE_BOX:
100 1.5 christos use_ice_box(obj);
101 1.5 christos break;
102 1.1 cgd case PICK_AXE:
103 1.1 cgd res = use_pick_axe(obj);
104 1.1 cgd break;
105 1.1 cgd
106 1.1 cgd case MAGIC_WHISTLE:
107 1.5 christos if (pl_character[0] == 'W' || u.ulevel > 9) {
108 1.1 cgd use_magic_whistle(obj);
109 1.1 cgd break;
110 1.1 cgd }
111 1.1 cgd /* fall into next case */
112 1.1 cgd case WHISTLE:
113 1.1 cgd use_whistle(obj);
114 1.1 cgd break;
115 1.1 cgd
116 1.1 cgd case CAN_OPENER:
117 1.5 christos if (!carrying(TIN)) {
118 1.1 cgd pline("You have no can to open.");
119 1.1 cgd goto xit;
120 1.1 cgd }
121 1.1 cgd pline("You cannot open a tin without eating its contents.");
122 1.1 cgd pline("In order to eat, use the 'e' command.");
123 1.5 christos if (obj != uwep)
124 1.5 christos pline("Opening the tin will be much easier if you wield the can-opener.");
125 1.1 cgd goto xit;
126 1.1 cgd
127 1.1 cgd default:
128 1.1 cgd pline("Sorry, I don't know how to use that.");
129 1.5 christos xit:
130 1.1 cgd nomul(0);
131 1.5 christos return (0);
132 1.1 cgd }
133 1.1 cgd nomul(0);
134 1.5 christos return (res);
135 1.1 cgd }
136 1.1 cgd
137 1.1 cgd /* ARGSUSED */
138 1.1 cgd static void
139 1.5 christos use_camera(obj) /* */
140 1.6 jsm struct obj *obj __attribute__((__unused__));
141 1.5 christos {
142 1.5 christos struct monst *mtmp;
143 1.5 christos if (!getdir(1)) { /* ask: in what direction? */
144 1.1 cgd flags.move = multi = 0;
145 1.1 cgd return;
146 1.1 cgd }
147 1.5 christos if (u.uswallow) {
148 1.1 cgd pline("You take a picture of %s's stomach.", monnam(u.ustuck));
149 1.1 cgd return;
150 1.1 cgd }
151 1.5 christos if (u.dz) {
152 1.1 cgd pline("You take a picture of the %s.",
153 1.5 christos (u.dz > 0) ? "floor" : "ceiling");
154 1.1 cgd return;
155 1.1 cgd }
156 1.5 christos if ((mtmp = bchit(u.dx, u.dy, COLNO, '!')) != NULL) {
157 1.5 christos if (mtmp->msleep) {
158 1.1 cgd mtmp->msleep = 0;
159 1.5 christos pline("The flash awakens %s.", monnam(mtmp)); /* a3 */
160 1.5 christos } else if (mtmp->data->mlet != 'y')
161 1.5 christos if (mtmp->mcansee || mtmp->mblinded) {
162 1.5 christos int tmp = dist(mtmp->mx, mtmp->my);
163 1.5 christos int tmp2;
164 1.5 christos if (cansee(mtmp->mx, mtmp->my))
165 1.5 christos pline("%s is blinded by the flash!", Monnam(mtmp));
166 1.5 christos setmangry(mtmp);
167 1.5 christos if (tmp < 9 && !mtmp->isshk && rn2(4)) {
168 1.5 christos mtmp->mflee = 1;
169 1.5 christos if (rn2(4))
170 1.5 christos mtmp->mfleetim = rnd(100);
171 1.5 christos }
172 1.5 christos if (tmp < 3)
173 1.5 christos mtmp->mcansee = mtmp->mblinded = 0;
174 1.5 christos else {
175 1.5 christos tmp2 = mtmp->mblinded;
176 1.5 christos tmp2 += rnd(1 + 50 / tmp);
177 1.5 christos if (tmp2 > 127)
178 1.5 christos tmp2 = 127;
179 1.5 christos mtmp->mblinded = tmp2;
180 1.5 christos mtmp->mcansee = 0;
181 1.5 christos }
182 1.1 cgd }
183 1.1 cgd }
184 1.1 cgd }
185 1.1 cgd
186 1.1 cgd static
187 1.5 christos struct obj *current_ice_box;/* a local variable of use_ice_box, to be
188 1.5 christos * used by its local procedures in/ck_ice_box */
189 1.5 christos static int
190 1.5 christos in_ice_box(obj)
191 1.5 christos struct obj *obj;
192 1.5 christos {
193 1.5 christos if (obj == current_ice_box ||
194 1.5 christos (Punished && (obj == uball || obj == uchain))) {
195 1.1 cgd pline("You must be kidding.");
196 1.5 christos return (0);
197 1.1 cgd }
198 1.5 christos if (obj->owornmask & (W_ARMOR | W_RING)) {
199 1.1 cgd pline("You cannot refrigerate something you are wearing.");
200 1.5 christos return (0);
201 1.1 cgd }
202 1.5 christos if (obj->owt + current_ice_box->owt > 70) {
203 1.1 cgd pline("It won't fit.");
204 1.5 christos return (1); /* be careful! */
205 1.1 cgd }
206 1.5 christos if (obj == uwep) {
207 1.5 christos if (uwep->cursed) {
208 1.1 cgd pline("Your weapon is welded to your hand!");
209 1.5 christos return (0);
210 1.1 cgd }
211 1.1 cgd setuwep((struct obj *) 0);
212 1.1 cgd }
213 1.1 cgd current_ice_box->owt += obj->owt;
214 1.1 cgd freeinv(obj);
215 1.1 cgd obj->o_cnt_id = current_ice_box->o_id;
216 1.1 cgd obj->nobj = fcobj;
217 1.1 cgd fcobj = obj;
218 1.1 cgd obj->age = moves - obj->age; /* actual age */
219 1.5 christos return (1);
220 1.1 cgd }
221 1.1 cgd
222 1.5 christos static int
223 1.5 christos ck_ice_box(obj)
224 1.5 christos struct obj *obj;
225 1.5 christos {
226 1.5 christos return (obj->o_cnt_id == current_ice_box->o_id);
227 1.1 cgd }
228 1.1 cgd
229 1.5 christos static int
230 1.5 christos out_ice_box(obj)
231 1.5 christos struct obj *obj;
232 1.5 christos {
233 1.5 christos struct obj *otmp;
234 1.5 christos if (obj == fcobj)
235 1.5 christos fcobj = fcobj->nobj;
236 1.1 cgd else {
237 1.5 christos for (otmp = fcobj; otmp->nobj != obj; otmp = otmp->nobj)
238 1.5 christos if (!otmp->nobj)
239 1.5 christos panic("out_ice_box");
240 1.1 cgd otmp->nobj = obj->nobj;
241 1.1 cgd }
242 1.1 cgd current_ice_box->owt -= obj->owt;
243 1.1 cgd obj->age = moves - obj->age; /* simulated point of time */
244 1.1 cgd (void) addinv(obj);
245 1.5 christos return 0;
246 1.1 cgd }
247 1.1 cgd
248 1.1 cgd static void
249 1.5 christos use_ice_box(obj)
250 1.5 christos struct obj *obj;
251 1.5 christos {
252 1.5 christos int cnt = 0;
253 1.5 christos struct obj *otmp;
254 1.1 cgd current_ice_box = obj; /* for use by in/out_ice_box */
255 1.5 christos for (otmp = fcobj; otmp; otmp = otmp->nobj)
256 1.5 christos if (otmp->o_cnt_id == obj->o_id)
257 1.1 cgd cnt++;
258 1.5 christos if (!cnt)
259 1.5 christos pline("Your ice-box is empty.");
260 1.1 cgd else {
261 1.5 christos pline("Do you want to take something out of the ice-box? [yn] ");
262 1.5 christos if (readchar() == 'y')
263 1.5 christos if (askchain(fcobj, (char *) 0, 0, out_ice_box, ck_ice_box, 0))
264 1.5 christos return;
265 1.1 cgd pline("That was all. Do you wish to put something in? [yn] ");
266 1.5 christos if (readchar() != 'y')
267 1.5 christos return;
268 1.1 cgd }
269 1.1 cgd /* call getobj: 0: allow cnt; #: allow all types; %: expect food */
270 1.1 cgd otmp = getobj("0#%", "put in");
271 1.5 christos if (!otmp || !in_ice_box(otmp))
272 1.1 cgd flags.move = multi = 0;
273 1.1 cgd }
274 1.1 cgd
275 1.5 christos static struct monst *
276 1.5 christos bchit(ddx, ddy, range, sym)
277 1.5 christos int ddx, ddy, range;
278 1.5 christos char sym;
279 1.5 christos {
280 1.5 christos struct monst *mtmp = (struct monst *) 0;
281 1.5 christos int bchx = u.ux, bchy = u.uy;
282 1.1 cgd
283 1.5 christos if (sym)
284 1.5 christos Tmp_at(-1, sym);/* open call */
285 1.5 christos while (range--) {
286 1.1 cgd bchx += ddx;
287 1.1 cgd bchy += ddy;
288 1.5 christos if ((mtmp = m_at(bchx, bchy)) != NULL)
289 1.1 cgd break;
290 1.5 christos if (!ZAP_POS(levl[bchx][bchy].typ)) {
291 1.1 cgd bchx -= ddx;
292 1.1 cgd bchy -= ddy;
293 1.1 cgd break;
294 1.1 cgd }
295 1.5 christos if (sym)
296 1.5 christos Tmp_at(bchx, bchy);
297 1.1 cgd }
298 1.5 christos if (sym)
299 1.5 christos Tmp_at(-1, -1);
300 1.5 christos return (mtmp);
301 1.1 cgd }
302 1.1 cgd
303 1.1 cgd /* ARGSUSED */
304 1.1 cgd static void
305 1.5 christos use_whistle(obj)
306 1.6 jsm struct obj *obj __attribute__((__unused__));
307 1.5 christos {
308 1.5 christos struct monst *mtmp = fmon;
309 1.1 cgd pline("You produce a high whistling sound.");
310 1.5 christos while (mtmp) {
311 1.5 christos if (dist(mtmp->mx, mtmp->my) < u.ulevel * 20) {
312 1.5 christos if (mtmp->msleep)
313 1.1 cgd mtmp->msleep = 0;
314 1.5 christos if (mtmp->mtame)
315 1.1 cgd EDOG(mtmp)->whistletime = moves;
316 1.1 cgd }
317 1.1 cgd mtmp = mtmp->nmon;
318 1.1 cgd }
319 1.1 cgd }
320 1.1 cgd
321 1.1 cgd /* ARGSUSED */
322 1.1 cgd static void
323 1.5 christos use_magic_whistle(obj)
324 1.6 jsm struct obj *obj __attribute__((__unused__));
325 1.5 christos {
326 1.5 christos struct monst *mtmp = fmon;
327 1.1 cgd pline("You produce a strange whistling sound.");
328 1.5 christos while (mtmp) {
329 1.5 christos if (mtmp->mtame)
330 1.5 christos mnexto(mtmp);
331 1.1 cgd mtmp = mtmp->nmon;
332 1.1 cgd }
333 1.1 cgd }
334 1.1 cgd
335 1.5 christos static int dig_effort; /* effort expended on current pos */
336 1.5 christos static uchar dig_level;
337 1.5 christos static coord dig_pos;
338 1.5 christos static boolean dig_down;
339 1.1 cgd
340 1.5 christos static int
341 1.5 christos dig()
342 1.5 christos {
343 1.5 christos struct rm *lev;
344 1.5 christos int dpx = dig_pos.x, dpy = dig_pos.y;
345 1.1 cgd
346 1.1 cgd /* perhaps a nymph stole his pick-axe while he was busy digging */
347 1.1 cgd /* or perhaps he teleported away */
348 1.5 christos if (u.uswallow || !uwep || uwep->otyp != PICK_AXE ||
349 1.1 cgd dig_level != dlevel ||
350 1.1 cgd ((dig_down && (dpx != u.ux || dpy != u.uy)) ||
351 1.5 christos (!dig_down && dist(dpx, dpy) > 2)))
352 1.5 christos return (0);
353 1.1 cgd
354 1.1 cgd dig_effort += 10 + abon() + uwep->spe + rn2(5);
355 1.5 christos if (dig_down) {
356 1.5 christos if (!xdnstair) {
357 1.1 cgd pline("The floor here seems too hard to dig in.");
358 1.5 christos return (0);
359 1.1 cgd }
360 1.5 christos if (dig_effort > 250) {
361 1.1 cgd dighole();
362 1.5 christos return (0); /* done with digging */
363 1.1 cgd }
364 1.5 christos if (dig_effort > 50) {
365 1.5 christos struct trap *ttmp = t_at(dpx, dpy);
366 1.1 cgd
367 1.5 christos if (!ttmp) {
368 1.5 christos ttmp = maketrap(dpx, dpy, PIT);
369 1.1 cgd ttmp->tseen = 1;
370 1.1 cgd pline("You have dug a pit.");
371 1.5 christos u.utrap = rn1(4, 2);
372 1.1 cgd u.utraptype = TT_PIT;
373 1.5 christos return (0);
374 1.1 cgd }
375 1.1 cgd }
376 1.5 christos } else if (dig_effort > 100) {
377 1.6 jsm const char *digtxt;
378 1.5 christos struct obj *obj;
379 1.1 cgd
380 1.1 cgd lev = &levl[dpx][dpy];
381 1.5 christos if ((obj = sobj_at(ENORMOUS_ROCK, dpx, dpy)) != NULL) {
382 1.1 cgd fracture_rock(obj);
383 1.1 cgd digtxt = "The rock falls apart.";
384 1.5 christos } else if (!lev->typ || lev->typ == SCORR) {
385 1.1 cgd lev->typ = CORR;
386 1.1 cgd digtxt = "You succeeded in cutting away some rock.";
387 1.5 christos } else if (lev->typ == HWALL || lev->typ == VWALL
388 1.5 christos || lev->typ == SDOOR) {
389 1.1 cgd lev->typ = xdnstair ? DOOR : ROOM;
390 1.1 cgd digtxt = "You just made an opening in the wall.";
391 1.1 cgd } else
392 1.5 christos digtxt = "Now what exactly was it that you were digging in?";
393 1.1 cgd mnewsym(dpx, dpy);
394 1.1 cgd prl(dpx, dpy);
395 1.5 christos pline(digtxt); /* after mnewsym & prl */
396 1.5 christos return (0);
397 1.1 cgd } else {
398 1.5 christos if (IS_WALL(levl[dpx][dpy].typ)) {
399 1.5 christos int rno = inroom(dpx, dpy);
400 1.1 cgd
401 1.5 christos if (rno >= 0 && rooms[rno].rtype >= 8) {
402 1.5 christos pline("This wall seems too hard to dig into.");
403 1.5 christos return (0);
404 1.1 cgd }
405 1.1 cgd }
406 1.1 cgd pline("You hit the rock with all your might.");
407 1.1 cgd }
408 1.5 christos return (1);
409 1.1 cgd }
410 1.1 cgd
411 1.1 cgd /* When will hole be finished? Very rough indication used by shopkeeper. */
412 1.5 christos int
413 1.5 christos holetime()
414 1.5 christos {
415 1.5 christos return ((occupation == dig) ? (250 - dig_effort) / 20 : -1);
416 1.1 cgd }
417 1.1 cgd
418 1.5 christos void
419 1.1 cgd dighole()
420 1.1 cgd {
421 1.5 christos struct trap *ttmp = t_at(u.ux, u.uy);
422 1.1 cgd
423 1.5 christos if (!xdnstair) {
424 1.1 cgd pline("The floor here seems too hard to dig in.");
425 1.1 cgd } else {
426 1.5 christos if (ttmp)
427 1.1 cgd ttmp->ttyp = TRAPDOOR;
428 1.1 cgd else
429 1.1 cgd ttmp = maketrap(u.ux, u.uy, TRAPDOOR);
430 1.1 cgd ttmp->tseen = 1;
431 1.1 cgd pline("You've made a hole in the floor.");
432 1.5 christos if (!u.ustuck) {
433 1.5 christos if (inshop())
434 1.1 cgd shopdig(1);
435 1.1 cgd pline("You fall through ...");
436 1.5 christos if (u.utraptype == TT_PIT) {
437 1.1 cgd u.utrap = 0;
438 1.1 cgd u.utraptype = 0;
439 1.1 cgd }
440 1.5 christos goto_level(dlevel + 1, FALSE);
441 1.1 cgd }
442 1.1 cgd }
443 1.1 cgd }
444 1.1 cgd
445 1.5 christos static int
446 1.1 cgd use_pick_axe(obj)
447 1.5 christos struct obj *obj;
448 1.1 cgd {
449 1.5 christos char dirsyms[12];
450 1.5 christos char *dsp = dirsyms, *sdp = sdir;
451 1.5 christos struct monst *mtmp;
452 1.5 christos struct rm *lev;
453 1.5 christos int rx, ry, res = 0;
454 1.1 cgd
455 1.5 christos if (obj != uwep) {
456 1.5 christos if (uwep && uwep->cursed) {
457 1.1 cgd /* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */
458 1.1 cgd pline("Since your weapon is welded to your hand,");
459 1.1 cgd pline("you cannot use that pick-axe.");
460 1.5 christos return (0);
461 1.1 cgd }
462 1.1 cgd pline("You now wield %s.", doname(obj));
463 1.1 cgd setuwep(obj);
464 1.1 cgd res = 1;
465 1.1 cgd }
466 1.5 christos while (*sdp) {
467 1.1 cgd (void) movecmd(*sdp); /* sets u.dx and u.dy and u.dz */
468 1.1 cgd rx = u.ux + u.dx;
469 1.1 cgd ry = u.uy + u.dy;
470 1.5 christos if (u.dz > 0 || (u.dz == 0 && isok(rx, ry) &&
471 1.5 christos (IS_ROCK(levl[rx][ry].typ)
472 1.5 christos || sobj_at(ENORMOUS_ROCK, rx, ry))))
473 1.1 cgd *dsp++ = *sdp;
474 1.1 cgd sdp++;
475 1.1 cgd }
476 1.1 cgd *dsp = 0;
477 1.1 cgd pline("In what direction do you want to dig? [%s] ", dirsyms);
478 1.5 christos if (!getdir(0)) /* no txt */
479 1.5 christos return (res);
480 1.5 christos if (u.uswallow && attack(u.ustuck)) /* return(1) */
481 1.5 christos ;
482 1.5 christos else if (u.dz < 0)
483 1.1 cgd pline("You cannot reach the ceiling.");
484 1.5 christos else if (u.dz == 0) {
485 1.5 christos if (Confusion)
486 1.1 cgd confdir();
487 1.1 cgd rx = u.ux + u.dx;
488 1.1 cgd ry = u.uy + u.dy;
489 1.5 christos if ((mtmp = m_at(rx, ry)) && attack(mtmp))
490 1.5 christos return (1);
491 1.5 christos if (!isok(rx, ry)) {
492 1.1 cgd pline("Clash!");
493 1.5 christos return (1);
494 1.1 cgd }
495 1.1 cgd lev = &levl[rx][ry];
496 1.5 christos if (lev->typ == DOOR)
497 1.1 cgd pline("Your %s against the door.",
498 1.5 christos aobjnam(obj, "clang"));
499 1.5 christos else if (!IS_ROCK(lev->typ)
500 1.5 christos && !sobj_at(ENORMOUS_ROCK, rx, ry)) {
501 1.1 cgd /* ACCESSIBLE or POOL */
502 1.1 cgd pline("You swing your %s through thin air.",
503 1.5 christos aobjnam(obj, (char *) 0));
504 1.1 cgd } else {
505 1.5 christos if (dig_pos.x != rx || dig_pos.y != ry
506 1.1 cgd || dig_level != dlevel || dig_down) {
507 1.1 cgd dig_down = FALSE;
508 1.1 cgd dig_pos.x = rx;
509 1.1 cgd dig_pos.y = ry;
510 1.1 cgd dig_level = dlevel;
511 1.1 cgd dig_effort = 0;
512 1.1 cgd pline("You start digging.");
513 1.1 cgd } else
514 1.1 cgd pline("You continue digging.");
515 1.1 cgd occupation = dig;
516 1.1 cgd occtxt = "digging";
517 1.1 cgd }
518 1.5 christos } else if (Levitation) {
519 1.1 cgd pline("You cannot reach the floor.");
520 1.1 cgd } else {
521 1.5 christos if (dig_pos.x != u.ux || dig_pos.y != u.uy
522 1.1 cgd || dig_level != dlevel || !dig_down) {
523 1.1 cgd dig_down = TRUE;
524 1.1 cgd dig_pos.x = u.ux;
525 1.1 cgd dig_pos.y = u.uy;
526 1.1 cgd dig_level = dlevel;
527 1.1 cgd dig_effort = 0;
528 1.1 cgd pline("You start digging in the floor.");
529 1.5 christos if (inshop())
530 1.1 cgd shopdig(0);
531 1.1 cgd } else
532 1.1 cgd pline("You continue digging in the floor.");
533 1.1 cgd occupation = dig;
534 1.1 cgd occtxt = "digging";
535 1.1 cgd }
536 1.5 christos return (1);
537 1.1 cgd }
538