2011-08-07 10:03:45 +04:00
|
|
|
/* $NetBSD: hack.wizard.c,v 1.10 2011/08/07 06:03:45 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
|
2011-08-07 10:03:45 +04:00
|
|
|
__RCSID("$NetBSD: hack.wizard.c,v 1.10 2011/08/07 06:03:45 dholland Exp $");
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
|
|
|
|
|
|
|
|
#include "hack.h"
|
1997-10-19 20:56:41 +04:00
|
|
|
#include "extern.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
#define WIZSHOT 6 /* one chance in WIZSHOT that wizard will try
|
|
|
|
* magic */
|
|
|
|
#define BOLT_LIM 8 /* from this distance D and 1 will try to hit
|
|
|
|
* you */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2009-08-12 11:28:40 +04:00
|
|
|
static const char wizapp[] = "@DNPTUVXcemntx";
|
|
|
|
|
|
|
|
static void aggravate(void);
|
|
|
|
static void clonewiz(struct monst *);
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* If he has found the Amulet, make the wizard appear after some time */
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
amulet(void)
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
struct obj *otmp;
|
|
|
|
struct monst *mtmp;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!flags.made_amulet || !flags.no_of_wizards)
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
|
|
|
/* find wizard, and wake him if necessary */
|
1997-10-19 20:56:41 +04:00
|
|
|
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
|
|
|
|
if (mtmp->data->mlet == '1' && mtmp->msleep && !rn2(40))
|
|
|
|
for (otmp = invent; otmp; otmp = otmp->nobj)
|
|
|
|
if (otmp->olet == AMULET_SYM && !otmp->spe) {
|
|
|
|
mtmp->msleep = 0;
|
|
|
|
if (dist(mtmp->mx, mtmp->my) > 2)
|
|
|
|
pline(
|
|
|
|
"You get the creepy feeling that somebody noticed your taking the Amulet."
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
wiz_hit(struct monst *mtmp)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
/* if we have stolen or found the amulet, we disappear */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->minvent && mtmp->minvent->olet == AMULET_SYM &&
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->minvent->spe == 0) {
|
|
|
|
/* vanish -- very primitive */
|
|
|
|
fall_down(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
/* if it is lying around someplace, we teleport to it */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!carrying(AMULET_OF_YENDOR)) {
|
|
|
|
struct obj *otmp;
|
|
|
|
|
|
|
|
for (otmp = fobj; otmp; otmp = otmp->nobj)
|
|
|
|
if (otmp->olet == AMULET_SYM && !otmp->spe) {
|
|
|
|
if ((u.ux != otmp->ox || u.uy != otmp->oy) &&
|
|
|
|
!m_at(otmp->ox, otmp->oy)) {
|
|
|
|
|
|
|
|
/* teleport to it and pick it up */
|
|
|
|
mtmp->mx = otmp->ox;
|
|
|
|
mtmp->my = otmp->oy;
|
|
|
|
freeobj(otmp);
|
|
|
|
mpickobj(mtmp, otmp);
|
|
|
|
pmon(mtmp);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
goto hithim;
|
|
|
|
}
|
|
|
|
return (0); /* we don't know where it is */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
hithim:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (rn2(2)) { /* hit - perhaps steal */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if hit 1/20 chance of stealing amulet & vanish - amulet is
|
|
|
|
* on level 26 again.
|
|
|
|
*/
|
|
|
|
if (hitu(mtmp, d(mtmp->data->damn, mtmp->data->damd))
|
2008-01-28 09:55:41 +03:00
|
|
|
&& !rn2(20) && stealamulet(mtmp)) {
|
|
|
|
/* nothing */
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
} else
|
|
|
|
inrange(mtmp); /* try magic */
|
|
|
|
return (0);
|
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
|
|
|
inrange(struct monst *mtmp)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
schar tx, ty;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* do nothing if cancelled (but make '1' say something) */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->data->mlet != '1' && mtmp->mcan)
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* spit fire only when both in a room or both in a corridor */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (inroom(u.ux, u.uy) != inroom(mtmp->mx, mtmp->my))
|
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
tx = u.ux - mtmp->mx;
|
|
|
|
ty = u.uy - mtmp->my;
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((!tx && abs(ty) < BOLT_LIM) || (!ty && abs(tx) < BOLT_LIM)
|
|
|
|
|| (abs(tx) == abs(ty) && abs(tx) < BOLT_LIM)) {
|
|
|
|
switch (mtmp->data->mlet) {
|
|
|
|
case 'D':
|
|
|
|
/* spit fire in the direction of @ (not nec. hitting) */
|
|
|
|
buzz(-1, mtmp->mx, mtmp->my, sgn(tx), sgn(ty));
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1997-10-19 20:56:41 +04:00
|
|
|
case '1':
|
|
|
|
if (rn2(WIZSHOT))
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* if you zapped wizard with wand of cancellation, he
|
|
|
|
* has to shake off the effects before he can throw
|
|
|
|
* spells successfully. 1/2 the time they fail
|
|
|
|
* anyway
|
|
|
|
*/
|
|
|
|
if (mtmp->mcan || rn2(2)) {
|
|
|
|
if (canseemon(mtmp))
|
|
|
|
pline("%s makes a gesture, then curses.",
|
|
|
|
Monnam(mtmp));
|
|
|
|
else
|
|
|
|
pline("You hear mumbled cursing.");
|
|
|
|
if (!rn2(3)) {
|
|
|
|
mtmp->mspeed = 0;
|
|
|
|
mtmp->minvis = 0;
|
|
|
|
}
|
|
|
|
if (!rn2(3))
|
|
|
|
mtmp->mcan = 0;
|
|
|
|
} else {
|
|
|
|
if (canseemon(mtmp)) {
|
|
|
|
if (!rn2(6) && !Invis) {
|
|
|
|
pline("%s hypnotizes you.", Monnam(mtmp));
|
|
|
|
nomul(rn2(3) + 3);
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
pline("%s chants an incantation.",
|
|
|
|
Monnam(mtmp));
|
|
|
|
} else
|
|
|
|
pline("You hear a mumbled incantation.");
|
|
|
|
switch (rn2(Invis ? 5 : 6)) {
|
|
|
|
case 0:
|
|
|
|
/*
|
|
|
|
* create a nasty monster from a deep
|
|
|
|
* level
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* (for the moment, 'nasty' is not
|
|
|
|
* implemented)
|
|
|
|
*/
|
|
|
|
(void) makemon((struct permonst *) 0, u.ux, u.uy);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
pline("\"Destroy the thief, my pets!\"");
|
|
|
|
aggravate(); /* aggravate all the
|
|
|
|
* monsters */
|
2011-08-07 10:03:45 +04:00
|
|
|
/* FALLTHROUGH */
|
1997-10-19 20:56:41 +04:00
|
|
|
case 2:
|
|
|
|
if (flags.no_of_wizards == 1 && rnd(5) == 0)
|
|
|
|
/*
|
|
|
|
* if only 1 wizard, clone
|
|
|
|
* himself
|
|
|
|
*/
|
|
|
|
clonewiz(mtmp);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (mtmp->mspeed == MSLOW)
|
|
|
|
mtmp->mspeed = 0;
|
|
|
|
else
|
|
|
|
mtmp->mspeed = MFAST;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
mtmp->minvis = 1;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
/* Only if not Invisible */
|
|
|
|
pline("You hear a clap of thunder!");
|
|
|
|
/*
|
|
|
|
* shoot a bolt of fire or cold, or a
|
|
|
|
* sleep ray
|
|
|
|
*/
|
|
|
|
buzz(-rnd(3), mtmp->mx, mtmp->my, sgn(tx), sgn(ty));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.uhp < 1)
|
|
|
|
done_in_by(mtmp);
|
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
|
|
|
aggravate(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *mtmp;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->msleep = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mfroz && !rn2(5))
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mfroz = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
2009-06-07 22:30:39 +04:00
|
|
|
clonewiz(struct monst *mtmp)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *mtmp2;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((mtmp2 = makemon(PM_WIZARD, mtmp->mx, mtmp->my)) != NULL) {
|
1993-03-21 12:45:37 +03:00
|
|
|
flags.no_of_wizards = 2;
|
|
|
|
unpmon(mtmp2);
|
1997-10-19 20:56:41 +04:00
|
|
|
mtmp2->mappearance = wizapp[rn2(sizeof(wizapp) - 1)];
|
1993-03-21 12:45:37 +03:00
|
|
|
pmon(mtmp);
|
|
|
|
}
|
|
|
|
}
|