コード例 #1
0
ファイル: polyself.c プロジェクト: DanielT/NitroHack
int dogaze(void)
{
	struct monst *mtmp;
	int looked = 0;
	char qbuf[QBUFSZ];
	int i;
	uchar adtyp = 0;

	for (i = 0; i < NATTK; i++) {
	    if (youmonst.data->mattk[i].aatyp == AT_GAZE) {
		adtyp = youmonst.data->mattk[i].adtyp;
		break;
	    }
	}
	if (adtyp != AD_CONF && adtyp != AD_FIRE) {
	    impossible("gaze attack %d?", adtyp);
	    return 0;
	}


	if (Blind) {
	    pline("You can't see anything to gaze at.");
	    return 0;
	}
	if (u.uen < 15) {
	    pline("You lack the energy to use your special gaze!");
	    return 0;
	}
	u.uen -= 15;
	iflags.botl = 1;

	for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) {
	    if (DEADMONSTER(mtmp)) continue;
	    if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my)) {
		looked++;
		if (Invis && !perceives(mtmp->data))
		    pline("%s seems not to notice your gaze.", Monnam(mtmp));
		else if (mtmp->minvis && !See_invisible)
		    pline("You can't see where to gaze at %s.", Monnam(mtmp));
		else if (mtmp->m_ap_type == M_AP_FURNITURE
			|| mtmp->m_ap_type == M_AP_OBJECT) {
		    looked--;
		    continue;
		} else if (flags.safe_dog && !Confusion && !Hallucination
		  && mtmp->mtame) {
		    pline("You avoid gazing at %s.", y_monnam(mtmp));
		} else {
		    if (flags.confirm && mtmp->mpeaceful && !Confusion
							&& !Hallucination) {
			sprintf(qbuf, "Really %s %s?",
			    (adtyp == AD_CONF) ? "confuse" : "attack",
			    mon_nam(mtmp));
			if (yn(qbuf) != 'y') continue;
			setmangry(mtmp);
		    }
		    if (!mtmp->mcanmove || mtmp->mstun || mtmp->msleeping ||
				    !mtmp->mcansee || !haseyes(mtmp->data)) {
			looked--;
			continue;
		    }
		    /* No reflection check for consistency with when a monster
		     * gazes at *you*--only medusa gaze gets reflected then.
		     */
		    if (adtyp == AD_CONF) {
			if (!mtmp->mconf)
			    pline("Your gaze confuses %s!", mon_nam(mtmp));
			else
			    pline("%s is getting more and more confused.",
							Monnam(mtmp));
			mtmp->mconf = 1;
		    } else if (adtyp == AD_FIRE) {
			int dmg = dice(2,6);
			pline("You attack %s with a fiery gaze!", mon_nam(mtmp));
			if (resists_fire(mtmp)) {
			    pline("The fire doesn't burn %s!", mon_nam(mtmp));
			    dmg = 0;
			}
			if ((int) u.ulevel > rn2(20))
			    destroy_mitem(mtmp, SCROLL_CLASS, AD_FIRE);
			if ((int) u.ulevel > rn2(20))
			    destroy_mitem(mtmp, POTION_CLASS, AD_FIRE);
			if ((int) u.ulevel > rn2(25))
			    destroy_mitem(mtmp, SPBOOK_CLASS, AD_FIRE);
			if (dmg && !DEADMONSTER(mtmp)) mtmp->mhp -= dmg;
			if (mtmp->mhp <= 0) killed(mtmp);
		    }
		    /* For consistency with passive() in uhitm.c, this only
		     * affects you if the monster is still alive.
		     */
		    if (!DEADMONSTER(mtmp) &&
			  (mtmp->data==&mons[PM_FLOATING_EYE]) && !mtmp->mcan) {
			if (!Free_action) {
			    pline("You are frozen by %s gaze!",
					     s_suffix(mon_nam(mtmp)));
			    nomul((u.ulevel > 6 || rn2(4)) ?
				    -dice((int)mtmp->m_lev+1,
					    (int)mtmp->data->mattk[0].damd)
				    : -200, "frozen by a monster's gaze");
			    return 1;
			} else
			    pline("You stiffen momentarily under %s gaze.",
				    s_suffix(mon_nam(mtmp)));
		    }
		    /* Technically this one shouldn't affect you at all because
		     * the Medusa gaze is an active monster attack that only
		     * works on the monster's turn, but for it to *not* have an
		     * effect would be too weird.
		     */
		    if (!DEADMONSTER(mtmp) &&
			    (mtmp->data == &mons[PM_MEDUSA]) && !mtmp->mcan) {
			pline(
			 "Gazing at the awake %s is not a very good idea.",
			    l_monnam(mtmp));
			/* as if gazing at a sleeping anything is fruitful... */
			pline("You turn to stone...");
			killer_format = KILLED_BY;
			killer = "deliberately meeting Medusa's gaze";
			done(STONING);
		    }
		}
	    }
	}
	if (!looked) pline("You gaze at no place in particular.");
	return 1;
}
コード例 #2
0
ファイル: sounds.c プロジェクト: ictxiangxin/LoongHack
static int dochat(void)
{
    struct monst *mtmp;
    int tx, ty;
    struct obj *otmp;
    schar dx, dy, dz;
    int mdx, mdy, mon_count;

    if (is_silent(youmonst.data)) {
	pline("As %s, you cannot speak.", an(mons_mname(youmonst.data)));
	return 0;
    }
    if (Strangled) {
	pline("You can't speak.  You're choking!");
	return 0;
    }
    if (u.uswallow) {
	pline("They won't hear you out there.");
	return 0;
    }
    if (Underwater) {
	pline("Your speech is unintelligible underwater.");
	return 0;
    }

    if (!Blind && (otmp = shop_object(u.ux, u.uy)) != NULL) {
	/* standing on something in a shop and chatting causes the shopkeeper
	   to describe the price(s).  This can inhibit other chatting inside
	   a shop, but that shouldn't matter much.  shop_object() returns an
	   object iff inside a shop and the shopkeeper is present and willing
	   (not angry) and able (not asleep) to speak and the position contains
	   any objects other than just gold.
	*/
	price_quote(otmp);
	return 1;
    }

    /* count the monsters around the player */
    mon_count = 0;
    for (mdx = -1; mdx <= 1; mdx++) {
	for (mdy = -1; mdy <= 1; mdy++) {
	    if (mdx == 0 && mdy == 0) {
		/* account for steed */
		if (u.usteed) {
		    mon_count++;
		    dx = 0;
		    dy = 0;
		    dz = 1;
		}
		continue;
	    }

	    mtmp = m_at(level, u.ux + mdx, u.uy + mdy);
	    if (mtmp && canspotmon(level, mtmp)) {
		mon_count++;
		dx = mdx;
		dy = mdy;
		dz = 0;
	    }
	}
    }

    /* don't ask for a direction if there's only one monster around */
    if ((mon_count != 1 || iflags.paranoid_chat) &&
	!getdir("Talk to whom? (in what direction)", &dx, &dy, &dz)) {
	/* decided not to chat */
	return 0;
    }

    if (u.usteed && dz > 0) {
	if (!u.usteed->mcanmove || u.usteed->msleeping) {
	    pline("Your steed remains silent...");
	    return 0;
	}
	return domonnoise(u.usteed);
    }
    if (dz) {
	pline("They won't hear you %s there.", dz < 0 ? "up" : "down");
	return 0;
    }

    if (dx == 0 && dy == 0) {
/*
 * Let's not include this.  It raises all sorts of questions: can you wear
 * 2 helmets, 2 amulets, 3 pairs of gloves or 6 rings as a marilith,
 * etc...  --KAA
	if (u.umonnum == PM_ETTIN) {
	    pline("You discover that your other head makes boring conversation.");
	    return 1;
	}
*/
	pline("Talking to yourself is a bad habit for a dungeoneer.");
	return 0;
    }

    tx = u.ux + dx;
    ty = u.uy + dy;
    mtmp = m_at(level, tx, ty);

    if (!mtmp || mtmp->mundetected ||
		mtmp->m_ap_type == M_AP_FURNITURE ||
		mtmp->m_ap_type == M_AP_OBJECT)
	return 0;

    /* sleeping monsters won't talk, except priests (who wake up) */
    if ((!mtmp->mcanmove || mtmp->msleeping) && !mtmp->ispriest) {
	/* If it is unseen, the player can't tell the difference between
	   not noticing him and just not existing, so skip the message. */
	if (canspotmon(level, mtmp))
	    pline("%s seems not to notice you.", Monnam(mtmp));
	return 0;
    }

    /* if this monster is waiting for something, prod it into action */
    mtmp->mstrategy &= ~STRAT_WAITMASK;

    if (mtmp->mtame && mtmp->meating) {
	if (!canspotmon(level, mtmp))
	    map_invisible(mtmp->mx, mtmp->my);
	pline("%s is eating noisily.", Monnam(mtmp));
	return 0;
    }

    if (Role_if(PM_CONVICT) && is_rat(mtmp->data) &&
	!mtmp->mpeaceful && !mtmp->mtame) {
	int soothe_roll = rnl(10);
	pline("You attempt to soothe the %s with chittering sounds.",
	      l_monnam(mtmp));
	if (soothe_roll < 2) {
	    tamedog(mtmp, NULL);
	} else if (soothe_roll > 8) {
	    pline("%s unfortunately ignores your overtures.", Monnam(mtmp));
	} else {
	    mtmp->mpeaceful = 1;
	    set_malign(mtmp);
	}
	return 1;
    }

    return domonnoise(mtmp);
}