2009-08-12 11:28:40 +04:00
|
|
|
/* $NetBSD: hack.zap.c,v 1.9 2009/08/12 07:28:41 dholland Exp $ */
|
1997-10-19 20:56:41 +04:00
|
|
|
|
1993-08-02 21:18:41 +04:00
|
|
|
/*
|
2003-04-02 22:36:33 +04:00
|
|
|
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
|
|
|
|
* Amsterdam
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* - Neither the name of the Stichting Centrum voor Wiskunde en
|
|
|
|
* Informatica, nor the names of its contributors may be used to endorse or
|
|
|
|
* promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
|
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
|
|
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1982 Jay Fenlason <hack@gnu.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1993-08-02 21:18:41 +04:00
|
|
|
*/
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-08-02 21:18:41 +04:00
|
|
|
#ifndef lint
|
2009-08-12 11:28:40 +04:00
|
|
|
__RCSID("$NetBSD: hack.zap.c,v 1.9 2009/08/12 07:28:41 dholland Exp $");
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#include "hack.h"
|
1997-10-19 20:56:41 +04:00
|
|
|
#include "extern.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static const char *const fl[] = {
|
1993-03-21 12:45:37 +03:00
|
|
|
"magic missile",
|
|
|
|
"bolt of fire",
|
|
|
|
"sleep ray",
|
|
|
|
"bolt of cold",
|
|
|
|
"death ray"
|
|
|
|
};
|
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static void bhitm(struct monst *, struct obj *);
|
|
|
|
static int bhito(struct obj *, struct obj *);
|
|
|
|
static char dirlet(int, int);
|
|
|
|
static int zhit(struct monst *, int);
|
|
|
|
static int revive(struct obj *);
|
|
|
|
static void rloco(struct obj *);
|
|
|
|
static void burn_scrolls(void);
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/* Routines for IMMEDIATE wands. */
|
|
|
|
/* bhitm: monster mtmp was hit by the effect of wand otmp */
|
2009-08-12 11:28:40 +04:00
|
|
|
static void
|
2009-06-07 22:30:39 +04:00
|
|
|
bhitm(struct monst *mtmp, struct obj *otmp)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
wakeup(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
switch (otmp->otyp) {
|
1993-03-21 12:45:37 +03:00
|
|
|
case WAN_STRIKING:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.uswallow || rnd(20) < 10 + mtmp->data->ac) {
|
|
|
|
int tmp = d(2, 12);
|
1993-03-21 12:45:37 +03:00
|
|
|
hit("wand", mtmp, exclam(tmp));
|
|
|
|
mtmp->mhp -= tmp;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mhp < 1)
|
|
|
|
killed(mtmp);
|
|
|
|
} else
|
|
|
|
miss("wand", mtmp);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case WAN_SLOW_MONSTER:
|
|
|
|
mtmp->mspeed = MSLOW;
|
|
|
|
break;
|
|
|
|
case WAN_SPEED_MONSTER:
|
|
|
|
mtmp->mspeed = MFAST;
|
|
|
|
break;
|
|
|
|
case WAN_UNDEAD_TURNING:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (strchr(UNDEAD, mtmp->data->mlet)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mhp -= rnd(8);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mhp < 1)
|
|
|
|
killed(mtmp);
|
|
|
|
else
|
|
|
|
mtmp->mflee = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WAN_POLYMORPH:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (newcham(mtmp, &mons[rn2(CMNUM)]))
|
1993-03-21 12:45:37 +03:00
|
|
|
objects[otmp->otyp].oc_name_known = 1;
|
|
|
|
break;
|
|
|
|
case WAN_CANCELLATION:
|
|
|
|
mtmp->mcan = 1;
|
|
|
|
break;
|
|
|
|
case WAN_TELEPORTATION:
|
|
|
|
rloc(mtmp);
|
|
|
|
break;
|
|
|
|
case WAN_MAKE_INVISIBLE:
|
|
|
|
mtmp->minvis = 1;
|
|
|
|
break;
|
|
|
|
#ifdef WAN_PROBING
|
|
|
|
case WAN_PROBING:
|
|
|
|
mstatusline(mtmp);
|
|
|
|
break;
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* WAN_PROBING */
|
1993-03-21 12:45:37 +03:00
|
|
|
default:
|
|
|
|
impossible("What an interesting wand (%u)", otmp->otyp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-07 22:30:39 +04:00
|
|
|
/*
|
|
|
|
* object obj was hit by the effect of wand otmp
|
|
|
|
* returns TRUE if sth was done
|
|
|
|
*/
|
2009-08-12 11:28:40 +04:00
|
|
|
static int
|
2009-06-07 22:30:39 +04:00
|
|
|
bhito(struct obj *obj, struct obj *otmp)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
int res = TRUE;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (obj == uball || obj == uchain)
|
1993-03-21 12:45:37 +03:00
|
|
|
res = FALSE;
|
|
|
|
else
|
1997-10-19 20:56:41 +04:00
|
|
|
switch (otmp->otyp) {
|
|
|
|
case WAN_POLYMORPH:
|
|
|
|
/*
|
|
|
|
* preserve symbol and quantity, but turn rocks into
|
|
|
|
* gems
|
|
|
|
*/
|
|
|
|
mkobj_at((obj->otyp == ROCK || obj->otyp == ENORMOUS_ROCK)
|
|
|
|
? GEM_SYM : obj->olet,
|
|
|
|
obj->ox, obj->oy)->quan = obj->quan;
|
|
|
|
delobj(obj);
|
|
|
|
break;
|
|
|
|
case WAN_STRIKING:
|
|
|
|
if (obj->otyp == ENORMOUS_ROCK)
|
|
|
|
fracture_rock(obj);
|
|
|
|
else
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
case WAN_CANCELLATION:
|
|
|
|
if (obj->spe && obj->olet != AMULET_SYM) {
|
|
|
|
obj->known = 0;
|
|
|
|
obj->spe = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WAN_TELEPORTATION:
|
|
|
|
rloco(obj);
|
|
|
|
break;
|
|
|
|
case WAN_MAKE_INVISIBLE:
|
|
|
|
obj->oinvis = 1;
|
|
|
|
break;
|
|
|
|
case WAN_UNDEAD_TURNING:
|
|
|
|
res = revive(obj);
|
|
|
|
break;
|
|
|
|
case WAN_SLOW_MONSTER: /* no effect on objects */
|
|
|
|
case WAN_SPEED_MONSTER:
|
|
|
|
#ifdef WAN_PROBING
|
|
|
|
case WAN_PROBING:
|
|
|
|
#endif /* WAN_PROBING */
|
1993-03-21 12:45:37 +03:00
|
|
|
res = FALSE;
|
1997-10-19 20:56:41 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
impossible("What an interesting wand (%u)", otmp->otyp);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
return (res);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
2009-06-07 22:30:39 +04:00
|
|
|
dozap(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct obj *obj;
|
|
|
|
xchar zx, zy;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
obj = getobj("/", "zap");
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!obj)
|
|
|
|
return (0);
|
|
|
|
if (obj->spe < 0 || (obj->spe == 0 && rn2(121))) {
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("Nothing Happens.");
|
1997-10-19 20:56:41 +04:00
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (obj->spe == 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("You wrest one more spell from the worn-out wand.");
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!(objects[obj->otyp].bits & NODIR) && !getdir(1))
|
|
|
|
return (1); /* make him pay for knowing !NODIR */
|
1993-03-21 12:45:37 +03:00
|
|
|
obj->spe--;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (objects[obj->otyp].bits & IMMEDIATE) {
|
|
|
|
if (u.uswallow)
|
1993-03-21 12:45:37 +03:00
|
|
|
bhitm(u.ustuck, obj);
|
1997-10-19 20:56:41 +04:00
|
|
|
else if (u.dz) {
|
|
|
|
if (u.dz > 0) {
|
|
|
|
struct obj *otmp = o_at(u.ux, u.uy);
|
|
|
|
if (otmp)
|
1993-03-21 12:45:37 +03:00
|
|
|
(void) bhito(otmp, obj);
|
|
|
|
}
|
|
|
|
} else
|
1997-10-19 20:56:41 +04:00
|
|
|
(void) bhit(u.dx, u.dy, rn1(8, 6), 0, bhitm, bhito, obj);
|
1993-03-21 12:45:37 +03:00
|
|
|
} else {
|
1997-10-19 20:56:41 +04:00
|
|
|
switch (obj->otyp) {
|
1993-03-21 12:45:37 +03:00
|
|
|
case WAN_LIGHT:
|
|
|
|
litroom(TRUE);
|
|
|
|
break;
|
|
|
|
case WAN_SECRET_DOOR_DETECTION:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!findit())
|
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case WAN_CREATE_MONSTER:
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
int cnt = 1;
|
|
|
|
if (!rn2(23))
|
|
|
|
cnt += rn2(7) + 1;
|
|
|
|
while (cnt--)
|
|
|
|
(void) makemon((struct permonst *) 0, u.ux, u.uy);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WAN_WISHING:
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
char buf[BUFSZ];
|
|
|
|
struct obj *otmp;
|
|
|
|
if (u.uluck + rn2(5) < 0) {
|
|
|
|
pline("Unfortunately, nothing happens.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pline("You may wish for an object. What do you want? ");
|
|
|
|
getlin(buf);
|
|
|
|
if (buf[0] == '\033')
|
|
|
|
buf[0] = 0;
|
|
|
|
otmp = readobjnam(buf);
|
|
|
|
otmp = addinv(otmp);
|
|
|
|
prinv(otmp);
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
case WAN_DIGGING:
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* Original effect (approximately): from CORR: dig
|
|
|
|
* until we pierce a wall from ROOM: piece wall and
|
|
|
|
* dig until we reach an ACCESSIBLE place. Currently:
|
|
|
|
* dig for digdepth positions; also down on request
|
|
|
|
* of Lennart Augustsson.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct rm *room;
|
|
|
|
int digdepth;
|
|
|
|
if (u.uswallow) {
|
|
|
|
struct monst *mtmp = u.ustuck;
|
|
|
|
|
|
|
|
pline("You pierce %s's stomach wall!",
|
|
|
|
monnam(mtmp));
|
|
|
|
mtmp->mhp = 1; /* almost dead */
|
|
|
|
unstuck(mtmp);
|
|
|
|
mnexto(mtmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (u.dz) {
|
|
|
|
if (u.dz < 0) {
|
|
|
|
pline("You loosen a rock from the ceiling.");
|
|
|
|
pline("It falls on your head!");
|
|
|
|
losehp(1, "falling rock");
|
|
|
|
mksobj_at(ROCK, u.ux, u.uy);
|
|
|
|
fobj->quan = 1;
|
|
|
|
stackobj(fobj);
|
|
|
|
if (Invisible)
|
|
|
|
newsym(u.ux, u.uy);
|
|
|
|
} else {
|
|
|
|
dighole();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
zx = u.ux + u.dx;
|
|
|
|
zy = u.uy + u.dy;
|
|
|
|
digdepth = 8 + rn2(18);
|
|
|
|
Tmp_at(-1, '*'); /* open call */
|
|
|
|
while (--digdepth >= 0) {
|
|
|
|
if (!isok(zx, zy))
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1997-10-19 20:56:41 +04:00
|
|
|
room = &levl[zx][zy];
|
|
|
|
Tmp_at(zx, zy);
|
|
|
|
if (!xdnstair) {
|
|
|
|
if (zx < 3 || zx > COLNO - 3 ||
|
|
|
|
zy < 3 || zy > ROWNO - 3)
|
|
|
|
break;
|
|
|
|
if (room->typ == HWALL ||
|
|
|
|
room->typ == VWALL) {
|
|
|
|
room->typ = ROOM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (room->typ == HWALL || room->typ == VWALL ||
|
|
|
|
room->typ == SDOOR || room->typ == LDOOR) {
|
|
|
|
room->typ = DOOR;
|
|
|
|
digdepth -= 2;
|
|
|
|
} else if (room->typ == SCORR || !room->typ) {
|
|
|
|
room->typ = CORR;
|
|
|
|
digdepth--;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
mnewsym(zx, zy);
|
|
|
|
zx += u.dx;
|
|
|
|
zy += u.dy;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
mnewsym(zx, zy); /* not always necessary */
|
|
|
|
Tmp_at(-1, -1); /* closing call */
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
buzz((int) obj->otyp - WAN_MAGIC_MISSILE,
|
1997-10-19 20:56:41 +04:00
|
|
|
u.ux, u.uy, u.dx, u.dy);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!objects[obj->otyp].oc_name_known) {
|
1993-03-21 12:45:37 +03:00
|
|
|
objects[obj->otyp].oc_name_known = 1;
|
1997-10-19 20:56:41 +04:00
|
|
|
more_experienced(0, 10);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2001-03-26 00:43:58 +04:00
|
|
|
const char *
|
2009-06-07 22:30:39 +04:00
|
|
|
exclam(int force)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
/* force == 0 occurs e.g. with sleep ray */
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* note that large force is usual with wands so that !! would require
|
|
|
|
* information about hand/weapon/wand
|
|
|
|
*/
|
|
|
|
return ((force < 0) ? "?" : (force <= 4) ? "." : "!");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
hit(const char *str, struct monst *mtmp, const char *force)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2009-06-07 22:30:39 +04:00
|
|
|
/* force is usually either "." or "!" */
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!cansee(mtmp->mx, mtmp->my))
|
|
|
|
pline("The %s hits it.", str);
|
|
|
|
else
|
|
|
|
pline("The %s hits %s%s", str, monnam(mtmp), force);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
miss(const char *str, struct monst *mtmp)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!cansee(mtmp->mx, mtmp->my))
|
|
|
|
pline("The %s misses it.", str);
|
|
|
|
else
|
|
|
|
pline("The %s misses %s.", str, monnam(mtmp));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* bhit: called when a weapon is thrown (sym = obj->olet) or when an
|
|
|
|
* IMMEDIATE wand is zapped (sym = 0); the weapon falls down at end of range
|
|
|
|
* or when a monster is hit; the monster is returned, and bhitpos is set to
|
|
|
|
* the final position of the weapon thrown; the ray of a wand may affect
|
|
|
|
* several objects and monsters on its path - for each of these an argument
|
|
|
|
* function is called.
|
|
|
|
*/
|
1993-03-21 12:45:37 +03:00
|
|
|
/* check !u.uswallow before calling bhit() */
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *
|
2009-06-07 22:30:39 +04:00
|
|
|
bhit(int ddx, int ddy, int range, /* direction and range */
|
|
|
|
int sym, /* symbol displayed on path */
|
|
|
|
/* fns called when mon/obj hit */
|
|
|
|
void (*fhitm)(struct monst *, struct obj *),
|
|
|
|
int (*fhito)(struct obj *, struct obj *),
|
|
|
|
struct obj *obj) /* 2nd arg to fhitm/fhito */
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *mtmp;
|
|
|
|
struct obj *otmp;
|
|
|
|
int typ;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
bhitpos.x = u.ux;
|
|
|
|
bhitpos.y = u.uy;
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (sym)
|
|
|
|
tmp_at(-1, sym);/* open call */
|
|
|
|
while (range-- > 0) {
|
1993-03-21 12:45:37 +03:00
|
|
|
bhitpos.x += ddx;
|
|
|
|
bhitpos.y += ddy;
|
|
|
|
typ = levl[bhitpos.x][bhitpos.y].typ;
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != NULL) {
|
|
|
|
if (sym) {
|
1993-03-21 12:45:37 +03:00
|
|
|
tmp_at(-1, -1); /* close call */
|
1997-10-19 20:56:41 +04:00
|
|
|
return (mtmp);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
(*fhitm) (mtmp, obj);
|
1993-03-21 12:45:37 +03:00
|
|
|
range -= 3;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (fhito && (otmp = o_at(bhitpos.x, bhitpos.y))) {
|
|
|
|
if ((*fhito) (otmp, obj))
|
1993-03-21 12:45:37 +03:00
|
|
|
range--;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!ZAP_POS(typ)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
bhitpos.x -= ddx;
|
|
|
|
bhitpos.y -= ddy;
|
|
|
|
break;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (sym)
|
|
|
|
tmp_at(bhitpos.x, bhitpos.y);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* leave last symbol unless in a pool */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (sym)
|
|
|
|
tmp_at(-1, (levl[bhitpos.x][bhitpos.y].typ == POOL) ? -1 : 0);
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *
|
2001-03-26 00:43:58 +04:00
|
|
|
boomhit(int dx, int dy)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
int i, ct;
|
|
|
|
struct monst *mtmp;
|
|
|
|
char sym = ')';
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
bhitpos.x = u.ux;
|
|
|
|
bhitpos.y = u.uy;
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
if (xdir[i] == dx && ydir[i] == dy)
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
tmp_at(-1, sym); /* open call */
|
1997-10-19 20:56:41 +04:00
|
|
|
for (ct = 0; ct < 10; ct++) {
|
|
|
|
if (i == 8)
|
|
|
|
i = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
sym = ')' + '(' - sym;
|
1997-10-19 20:56:41 +04:00
|
|
|
tmp_at(-2, sym);/* change let call */
|
1993-03-21 12:45:37 +03:00
|
|
|
dx = xdir[i];
|
|
|
|
dy = ydir[i];
|
|
|
|
bhitpos.x += dx;
|
|
|
|
bhitpos.y += dy;
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != NULL) {
|
|
|
|
tmp_at(-1, -1);
|
|
|
|
return (mtmp);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
bhitpos.x -= dx;
|
|
|
|
bhitpos.y -= dy;
|
|
|
|
break;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (bhitpos.x == u.ux && bhitpos.y == u.uy) { /* ct == 9 */
|
|
|
|
if (rn2(20) >= 10 + u.ulevel) { /* we hit ourselves */
|
1993-03-21 12:45:37 +03:00
|
|
|
(void) thitu(10, rnd(10), "boomerang");
|
|
|
|
break;
|
1997-10-19 20:56:41 +04:00
|
|
|
} else {/* we catch it */
|
|
|
|
tmp_at(-1, -1);
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("Skillfully, you catch the boomerang.");
|
1997-10-19 20:56:41 +04:00
|
|
|
return (&youmonst);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
tmp_at(bhitpos.x, bhitpos.y);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (ct % 5 != 0)
|
|
|
|
i++;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
tmp_at(-1, -1); /* do not leave last symbol */
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static char
|
2009-06-07 22:30:39 +04:00
|
|
|
dirlet(int dx, int dy)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
1993-03-21 12:45:37 +03:00
|
|
|
return
|
|
|
|
(dx == dy) ? '\\' : (dx && dy) ? '/' : dx ? '-' : '|';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* type == -1: monster spitting fire at you */
|
|
|
|
/* type == -1,-2,-3: bolts sent out by wizard */
|
|
|
|
/* called with dx = dy = 0 with vertical bolts */
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
buzz(int type, xchar sx, xchar sy, int dx, int dy)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
int abstype = abs(type);
|
2001-03-26 00:43:58 +04:00
|
|
|
const char *fltxt = (type == -1) ? "blaze of fire" : fl[abstype];
|
1997-10-19 20:56:41 +04:00
|
|
|
struct rm *lev;
|
|
|
|
xchar range;
|
|
|
|
struct monst *mon;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.uswallow) {
|
|
|
|
int tmp;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (type < 0)
|
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
tmp = zhit(u.ustuck, type);
|
|
|
|
pline("The %s rips into %s%s",
|
1997-10-19 20:56:41 +04:00
|
|
|
fltxt, monnam(u.ustuck), exclam(tmp));
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (type < 0)
|
|
|
|
pru();
|
|
|
|
range = rn1(7, 7);
|
|
|
|
Tmp_at(-1, dirlet(dx, dy)); /* open call */
|
|
|
|
while (range-- > 0) {
|
1993-03-21 12:45:37 +03:00
|
|
|
sx += dx;
|
|
|
|
sy += dy;
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((lev = &levl[sx][sy])->typ)
|
|
|
|
Tmp_at(sx, sy);
|
1993-03-21 12:45:37 +03:00
|
|
|
else {
|
1997-10-19 20:56:41 +04:00
|
|
|
int bounce = 0;
|
|
|
|
if (cansee(sx - dx, sy - dy))
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("The %s bounces!", fltxt);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (ZAP_POS(levl[sx][sy - dy].typ))
|
1993-03-21 12:45:37 +03:00
|
|
|
bounce = 1;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (ZAP_POS(levl[sx - dx][sy].typ)) {
|
|
|
|
if (!bounce || rn2(2))
|
|
|
|
bounce = 2;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
switch (bounce) {
|
1993-03-21 12:45:37 +03:00
|
|
|
case 0:
|
|
|
|
dx = -dx;
|
|
|
|
dy = -dy;
|
|
|
|
continue;
|
|
|
|
case 1:
|
|
|
|
dy = -dy;
|
|
|
|
sx -= dx;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
dx = -dx;
|
|
|
|
sy -= dy;
|
|
|
|
break;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
Tmp_at(-2, dirlet(dx, dy));
|
1993-03-21 12:45:37 +03:00
|
|
|
continue;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (lev->typ == POOL && abstype == 1 /* fire */ ) {
|
1993-03-21 12:45:37 +03:00
|
|
|
range -= 3;
|
|
|
|
lev->typ = ROOM;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (cansee(sx, sy)) {
|
|
|
|
mnewsym(sx, sy);
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("The water evaporates.");
|
|
|
|
} else
|
|
|
|
pline("You hear a hissing sound.");
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((mon = m_at(sx, sy)) &&
|
|
|
|
(type != -1 || mon->data->mlet != 'D')) {
|
1993-03-21 12:45:37 +03:00
|
|
|
wakeup(mon);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (rnd(20) < 18 + mon->data->ac) {
|
|
|
|
int tmp = zhit(mon, abstype);
|
|
|
|
if (mon->mhp < 1) {
|
|
|
|
if (type < 0) {
|
|
|
|
if (cansee(mon->mx, mon->my))
|
|
|
|
pline("%s is killed by the %s!",
|
|
|
|
Monnam(mon), fltxt);
|
|
|
|
mondied(mon);
|
1993-03-21 12:45:37 +03:00
|
|
|
} else
|
1997-10-19 20:56:41 +04:00
|
|
|
killed(mon);
|
1993-03-21 12:45:37 +03:00
|
|
|
} else
|
|
|
|
hit(fltxt, mon, exclam(tmp));
|
|
|
|
range -= 2;
|
|
|
|
} else
|
1997-10-19 20:56:41 +04:00
|
|
|
miss(fltxt, mon);
|
|
|
|
} else if (sx == u.ux && sy == u.uy) {
|
1993-03-21 12:45:37 +03:00
|
|
|
nomul(0);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (rnd(20) < 18 + u.uac) {
|
|
|
|
int dam = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
range -= 2;
|
1997-10-19 20:56:41 +04:00
|
|
|
pline("The %s hits you!", fltxt);
|
|
|
|
switch (abstype) {
|
1993-03-21 12:45:37 +03:00
|
|
|
case 0:
|
1997-10-19 20:56:41 +04:00
|
|
|
dam = d(2, 6);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (Fire_resistance)
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("You don't feel hot!");
|
1997-10-19 20:56:41 +04:00
|
|
|
else
|
|
|
|
dam = d(6, 6);
|
|
|
|
if (!rn2(3))
|
1993-03-21 12:45:37 +03:00
|
|
|
burn_scrolls();
|
|
|
|
break;
|
|
|
|
case 2:
|
1997-10-19 20:56:41 +04:00
|
|
|
nomul(-rnd(25)); /* sleep ray */
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (Cold_resistance)
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("You don't feel cold!");
|
1997-10-19 20:56:41 +04:00
|
|
|
else
|
|
|
|
dam = d(6, 6);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
u.uhp = -1;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
losehp(dam, fltxt);
|
|
|
|
} else
|
|
|
|
pline("The %s whizzes by you!", fltxt);
|
1993-03-21 12:45:37 +03:00
|
|
|
stop_occupation();
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!ZAP_POS(lev->typ)) {
|
|
|
|
int bounce = 0, rmn;
|
|
|
|
if (cansee(sx, sy))
|
|
|
|
pline("The %s bounces!", fltxt);
|
1993-03-21 12:45:37 +03:00
|
|
|
range--;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!dx || !dy || !rn2(20)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
dx = -dx;
|
|
|
|
dy = -dy;
|
|
|
|
} else {
|
1997-10-19 20:56:41 +04:00
|
|
|
if (ZAP_POS(rmn = levl[sx][sy - dy].typ) &&
|
|
|
|
(IS_ROOM(rmn) || ZAP_POS(levl[sx + dx][sy - dy].typ)))
|
|
|
|
bounce = 1;
|
|
|
|
if (ZAP_POS(rmn = levl[sx - dx][sy].typ) &&
|
|
|
|
(IS_ROOM(rmn) || ZAP_POS(levl[sx - dx][sy + dy].typ)))
|
|
|
|
if (!bounce || rn2(2))
|
|
|
|
bounce = 2;
|
|
|
|
|
|
|
|
switch (bounce) {
|
|
|
|
case 0:
|
|
|
|
dy = -dy;
|
|
|
|
dx = -dx;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
dy = -dy;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
dx = -dx;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Tmp_at(-2, dirlet(dx, dy));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
Tmp_at(-1, -1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static int
|
2009-06-07 22:30:39 +04:00
|
|
|
zhit(struct monst *mon, int type) /* returns damage to mon */
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
int tmp = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
switch (type) {
|
|
|
|
case 0: /* magic missile */
|
|
|
|
tmp = d(2, 6);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case -1: /* Dragon blazing fire */
|
1997-10-19 20:56:41 +04:00
|
|
|
case 1: /* fire */
|
|
|
|
if (strchr("Dg", mon->data->mlet))
|
|
|
|
break;
|
|
|
|
tmp = d(6, 6);
|
|
|
|
if (strchr("YF", mon->data->mlet))
|
|
|
|
tmp += 7;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1997-10-19 20:56:41 +04:00
|
|
|
case 2: /* sleep */
|
1993-03-21 12:45:37 +03:00
|
|
|
mon->mfroz = 1;
|
|
|
|
break;
|
1997-10-19 20:56:41 +04:00
|
|
|
case 3: /* cold */
|
|
|
|
if (strchr("YFgf", mon->data->mlet))
|
|
|
|
break;
|
|
|
|
tmp = d(6, 6);
|
|
|
|
if (mon->data->mlet == 'D')
|
|
|
|
tmp += 7;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1997-10-19 20:56:41 +04:00
|
|
|
case 4: /* death */
|
|
|
|
if (strchr(UNDEAD, mon->data->mlet))
|
|
|
|
break;
|
|
|
|
tmp = mon->mhp + 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
mon->mhp -= tmp;
|
1997-10-19 20:56:41 +04:00
|
|
|
return (tmp);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#define CORPSE_I_TO_C(otyp) (char) ((otyp >= DEAD_ACID_BLOB)\
|
|
|
|
? 'a' + (otyp - DEAD_ACID_BLOB)\
|
|
|
|
: '@' + (otyp - DEAD_HUMAN))
|
2009-08-12 11:28:40 +04:00
|
|
|
static int
|
2009-06-07 22:30:39 +04:00
|
|
|
revive(struct obj *obj)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *mtmp = NULL;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (obj->olet == FOOD_SYM && obj->otyp > CORPSE) {
|
1993-03-21 12:45:37 +03:00
|
|
|
/* do not (yet) revive shopkeepers */
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* Note: this might conceivably produce two monsters at the
|
|
|
|
* same position - strange, but harmless
|
|
|
|
*/
|
|
|
|
mtmp = mkmon_at(CORPSE_I_TO_C(obj->otyp), obj->ox, obj->oy);
|
1993-03-21 12:45:37 +03:00
|
|
|
delobj(obj);
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
return (!!mtmp); /* TRUE if some monster created */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static void
|
2009-06-07 22:30:39 +04:00
|
|
|
rloco(struct obj *obj)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
int tx, ty, otx, oty;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
otx = obj->ox;
|
|
|
|
oty = obj->oy;
|
|
|
|
do {
|
1997-10-19 20:56:41 +04:00
|
|
|
tx = rn1(COLNO - 3, 2);
|
1993-03-21 12:45:37 +03:00
|
|
|
ty = rn2(ROWNO);
|
1997-10-19 20:56:41 +04:00
|
|
|
} while (!goodpos(tx, ty));
|
1993-03-21 12:45:37 +03:00
|
|
|
obj->ox = tx;
|
|
|
|
obj->oy = ty;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (cansee(otx, oty))
|
|
|
|
newsym(otx, oty);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2009-06-07 22:30:39 +04:00
|
|
|
/* fractured by pick-axe or wand of striking */
|
|
|
|
/* no texts here! */
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
fracture_rock(struct obj *obj)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
/* unpobj(obj); */
|
|
|
|
obj->otyp = ROCK;
|
|
|
|
obj->quan = 7 + rn2(60);
|
|
|
|
obj->owt = weight(obj);
|
|
|
|
obj->olet = WEAPON_SYM;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (cansee(obj->ox, obj->oy))
|
|
|
|
prl(obj->ox, obj->oy);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static void
|
2009-06-07 22:30:39 +04:00
|
|
|
burn_scrolls(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct obj *obj, *obj2;
|
|
|
|
int cnt = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
for (obj = invent; obj; obj = obj2) {
|
1993-03-21 12:45:37 +03:00
|
|
|
obj2 = obj->nobj;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (obj->olet == SCROLL_SYM) {
|
1993-03-21 12:45:37 +03:00
|
|
|
cnt++;
|
|
|
|
useup(obj);
|
|
|
|
}
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (cnt > 1) {
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("Your scrolls catch fire!");
|
|
|
|
losehp(cnt, "burning scrolls");
|
1997-10-19 20:56:41 +04:00
|
|
|
} else if (cnt) {
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("Your scroll catches fire!");
|
|
|
|
losehp(1, "burning scroll");
|
|
|
|
}
|
|
|
|
}
|