1997-10-19 20:56:41 +04:00
|
|
|
/* $NetBSD: hack.mon.c,v 1.4 1997/10/19 16:58:34 christos Exp $ */
|
|
|
|
|
1993-08-02 21:16:36 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
|
|
|
|
*/
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-08-02 21:16:36 +04:00
|
|
|
#ifndef lint
|
1997-10-19 20:56:41 +04:00
|
|
|
__RCSID("$NetBSD: hack.mon.c,v 1.4 1997/10/19 16:58:34 christos Exp $");
|
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
#include <stdlib.h>
|
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
|
|
|
#include "hack.mfndpos.h"
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL (char *) 0
|
|
|
|
#endif
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int warnlevel; /* used by movemon and dochugw */
|
|
|
|
long lastwarntime;
|
|
|
|
int lastwarnlev;
|
|
|
|
char *warnings[] = {
|
1993-03-21 12:45:37 +03:00
|
|
|
"white", "pink", "red", "ruby", "purple", "black"
|
|
|
|
};
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
movemon()
|
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *mtmp;
|
|
|
|
int fr;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
warnlevel = 0;
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
while (1) {
|
1993-03-21 12:45:37 +03:00
|
|
|
/* find a monster that we haven't treated yet */
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* note that mtmp or mtmp->nmon might get killed while mtmp
|
|
|
|
* moves, so we cannot just walk down the chain (even new
|
|
|
|
* monsters might get created!)
|
|
|
|
*/
|
|
|
|
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
|
|
|
|
if (mtmp->mlstmv < moves)
|
|
|
|
goto next_mon;
|
1993-03-21 12:45:37 +03:00
|
|
|
/* treated all monsters */
|
|
|
|
break;
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
next_mon:
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mlstmv = moves;
|
|
|
|
|
|
|
|
/* most monsters drown in pools */
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
boolean inpool, iseel;
|
|
|
|
|
|
|
|
inpool = (levl[mtmp->mx][mtmp->my].typ == POOL);
|
|
|
|
iseel = (mtmp->data->mlet == ';');
|
|
|
|
if (inpool && !iseel) {
|
|
|
|
if (cansee(mtmp->mx, mtmp->my))
|
|
|
|
pline("%s drowns.", Monnam(mtmp));
|
|
|
|
mondead(mtmp);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* but eels have a difficult time outside */
|
|
|
|
if (iseel && !inpool) {
|
|
|
|
if (mtmp->mhp > 1)
|
|
|
|
mtmp->mhp--;
|
|
|
|
mtmp->mflee = 1;
|
|
|
|
mtmp->mfleetim += 2;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mblinded && !--mtmp->mblinded)
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mcansee = 1;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mfleetim && !--mtmp->mfleetim)
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mflee = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mimic)
|
|
|
|
continue;
|
|
|
|
if (mtmp->mspeed != MSLOW || !(moves % 2)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
/* continue if the monster died fighting */
|
|
|
|
fr = -1;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (Conflict && cansee(mtmp->mx, mtmp->my)
|
|
|
|
&& (fr = fightm(mtmp)) == 2)
|
1993-03-21 12:45:37 +03:00
|
|
|
continue;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (fr < 0 && dochugw(mtmp))
|
1993-03-21 12:45:37 +03:00
|
|
|
continue;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mspeed == MFAST && dochugw(mtmp))
|
1993-03-21 12:45:37 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
warnlevel -= u.ulevel;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (warnlevel >= SIZE(warnings))
|
|
|
|
warnlevel = SIZE(warnings) - 1;
|
|
|
|
if (warnlevel >= 0)
|
|
|
|
if (warnlevel > lastwarnlev || moves > lastwarntime + 5) {
|
|
|
|
char *rr;
|
|
|
|
switch (Warning & (LEFT_RING | RIGHT_RING)) {
|
|
|
|
case LEFT_RING:
|
|
|
|
rr = "Your left ring glows";
|
|
|
|
break;
|
|
|
|
case RIGHT_RING:
|
|
|
|
rr = "Your right ring glows";
|
|
|
|
break;
|
|
|
|
case LEFT_RING | RIGHT_RING:
|
|
|
|
rr = "Both your rings glow";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rr = "Your fingertips glow";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pline("%s %s!", rr, warnings[warnlevel]);
|
|
|
|
lastwarntime = moves;
|
|
|
|
lastwarnlev = warnlevel;
|
|
|
|
}
|
|
|
|
dmonsfree(); /* remove all dead monsters */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
justswld(mtmp, name)
|
|
|
|
struct monst *mtmp;
|
|
|
|
char *name;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
mtmp->mx = u.ux;
|
|
|
|
mtmp->my = u.uy;
|
|
|
|
u.ustuck = mtmp;
|
|
|
|
pmon(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
kludge("%s swallows you!", name);
|
1993-03-21 12:45:37 +03:00
|
|
|
more();
|
|
|
|
seeoff(1);
|
|
|
|
u.uswallow = 1;
|
|
|
|
u.uswldtim = 0;
|
|
|
|
swallowed();
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
youswld(mtmp, dam, die, name)
|
|
|
|
struct monst *mtmp;
|
|
|
|
int dam, die;
|
|
|
|
char *name;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp != u.ustuck)
|
|
|
|
return;
|
|
|
|
kludge("%s digests you!", name);
|
1993-03-21 12:45:37 +03:00
|
|
|
u.uhp -= dam;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.uswldtim++ >= die) { /* a3 */
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("It totally digests you!");
|
|
|
|
u.uhp = -1;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.uhp < 1)
|
|
|
|
done_in_by(mtmp);
|
|
|
|
#if 0
|
|
|
|
flags.botlx = 1; /* should we show status line ? */
|
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
|
|
|
dochugw(mtmp)
|
|
|
|
struct monst *mtmp;
|
|
|
|
{
|
|
|
|
int x = mtmp->mx;
|
|
|
|
int y = mtmp->my;
|
|
|
|
int d = dochug(mtmp);
|
|
|
|
int dd;
|
|
|
|
if (!d) /* monster still alive */
|
|
|
|
if (Warning)
|
|
|
|
if (!mtmp->mpeaceful)
|
|
|
|
if (mtmp->data->mlevel > warnlevel)
|
|
|
|
if ((dd = dist(mtmp->mx, mtmp->my)) < dist(x, y))
|
|
|
|
if (dd < 100)
|
|
|
|
if (!canseemon(mtmp))
|
|
|
|
warnlevel = mtmp->data->mlevel;
|
|
|
|
return (d);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* returns 1 if monster died moving, 0 otherwise */
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
dochug(mtmp)
|
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
|
|
|
struct permonst *mdat;
|
|
|
|
int tmp = 0, nearby, scared;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->cham && !rn2(6))
|
|
|
|
(void) newcham(mtmp, &mons[dlevel + 14 + rn2(CMNUM - 14 - dlevel)]);
|
1993-03-21 12:45:37 +03:00
|
|
|
mdat = mtmp->data;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mdat->mlevel < 0)
|
|
|
|
panic("bad monster %c (%d)", mdat->mlet, mdat->mlevel);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* regenerate monsters */
|
1997-10-19 20:56:41 +04:00
|
|
|
if ((!(moves % 20) || strchr(MREGEN, mdat->mlet)) &&
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mhp < mtmp->mhpmax)
|
|
|
|
mtmp->mhp++;
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mfroz)
|
|
|
|
return (0); /* frozen monsters don't do anything */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->msleep) {
|
1993-03-21 12:45:37 +03:00
|
|
|
/* wake up, or get out of here. */
|
|
|
|
/* ettins are hard to surprise */
|
|
|
|
/* Nymphs and Leprechauns do not easily wake up */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (cansee(mtmp->mx, mtmp->my) &&
|
|
|
|
(!Stealth || (mdat->mlet == 'e' && rn2(10))) &&
|
|
|
|
(!strchr("NL", mdat->mlet) || !rn2(50)) &&
|
|
|
|
(Aggravate_monster || strchr("d1", mdat->mlet)
|
|
|
|
|| (!rn2(7) && !mtmp->mimic)))
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->msleep = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
else
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
/* not frozen or sleeping: wipe out texts written in the dust */
|
|
|
|
wipe_engr_at(mtmp->mx, mtmp->my, 1);
|
|
|
|
|
|
|
|
/* confused monsters get unconfused with small probability */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mconf && !rn2(50))
|
|
|
|
mtmp->mconf = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* some monsters teleport */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mflee && strchr("tNL", mdat->mlet) && !rn2(40)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
rloc(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mdat->mmove < rnd(6))
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* fleeing monsters might regain courage */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mflee && !mtmp->mfleetim
|
1993-03-21 12:45:37 +03:00
|
|
|
&& mtmp->mhp == mtmp->mhpmax && !rn2(25))
|
|
|
|
mtmp->mflee = 0;
|
|
|
|
|
|
|
|
nearby = (dist(mtmp->mx, mtmp->my) < 3);
|
|
|
|
scared = (nearby && (sengr_at("Elbereth", u.ux, u.uy) ||
|
1997-10-19 20:56:41 +04:00
|
|
|
sobj_at(SCR_SCARE_MONSTER, u.ux, u.uy)));
|
|
|
|
if (scared && !mtmp->mflee) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mflee = 1;
|
|
|
|
mtmp->mfleetim = (rn2(7) ? rnd(10) : rnd(100));
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!nearby ||
|
|
|
|
mtmp->mflee ||
|
|
|
|
mtmp->mconf ||
|
|
|
|
(mtmp->minvis && !rn2(3)) ||
|
|
|
|
(strchr("BIuy", mdat->mlet) && !rn2(4)) ||
|
|
|
|
(mdat->mlet == 'L' && !u.ugold && (mtmp->mgold || rn2(2))) ||
|
|
|
|
(!mtmp->mcansee && !rn2(4)) ||
|
|
|
|
mtmp->mpeaceful
|
|
|
|
) {
|
|
|
|
tmp = m_move(mtmp, 0); /* 2: monster died moving */
|
|
|
|
if (tmp == 2 || (tmp && mdat->mmove <= 12))
|
|
|
|
return (tmp == 2);
|
|
|
|
}
|
|
|
|
if (!strchr("Ea", mdat->mlet) && nearby &&
|
|
|
|
!mtmp->mpeaceful && u.uhp > 0 && !scared) {
|
|
|
|
if (mhitu(mtmp))
|
|
|
|
return (1); /* monster died (e.g. 'y' or 'F') */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
/* extra movement for fast monsters */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mdat->mmove - 12 > rnd(12))
|
|
|
|
tmp = m_move(mtmp, 1);
|
|
|
|
return (tmp == 2);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
|
|
|
m_move(mtmp, after)
|
|
|
|
struct monst *mtmp;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *mtmp2;
|
|
|
|
int nx, ny, omx, omy, appr, nearer, cnt, i, j;
|
|
|
|
xchar gx, gy, nix, niy, chcnt;
|
|
|
|
schar chi;
|
|
|
|
boolean likegold = 0, likegems = 0, likeobjs = 0;
|
|
|
|
char msym = mtmp->data->mlet;
|
|
|
|
schar mmoved = 0; /* not strictly nec.: chi >= 0 will
|
|
|
|
* do */
|
|
|
|
coord poss[9];
|
|
|
|
int info[9];
|
|
|
|
|
|
|
|
if (mtmp->mfroz || mtmp->msleep)
|
|
|
|
return (0);
|
|
|
|
if (mtmp->mtrapped) {
|
1993-03-21 12:45:37 +03:00
|
|
|
i = mintrap(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (i == 2)
|
|
|
|
return (2); /* he died */
|
|
|
|
if (i == 1)
|
|
|
|
return (0); /* still in trap, so didnt move */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mhide && o_at(mtmp->mx, mtmp->my) && rn2(10))
|
|
|
|
return (0); /* do not leave hiding place */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#ifndef NOWORM
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->wormno)
|
1993-03-21 12:45:37 +03:00
|
|
|
goto not_special;
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* NOWORM */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* my dog gets a special treatment */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mtame) {
|
|
|
|
return (dog_move(mtmp, after));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
/* likewise for shopkeeper */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->isshk) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mmoved = shk_move(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mmoved >= 0)
|
1993-03-21 12:45:37 +03:00
|
|
|
goto postmov;
|
1997-10-19 20:56:41 +04:00
|
|
|
mmoved = 0; /* follow player outside shop */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
/* and for the guard */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->isgd) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mmoved = gd_move();
|
|
|
|
goto postmov;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* teleport if that lies in our nature ('t') or when badly wounded
|
|
|
|
* ('1')
|
|
|
|
*/
|
|
|
|
if ((msym == 't' && !rn2(5))
|
|
|
|
|| (msym == '1' && (mtmp->mhp < 7 || (!xdnstair && !rn2(5))
|
|
|
|
|| levl[u.ux][u.uy].typ == STAIRS))) {
|
|
|
|
if (mtmp->mhp < 7 || (msym == 't' && rn2(2)))
|
1993-03-21 12:45:37 +03:00
|
|
|
rloc(mtmp);
|
|
|
|
else
|
|
|
|
mnexto(mtmp);
|
|
|
|
mmoved = 1;
|
|
|
|
goto postmov;
|
|
|
|
}
|
|
|
|
/* spit fire ('D') or use a wand ('1') when appropriate */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (strchr("D1", msym))
|
1993-03-21 12:45:37 +03:00
|
|
|
inrange(mtmp);
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (msym == 'U' && !mtmp->mcan && canseemon(mtmp) &&
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mcansee && rn2(5)) {
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!Confusion)
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("%s's gaze has confused you!", Monnam(mtmp));
|
|
|
|
else
|
|
|
|
pline("You are getting more and more confused.");
|
1997-10-19 20:56:41 +04:00
|
|
|
if (rn2(3))
|
|
|
|
mtmp->mcan = 1;
|
|
|
|
Confusion += d(3, 4); /* timeout */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
not_special:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (!mtmp->mflee && u.uswallow && u.ustuck != mtmp)
|
|
|
|
return (1);
|
1993-03-21 12:45:37 +03:00
|
|
|
appr = 1;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->mflee)
|
|
|
|
appr = -1;
|
|
|
|
if (mtmp->mconf || Invis || !mtmp->mcansee ||
|
|
|
|
(strchr("BIy", msym) && !rn2(3)))
|
1993-03-21 12:45:37 +03:00
|
|
|
appr = 0;
|
|
|
|
omx = mtmp->mx;
|
|
|
|
omy = mtmp->my;
|
|
|
|
gx = u.ux;
|
|
|
|
gy = u.uy;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (msym == 'L' && appr == 1 && mtmp->mgold > u.ugold)
|
1993-03-21 12:45:37 +03:00
|
|
|
appr = -1;
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* random criterion for 'smell' or track finding ability should use
|
|
|
|
* mtmp->msmell or sth
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1997-10-19 20:56:41 +04:00
|
|
|
if (msym == '@' ||
|
|
|
|
('a' <= msym && msym <= 'z')) {
|
|
|
|
coord *cp;
|
|
|
|
schar mroom;
|
|
|
|
mroom = inroom(omx, omy);
|
|
|
|
if (mroom < 0 || mroom != inroom(u.ux, u.uy)) {
|
|
|
|
cp = gettrack(omx, omy);
|
|
|
|
if (cp) {
|
|
|
|
gx = cp->x;
|
|
|
|
gy = cp->y;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* look for gold or jewels nearby */
|
1997-10-19 20:56:41 +04:00
|
|
|
likegold = (strchr("LOD", msym) != NULL);
|
|
|
|
likegems = (strchr("ODu", msym) != NULL);
|
1993-03-21 12:45:37 +03:00
|
|
|
likeobjs = mtmp->mhide;
|
|
|
|
#define SRCHRADIUS 25
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
xchar mind = SRCHRADIUS; /* not too far away */
|
|
|
|
int dd;
|
|
|
|
if (likegold) {
|
|
|
|
struct gold *gold;
|
|
|
|
for (gold = fgold; gold; gold = gold->ngold)
|
|
|
|
if ((dd = DIST(omx, omy, gold->gx, gold->gy)) < mind) {
|
|
|
|
mind = dd;
|
|
|
|
gx = gold->gx;
|
|
|
|
gy = gold->gy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (likegems || likeobjs) {
|
|
|
|
struct obj *otmp;
|
|
|
|
for (otmp = fobj; otmp; otmp = otmp->nobj)
|
|
|
|
if (likeobjs || otmp->olet == GEM_SYM)
|
|
|
|
if (msym != 'u' ||
|
|
|
|
objects[otmp->otyp].g_val != 0)
|
|
|
|
if ((dd = DIST(omx, omy, otmp->ox, otmp->oy)) < mind) {
|
|
|
|
mind = dd;
|
|
|
|
gx = otmp->ox;
|
|
|
|
gy = otmp->oy;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mind < SRCHRADIUS && appr == -1) {
|
|
|
|
if (dist(omx, omy) < 10) {
|
|
|
|
gx = u.ux;
|
|
|
|
gy = u.uy;
|
|
|
|
} else
|
|
|
|
appr = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
nix = omx;
|
|
|
|
niy = omy;
|
1997-10-19 20:56:41 +04:00
|
|
|
cnt = mfndpos(mtmp, poss, info,
|
|
|
|
msym == 'u' ? NOTONL :
|
|
|
|
(msym == '@' || msym == '1') ? (ALLOW_SSM | ALLOW_TRAPS) :
|
|
|
|
strchr(UNDEAD, msym) ? NOGARLIC : ALLOW_TRAPS);
|
|
|
|
/* ALLOW_ROCK for some monsters ? */
|
1993-03-21 12:45:37 +03:00
|
|
|
chcnt = 0;
|
|
|
|
chi = -1;
|
1997-10-19 20:56:41 +04:00
|
|
|
for (i = 0; i < cnt; i++) {
|
1993-03-21 12:45:37 +03:00
|
|
|
nx = poss[i].x;
|
|
|
|
ny = poss[i].y;
|
1997-10-19 20:56:41 +04:00
|
|
|
for (j = 0; j < MTSZ && j < cnt - 1; j++)
|
|
|
|
if (nx == mtmp->mtrack[j].x && ny == mtmp->mtrack[j].y)
|
|
|
|
if (rn2(4 * (cnt - j)))
|
|
|
|
goto nxti;
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifdef STUPID
|
|
|
|
/* some stupid compilers think that this is too complicated */
|
1997-10-19 20:56:41 +04:00
|
|
|
{
|
|
|
|
int d1 = DIST(nx, ny, gx, gy);
|
|
|
|
int d2 = DIST(nix, niy, gx, gy);
|
|
|
|
nearer = (d1 < d2);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
#else
|
1997-10-19 20:56:41 +04:00
|
|
|
nearer = (DIST(nx, ny, gx, gy) < DIST(nix, niy, gx, gy));
|
|
|
|
#endif /* STUPID */
|
|
|
|
if ((appr == 1 && nearer) || (appr == -1 && !nearer) ||
|
|
|
|
!mmoved ||
|
|
|
|
(!appr && !rn2(++chcnt))) {
|
1993-03-21 12:45:37 +03:00
|
|
|
nix = nx;
|
|
|
|
niy = ny;
|
|
|
|
chi = i;
|
|
|
|
mmoved = 1;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
nxti: ;
|
|
|
|
}
|
|
|
|
if (mmoved) {
|
|
|
|
if (info[chi] & ALLOW_M) {
|
|
|
|
mtmp2 = m_at(nix, niy);
|
|
|
|
if (hitmm(mtmp, mtmp2) == 1 && rn2(4) &&
|
|
|
|
hitmm(mtmp2, mtmp) == 2)
|
|
|
|
return (2);
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (info[chi] & ALLOW_U) {
|
|
|
|
(void) hitu(mtmp, d(mtmp->data->damn, mtmp->data->damd) + 1);
|
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
mtmp->mx = nix;
|
|
|
|
mtmp->my = niy;
|
1997-10-19 20:56:41 +04:00
|
|
|
for (j = MTSZ - 1; j > 0; j--)
|
|
|
|
mtmp->mtrack[j] = mtmp->mtrack[j - 1];
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mtrack[0].x = omx;
|
|
|
|
mtmp->mtrack[0].y = omy;
|
|
|
|
#ifndef NOWORM
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->wormno)
|
|
|
|
worm_move(mtmp);
|
|
|
|
#endif /* NOWORM */
|
1993-03-21 12:45:37 +03:00
|
|
|
} else {
|
1997-10-19 20:56:41 +04:00
|
|
|
if (msym == 'u' && rn2(2)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
rloc(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
#ifndef NOWORM
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->wormno)
|
|
|
|
worm_nomove(mtmp);
|
|
|
|
#endif /* NOWORM */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
postmov:
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mmoved == 1) {
|
|
|
|
if (mintrap(mtmp) == 2) /* he died */
|
|
|
|
return (2);
|
|
|
|
if (likegold)
|
|
|
|
mpickgold(mtmp);
|
|
|
|
if (likegems)
|
|
|
|
mpickgems(mtmp);
|
|
|
|
if (mtmp->mhide)
|
|
|
|
mtmp->mundetected = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
pmon(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
return (mmoved);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
mpickgold(mtmp)
|
|
|
|
struct monst *mtmp;
|
|
|
|
{
|
|
|
|
struct gold *gold;
|
|
|
|
while ((gold = g_at(mtmp->mx, mtmp->my)) != NULL) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mgold += gold->amount;
|
|
|
|
freegold(gold);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (levl[mtmp->mx][mtmp->my].scrsym == '$')
|
1993-03-21 12:45:37 +03:00
|
|
|
newsym(mtmp->mx, mtmp->my);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
mpickgems(mtmp)
|
|
|
|
struct monst *mtmp;
|
|
|
|
{
|
|
|
|
struct obj *otmp;
|
|
|
|
for (otmp = fobj; otmp; otmp = otmp->nobj)
|
|
|
|
if (otmp->olet == GEM_SYM)
|
|
|
|
if (otmp->ox == mtmp->mx && otmp->oy == mtmp->my)
|
|
|
|
if (mtmp->data->mlet != 'u' || objects[otmp->otyp].g_val != 0) {
|
|
|
|
freeobj(otmp);
|
|
|
|
mpickobj(mtmp, otmp);
|
|
|
|
if (levl[mtmp->mx][mtmp->my].scrsym == GEM_SYM)
|
|
|
|
newsym(mtmp->mx, mtmp->my); /* %% */
|
|
|
|
return; /* pick only one object */
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return number of acceptable neighbour positions */
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
|
|
|
mfndpos(mon, poss, info, flag)
|
|
|
|
struct monst *mon;
|
|
|
|
coord poss[9];
|
|
|
|
int info[9], flag;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
int x, y, nx, ny, cnt = 0, ntyp;
|
|
|
|
struct monst *mtmp;
|
|
|
|
int nowtyp;
|
|
|
|
boolean pool;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
x = mon->mx;
|
|
|
|
y = mon->my;
|
|
|
|
nowtyp = levl[x][y].typ;
|
|
|
|
|
|
|
|
pool = (mon->data->mlet == ';');
|
1997-10-19 20:56:41 +04:00
|
|
|
nexttry: /* eels prefer the water, but if there is no
|
|
|
|
* water nearby, they will crawl over land */
|
|
|
|
if (mon->mconf) {
|
1993-03-21 12:45:37 +03:00
|
|
|
flag |= ALLOW_ALL;
|
|
|
|
flag &= ~NOTONL;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
for (nx = x - 1; nx <= x + 1; nx++)
|
|
|
|
for (ny = y - 1; ny <= y + 1; ny++)
|
|
|
|
if (nx != x || ny != y)
|
|
|
|
if (isok(nx, ny))
|
|
|
|
if (!IS_ROCK(ntyp = levl[nx][ny].typ))
|
|
|
|
if (!(nx != x && ny != y && (nowtyp == DOOR || ntyp == DOOR)))
|
|
|
|
if ((ntyp == POOL) == pool) {
|
|
|
|
info[cnt] = 0;
|
|
|
|
if (nx == u.ux && ny == u.uy) {
|
|
|
|
if (!(flag & ALLOW_U))
|
|
|
|
continue;
|
|
|
|
info[cnt] = ALLOW_U;
|
|
|
|
} else if ((mtmp = m_at(nx, ny)) != NULL) {
|
|
|
|
if (!(flag & ALLOW_M))
|
|
|
|
continue;
|
|
|
|
info[cnt] = ALLOW_M;
|
|
|
|
if (mtmp->mtame) {
|
|
|
|
if (!(flag & ALLOW_TM))
|
|
|
|
continue;
|
|
|
|
info[cnt] |= ALLOW_TM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sobj_at(CLOVE_OF_GARLIC, nx, ny)) {
|
|
|
|
if (flag & NOGARLIC)
|
|
|
|
continue;
|
|
|
|
info[cnt] |= NOGARLIC;
|
|
|
|
}
|
|
|
|
if (sobj_at(SCR_SCARE_MONSTER, nx, ny) ||
|
|
|
|
(!mon->mpeaceful && sengr_at("Elbereth", nx, ny))) {
|
|
|
|
if (!(flag & ALLOW_SSM))
|
|
|
|
continue;
|
|
|
|
info[cnt] |= ALLOW_SSM;
|
|
|
|
}
|
|
|
|
if (sobj_at(ENORMOUS_ROCK, nx, ny)) {
|
|
|
|
if (!(flag & ALLOW_ROCK))
|
|
|
|
continue;
|
|
|
|
info[cnt] |= ALLOW_ROCK;
|
|
|
|
}
|
|
|
|
if (!Invis && online(nx, ny)) {
|
|
|
|
if (flag & NOTONL)
|
|
|
|
continue;
|
|
|
|
info[cnt] |= NOTONL;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* we cannot
|
|
|
|
* avoid
|
|
|
|
* traps of
|
|
|
|
* an unknown
|
|
|
|
* kind
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
struct trap *ttmp = t_at(nx, ny);
|
|
|
|
int tt;
|
|
|
|
if (ttmp) {
|
|
|
|
tt = 1 << ttmp->ttyp;
|
|
|
|
if (mon->mtrapseen & tt) {
|
|
|
|
if (!(flag & tt))
|
|
|
|
continue;
|
|
|
|
info[cnt] |= tt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
poss[cnt].x = nx;
|
|
|
|
poss[cnt].y = ny;
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
if (!cnt && pool && nowtyp != POOL) {
|
1993-03-21 12:45:37 +03:00
|
|
|
pool = FALSE;
|
|
|
|
goto nexttry;
|
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
return (cnt);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
|
|
|
dist(x, y)
|
|
|
|
int x, y;
|
|
|
|
{
|
|
|
|
return ((x - u.ux) * (x - u.ux) + (y - u.uy) * (y - u.uy));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
poisoned(string, pname)
|
1997-10-19 20:56:41 +04:00
|
|
|
char *string, *pname;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
int i;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (Blind)
|
|
|
|
pline("It was poisoned.");
|
|
|
|
else
|
|
|
|
pline("The %s was poisoned!", string);
|
|
|
|
if (Poison_resistance) {
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("The poison doesn't seem to affect you.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
i = rn2(10);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (i == 0) {
|
1993-03-21 12:45:37 +03:00
|
|
|
u.uhp = -1;
|
|
|
|
pline("I am afraid the poison was deadly ...");
|
1997-10-19 20:56:41 +04:00
|
|
|
} else if (i <= 5) {
|
|
|
|
losestr(rn1(3, 3));
|
1993-03-21 12:45:37 +03:00
|
|
|
} else {
|
1997-10-19 20:56:41 +04:00
|
|
|
losehp(rn1(10, 6), pname);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.uhp < 1) {
|
1993-03-21 12:45:37 +03:00
|
|
|
killer = pname;
|
|
|
|
done("died");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
mondead(mtmp)
|
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
|
|
|
relobj(mtmp, 1);
|
1993-03-21 12:45:37 +03:00
|
|
|
unpmon(mtmp);
|
|
|
|
relmon(mtmp);
|
|
|
|
unstuck(mtmp);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->isshk)
|
|
|
|
shkdead(mtmp);
|
|
|
|
if (mtmp->isgd)
|
|
|
|
gddead();
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef NOWORM
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->wormno)
|
|
|
|
wormdead(mtmp);
|
|
|
|
#endif /* NOWORM */
|
1993-03-21 12:45:37 +03:00
|
|
|
monfree(mtmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* called when monster is moved to larger structure */
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
replmon(mtmp, mtmp2)
|
|
|
|
struct monst *mtmp, *mtmp2;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
relmon(mtmp);
|
|
|
|
monfree(mtmp);
|
|
|
|
mtmp2->nmon = fmon;
|
|
|
|
fmon = mtmp2;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.ustuck == mtmp)
|
|
|
|
u.ustuck = mtmp2;
|
|
|
|
if (mtmp2->isshk)
|
|
|
|
replshk(mtmp, mtmp2);
|
|
|
|
if (mtmp2->isgd)
|
|
|
|
replgd(mtmp, mtmp2);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
relmon(mon)
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *mon;
|
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
|
|
|
if (mon == fmon)
|
|
|
|
fmon = fmon->nmon;
|
1993-03-21 12:45:37 +03:00
|
|
|
else {
|
1997-10-19 20:56:41 +04:00
|
|
|
for (mtmp = fmon; mtmp->nmon != mon; mtmp = mtmp->nmon);
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->nmon = mon->nmon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* we do not free monsters immediately, in order to have their name available
|
|
|
|
* shortly after their demise
|
|
|
|
*/
|
|
|
|
struct monst *fdmon; /* chain of dead monsters, need not to be
|
|
|
|
* saved */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
monfree(mtmp)
|
|
|
|
struct monst *mtmp;
|
|
|
|
{
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->nmon = fdmon;
|
|
|
|
fdmon = mtmp;
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
dmonsfree()
|
|
|
|
{
|
|
|
|
struct monst *mtmp;
|
|
|
|
while ((mtmp = fdmon) != NULL) {
|
1993-03-21 12:45:37 +03:00
|
|
|
fdmon = mtmp->nmon;
|
|
|
|
free((char *) mtmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
unstuck(mtmp)
|
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
|
|
|
if (u.ustuck == mtmp) {
|
|
|
|
if (u.uswallow) {
|
1993-03-21 12:45:37 +03:00
|
|
|
u.ux = mtmp->mx;
|
|
|
|
u.uy = mtmp->my;
|
|
|
|
u.uswallow = 0;
|
|
|
|
setsee();
|
|
|
|
docrt();
|
|
|
|
}
|
|
|
|
u.ustuck = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
1993-03-21 12:45:37 +03:00
|
|
|
killed(mtmp)
|
1997-10-19 20:56:41 +04:00
|
|
|
struct monst *mtmp;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
#ifdef lint
|
|
|
|
#define NEW_SCORING
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* lint */
|
|
|
|
int tmp, nk, x, y;
|
|
|
|
struct permonst *mdat;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->cham)
|
|
|
|
mtmp->data = PM_CHAMELEON;
|
1993-03-21 12:45:37 +03:00
|
|
|
mdat = mtmp->data;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (Blind)
|
|
|
|
pline("You destroy it!");
|
1993-03-21 12:45:37 +03:00
|
|
|
else {
|
|
|
|
pline("You destroy %s!",
|
1997-10-19 20:56:41 +04:00
|
|
|
mtmp->mtame ? amonnam(mtmp, "poor") : monnam(mtmp));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-19 20:56:41 +04:00
|
|
|
if (u.umconf) {
|
|
|
|
if (!Blind)
|
|
|
|
pline("Your hands stop glowing blue.");
|
1993-03-21 12:45:37 +03:00
|
|
|
u.umconf = 0;
|
|
|
|
}
|
|
|
|
/* count killed monsters */
|
|
|
|
#define MAXMONNO 100
|
1997-10-19 20:56:41 +04:00
|
|
|
nk = 1; /* in case we cannot find it in mons */
|
|
|
|
tmp = mdat - mons; /* strchr in mons array (if not 'd', '@', ...) */
|
|
|
|
if (tmp >= 0 && tmp < CMNUM + 2) {
|
|
|
|
u.nr_killed[tmp]++;
|
|
|
|
if ((nk = u.nr_killed[tmp]) > MAXMONNO &&
|
|
|
|
!strchr(fut_geno, mdat->mlet))
|
|
|
|
charcat(fut_geno, mdat->mlet);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
/* punish bad behaviour */
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mdat->mlet == '@')
|
|
|
|
Telepat = 0, u.uluck -= 2;
|
|
|
|
if (mtmp->mpeaceful || mtmp->mtame)
|
|
|
|
u.uluck--;
|
|
|
|
if (mdat->mlet == 'u')
|
|
|
|
u.uluck -= 5;
|
|
|
|
if ((int) u.uluck < LUCKMIN)
|
|
|
|
u.uluck = LUCKMIN;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* give experience points */
|
|
|
|
tmp = 1 + mdat->mlevel * mdat->mlevel;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mdat->ac < 3)
|
|
|
|
tmp += 2 * (7 - mdat->ac);
|
|
|
|
if (strchr("AcsSDXaeRTVWU&In:P", mdat->mlet))
|
|
|
|
tmp += 2 * mdat->mlevel;
|
|
|
|
if (strchr("DeV&P", mdat->mlet))
|
|
|
|
tmp += (7 * mdat->mlevel);
|
|
|
|
if (mdat->mlevel > 6)
|
|
|
|
tmp += 50;
|
|
|
|
if (mdat->mlet == ';')
|
|
|
|
tmp += 1000;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#ifdef NEW_SCORING
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* ------- recent addition: make nr of points decrease when this is
|
|
|
|
* not the first of this kind
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
int ul = u.ulevel;
|
|
|
|
int ml = mdat->mlevel;
|
|
|
|
|
|
|
|
if (ul < 14) /* points are given based on present and
|
|
|
|
* future level */
|
|
|
|
for (tmp2 = 0; !tmp2 || ul + tmp2 <= ml; tmp2++)
|
|
|
|
if (u.uexp + 1 + (tmp + ((tmp2 <= 0) ? 0 : 4 << (tmp2 - 1))) / nk
|
|
|
|
>= 10 * pow((unsigned) (ul - 1)))
|
|
|
|
if (++ul == 14)
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp2 = ml - ul - 1;
|
|
|
|
tmp = (tmp + ((tmp2 < 0) ? 0 : 4 << tmp2)) / nk;
|
|
|
|
if (!tmp)
|
|
|
|
tmp = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
/* note: ul is not necessarily the future value of u.ulevel */
|
|
|
|
/* ------- end of recent valuation change ------- */
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* NEW_SCORING */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
more_experienced(tmp, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
flags.botl = 1;
|
1997-10-19 20:56:41 +04:00
|
|
|
while (u.ulevel < 14 && u.uexp >= newuexp()) {
|
1993-03-21 12:45:37 +03:00
|
|
|
pline("Welcome to experience level %u.", ++u.ulevel);
|
|
|
|
tmp = rnd(10);
|
1997-10-19 20:56:41 +04:00
|
|
|
if (tmp < 3)
|
|
|
|
tmp = rnd(10);
|
1993-03-21 12:45:37 +03:00
|
|
|
u.uhpmax += tmp;
|
|
|
|
u.uhp += tmp;
|
|
|
|
flags.botl = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dispose of monster and make cadaver */
|
1997-10-19 20:56:41 +04:00
|
|
|
x = mtmp->mx;
|
|
|
|
y = mtmp->my;
|
1993-03-21 12:45:37 +03:00
|
|
|
mondead(mtmp);
|
|
|
|
tmp = mdat->mlet;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (tmp == 'm') { /* he killed a minotaur, give him a wand of
|
|
|
|
* digging */
|
|
|
|
/* note: the dead minotaur will be on top of it! */
|
1993-03-21 12:45:37 +03:00
|
|
|
mksobj_at(WAN_DIGGING, x, y);
|
|
|
|
/* if(cansee(x,y)) atl(x,y,fobj->olet); */
|
|
|
|
stackobj(fobj);
|
|
|
|
} else
|
|
|
|
#ifndef NOWORM
|
1997-10-19 20:56:41 +04:00
|
|
|
if (tmp == 'w') {
|
1993-03-21 12:45:37 +03:00
|
|
|
mksobj_at(WORM_TOOTH, x, y);
|
|
|
|
stackobj(fobj);
|
|
|
|
} else
|
1997-10-19 20:56:41 +04:00
|
|
|
#endif /* NOWORM */
|
|
|
|
if (!letter(tmp) || (!strchr("mw", tmp) && !rn2(3)))
|
|
|
|
tmp = 0;
|
|
|
|
|
|
|
|
if (ACCESSIBLE(levl[x][y].typ)) /* might be mimic in wall or dead eel */
|
|
|
|
if (x != u.ux || y != u.uy) /* might be here after
|
|
|
|
* swallowed */
|
|
|
|
if (strchr("NTVm&", mdat->mlet) || rn2(5)) {
|
|
|
|
struct obj *obj2 = mkobj_at(tmp, x, y);
|
|
|
|
if (cansee(x, y))
|
|
|
|
atl(x, y, obj2->olet);
|
|
|
|
stackobj(obj2);
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
kludge(str, arg)
|
|
|
|
char *str, *arg;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
if (Blind) {
|
|
|
|
if (*str == '%')
|
|
|
|
pline(str, "It");
|
|
|
|
else
|
|
|
|
pline(str, "it");
|
|
|
|
} else
|
|
|
|
pline(str, arg);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
rescham()
|
|
|
|
{ /* force all chameleons to become normal */
|
|
|
|
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)
|
|
|
|
if (mtmp->cham) {
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->cham = 0;
|
|
|
|
(void) newcham(mtmp, PM_CHAMELEON);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
|
|
|
newcham(mtmp, mdat) /* make a chameleon look like a new monster */
|
|
|
|
/* returns 1 if the monster actually changed */
|
|
|
|
struct monst *mtmp;
|
|
|
|
struct permonst *mdat;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
int mhp, hpn, hpd;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mdat == mtmp->data)
|
|
|
|
return (0); /* still the same monster */
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef NOWORM
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mtmp->wormno)
|
|
|
|
wormdead(mtmp); /* throw tail away */
|
|
|
|
#endif /* NOWORM */
|
1993-03-21 12:45:37 +03:00
|
|
|
if (u.ustuck == mtmp) {
|
|
|
|
if (u.uswallow) {
|
|
|
|
u.uswallow = 0;
|
|
|
|
u.uswldtim = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
mnexto(mtmp);
|
|
|
|
docrt();
|
|
|
|
prme();
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
u.ustuck = 0;
|
|
|
|
}
|
|
|
|
hpn = mtmp->mhp;
|
1997-10-19 20:56:41 +04:00
|
|
|
hpd = (mtmp->data->mlevel) * 8;
|
|
|
|
if (!hpd)
|
|
|
|
hpd = 4;
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->data = mdat;
|
1997-10-19 20:56:41 +04:00
|
|
|
mhp = (mdat->mlevel) * 8;
|
1993-03-21 12:45:37 +03:00
|
|
|
/* new hp: same fraction of max as before */
|
1997-10-19 20:56:41 +04:00
|
|
|
mtmp->mhp = 2 + (hpn * mhp) / hpd;
|
1993-03-21 12:45:37 +03:00
|
|
|
hpn = mtmp->mhpmax;
|
1997-10-19 20:56:41 +04:00
|
|
|
mtmp->mhpmax = 2 + (hpn * mhp) / hpd;
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->minvis = (mdat->mlet == 'I') ? 1 : 0;
|
|
|
|
#ifndef NOWORM
|
1997-10-19 20:56:41 +04:00
|
|
|
if (mdat->mlet == 'w' && getwn(mtmp))
|
|
|
|
initworm(mtmp);
|
|
|
|
/* perhaps we should clear mtmp->mtame here? */
|
|
|
|
#endif /* NOWORM */
|
|
|
|
unpmon(mtmp); /* necessary for 'I' and to force pmon */
|
1993-03-21 12:45:37 +03:00
|
|
|
pmon(mtmp);
|
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
|
|
|
void
|
|
|
|
mnexto(mtmp) /* Make monster mtmp next to you (if
|
|
|
|
* possible) */
|
|
|
|
struct monst *mtmp;
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-19 20:56:41 +04:00
|
|
|
coord mm;
|
1993-03-21 12:45:37 +03:00
|
|
|
mm = enexto(u.ux, u.uy);
|
|
|
|
mtmp->mx = mm.x;
|
|
|
|
mtmp->my = mm.y;
|
|
|
|
pmon(mtmp);
|
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
int
|
|
|
|
ishuman(mtmp)
|
|
|
|
struct monst *mtmp;
|
|
|
|
{
|
|
|
|
return (mtmp->data->mlet == '@');
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
void
|
|
|
|
setmangry(mtmp)
|
|
|
|
struct monst *mtmp;
|
|
|
|
{
|
|
|
|
if (!mtmp->mpeaceful)
|
|
|
|
return;
|
|
|
|
if (mtmp->mtame)
|
|
|
|
return;
|
1993-03-21 12:45:37 +03:00
|
|
|
mtmp->mpeaceful = 0;
|
1997-10-19 20:56:41 +04:00
|
|
|
if (ishuman(mtmp))
|
|
|
|
pline("%s gets angry!", Monnam(mtmp));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-19 20:56:41 +04:00
|
|
|
/*
|
|
|
|
* not one hundred procent correct: now a snake may hide under an invisible
|
|
|
|
* object
|
|
|
|
*/
|
|
|
|
int
|
1993-03-21 12:45:37 +03:00
|
|
|
canseemon(mtmp)
|
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
|
|
|
return ((!mtmp->minvis || See_invisible)
|
|
|
|
&& (!mtmp->mhide || !o_at(mtmp->mx, mtmp->my))
|
1993-03-21 12:45:37 +03:00
|
|
|
&& cansee(mtmp->mx, mtmp->my));
|
|
|
|
}
|