1 1.13 dholland /* $NetBSD: hack.apply.c,v 1.13 2011/08/07 06:03:45 dholland 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.13 dholland __RCSID("$NetBSD: hack.apply.c,v 1.13 2011/08/07 06:03:45 dholland 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.8 jsm static void use_camera(struct obj *); 75 1.8 jsm static int in_ice_box(struct obj *); 76 1.8 jsm static int ck_ice_box(struct obj *); 77 1.8 jsm static int out_ice_box(struct obj *); 78 1.8 jsm static void use_ice_box(struct obj *); 79 1.8 jsm static struct monst *bchit(int, int , int , int); 80 1.8 jsm static void use_whistle(struct obj *); 81 1.8 jsm static void use_magic_whistle(struct obj *); 82 1.8 jsm static int dig(void); 83 1.8 jsm static int use_pick_axe(struct obj *); 84 1.5 christos 85 1.5 christos int 86 1.10 dholland doapply(void) 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.13 dholland /* FALLTHROUGH */ 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.10 dholland use_camera(struct obj *obj __unused) 140 1.5 christos { 141 1.5 christos struct monst *mtmp; 142 1.5 christos if (!getdir(1)) { /* ask: in what direction? */ 143 1.1 cgd flags.move = multi = 0; 144 1.1 cgd return; 145 1.1 cgd } 146 1.5 christos if (u.uswallow) { 147 1.1 cgd pline("You take a picture of %s's stomach.", monnam(u.ustuck)); 148 1.1 cgd return; 149 1.1 cgd } 150 1.5 christos if (u.dz) { 151 1.1 cgd pline("You take a picture of the %s.", 152 1.5 christos (u.dz > 0) ? "floor" : "ceiling"); 153 1.1 cgd return; 154 1.1 cgd } 155 1.5 christos if ((mtmp = bchit(u.dx, u.dy, COLNO, '!')) != NULL) { 156 1.5 christos if (mtmp->msleep) { 157 1.1 cgd mtmp->msleep = 0; 158 1.5 christos pline("The flash awakens %s.", monnam(mtmp)); /* a3 */ 159 1.5 christos } else if (mtmp->data->mlet != 'y') 160 1.5 christos if (mtmp->mcansee || mtmp->mblinded) { 161 1.5 christos int tmp = dist(mtmp->mx, mtmp->my); 162 1.5 christos int tmp2; 163 1.5 christos if (cansee(mtmp->mx, mtmp->my)) 164 1.5 christos pline("%s is blinded by the flash!", Monnam(mtmp)); 165 1.5 christos setmangry(mtmp); 166 1.5 christos if (tmp < 9 && !mtmp->isshk && rn2(4)) { 167 1.5 christos mtmp->mflee = 1; 168 1.5 christos if (rn2(4)) 169 1.5 christos mtmp->mfleetim = rnd(100); 170 1.5 christos } 171 1.5 christos if (tmp < 3) 172 1.5 christos mtmp->mcansee = mtmp->mblinded = 0; 173 1.5 christos else { 174 1.5 christos tmp2 = mtmp->mblinded; 175 1.5 christos tmp2 += rnd(1 + 50 / tmp); 176 1.5 christos if (tmp2 > 127) 177 1.5 christos tmp2 = 127; 178 1.5 christos mtmp->mblinded = tmp2; 179 1.5 christos mtmp->mcansee = 0; 180 1.5 christos } 181 1.1 cgd } 182 1.1 cgd } 183 1.1 cgd } 184 1.1 cgd 185 1.1 cgd static 186 1.5 christos struct obj *current_ice_box;/* a local variable of use_ice_box, to be 187 1.5 christos * used by its local procedures in/ck_ice_box */ 188 1.5 christos static int 189 1.10 dholland in_ice_box(struct obj *obj) 190 1.5 christos { 191 1.5 christos if (obj == current_ice_box || 192 1.5 christos (Punished && (obj == uball || obj == uchain))) { 193 1.1 cgd pline("You must be kidding."); 194 1.5 christos return (0); 195 1.1 cgd } 196 1.5 christos if (obj->owornmask & (W_ARMOR | W_RING)) { 197 1.1 cgd pline("You cannot refrigerate something you are wearing."); 198 1.5 christos return (0); 199 1.1 cgd } 200 1.5 christos if (obj->owt + current_ice_box->owt > 70) { 201 1.1 cgd pline("It won't fit."); 202 1.5 christos return (1); /* be careful! */ 203 1.1 cgd } 204 1.5 christos if (obj == uwep) { 205 1.5 christos if (uwep->cursed) { 206 1.1 cgd pline("Your weapon is welded to your hand!"); 207 1.5 christos return (0); 208 1.1 cgd } 209 1.1 cgd setuwep((struct obj *) 0); 210 1.1 cgd } 211 1.1 cgd current_ice_box->owt += obj->owt; 212 1.1 cgd freeinv(obj); 213 1.1 cgd obj->o_cnt_id = current_ice_box->o_id; 214 1.1 cgd obj->nobj = fcobj; 215 1.1 cgd fcobj = obj; 216 1.1 cgd obj->age = moves - obj->age; /* actual age */ 217 1.5 christos return (1); 218 1.1 cgd } 219 1.1 cgd 220 1.5 christos static int 221 1.10 dholland ck_ice_box(struct obj *obj) 222 1.5 christos { 223 1.5 christos return (obj->o_cnt_id == current_ice_box->o_id); 224 1.1 cgd } 225 1.1 cgd 226 1.5 christos static int 227 1.10 dholland out_ice_box(struct obj *obj) 228 1.5 christos { 229 1.5 christos struct obj *otmp; 230 1.5 christos if (obj == fcobj) 231 1.5 christos fcobj = fcobj->nobj; 232 1.1 cgd else { 233 1.5 christos for (otmp = fcobj; otmp->nobj != obj; otmp = otmp->nobj) 234 1.5 christos if (!otmp->nobj) 235 1.5 christos panic("out_ice_box"); 236 1.1 cgd otmp->nobj = obj->nobj; 237 1.1 cgd } 238 1.1 cgd current_ice_box->owt -= obj->owt; 239 1.1 cgd obj->age = moves - obj->age; /* simulated point of time */ 240 1.1 cgd (void) addinv(obj); 241 1.5 christos return 0; 242 1.1 cgd } 243 1.1 cgd 244 1.1 cgd static void 245 1.10 dholland use_ice_box(struct obj *obj) 246 1.5 christos { 247 1.5 christos int cnt = 0; 248 1.5 christos struct obj *otmp; 249 1.1 cgd current_ice_box = obj; /* for use by in/out_ice_box */ 250 1.5 christos for (otmp = fcobj; otmp; otmp = otmp->nobj) 251 1.5 christos if (otmp->o_cnt_id == obj->o_id) 252 1.1 cgd cnt++; 253 1.5 christos if (!cnt) 254 1.5 christos pline("Your ice-box is empty."); 255 1.1 cgd else { 256 1.5 christos pline("Do you want to take something out of the ice-box? [yn] "); 257 1.5 christos if (readchar() == 'y') 258 1.12 dholland if (askchain(fcobj, NULL, 0, out_ice_box, ck_ice_box, 0)) 259 1.5 christos return; 260 1.1 cgd pline("That was all. Do you wish to put something in? [yn] "); 261 1.5 christos if (readchar() != 'y') 262 1.5 christos return; 263 1.1 cgd } 264 1.1 cgd /* call getobj: 0: allow cnt; #: allow all types; %: expect food */ 265 1.1 cgd otmp = getobj("0#%", "put in"); 266 1.5 christos if (!otmp || !in_ice_box(otmp)) 267 1.1 cgd flags.move = multi = 0; 268 1.1 cgd } 269 1.1 cgd 270 1.5 christos static struct monst * 271 1.10 dholland bchit(int ddx, int ddy, int range, int sym) 272 1.5 christos { 273 1.5 christos struct monst *mtmp = (struct monst *) 0; 274 1.5 christos int bchx = u.ux, bchy = u.uy; 275 1.1 cgd 276 1.5 christos if (sym) 277 1.5 christos Tmp_at(-1, sym);/* open call */ 278 1.5 christos while (range--) { 279 1.1 cgd bchx += ddx; 280 1.1 cgd bchy += ddy; 281 1.5 christos if ((mtmp = m_at(bchx, bchy)) != NULL) 282 1.1 cgd break; 283 1.5 christos if (!ZAP_POS(levl[bchx][bchy].typ)) { 284 1.1 cgd bchx -= ddx; 285 1.1 cgd bchy -= ddy; 286 1.1 cgd break; 287 1.1 cgd } 288 1.5 christos if (sym) 289 1.5 christos Tmp_at(bchx, bchy); 290 1.1 cgd } 291 1.5 christos if (sym) 292 1.5 christos Tmp_at(-1, -1); 293 1.5 christos return (mtmp); 294 1.1 cgd } 295 1.1 cgd 296 1.1 cgd /* ARGSUSED */ 297 1.1 cgd static void 298 1.10 dholland use_whistle(struct obj *obj __unused) 299 1.5 christos { 300 1.5 christos struct monst *mtmp = fmon; 301 1.1 cgd pline("You produce a high whistling sound."); 302 1.5 christos while (mtmp) { 303 1.5 christos if (dist(mtmp->mx, mtmp->my) < u.ulevel * 20) { 304 1.5 christos if (mtmp->msleep) 305 1.1 cgd mtmp->msleep = 0; 306 1.5 christos if (mtmp->mtame) 307 1.1 cgd EDOG(mtmp)->whistletime = moves; 308 1.1 cgd } 309 1.1 cgd mtmp = mtmp->nmon; 310 1.1 cgd } 311 1.1 cgd } 312 1.1 cgd 313 1.1 cgd /* ARGSUSED */ 314 1.1 cgd static void 315 1.10 dholland use_magic_whistle(struct obj *obj __unused) 316 1.5 christos { 317 1.5 christos struct monst *mtmp = fmon; 318 1.1 cgd pline("You produce a strange whistling sound."); 319 1.5 christos while (mtmp) { 320 1.5 christos if (mtmp->mtame) 321 1.5 christos mnexto(mtmp); 322 1.1 cgd mtmp = mtmp->nmon; 323 1.1 cgd } 324 1.1 cgd } 325 1.1 cgd 326 1.5 christos static int dig_effort; /* effort expended on current pos */ 327 1.5 christos static uchar dig_level; 328 1.5 christos static coord dig_pos; 329 1.5 christos static boolean dig_down; 330 1.1 cgd 331 1.5 christos static int 332 1.10 dholland dig(void) 333 1.5 christos { 334 1.5 christos struct rm *lev; 335 1.5 christos int dpx = dig_pos.x, dpy = dig_pos.y; 336 1.1 cgd 337 1.1 cgd /* perhaps a nymph stole his pick-axe while he was busy digging */ 338 1.1 cgd /* or perhaps he teleported away */ 339 1.5 christos if (u.uswallow || !uwep || uwep->otyp != PICK_AXE || 340 1.1 cgd dig_level != dlevel || 341 1.1 cgd ((dig_down && (dpx != u.ux || dpy != u.uy)) || 342 1.5 christos (!dig_down && dist(dpx, dpy) > 2))) 343 1.5 christos return (0); 344 1.1 cgd 345 1.1 cgd dig_effort += 10 + abon() + uwep->spe + rn2(5); 346 1.5 christos if (dig_down) { 347 1.5 christos if (!xdnstair) { 348 1.1 cgd pline("The floor here seems too hard to dig in."); 349 1.5 christos return (0); 350 1.1 cgd } 351 1.5 christos if (dig_effort > 250) { 352 1.1 cgd dighole(); 353 1.5 christos return (0); /* done with digging */ 354 1.1 cgd } 355 1.5 christos if (dig_effort > 50) { 356 1.5 christos struct trap *ttmp = t_at(dpx, dpy); 357 1.1 cgd 358 1.5 christos if (!ttmp) { 359 1.5 christos ttmp = maketrap(dpx, dpy, PIT); 360 1.1 cgd ttmp->tseen = 1; 361 1.1 cgd pline("You have dug a pit."); 362 1.5 christos u.utrap = rn1(4, 2); 363 1.1 cgd u.utraptype = TT_PIT; 364 1.5 christos return (0); 365 1.1 cgd } 366 1.1 cgd } 367 1.5 christos } else if (dig_effort > 100) { 368 1.6 jsm const char *digtxt; 369 1.5 christos struct obj *obj; 370 1.1 cgd 371 1.1 cgd lev = &levl[dpx][dpy]; 372 1.5 christos if ((obj = sobj_at(ENORMOUS_ROCK, dpx, dpy)) != NULL) { 373 1.1 cgd fracture_rock(obj); 374 1.1 cgd digtxt = "The rock falls apart."; 375 1.5 christos } else if (!lev->typ || lev->typ == SCORR) { 376 1.1 cgd lev->typ = CORR; 377 1.1 cgd digtxt = "You succeeded in cutting away some rock."; 378 1.5 christos } else if (lev->typ == HWALL || lev->typ == VWALL 379 1.5 christos || lev->typ == SDOOR) { 380 1.1 cgd lev->typ = xdnstair ? DOOR : ROOM; 381 1.1 cgd digtxt = "You just made an opening in the wall."; 382 1.1 cgd } else 383 1.5 christos digtxt = "Now what exactly was it that you were digging in?"; 384 1.1 cgd mnewsym(dpx, dpy); 385 1.1 cgd prl(dpx, dpy); 386 1.11 joerg pline("%s", digtxt); /* after mnewsym & prl */ 387 1.5 christos return (0); 388 1.1 cgd } else { 389 1.5 christos if (IS_WALL(levl[dpx][dpy].typ)) { 390 1.5 christos int rno = inroom(dpx, dpy); 391 1.1 cgd 392 1.5 christos if (rno >= 0 && rooms[rno].rtype >= 8) { 393 1.5 christos pline("This wall seems too hard to dig into."); 394 1.5 christos return (0); 395 1.1 cgd } 396 1.1 cgd } 397 1.1 cgd pline("You hit the rock with all your might."); 398 1.1 cgd } 399 1.5 christos return (1); 400 1.1 cgd } 401 1.1 cgd 402 1.1 cgd /* When will hole be finished? Very rough indication used by shopkeeper. */ 403 1.5 christos int 404 1.10 dholland holetime(void) 405 1.5 christos { 406 1.5 christos return ((occupation == dig) ? (250 - dig_effort) / 20 : -1); 407 1.1 cgd } 408 1.1 cgd 409 1.5 christos void 410 1.10 dholland dighole(void) 411 1.1 cgd { 412 1.5 christos struct trap *ttmp = t_at(u.ux, u.uy); 413 1.1 cgd 414 1.5 christos if (!xdnstair) { 415 1.1 cgd pline("The floor here seems too hard to dig in."); 416 1.1 cgd } else { 417 1.5 christos if (ttmp) 418 1.1 cgd ttmp->ttyp = TRAPDOOR; 419 1.1 cgd else 420 1.1 cgd ttmp = maketrap(u.ux, u.uy, TRAPDOOR); 421 1.1 cgd ttmp->tseen = 1; 422 1.1 cgd pline("You've made a hole in the floor."); 423 1.5 christos if (!u.ustuck) { 424 1.5 christos if (inshop()) 425 1.1 cgd shopdig(1); 426 1.1 cgd pline("You fall through ..."); 427 1.5 christos if (u.utraptype == TT_PIT) { 428 1.1 cgd u.utrap = 0; 429 1.1 cgd u.utraptype = 0; 430 1.1 cgd } 431 1.5 christos goto_level(dlevel + 1, FALSE); 432 1.1 cgd } 433 1.1 cgd } 434 1.1 cgd } 435 1.1 cgd 436 1.5 christos static int 437 1.10 dholland use_pick_axe(struct obj *obj) 438 1.1 cgd { 439 1.5 christos char dirsyms[12]; 440 1.5 christos char *dsp = dirsyms, *sdp = sdir; 441 1.5 christos struct monst *mtmp; 442 1.5 christos struct rm *lev; 443 1.5 christos int rx, ry, res = 0; 444 1.1 cgd 445 1.5 christos if (obj != uwep) { 446 1.5 christos if (uwep && uwep->cursed) { 447 1.1 cgd /* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */ 448 1.1 cgd pline("Since your weapon is welded to your hand,"); 449 1.1 cgd pline("you cannot use that pick-axe."); 450 1.5 christos return (0); 451 1.1 cgd } 452 1.1 cgd pline("You now wield %s.", doname(obj)); 453 1.1 cgd setuwep(obj); 454 1.1 cgd res = 1; 455 1.1 cgd } 456 1.5 christos while (*sdp) { 457 1.1 cgd (void) movecmd(*sdp); /* sets u.dx and u.dy and u.dz */ 458 1.1 cgd rx = u.ux + u.dx; 459 1.1 cgd ry = u.uy + u.dy; 460 1.5 christos if (u.dz > 0 || (u.dz == 0 && isok(rx, ry) && 461 1.5 christos (IS_ROCK(levl[rx][ry].typ) 462 1.5 christos || sobj_at(ENORMOUS_ROCK, rx, ry)))) 463 1.1 cgd *dsp++ = *sdp; 464 1.1 cgd sdp++; 465 1.1 cgd } 466 1.1 cgd *dsp = 0; 467 1.1 cgd pline("In what direction do you want to dig? [%s] ", dirsyms); 468 1.5 christos if (!getdir(0)) /* no txt */ 469 1.5 christos return (res); 470 1.5 christos if (u.uswallow && attack(u.ustuck)) /* return(1) */ 471 1.5 christos ; 472 1.5 christos else if (u.dz < 0) 473 1.1 cgd pline("You cannot reach the ceiling."); 474 1.5 christos else if (u.dz == 0) { 475 1.5 christos if (Confusion) 476 1.1 cgd confdir(); 477 1.1 cgd rx = u.ux + u.dx; 478 1.1 cgd ry = u.uy + u.dy; 479 1.5 christos if ((mtmp = m_at(rx, ry)) && attack(mtmp)) 480 1.5 christos return (1); 481 1.5 christos if (!isok(rx, ry)) { 482 1.1 cgd pline("Clash!"); 483 1.5 christos return (1); 484 1.1 cgd } 485 1.1 cgd lev = &levl[rx][ry]; 486 1.5 christos if (lev->typ == DOOR) 487 1.1 cgd pline("Your %s against the door.", 488 1.5 christos aobjnam(obj, "clang")); 489 1.5 christos else if (!IS_ROCK(lev->typ) 490 1.5 christos && !sobj_at(ENORMOUS_ROCK, rx, ry)) { 491 1.1 cgd /* ACCESSIBLE or POOL */ 492 1.1 cgd pline("You swing your %s through thin air.", 493 1.12 dholland aobjnam(obj, NULL)); 494 1.1 cgd } else { 495 1.5 christos if (dig_pos.x != rx || dig_pos.y != ry 496 1.1 cgd || dig_level != dlevel || dig_down) { 497 1.1 cgd dig_down = FALSE; 498 1.1 cgd dig_pos.x = rx; 499 1.1 cgd dig_pos.y = ry; 500 1.1 cgd dig_level = dlevel; 501 1.1 cgd dig_effort = 0; 502 1.1 cgd pline("You start digging."); 503 1.1 cgd } else 504 1.1 cgd pline("You continue digging."); 505 1.1 cgd occupation = dig; 506 1.1 cgd occtxt = "digging"; 507 1.1 cgd } 508 1.5 christos } else if (Levitation) { 509 1.1 cgd pline("You cannot reach the floor."); 510 1.1 cgd } else { 511 1.5 christos if (dig_pos.x != u.ux || dig_pos.y != u.uy 512 1.1 cgd || dig_level != dlevel || !dig_down) { 513 1.1 cgd dig_down = TRUE; 514 1.1 cgd dig_pos.x = u.ux; 515 1.1 cgd dig_pos.y = u.uy; 516 1.1 cgd dig_level = dlevel; 517 1.1 cgd dig_effort = 0; 518 1.1 cgd pline("You start digging in the floor."); 519 1.5 christos if (inshop()) 520 1.1 cgd shopdig(0); 521 1.1 cgd } else 522 1.1 cgd pline("You continue digging in the floor."); 523 1.1 cgd occupation = dig; 524 1.1 cgd occtxt = "digging"; 525 1.1 cgd } 526 1.5 christos return (1); 527 1.1 cgd } 528