1 /* NetHack 3.6 muse.c $NHDT-Date: 1547025167 2019/01/09 09:12:47 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.92 $ */
2 /* Copyright (C) 1990 by Ken Arromdee */
3 /* NetHack may be freely redistributed. See license for details. */
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2019 */
8 /* JNetHack may be freely redistributed. See license for details. */
11 * Monster item usage routines.
16 boolean m_using = FALSE;
18 /* Let monsters use magic items. Arbitrary assumptions: Monsters only use
19 * scrolls when they can see, monsters know when wands have 0 charges,
20 * monsters cannot recognize if items are cursed are not, monsters which
21 * are confused don't know not to read scrolls, etc....
24 STATIC_DCL struct permonst *FDECL(muse_newcham_mon, (struct monst *));
25 STATIC_DCL int FDECL(precheck, (struct monst *, struct obj *));
26 STATIC_DCL void FDECL(mzapmsg, (struct monst *, struct obj *, BOOLEAN_P));
27 STATIC_DCL void FDECL(mreadmsg, (struct monst *, struct obj *));
28 STATIC_DCL void FDECL(mquaffmsg, (struct monst *, struct obj *));
29 STATIC_DCL boolean FDECL(m_use_healing, (struct monst *));
30 STATIC_PTR int FDECL(mbhitm, (struct monst *, struct obj *));
31 STATIC_DCL void FDECL(mbhit, (struct monst *, int,
32 int FDECL((*), (MONST_P, OBJ_P)),
33 int FDECL((*), (OBJ_P, OBJ_P)), struct obj *));
34 STATIC_DCL void FDECL(you_aggravate, (struct monst *));
35 STATIC_DCL void FDECL(mon_consume_unstone, (struct monst *, struct obj *,
36 BOOLEAN_P, BOOLEAN_P));
37 STATIC_DCL boolean FDECL(cures_stoning, (struct monst *, struct obj *,
39 STATIC_DCL boolean FDECL(mcould_eat_tin, (struct monst *));
40 STATIC_DCL boolean FDECL(muse_unslime, (struct monst *, struct obj *,
41 struct trap *, BOOLEAN_P));
42 STATIC_DCL int FDECL(cures_sliming, (struct monst *, struct obj *));
43 STATIC_DCL boolean FDECL(green_mon, (struct monst *));
45 static struct musable {
46 struct obj *offensive;
47 struct obj *defensive;
49 int has_offense, has_defense, has_misc;
50 /* =0, no capability; otherwise, different numbers.
51 * If it's an object, the object is also set (it's 0 otherwise).
54 static int trapx, trapy;
55 static boolean zap_oseen; /* for wands which use mbhitm and are zapped at
56 * players. We usually want an oseen local to
57 * the function, but this is impossible since the
58 * function mbhitm has to be compatible with the
59 * normal zap routines, and those routines don't
60 * remember who zapped the wand. */
62 /* Any preliminary checks which may result in the monster being unable to use
63 * the item. Returns 0 if nothing happened, 2 if the monster can't do
64 * anything (i.e. it teleported) and 1 if it's dead.
75 vis = cansee(mon->mx, mon->my);
77 if (obj->oclass == POTION_CLASS) {
80 static const char *empty = "The potion turns out to be empty.";
82 static const char *empty = "
\96ò
\82Í
\8bó
\82Á
\82Û
\82Å
\82 \82é
\82±
\82Æ
\82ª
\82í
\82©
\82Á
\82½
\81D";
83 const char *potion_descr;
86 potion_descr = OBJ_DESCR(objects[obj->otyp]);
88 if (potion_descr && !strcmp(potion_descr, "milky")) {
90 if (potion_descr && !strcmp(potion_descr, "
\83~
\83\8b\83N
\90F
\82Ì")) {
91 if (!(mvitals[PM_GHOST].mvflags & G_GONE)
92 && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_GHOST].born))) {
93 if (!enexto(&cc, mon->mx, mon->my, &mons[PM_GHOST]))
97 mtmp = makemon(&mons[PM_GHOST], cc.x, cc.y, NO_MM_FLAGS);
105 "As %s opens the bottle, an enormous %s emerges!",
107 Hallucination ? rndmonnam(NULL)
108 : (const char *) "ghost");
111 "%s
\82ª
\95r
\82ð
\8aJ
\82¯
\82é
\82Æ
\81C
\8b\90\91å
\82È%s
\82ª
\8fo
\82Ä
\82«
\82½
\81I",
113 Hallucination ? rndmonnam(NULL)
114 : (const char *)"
\97H
\97ì");
117 pline("%s is frightened to death, and unable to move.",
119 pline("%s
\82Í
\82Ü
\82Á
\82³
\82¨
\82É
\82È
\82Á
\82Ä
\8bÁ
\82«
\81C
\93®
\82¯
\82È
\82
\82È
\82Á
\82½
\81D",
122 paralyze_monst(mon, 3);
128 if (potion_descr && !strcmp(potion_descr, "smoky")
130 if (potion_descr && !strcmp(potion_descr, "
\89\8c\82Ì
\8fo
\82Ä
\82¢
\82é")
131 && !(mvitals[PM_DJINNI].mvflags & G_GONE)
132 && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_DJINNI].born))) {
133 if (!enexto(&cc, mon->mx, mon->my, &mons[PM_DJINNI]))
137 mtmp = makemon(&mons[PM_DJINNI], cc.x, cc.y, NO_MM_FLAGS);
144 pline("In a cloud of smoke, %s emerges!", a_monnam(mtmp));
146 pline("
\89\8c\82Ì
\92\86\82©
\82ç
\81C%s
\82ª
\8c»
\82í
\82ê
\82½
\81I", a_monnam(mtmp));
148 pline("%s speaks.", vis ? Monnam(mtmp) : Something);
150 pline("%s
\82Í
\98b
\82µ
\82½
\81D", vis ? Monnam(mtmp) : Something);
151 /* I suspect few players will be upset that monsters */
152 /* can't wish for wands of death here.... */
155 verbalize("You freed me!");
157 verbalize("
\89ð
\95ú
\82µ
\82Ä
\82
\82ê
\82½
\82Ì
\82Í
\82¨
\91O
\82©
\81I");
162 verbalize("It is about time.");
164 verbalize("
\82³
\82ç
\82Î
\82¾
\81I");
167 pline("%s vanishes.", Monnam(mtmp));
169 pline("%s
\82Í
\8fÁ
\82¦
\82½
\81D", Monnam(mtmp));
176 if (obj->oclass == WAND_CLASS && obj->cursed
177 && !rn2(WAND_BACKFIRE_CHANCE)) {
178 int dam = d(obj->spe + 2, 6);
180 /* 3.6.1: no Deaf filter; 'if' message doesn't warrant it, 'else'
181 message doesn't need it since You_hear() has one of its own */
184 pline("%s zaps %s, which suddenly explodes!", Monnam(mon),
187 pline("%s
\82ª%s
\82ð
\82Ó
\82è
\82©
\82´
\82·
\82Æ
\81C
\82»
\82ê
\82Í
\93Ë
\91R
\94\9a\94
\82µ
\82½
\81I", Monnam(mon),
191 /* same near/far threshold as mzapmsg() */
192 int range = couldsee(mon->mx, mon->my) /* 9 or 5 */
193 ? (BOLT_LIM + 1) : (BOLT_LIM - 3);
196 You_hear("a zap and an explosion %s.",
197 (distu(mon->mx, mon->my) <= range * range)
198 ? "nearby" : "in the distance");
200 You_hear("%s
\82
\82Ì
\8fñ
\82Ì
\89¹
\82Æ
\94\9a\94
\89¹
\82ð
\95·
\82¢
\82½
\81D",
201 (distu(mon->mx, mon->my) <= range * range)
202 ? "
\8bß" : "
\89\93");
207 if (DEADMONSTER(mon)) {
208 monkilled(mon, "", AD_RBRE);
211 m.has_defense = m.has_offense = m.has_misc = 0;
212 /* Only one needed to be set to 0 but the others are harmless */
218 mzapmsg(mtmp, otmp, self)
223 if (!canseemon(mtmp)) {
224 int range = couldsee(mtmp->mx, mtmp->my) /* 9 or 5 */
225 ? (BOLT_LIM + 1) : (BOLT_LIM - 3);
228 You_hear("a %s zap.", (distu(mtmp->mx, mtmp->my) <= range * range)
229 ? "nearby" : "distant");
231 You_hear("%s
\82
\82Å
\8fñ
\82Ì
\89¹
\82ð
\95·
\82¢
\82½
\81D",
232 (distu(mtmp->mx, mtmp->my) <= range * range)
233 ? "
\8bß" : "
\89\93");
237 pline("%s zaps %sself with %s!", Monnam(mtmp), mhim(mtmp),
240 pline("%s
\82Í
\8e©
\95ª
\8e©
\90g
\82É%s
\82ð
\82Ó
\82è
\82©
\82´
\82µ
\82½
\81I", Monnam(mtmp),
245 pline("%s zaps %s!", Monnam(mtmp), an(xname(otmp)));
247 pline("%s
\82Í%s
\82ð
\82Ó
\82è
\82©
\82´
\82µ
\82½
\81I", Monnam(mtmp), an(xname(otmp)));
257 boolean vismon = canseemon(mtmp);
263 return; /* no feedback */
265 otmp->dknown = 1; /* seeing or hearing it read reveals its label */
266 /* shouldn't be able to hear curse/bless status of unseen scrolls;
267 for priest characters, bknown will always be set during naming */
268 savebknown = otmp->bknown;
269 saverole = Role_switch;
272 if (Role_if(PM_PRIEST))
275 Strcpy(onambuf, singular(otmp, doname));
276 Role_switch = saverole;
277 otmp->bknown = savebknown;
281 pline("%s reads %s!", Monnam(mtmp), onambuf);
283 pline("%s
\82Í%s
\82ð
\93Ç
\82ñ
\82¾
\81I", Monnam(mtmp), onambuf);
286 You_hear("%s reading %s.",
287 x_monnam(mtmp, ARTICLE_A, (char *) 0,
288 (SUPPRESS_IT | SUPPRESS_INVISIBLE | SUPPRESS_SADDLE),
292 You_hear("%s
\82ª%s
\82ð
\93Ç
\82ñ
\82Å
\82¢
\82é
\90º
\82ð
\95·
\82¢
\82½
\81D",
293 x_monnam(mtmp, ARTICLE_A, (char *)0,
294 (SUPPRESS_IT|SUPPRESS_INVISIBLE|SUPPRESS_SADDLE),
301 pline("Being confused, %s mispronounces the magic words...",
303 pline("
\8d¬
\97\90\82µ
\82Ä
\82¢
\82é
\82Ì
\82Å
\81C%s
\82Í
\8eô
\95¶
\82ð
\8aÔ
\88á
\82Á
\82Ä
\8f¥
\82¦
\82Ä
\82µ
\82Ü
\82Á
\82½
\81D
\81D
\81D",
304 vismon ? mon_nam(mtmp) : mhe(mtmp));
308 mquaffmsg(mtmp, otmp)
312 if (canseemon(mtmp)) {
315 pline("%s drinks %s!", Monnam(mtmp), singular(otmp, doname));
317 pline("%s
\82Í%s
\82ð
\88ù
\82ñ
\82¾
\81I", Monnam(mtmp), singular(otmp, doname));
320 You_hear("a chugging sound.");
322 You_hear("
\83S
\83N
\83b
\81I
\82Æ
\82¢
\82¤
\89¹
\82ð
\95·
\82¢
\82½
\81D");
325 /* Defines for various types of stuff. The order in which monsters prefer
326 * to use them is determined by the order of the code logic, not the
327 * numerical order in which they are defined.
329 #define MUSE_SCR_TELEPORTATION 1
330 #define MUSE_WAN_TELEPORTATION_SELF 2
331 #define MUSE_POT_HEALING 3
332 #define MUSE_POT_EXTRA_HEALING 4
333 #define MUSE_WAN_DIGGING 5
334 #define MUSE_TRAPDOOR 6
335 #define MUSE_TELEPORT_TRAP 7
336 #define MUSE_UPSTAIRS 8
337 #define MUSE_DOWNSTAIRS 9
338 #define MUSE_WAN_CREATE_MONSTER 10
339 #define MUSE_SCR_CREATE_MONSTER 11
340 #define MUSE_UP_LADDER 12
341 #define MUSE_DN_LADDER 13
342 #define MUSE_SSTAIRS 14
343 #define MUSE_WAN_TELEPORTATION 15
344 #define MUSE_BUGLE 16
345 #define MUSE_UNICORN_HORN 17
346 #define MUSE_POT_FULL_HEALING 18
347 #define MUSE_LIZARD_CORPSE 19
349 #define MUSE_INNATE_TPT 9999
350 * We cannot use this. Since monsters get unlimited teleportation, if they
351 * were allowed to teleport at will you could never catch them. Instead,
352 * assume they only teleport at random times, despite the inconsistency
353 * that if you polymorph into one you teleport at will.
361 if ((obj = m_carrying(mtmp, POT_FULL_HEALING)) != 0) {
363 m.has_defense = MUSE_POT_FULL_HEALING;
366 if ((obj = m_carrying(mtmp, POT_EXTRA_HEALING)) != 0) {
368 m.has_defense = MUSE_POT_EXTRA_HEALING;
371 if ((obj = m_carrying(mtmp, POT_HEALING)) != 0) {
373 m.has_defense = MUSE_POT_HEALING;
379 /* Select a defensive item/action for a monster. Returns TRUE iff one is
385 register struct obj *obj = 0;
387 int x = mtmp->mx, y = mtmp->my;
388 boolean stuck = (mtmp == u.ustuck);
389 boolean immobile = (mtmp->data->mmove == 0);
392 if (is_animal(mtmp->data) || mindless(mtmp->data))
394 if (dist2(x, y, mtmp->mux, mtmp->muy) > 25)
396 if (u.uswallow && stuck)
399 m.defensive = (struct obj *) 0;
402 /* since unicorn horns don't get used up, the monster would look
403 * silly trying to use the same cursed horn round after round
405 if (mtmp->mconf || mtmp->mstun || !mtmp->mcansee) {
406 if (!is_unicorn(mtmp->data) && !nohands(mtmp->data)) {
407 for (obj = mtmp->minvent; obj; obj = obj->nobj)
408 if (obj->otyp == UNICORN_HORN && !obj->cursed)
411 if (obj || is_unicorn(mtmp->data)) {
413 m.has_defense = MUSE_UNICORN_HORN;
418 if (mtmp->mconf || mtmp->mstun) {
419 struct obj *liztin = 0;
421 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
422 if (obj->otyp == CORPSE && obj->corpsenm == PM_LIZARD) {
424 m.has_defense = MUSE_LIZARD_CORPSE;
426 } else if (obj->otyp == TIN && obj->corpsenm == PM_LIZARD) {
430 /* confused or stunned monster might not be able to open tin */
431 if (liztin && mcould_eat_tin(mtmp) && rn2(3)) {
432 m.defensive = liztin;
433 /* tin and corpse ultimately end up being handled the same */
434 m.has_defense = MUSE_LIZARD_CORPSE;
439 /* It so happens there are two unrelated cases when we might want to
440 * check specifically for healing alone. The first is when the monster
441 * is blind (healing cures blindness). The second is when the monster
442 * is peaceful; then we don't want to flee the player, and by
443 * coincidence healing is all there is that doesn't involve fleeing.
444 * These would be hard to combine because of the control flow.
445 * Pestilence won't use healing even when blind.
447 if (!mtmp->mcansee && !nohands(mtmp->data)
448 && mtmp->data != &mons[PM_PESTILENCE]) {
449 if (m_use_healing(mtmp))
453 fraction = u.ulevel < 10 ? 5 : u.ulevel < 14 ? 4 : 3;
454 if (mtmp->mhp >= mtmp->mhpmax
455 || (mtmp->mhp >= 10 && mtmp->mhp * fraction >= mtmp->mhpmax))
458 if (mtmp->mpeaceful) {
459 if (!nohands(mtmp->data)) {
460 if (m_use_healing(mtmp))
466 if (stuck || immobile) {
467 ; /* fleeing by stairs or traps is not possible */
468 } else if (levl[x][y].typ == STAIRS) {
469 if (x == xdnstair && y == ydnstair) {
470 if (!is_floater(mtmp->data))
471 m.has_defense = MUSE_DOWNSTAIRS;
472 } else if (x == xupstair && y == yupstair) {
473 m.has_defense = MUSE_UPSTAIRS;
474 } else if (sstairs.sx && x == sstairs.sx && y == sstairs.sy) {
475 if (sstairs.up || !is_floater(mtmp->data))
476 m.has_defense = MUSE_SSTAIRS;
478 } else if (levl[x][y].typ == LADDER) {
479 if (x == xupladder && y == yupladder) {
480 m.has_defense = MUSE_UP_LADDER;
481 } else if (x == xdnladder && y == ydnladder) {
482 if (!is_floater(mtmp->data))
483 m.has_defense = MUSE_DN_LADDER;
484 } else if (sstairs.sx && x == sstairs.sx && y == sstairs.sy) {
485 if (sstairs.up || !is_floater(mtmp->data))
486 m.has_defense = MUSE_SSTAIRS;
489 /* Note: trap doors take precedence over teleport traps. */
490 int xx, yy, i, locs[10][2];
491 boolean ignore_boulders = (verysmall(mtmp->data)
492 || throws_rocks(mtmp->data)
493 || passes_walls(mtmp->data)),
494 diag_ok = !NODIAG(monsndx(mtmp->data));
496 for (i = 0; i < 10; ++i) /* 10: 9 spots plus sentinel */
497 locs[i][0] = locs[i][1] = 0;
498 /* collect viable spots; monster's <mx,my> comes first */
499 locs[0][0] = x, locs[0][1] = y;
501 for (xx = x - 1; xx <= x + 1; xx++)
502 for (yy = y - 1; yy <= y + 1; yy++)
503 if (isok(xx, yy) && (xx != x || yy != y)) {
504 locs[i][0] = xx, locs[i][1] = yy;
507 /* look for a suitable trap among the viable spots */
508 for (i = 0; i < 10; ++i) {
509 xx = locs[i][0], yy = locs[i][1];
511 break; /* we've run out of spots */
512 /* skip if it's hero's location
513 or a diagonal spot and monster can't move diagonally
514 or some other monster is there */
515 if ((xx == u.ux && yy == u.uy)
516 || (xx != x && yy != y && !diag_ok)
517 || (level.monsters[xx][yy] && !(xx == x && yy == y)))
519 /* skip if there's no trap or can't/won't move onto trap */
520 if ((t = t_at(xx, yy)) == 0
521 || (!ignore_boulders && sobj_at(BOULDER, xx, yy))
522 || onscary(xx, yy, mtmp))
524 /* use trap if it's the correct type */
526 && !is_floater(mtmp->data)
527 && !mtmp->isshk && !mtmp->isgd && !mtmp->ispriest
528 && Can_fall_thru(&u.uz)) {
531 m.has_defense = MUSE_TRAPDOOR;
532 break; /* no need to look at any other spots */
533 } else if (t->ttyp == TELEP_TRAP) {
536 m.has_defense = MUSE_TELEPORT_TRAP;
541 if (nohands(mtmp->data)) /* can't use objects */
544 if (is_mercenary(mtmp->data) && (obj = m_carrying(mtmp, BUGLE)) != 0) {
548 /* Distance is arbitrary. What we really want to do is
549 * have the soldier play the bugle when it sees or
550 * remembers soldiers nearby...
552 for (xx = x - 3; xx <= x + 3; xx++) {
553 for (yy = y - 3; yy <= y + 3; yy++) {
554 if (!isok(xx, yy) || (xx == x && yy == y))
556 if ((mon = m_at(xx, yy)) != 0 && is_mercenary(mon->data)
557 && mon->data != &mons[PM_GUARD]
558 && (mon->msleeping || !mon->mcanmove)) {
560 m.has_defense = MUSE_BUGLE;
561 goto toot; /* double break */
569 /* use immediate physical escape prior to attempting magic */
570 if (m.has_defense) /* stairs, trap door or tele-trap, bugle alert */
573 /* kludge to cut down on trap destruction (particularly portals) */
575 if (t && (is_pit(t->ttyp) || t->ttyp == WEB
576 || t->ttyp == BEAR_TRAP))
577 t = 0; /* ok for monster to dig here */
579 #define nomore(x) if (m.has_defense == x) continue;
580 /* selection could be improved by collecting all possibilities
581 into an array and then picking one at random */
582 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
583 /* don't always use the same selection pattern */
584 if (m.has_defense && !rn2(3))
587 /* nomore(MUSE_WAN_DIGGING); */
588 if (m.has_defense == MUSE_WAN_DIGGING)
590 if (obj->otyp == WAN_DIGGING && obj->spe > 0 && !stuck && !t
591 && !mtmp->isshk && !mtmp->isgd && !mtmp->ispriest
592 && !is_floater(mtmp->data)
593 /* monsters digging in Sokoban can ruin things */
595 /* digging wouldn't be effective; assume they know that */
596 && !(levl[x][y].wall_info & W_NONDIGGABLE)
597 && !(Is_botlevel(&u.uz) || In_endgame(&u.uz))
598 && !(is_ice(x, y) || is_pool(x, y) || is_lava(x, y))
599 && !(mtmp->data == &mons[PM_VLAD_THE_IMPALER]
600 && In_V_tower(&u.uz))) {
602 m.has_defense = MUSE_WAN_DIGGING;
604 nomore(MUSE_WAN_TELEPORTATION_SELF);
605 nomore(MUSE_WAN_TELEPORTATION);
606 if (obj->otyp == WAN_TELEPORTATION && obj->spe > 0) {
607 /* use the TELEP_TRAP bit to determine if they know
608 * about noteleport on this level or not. Avoids
609 * ineffective re-use of teleportation. This does
610 * mean if the monster leaves the level, they'll know
611 * about teleport traps.
613 if (!level.flags.noteleport
614 || !(mtmp->mtrapseen & (1 << (TELEP_TRAP - 1)))) {
616 m.has_defense = (mon_has_amulet(mtmp))
617 ? MUSE_WAN_TELEPORTATION
618 : MUSE_WAN_TELEPORTATION_SELF;
621 nomore(MUSE_SCR_TELEPORTATION);
622 if (obj->otyp == SCR_TELEPORTATION && mtmp->mcansee
623 && haseyes(mtmp->data)
624 && (!obj->cursed || (!(mtmp->isshk && inhishop(mtmp))
625 && !mtmp->isgd && !mtmp->ispriest))) {
626 /* see WAN_TELEPORTATION case above */
627 if (!level.flags.noteleport
628 || !(mtmp->mtrapseen & (1 << (TELEP_TRAP - 1)))) {
630 m.has_defense = MUSE_SCR_TELEPORTATION;
634 if (mtmp->data != &mons[PM_PESTILENCE]) {
635 nomore(MUSE_POT_FULL_HEALING);
636 if (obj->otyp == POT_FULL_HEALING) {
638 m.has_defense = MUSE_POT_FULL_HEALING;
640 nomore(MUSE_POT_EXTRA_HEALING);
641 if (obj->otyp == POT_EXTRA_HEALING) {
643 m.has_defense = MUSE_POT_EXTRA_HEALING;
645 nomore(MUSE_WAN_CREATE_MONSTER);
646 if (obj->otyp == WAN_CREATE_MONSTER && obj->spe > 0) {
648 m.has_defense = MUSE_WAN_CREATE_MONSTER;
650 nomore(MUSE_POT_HEALING);
651 if (obj->otyp == POT_HEALING) {
653 m.has_defense = MUSE_POT_HEALING;
655 } else { /* Pestilence */
656 nomore(MUSE_POT_FULL_HEALING);
657 if (obj->otyp == POT_SICKNESS) {
659 m.has_defense = MUSE_POT_FULL_HEALING;
661 nomore(MUSE_WAN_CREATE_MONSTER);
662 if (obj->otyp == WAN_CREATE_MONSTER && obj->spe > 0) {
664 m.has_defense = MUSE_WAN_CREATE_MONSTER;
667 nomore(MUSE_SCR_CREATE_MONSTER);
668 if (obj->otyp == SCR_CREATE_MONSTER) {
670 m.has_defense = MUSE_SCR_CREATE_MONSTER;
674 return (boolean) !!m.has_defense;
678 /* Perform a defensive action for a monster. Must be called immediately
679 * after find_defensive(). Return values are 0: did something, 1: died,
680 * 2: did something and can't attack again (i.e. teleported).
686 int i, fleetim, how = 0;
687 struct obj *otmp = m.defensive;
688 boolean vis, vismon, oseen;
691 if ((i = precheck(mtmp, otmp)) != 0)
693 vis = cansee(mtmp->mx, mtmp->my);
694 vismon = canseemon(mtmp);
695 oseen = otmp && vismon;
697 /* when using defensive choice to run away, we want monster to avoid
698 rushing right straight back; don't override if already scared */
699 fleetim = !mtmp->mflee ? (33 - (30 * mtmp->mhp / mtmp->mhpmax)) : 0;
701 if (fleetim && !m->iswiz) { \
702 monflee(m, fleetim, FALSE, FALSE); \
705 switch (m.has_defense) {
706 case MUSE_UNICORN_HORN:
710 pline("%s uses a unicorn horn!", Monnam(mtmp));
712 pline("%s
\82Í
\83\86\83j
\83R
\81[
\83\93\82Ì
\8ap
\82ð
\8eg
\82Á
\82½
\81I", Monnam(mtmp));
715 pline_The("tip of %s's horn glows!", mon_nam(mtmp));
717 pline("%s
\82Ì
\8ap
\82Ì
\90æ
\92[
\82ª
\8bP
\82¢
\82½
\81I", mon_nam(mtmp));
719 if (!mtmp->mcansee) {
720 mcureblindness(mtmp, vismon);
721 } else if (mtmp->mconf || mtmp->mstun) {
722 mtmp->mconf = mtmp->mstun = 0;
725 pline("%s seems steadier now.", Monnam(mtmp));
727 pline("%s
\82Í
\95½
\90Ã
\82ð
\82Æ
\82è
\82à
\82Ç
\82µ
\82½
\81D", Monnam(mtmp));
729 impossible("No need for unicorn horn?");
734 pline("%s plays %s!", Monnam(mtmp), doname(otmp));
736 pline("%s
\82Í%s
\82ð
\90\81\82¢
\82½
\81I", Monnam(mtmp), doname(otmp));
739 You_hear("a bugle playing reveille!");
741 You_hear("
\8bN
\8f°
\83\89\83b
\83p
\82Ì
\89¹
\82ð
\95·
\82¢
\82½
\81I");
742 awaken_soldiers(mtmp);
744 case MUSE_WAN_TELEPORTATION_SELF:
745 if ((mtmp->isshk && inhishop(mtmp)) || mtmp->isgd || mtmp->ispriest)
748 mzapmsg(mtmp, otmp, TRUE);
750 how = WAN_TELEPORTATION;
752 if (tele_restrict(mtmp)) { /* mysterious force... */
753 if (vismon && how) /* mentions 'teleport' */
755 /* monster learns that teleportation isn't useful here */
756 if (level.flags.noteleport)
757 mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1));
760 if ((mon_has_amulet(mtmp) || On_W_tower_level(&u.uz)) && !rn2(3)) {
763 pline("%s seems disoriented for a moment.", Monnam(mtmp));
765 pline("%s
\82Í
\88ê
\8fu
\95û
\8cü
\8a´
\8ao
\82ð
\8e¸
\82Á
\82½
\81D", Monnam(mtmp));
770 (void) rloc(mtmp, TRUE);
772 case MUSE_WAN_TELEPORTATION:
774 mzapmsg(mtmp, otmp, FALSE);
777 mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp);
778 /* monster learns that teleportation isn't useful here */
779 if (level.flags.noteleport)
780 mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1));
783 case MUSE_SCR_TELEPORTATION: {
784 int obj_is_cursed = otmp->cursed;
786 if (mtmp->isshk || mtmp->isgd || mtmp->ispriest)
789 mreadmsg(mtmp, otmp);
790 m_useup(mtmp, otmp); /* otmp might be free'ed */
791 how = SCR_TELEPORTATION;
792 if (obj_is_cursed || mtmp->mconf) {
796 if (mon_has_amulet(mtmp) || In_endgame(&u.uz)) {
799 pline("%s seems very disoriented for a moment.",
801 pline("%s
\82Í
\88ê
\8fu
\95û
\8cü
\8a´
\8ao
\82ð
\8e¸
\82Á
\82½
\81D",
805 nlev = random_teleport_level();
806 if (nlev == depth(&u.uz)) {
809 pline("%s shudders for a moment.", Monnam(mtmp));
811 pline("%s
\82Í
\88ê
\8fu
\90k
\82¦
\82½
\81D", Monnam(mtmp));
814 get_level(&flev, nlev);
815 migrate_to_level(mtmp, ledger_no(&flev), MIGR_RANDOM,
818 makeknown(SCR_TELEPORTATION);
823 case MUSE_WAN_DIGGING: {
827 mzapmsg(mtmp, otmp, FALSE);
830 makeknown(WAN_DIGGING);
831 if (IS_FURNITURE(levl[mtmp->mx][mtmp->my].typ)
832 || IS_DRAWBRIDGE(levl[mtmp->mx][mtmp->my].typ)
833 || (is_drawbridge_wall(mtmp->mx, mtmp->my) >= 0)
834 || (sstairs.sx && sstairs.sx == mtmp->mx
835 && sstairs.sy == mtmp->my)) {
837 pline_The("digging ray is ineffective.");
839 pline("
\8c@
\8dí
\8cõ
\90ü
\82Í
\8cø
\89Ê
\82ª
\82È
\82¢
\81D");
842 if (!Can_dig_down(&u.uz) && !levl[mtmp->mx][mtmp->my].candig) {
845 pline_The("%s here is too hard to dig in.",
847 pline("
\82±
\82±
\82Ì%s
\82Í
\8cÅ
\82
\82Ä
\8c@
\82ê
\82È
\82¢
\81D",
848 surface(mtmp->mx, mtmp->my));
851 ttmp = maketrap(mtmp->mx, mtmp->my, HOLE);
857 pline("%s has made a hole in the %s.", Monnam(mtmp),
858 surface(mtmp->mx, mtmp->my));
860 pline("%s
\82Í%s
\82É
\8c\8a\82ð
\8aJ
\82¯
\82½
\81D", Monnam(mtmp),
861 surface(mtmp->mx, mtmp->my));
864 pline("%s %s through...", Monnam(mtmp),
865 is_flyer(mtmp->data) ? "dives" : "falls");
867 pline("%s
\82Í
\92Ê
\82è
\94²
\82¯
\82Ä%s
\81D
\81D
\81D", Monnam(mtmp),
868 is_flyer(mtmp->data) ? "
\94ò
\82Ñ
\82±
\82ñ
\82¾" : "
\97\8e\82¿
\82½");
872 You_hear("%s crash through the %s.", something,
873 surface(mtmp->mx, mtmp->my));
875 You_hear("
\89½
\82©
\82ª%s
\82ð
\92Ê
\82è
\94²
\82¯
\82Ä
\97\8e\82¿
\82é
\89¹
\82ð
\95·
\82¢
\82½
\81D
\81D
\81D",
876 surface(mtmp->mx, mtmp->my));
878 /* we made sure that there is a level for mtmp to go to */
879 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_RANDOM,
883 case MUSE_WAN_CREATE_MONSTER: {
885 /* pm: 0 => random, eel => aquatic, croc => amphibious */
886 struct permonst *pm =
887 !is_pool(mtmp->mx, mtmp->my)
889 : &mons[u.uinwater ? PM_GIANT_EEL : PM_CROCODILE];
892 if (!enexto(&cc, mtmp->mx, mtmp->my, pm))
894 mzapmsg(mtmp, otmp, FALSE);
896 mon = makemon((struct permonst *) 0, cc.x, cc.y, NO_MM_FLAGS);
897 if (mon && canspotmon(mon) && oseen)
898 makeknown(WAN_CREATE_MONSTER);
901 case MUSE_SCR_CREATE_MONSTER: {
903 struct permonst *pm = 0, *fish = 0;
906 boolean known = FALSE;
910 if (mtmp->mconf || otmp->cursed)
913 pm = fish = &mons[PM_ACID_BLOB];
914 else if (is_pool(mtmp->mx, mtmp->my))
915 fish = &mons[u.uinwater ? PM_GIANT_EEL : PM_CROCODILE];
916 mreadmsg(mtmp, otmp);
918 /* `fish' potentially gives bias towards water locations;
919 `pm' is what to actually create (0 => random) */
920 if (!enexto(&cc, mtmp->mx, mtmp->my, fish))
922 mon = makemon(pm, cc.x, cc.y, NO_MM_FLAGS);
923 if (mon && canspotmon(mon))
926 /* The only case where we don't use oseen. For wands, you
927 * have to be able to see the monster zap the wand to know
928 * what type it is. For teleport scrolls, you have to see
929 * the monster to know it teleported.
932 makeknown(SCR_CREATE_MONSTER);
933 else if (!objects[SCR_CREATE_MONSTER].oc_name_known
934 && !objects[SCR_CREATE_MONSTER].oc_uname)
940 /* trap doors on "bottom" levels of dungeons are rock-drop
941 * trap doors, not holes in the floor. We check here for
944 if (Is_botlevel(&u.uz))
948 struct trap *t = t_at(trapx, trapy);
952 pline("%s %s into a %s!", Mnam,
953 vtense(Mnam, locomotion(mtmp->data, "jump")),
954 (t->ttyp == TRAPDOOR) ? "trap door" : "hole");
956 pline("%s
\82Í%s
\82É%s
\93ü
\82Á
\82½
\81I", Mnam,
957 t->ttyp == TRAPDOOR ? "
\97\8e\82µ
\94à" : "
\8c\8a",
958 jconj(locomotion(mtmp->data, "
\94ò
\82Ô"), "
\82Ä"));
960 if (levl[trapx][trapy].typ == SCORR) {
961 levl[trapx][trapy].typ = CORR;
962 unblock_point(trapx, trapy);
964 seetrap(t_at(trapx, trapy));
967 /* don't use rloc_to() because worm tails must "move" */
968 remove_monster(mtmp->mx, mtmp->my);
969 newsym(mtmp->mx, mtmp->my); /* update old location */
970 place_monster(mtmp, trapx, trapy);
973 newsym(trapx, trapy);
975 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_RANDOM,
980 if (ledger_no(&u.uz) == 1)
981 goto escape; /* impossible; level 1 upstairs are SSTAIRS */
982 if (Inhell && mon_has_amulet(mtmp) && !rn2(4)
983 && (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz) - 3)) {
987 "As %s climbs the stairs, a mysterious force momentarily surrounds %s...",
988 mon_nam(mtmp), mhim(mtmp));
991 "%s
\82ª
\8aK
\92i
\82ð
\82Ì
\82Ú
\82ë
\82¤
\82Æ
\82·
\82é
\82Æ
\8aï
\96
\82È
\97Í
\82ª%s
\82ð
\82Â
\82Â
\82ñ
\82¾
\81D
\81D
\81D",
992 mon_nam(mtmp), mhim(mtmp));
994 /* simpler than for the player; this will usually be
995 the Wizard and he'll immediately go right to the
996 upstairs, so there's not much point in having any
997 chance for a random position on the current level */
998 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_RANDOM,
1003 pline("%s escapes upstairs!", Monnam(mtmp));
1005 pline("%s
\82Í
\8aK
\92i
\82ð
\82Ì
\82Ú
\82Á
\82Ä
\93¦
\82°
\82½
\81I", Monnam(mtmp));
1006 migrate_to_level(mtmp, ledger_no(&u.uz) - 1, MIGR_STAIRS_DOWN,
1010 case MUSE_DOWNSTAIRS:
1014 pline("%s escapes downstairs!", Monnam(mtmp));
1016 pline("%s
\82Í
\8aK
\92i
\82ð
\8d~
\82è
\82Ä
\93¦
\82°
\82½
\81I", Monnam(mtmp));
1017 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_STAIRS_UP,
1020 case MUSE_UP_LADDER:
1024 pline("%s escapes up the ladder!", Monnam(mtmp));
1026 pline("%s
\82Í
\82Í
\82µ
\82²
\82ð
\82Ì
\82Ú
\82Á
\82Ä
\93¦
\82°
\82½
\81I", Monnam(mtmp));
1027 migrate_to_level(mtmp, ledger_no(&u.uz) - 1, MIGR_LADDER_DOWN,
1030 case MUSE_DN_LADDER:
1034 pline("%s escapes down the ladder!", Monnam(mtmp));
1036 pline("%s
\82Í
\82Í
\82µ
\82²
\82ð
\8d~
\82è
\82Ä
\93¦
\82°
\82½
\81I", Monnam(mtmp));
1037 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_LADDER_UP,
1042 if (ledger_no(&u.uz) == 1) {
1044 /* Monsters without the Amulet escape the dungeon and
1045 * are gone for good when they leave up the up stairs.
1046 * A monster with the Amulet would leave it behind
1047 * (mongone -> mdrop_special_objs) but we force any
1048 * monster who manages to acquire it or the invocation
1049 * tools to stick around instead of letting it escape.
1051 if (mon_has_special(mtmp))
1055 pline("%s escapes the dungeon!", Monnam(mtmp));
1057 pline("%s
\82Í
\96À
\8b{
\82©
\82ç
\93¦
\91\96\82µ
\82½
\81I", Monnam(mtmp));
1063 pline("%s escapes %sstairs!", Monnam(mtmp),
1064 sstairs.up ? "up" : "down");
1066 pline("%s
\82Í
\8aK
\92i
\82ð%s
\93¦
\82°
\82½
\81I", Monnam(mtmp),
1067 sstairs.up ? "
\82Ì
\82Ú
\82Á
\82Ä" : "
\8d~
\82è
\82Ä");
1069 /* going from the Valley to Castle (Stronghold) has no sstairs
1070 to target, but having sstairs.<sx,sy> == <0,0> will work the
1071 same as specifying MIGR_RANDOM when mon_arrive() eventually
1072 places the monster, so we can use MIGR_SSTAIRS unconditionally */
1073 migrate_to_level(mtmp, ledger_no(&sstairs.tolev), MIGR_SSTAIRS,
1076 case MUSE_TELEPORT_TRAP:
1079 Mnam = Monnam(mtmp);
1081 pline("%s %s onto a teleport trap!", Mnam,
1082 vtense(Mnam, locomotion(mtmp->data, "jump")));
1084 /*
\93ú
\96{
\8cê
\82Å
\82Í
\91S
\82Ä
\81u
\94ò
\82Ñ
\8d\9e\82ñ
\82¾
\81v */
1085 pline("%s
\82Í
\8fu
\8aÔ
\88Ú
\93®
\82Ìã©
\82É
\94ò
\82Ñ
\8d\9e\82ñ
\82¾
\81I", Mnam);
1087 seetrap(t_at(trapx, trapy));
1089 /* don't use rloc_to() because worm tails must "move" */
1090 remove_monster(mtmp->mx, mtmp->my);
1091 newsym(mtmp->mx, mtmp->my); /* update old location */
1092 place_monster(mtmp, trapx, trapy);
1095 newsym(trapx, trapy);
1098 case MUSE_POT_HEALING:
1099 mquaffmsg(mtmp, otmp);
1100 i = d(6 + 2 * bcsign(otmp), 4);
1102 if (mtmp->mhp > mtmp->mhpmax)
1103 mtmp->mhp = ++mtmp->mhpmax;
1104 if (!otmp->cursed && !mtmp->mcansee)
1105 mcureblindness(mtmp, vismon);
1108 pline("%s looks better.", Monnam(mtmp));
1110 pline("%s
\82Í
\8bC
\95ª
\82ª
\82æ
\82
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mtmp));
1112 makeknown(POT_HEALING);
1113 m_useup(mtmp, otmp);
1115 case MUSE_POT_EXTRA_HEALING:
1116 mquaffmsg(mtmp, otmp);
1117 i = d(6 + 2 * bcsign(otmp), 8);
1119 if (mtmp->mhp > mtmp->mhpmax)
1120 mtmp->mhp = (mtmp->mhpmax += (otmp->blessed ? 5 : 2));
1122 mcureblindness(mtmp, vismon);
1125 pline("%s looks much better.", Monnam(mtmp));
1127 pline("%s
\82Í
\82Æ
\82Ä
\82à
\8bC
\95ª
\82ª
\82æ
\82
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mtmp));
1129 makeknown(POT_EXTRA_HEALING);
1130 m_useup(mtmp, otmp);
1132 case MUSE_POT_FULL_HEALING:
1133 mquaffmsg(mtmp, otmp);
1134 if (otmp->otyp == POT_SICKNESS)
1135 unbless(otmp); /* Pestilence */
1136 mtmp->mhp = (mtmp->mhpmax += (otmp->blessed ? 8 : 4));
1137 if (!mtmp->mcansee && otmp->otyp != POT_SICKNESS)
1138 mcureblindness(mtmp, vismon);
1141 pline("%s looks completely healed.", Monnam(mtmp));
1143 pline("%s
\82Í
\8a®
\91S
\82É
\89ñ
\95\9c\82µ
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mtmp));
1145 makeknown(otmp->otyp);
1146 m_useup(mtmp, otmp);
1148 case MUSE_LIZARD_CORPSE:
1149 /* not actually called for its unstoning effect */
1150 mon_consume_unstone(mtmp, otmp, FALSE, FALSE);
1153 return 0; /* i.e. an exploded wand */
1155 impossible("%s wanted to perform action %d?", Monnam(mtmp),
1164 rnd_defensive_item(mtmp)
1167 struct permonst *pm = mtmp->data;
1168 int difficulty = mons[(monsndx(pm))].difficulty;
1171 if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
1172 || pm->mlet == S_GHOST || pm->mlet == S_KOP)
1175 switch (rn2(8 + (difficulty > 3) + (difficulty > 6) + (difficulty > 8))) {
1178 if (level.flags.noteleport && ++trycnt < 2)
1181 return WAN_TELEPORTATION;
1185 return SCR_TELEPORTATION;
1189 return WAN_CREATE_MONSTER;
1192 return SCR_CREATE_MONSTER;
1196 return POT_EXTRA_HEALING;
1198 return (mtmp->data != &mons[PM_PESTILENCE]) ? POT_FULL_HEALING
1201 if (is_floater(pm) || mtmp->isshk || mtmp->isgd || mtmp->ispriest)
1210 #define MUSE_WAN_DEATH 1
1211 #define MUSE_WAN_SLEEP 2
1212 #define MUSE_WAN_FIRE 3
1213 #define MUSE_WAN_COLD 4
1214 #define MUSE_WAN_LIGHTNING 5
1215 #define MUSE_WAN_MAGIC_MISSILE 6
1216 #define MUSE_WAN_STRIKING 7
1217 #define MUSE_SCR_FIRE 8
1218 #define MUSE_POT_PARALYSIS 9
1219 #define MUSE_POT_BLINDNESS 10
1220 #define MUSE_POT_CONFUSION 11
1221 #define MUSE_FROST_HORN 12
1222 #define MUSE_FIRE_HORN 13
1223 #define MUSE_POT_ACID 14
1224 /*#define MUSE_WAN_TELEPORTATION 15*/
1225 #define MUSE_POT_SLEEPING 16
1226 #define MUSE_SCR_EARTH 17
1228 /* Select an offensive item/action for a monster. Returns TRUE iff one is
1232 find_offensive(mtmp)
1235 register struct obj *obj;
1236 boolean reflection_skip = (Reflecting && rn2(2));
1237 struct obj *helmet = which_armor(mtmp, W_ARMH);
1239 m.offensive = (struct obj *) 0;
1241 if (mtmp->mpeaceful || is_animal(mtmp->data) || mindless(mtmp->data)
1242 || nohands(mtmp->data))
1246 if (in_your_sanctuary(mtmp, 0, 0))
1248 if (dmgtype(mtmp->data, AD_HEAL)
1249 && !uwep && !uarmu && !uarm && !uarmh
1250 && !uarms && !uarmg && !uarmc && !uarmf)
1252 /* all offensive items require orthogonal or diagonal targetting */
1253 if (!lined_up(mtmp))
1256 #define nomore(x) if (m.has_offense == x) continue;
1257 /* this picks the last viable item rather than prioritizing choices */
1258 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
1259 if (!reflection_skip) {
1260 nomore(MUSE_WAN_DEATH);
1261 if (obj->otyp == WAN_DEATH && obj->spe > 0) {
1263 m.has_offense = MUSE_WAN_DEATH;
1265 nomore(MUSE_WAN_SLEEP);
1266 if (obj->otyp == WAN_SLEEP && obj->spe > 0 && multi >= 0) {
1268 m.has_offense = MUSE_WAN_SLEEP;
1270 nomore(MUSE_WAN_FIRE);
1271 if (obj->otyp == WAN_FIRE && obj->spe > 0) {
1273 m.has_offense = MUSE_WAN_FIRE;
1275 nomore(MUSE_FIRE_HORN);
1276 if (obj->otyp == FIRE_HORN && obj->spe > 0 && can_blow(mtmp)) {
1278 m.has_offense = MUSE_FIRE_HORN;
1280 nomore(MUSE_WAN_COLD);
1281 if (obj->otyp == WAN_COLD && obj->spe > 0) {
1283 m.has_offense = MUSE_WAN_COLD;
1285 nomore(MUSE_FROST_HORN);
1286 if (obj->otyp == FROST_HORN && obj->spe > 0 && can_blow(mtmp)) {
1288 m.has_offense = MUSE_FROST_HORN;
1290 nomore(MUSE_WAN_LIGHTNING);
1291 if (obj->otyp == WAN_LIGHTNING && obj->spe > 0) {
1293 m.has_offense = MUSE_WAN_LIGHTNING;
1295 nomore(MUSE_WAN_MAGIC_MISSILE);
1296 if (obj->otyp == WAN_MAGIC_MISSILE && obj->spe > 0) {
1298 m.has_offense = MUSE_WAN_MAGIC_MISSILE;
1301 nomore(MUSE_WAN_STRIKING);
1302 if (obj->otyp == WAN_STRIKING && obj->spe > 0) {
1304 m.has_offense = MUSE_WAN_STRIKING;
1306 #if 0 /* use_offensive() has had some code to support wand of teleportation
1307 * for a long time, but find_offensive() never selected one;
1308 * so for the time being, this is still disabled */
1309 nomore(MUSE_WAN_TELEPORTATION);
1310 if (obj->otyp == WAN_TELEPORTATION && obj->spe > 0
1311 /* don't give controlled hero a free teleport */
1312 && !Teleport_control
1313 /* do try to move hero to a more vulnerable spot */
1314 && (onscary(u.ux, u.uy, mtmp)
1315 || (u.ux == xupstair && u.uy == yupstair)
1316 || (u.ux == xdnstair && u.uy == ydnstair)
1317 || (u.ux == sstairs.sx && u.uy == sstairs.sy)
1318 || (u.ux == xupladder && u.uy == yupladder)
1319 || (u.ux == xdnladder && u.uy == ydnladder))) {
1321 m.has_offense = MUSE_WAN_TELEPORTATION;
1324 nomore(MUSE_POT_PARALYSIS);
1325 if (obj->otyp == POT_PARALYSIS && multi >= 0) {
1327 m.has_offense = MUSE_POT_PARALYSIS;
1329 nomore(MUSE_POT_BLINDNESS);
1330 if (obj->otyp == POT_BLINDNESS && !attacktype(mtmp->data, AT_GAZE)) {
1332 m.has_offense = MUSE_POT_BLINDNESS;
1334 nomore(MUSE_POT_CONFUSION);
1335 if (obj->otyp == POT_CONFUSION) {
1337 m.has_offense = MUSE_POT_CONFUSION;
1339 nomore(MUSE_POT_SLEEPING);
1340 if (obj->otyp == POT_SLEEPING) {
1342 m.has_offense = MUSE_POT_SLEEPING;
1344 nomore(MUSE_POT_ACID);
1345 if (obj->otyp == POT_ACID) {
1347 m.has_offense = MUSE_POT_ACID;
1349 /* we can safely put this scroll here since the locations that
1350 * are in a 1 square radius are a subset of the locations that
1351 * are in wand or throwing range (in other words, always lined_up())
1353 nomore(MUSE_SCR_EARTH);
1354 if (obj->otyp == SCR_EARTH
1355 && ((helmet && is_metallic(helmet)) || mtmp->mconf
1356 || amorphous(mtmp->data) || passes_walls(mtmp->data)
1357 || noncorporeal(mtmp->data) || unsolid(mtmp->data)
1359 && dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= 2
1360 && mtmp->mcansee && haseyes(mtmp->data)
1361 && !Is_rogue_level(&u.uz)
1362 && (!In_endgame(&u.uz) || Is_earthlevel(&u.uz))) {
1364 m.has_offense = MUSE_SCR_EARTH;
1367 nomore(MUSE_SCR_FIRE);
1368 if (obj->otyp == SCR_FIRE && resists_fire(mtmp)
1369 && dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= 2
1370 && mtmp->mcansee && haseyes(mtmp->data)) {
1372 m.has_offense = MUSE_SCR_FIRE;
1376 return (boolean) !!m.has_offense;
1383 register struct monst *mtmp;
1384 register struct obj *otmp;
1387 boolean reveal_invis = FALSE;
1389 if (mtmp != &youmonst) {
1390 mtmp->msleeping = 0;
1391 if (mtmp->m_ap_type)
1394 switch (otmp->otyp) {
1396 reveal_invis = TRUE;
1397 if (mtmp == &youmonst) {
1399 makeknown(WAN_STRIKING);
1401 shieldeff(u.ux, u.uy);
1405 pline("
\83{
\83C
\83\93\81I");
1406 } else if (rnd(20) < 10 + u.uac) {
1408 pline_The("wand hits you!");
1410 pline("
\8fñ
\82Í
\82 \82È
\82½
\82É
\96½
\92\86\82µ
\82½
\81I");
1412 if (Half_spell_damage)
1413 tmp = (tmp + 1) / 2;
1415 losehp(tmp, "wand", KILLED_BY_AN);
1417 losehp(tmp, "
\8fÕ
\8c\82\82Ì
\8fñ
\82É
\82æ
\82Á
\82Ä", KILLED_BY_AN);
1420 pline_The("wand misses you.");
1422 pline("
\8fñ
\82Í
\82Í
\82¸
\82ê
\82½
\81D");
1425 } else if (resists_magm(mtmp)) {
1426 shieldeff(mtmp->mx, mtmp->my);
1430 pline("
\83{
\83C
\83\93\81I");
1431 } else if (rnd(20) < 10 + find_mac(mtmp)) {
1434 hit("wand", mtmp, exclam(tmp));
1436 hit("
\8fñ", mtmp, exclam(tmp));
1437 (void) resist(mtmp, otmp->oclass, tmp, TELL);
1438 if (cansee(mtmp->mx, mtmp->my) && zap_oseen)
1439 makeknown(WAN_STRIKING);
1445 if (cansee(mtmp->mx, mtmp->my) && zap_oseen)
1446 makeknown(WAN_STRIKING);
1449 #if 0 /* disabled because find_offensive() never picks WAN_TELEPORTATION */
1450 case WAN_TELEPORTATION:
1451 if (mtmp == &youmonst) {
1453 makeknown(WAN_TELEPORTATION);
1456 /* for consistency with zap.c, don't identify */
1457 if (mtmp->ispriest && *in_rooms(mtmp->mx, mtmp->my, TEMPLE)) {
1458 if (cansee(mtmp->mx, mtmp->my))
1460 pline("%s resists the magic!", Monnam(mtmp));
1462 pline("%s
\82Í
\96\82\96@
\82ð
\96h
\82¢
\82¾
\81I", Monnam(mtmp));
1463 } else if (!tele_restrict(mtmp))
1464 (void) rloc(mtmp, TRUE);
1468 case WAN_CANCELLATION:
1469 case SPE_CANCELLATION:
1470 (void) cancel_monst(mtmp, otmp, FALSE, TRUE, FALSE);
1474 if (!DEADMONSTER(mtmp) && cansee(bhitpos.x, bhitpos.y)
1475 && !canspotmon(mtmp))
1476 map_invisible(bhitpos.x, bhitpos.y);
1481 /* A modified bhit() for monsters. Based on bhit() in zap.c. Unlike
1482 * buzz(), bhit() doesn't take into account the possibility of a monster
1483 * zapping you, so we need a special function for it. (Unless someone wants
1484 * to merge the two functions...)
1487 mbhit(mon, range, fhitm, fhito, obj)
1488 struct monst *mon; /* monster shooting the wand */
1489 register int range; /* direction and range */
1490 int FDECL((*fhitm), (MONST_P, OBJ_P));
1491 int FDECL((*fhito), (OBJ_P, OBJ_P)); /* fns called when mon/obj hit */
1492 struct obj *obj; /* 2nd arg to fhitm/fhito */
1494 register struct monst *mtmp;
1495 register struct obj *otmp;
1499 bhitpos.x = mon->mx;
1500 bhitpos.y = mon->my;
1501 ddx = sgn(mon->mux - mon->mx);
1502 ddy = sgn(mon->muy - mon->my);
1504 while (range-- > 0) {
1517 if (find_drawbridge(&x, &y))
1518 switch (obj->otyp) {
1520 destroy_drawbridge(x, y);
1522 if (bhitpos.x == u.ux && bhitpos.y == u.uy) {
1523 (*fhitm)(&youmonst, obj);
1525 } else if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) {
1526 if (cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp))
1527 map_invisible(bhitpos.x, bhitpos.y);
1528 (*fhitm)(mtmp, obj);
1531 /* modified by GAN to hit all objects */
1533 int hitanything = 0;
1534 register struct obj *next_obj;
1536 for (otmp = level.objects[bhitpos.x][bhitpos.y]; otmp;
1538 /* Fix for polymorph bug, Tim Wright */
1539 next_obj = otmp->nexthere;
1540 hitanything += (*fhito)(otmp, obj);
1545 typ = levl[bhitpos.x][bhitpos.y].typ;
1546 if (IS_DOOR(typ) || typ == SDOOR) {
1547 switch (obj->otyp) {
1548 /* note: monsters don't use opening or locking magic
1549 at present, but keep these as placeholders */
1553 if (doorlock(obj, bhitpos.x, bhitpos.y)) {
1555 makeknown(obj->otyp);
1556 /* if a shop door gets broken, add it to
1557 the shk's fix list (no cost to player) */
1558 if (levl[bhitpos.x][bhitpos.y].doormask == D_BROKEN
1559 && *in_rooms(bhitpos.x, bhitpos.y, SHOPBASE))
1560 add_damage(bhitpos.x, bhitpos.y, 0L);
1566 || (IS_DOOR(typ) && (levl[bhitpos.x][bhitpos.y].doormask
1567 & (D_LOCKED | D_CLOSED)))) {
1575 /* Perform an offensive action for a monster. Must be called immediately
1576 * after find_offensive(). Return values are same as use_defensive().
1583 struct obj *otmp = m.offensive;
1586 /* offensive potions are not drunk, they're thrown */
1587 if (otmp->oclass != POTION_CLASS && (i = precheck(mtmp, otmp)) != 0)
1589 oseen = otmp && canseemon(mtmp);
1591 switch (m.has_offense) {
1592 case MUSE_WAN_DEATH:
1593 case MUSE_WAN_SLEEP:
1596 case MUSE_WAN_LIGHTNING:
1597 case MUSE_WAN_MAGIC_MISSILE:
1598 mzapmsg(mtmp, otmp, FALSE);
1601 makeknown(otmp->otyp);
1603 buzz((int) (-30 - (otmp->otyp - WAN_MAGIC_MISSILE)),
1604 (otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my,
1605 sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my));
1607 return (DEADMONSTER(mtmp)) ? 1 : 2;
1608 case MUSE_FIRE_HORN:
1609 case MUSE_FROST_HORN:
1611 makeknown(otmp->otyp);
1613 pline("%s plays a %s!", Monnam(mtmp), xname(otmp));
1615 pline("%s
\82Í%s
\82ð
\90\81\82¢
\82½
\81I", Monnam(mtmp), xname(otmp));
1618 You_hear("a horn being played.");
1620 You_hear("
\83z
\83\8b\83\93\82Ì
\89¹
\82ð
\95·
\82¢
\82½
\81D");
1623 buzz(-30 - ((otmp->otyp == FROST_HORN) ? AD_COLD - 1 : AD_FIRE - 1),
1624 rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
1625 sgn(mtmp->muy - mtmp->my));
1627 return (DEADMONSTER(mtmp)) ? 1 : 2;
1628 case MUSE_WAN_TELEPORTATION:
1629 case MUSE_WAN_STRIKING:
1631 mzapmsg(mtmp, otmp, FALSE);
1634 mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp);
1637 case MUSE_SCR_EARTH: {
1638 /* TODO: handle steeds */
1640 /* don't use monster fields after killing it */
1641 boolean confused = (mtmp->mconf ? TRUE : FALSE);
1642 int mmx = mtmp->mx, mmy = mtmp->my;
1643 boolean is_cursed = otmp->cursed;
1645 mreadmsg(mtmp, otmp);
1646 /* Identify the scroll */
1647 if (canspotmon(mtmp)) {
1649 pline_The("%s rumbles %s %s!", ceiling(mtmp->mx, mtmp->my),
1650 otmp->blessed ? "around" : "above", mon_nam(mtmp));
1652 pline("%s
\82Ì%s
\82Ì%s
\82©
\82ç
\83S
\83\8d\83S
\83\8d\82Æ
\89¹
\82ª
\95·
\82±
\82¦
\82Ä
\82«
\82½
\81D",
1654 otmp->blessed ? "
\82Ü
\82í
\82è" : "
\90^
\8fã",
1655 ceiling(mtmp->mx, mtmp->my));
1658 makeknown(otmp->otyp);
1659 } else if (cansee(mtmp->mx, mtmp->my)) {
1661 pline_The("%s rumbles in the middle of nowhere!",
1663 pline_The("
\82Ç
\82±
\82©
\82Ì%s
\82©
\82ç
\83S
\83\8d\83S
\83\8d\82Æ
\89¹
\82ª
\95·
\82±
\82¦
\82Ä
\82«
\82½
\81D",
1664 ceiling(mtmp->mx, mtmp->my));
1666 map_invisible(mtmp->mx, mtmp->my);
1668 makeknown(otmp->otyp);
1671 /* Loop through the surrounding squares */
1672 for (x = mmx - 1; x <= mmx + 1; x++) {
1673 for (y = mmy - 1; y <= mmy + 1; y++) {
1674 /* Is this a suitable spot? */
1675 if (isok(x, y) && !closed_door(x, y)
1676 && !IS_ROCK(levl[x][y].typ) && !IS_AIR(levl[x][y].typ)
1677 && (((x == mmx) && (y == mmy)) ? !otmp->blessed
1679 && (x != u.ux || y != u.uy)) {
1680 (void) drop_boulder_on_monster(x, y, confused, FALSE);
1684 m_useup(mtmp, otmp);
1685 /* Attack the player */
1686 if (distmin(mmx, mmy, u.ux, u.uy) == 1 && !is_cursed) {
1687 drop_boulder_on_player(confused, !is_cursed, FALSE, TRUE);
1690 return (DEADMONSTER(mtmp)) ? 1 : 2;
1693 case MUSE_SCR_FIRE: {
1694 boolean vis = cansee(mtmp->mx, mtmp->my);
1696 mreadmsg(mtmp, otmp);
1700 pline("Oh, what a pretty fire!");
1702 pline("
\82í
\82\9f\81C
\82«
\82ê
\82¢
\82È
\89\8a\82¾
\81I");
1704 struct monst *mtmp2;
1709 pline_The("scroll erupts in a tower of flame!");
1711 pline("
\8aª
\95¨
\82©
\82ç
\89Î
\92\8c\82ª
\97§
\82¿
\8f¸
\82Á
\82½
\81I");
1712 shieldeff(mtmp->mx, mtmp->my);
1714 pline("%s is uninjured.", Monnam(mtmp));
1716 pline("%s
\82Í
\8f\9d\82Â
\82©
\82È
\82©
\82Á
\82½
\81D", Monnam(mtmp));
1717 (void) destroy_mitem(mtmp, SCROLL_CLASS, AD_FIRE);
1718 (void) destroy_mitem(mtmp, SPBOOK_CLASS, AD_FIRE);
1719 (void) destroy_mitem(mtmp, POTION_CLASS, AD_FIRE);
1720 num = (2 * (rn1(3, 3) + 2 * bcsign(otmp)) + 1) / 3;
1721 if (Fire_resistance)
1723 You("are not harmed.");
1725 You("
\8f\9d\82Â
\82©
\82È
\82©
\82Á
\82½
\81D");
1727 if (Half_spell_damage)
1728 num = (num + 1) / 2;
1731 losehp(num, "scroll of fire", KILLED_BY_AN);
1733 losehp(num, "
\89\8a\82Ì
\8aª
\95¨
\82Å", KILLED_BY_AN);
1734 for (mtmp2 = fmon; mtmp2; mtmp2 = mtmp2->nmon) {
1735 if (DEADMONSTER(mtmp2))
1739 if (dist2(mtmp2->mx, mtmp2->my, mtmp->mx, mtmp->my) < 3) {
1740 if (resists_fire(mtmp2))
1743 if (resists_cold(mtmp2))
1744 mtmp2->mhp -= 3 * num;
1745 if (DEADMONSTER(mtmp2)) {
1755 case MUSE_POT_PARALYSIS:
1756 case MUSE_POT_BLINDNESS:
1757 case MUSE_POT_CONFUSION:
1758 case MUSE_POT_SLEEPING:
1760 /* Note: this setting of dknown doesn't suffice. A monster
1761 * which is out of sight might throw and it hits something _in_
1762 * sight, a problem not existing with wands because wand rays
1763 * are not objects. Also set dknown in mthrowu.c.
1765 if (cansee(mtmp->mx, mtmp->my)) {
1768 pline("%s hurls %s!", Monnam(mtmp), singular(otmp, doname));
1770 pline("%s
\82Í%s
\82ð
\8b
\82
\93\8a\82°
\82Â
\82¯
\82½
\81I", Monnam(mtmp), singular(otmp, doname));
1772 m_throw(mtmp, mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
1773 sgn(mtmp->muy - mtmp->my),
1774 distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy), otmp);
1777 return 0; /* i.e. an exploded wand */
1779 impossible("%s wanted to perform action %d?", Monnam(mtmp),
1787 rnd_offensive_item(mtmp)
1790 struct permonst *pm = mtmp->data;
1791 int difficulty = mons[(monsndx(pm))].difficulty;
1793 if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
1794 || pm->mlet == S_GHOST || pm->mlet == S_KOP)
1796 if (difficulty > 7 && !rn2(35))
1798 switch (rn2(9 - (difficulty < 4) + 4 * (difficulty > 6))) {
1800 struct obj *helmet = which_armor(mtmp, W_ARMH);
1802 if ((helmet && is_metallic(helmet)) || amorphous(pm)
1803 || passes_walls(pm) || noncorporeal(pm) || unsolid(pm))
1805 } /* fall through */
1807 return WAN_STRIKING;
1811 return POT_CONFUSION;
1813 return POT_BLINDNESS;
1815 return POT_SLEEPING;
1817 return POT_PARALYSIS;
1820 return WAN_MAGIC_MISSILE;
1828 return WAN_LIGHTNING;
1834 #define MUSE_POT_GAIN_LEVEL 1
1835 #define MUSE_WAN_MAKE_INVISIBLE 2
1836 #define MUSE_POT_INVISIBILITY 3
1837 #define MUSE_POLY_TRAP 4
1838 #define MUSE_WAN_POLYMORPH 5
1839 #define MUSE_POT_SPEED 6
1840 #define MUSE_WAN_SPEED_MONSTER 7
1841 #define MUSE_BULLWHIP 8
1842 #define MUSE_POT_POLYMORPH 9
1848 register struct obj *obj;
1849 struct permonst *mdat = mtmp->data;
1850 int x = mtmp->mx, y = mtmp->my;
1852 int xx, yy, pmidx = NON_PM;
1853 boolean immobile = (mdat->mmove == 0);
1854 boolean stuck = (mtmp == u.ustuck);
1856 m.misc = (struct obj *) 0;
1858 if (is_animal(mdat) || mindless(mdat))
1860 if (u.uswallow && stuck)
1863 /* We arbitrarily limit to times when a player is nearby for the
1864 * same reason as Junior Pac-Man doesn't have energizers eaten until
1865 * you can see them...
1867 if (dist2(x, y, mtmp->mux, mtmp->muy) > 36)
1870 if (!stuck && !immobile && (mtmp->cham == NON_PM)
1871 && mons[(pmidx = monsndx(mdat))].difficulty < 6) {
1872 boolean ignore_boulders = (verysmall(mdat) || throws_rocks(mdat)
1873 || passes_walls(mdat)),
1874 diag_ok = !NODIAG(pmidx);
1876 for (xx = x - 1; xx <= x + 1; xx++)
1877 for (yy = y - 1; yy <= y + 1; yy++)
1878 if (isok(xx, yy) && (xx != u.ux || yy != u.uy)
1879 && (diag_ok || xx == x || yy == y)
1880 && ((xx == x && yy == y) || !level.monsters[xx][yy]))
1881 if ((t = t_at(xx, yy)) != 0
1882 && (ignore_boulders || !sobj_at(BOULDER, xx, yy))
1883 && !onscary(xx, yy, mtmp)) {
1884 /* use trap if it's the correct type */
1885 if (t->ttyp == POLY_TRAP) {
1888 m.has_misc = MUSE_POLY_TRAP;
1896 #define nomore(x) if (m.has_misc == x) continue
1898 * [bug?] Choice of item is not prioritized; the last viable one
1899 * in the monster's inventory will be chosen.
1900 * 'nomore()' is nearly worthless because it only screens checking
1901 * of duplicates when there is no alternate type in between them.
1903 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
1904 /* Monsters shouldn't recognize cursed items; this kludge is
1905 necessary to prevent serious problems though... */
1906 if (obj->otyp == POT_GAIN_LEVEL
1908 || (!mtmp->isgd && !mtmp->isshk && !mtmp->ispriest))) {
1910 m.has_misc = MUSE_POT_GAIN_LEVEL;
1912 nomore(MUSE_BULLWHIP);
1913 if (obj->otyp == BULLWHIP && !mtmp->mpeaceful
1914 /* the random test prevents whip-wielding
1915 monster from attempting disarm every turn */
1916 && uwep && !rn2(5) && obj == MON_WEP(mtmp)
1917 /* hero's location must be known and adjacent */
1918 && mtmp->mux == u.ux && mtmp->muy == u.uy
1919 && distu(mtmp->mx, mtmp->my) <= 2
1920 /* don't bother if it can't work (this doesn't
1921 prevent cursed weapons from being targetted) */
1922 && (canletgo(uwep, "")
1923 || (u.twoweap && canletgo(uswapwep, "")))) {
1925 m.has_misc = MUSE_BULLWHIP;
1927 /* Note: peaceful/tame monsters won't make themselves
1928 * invisible unless you can see them. Not really right, but...
1930 nomore(MUSE_WAN_MAKE_INVISIBLE);
1931 if (obj->otyp == WAN_MAKE_INVISIBLE && obj->spe > 0 && !mtmp->minvis
1932 && !mtmp->invis_blkd && (!mtmp->mpeaceful || See_invisible)
1933 && (!attacktype(mtmp->data, AT_GAZE) || mtmp->mcan)) {
1935 m.has_misc = MUSE_WAN_MAKE_INVISIBLE;
1937 nomore(MUSE_POT_INVISIBILITY);
1938 if (obj->otyp == POT_INVISIBILITY && !mtmp->minvis
1939 && !mtmp->invis_blkd && (!mtmp->mpeaceful || See_invisible)
1940 && (!attacktype(mtmp->data, AT_GAZE) || mtmp->mcan)) {
1942 m.has_misc = MUSE_POT_INVISIBILITY;
1944 nomore(MUSE_WAN_SPEED_MONSTER);
1945 if (obj->otyp == WAN_SPEED_MONSTER && obj->spe > 0
1946 && mtmp->mspeed != MFAST && !mtmp->isgd) {
1948 m.has_misc = MUSE_WAN_SPEED_MONSTER;
1950 nomore(MUSE_POT_SPEED);
1951 if (obj->otyp == POT_SPEED && mtmp->mspeed != MFAST && !mtmp->isgd) {
1953 m.has_misc = MUSE_POT_SPEED;
1955 nomore(MUSE_WAN_POLYMORPH);
1956 if (obj->otyp == WAN_POLYMORPH && obj->spe > 0
1957 && (mtmp->cham == NON_PM) && mons[monsndx(mdat)].difficulty < 6) {
1959 m.has_misc = MUSE_WAN_POLYMORPH;
1961 nomore(MUSE_POT_POLYMORPH);
1962 if (obj->otyp == POT_POLYMORPH && (mtmp->cham == NON_PM)
1963 && mons[monsndx(mdat)].difficulty < 6) {
1965 m.has_misc = MUSE_POT_POLYMORPH;
1968 return (boolean) !!m.has_misc;
1972 /* type of monster to polymorph into; defaults to one suitable for the
1973 current level rather than the totally arbitrary choice of newcham() */
1974 static struct permonst *
1975 muse_newcham_mon(mon)
1980 if ((m_armr = which_armor(mon, W_ARM)) != 0) {
1981 if (Is_dragon_scales(m_armr))
1982 return Dragon_scales_to_pm(m_armr);
1983 else if (Is_dragon_mail(m_armr))
1984 return Dragon_mail_to_pm(m_armr);
1994 struct obj *otmp = m.misc;
1995 boolean vis, vismon, oseen;
1998 if ((i = precheck(mtmp, otmp)) != 0)
2000 vis = cansee(mtmp->mx, mtmp->my);
2001 vismon = canseemon(mtmp);
2002 oseen = otmp && vismon;
2004 switch (m.has_misc) {
2005 case MUSE_POT_GAIN_LEVEL:
2006 mquaffmsg(mtmp, otmp);
2008 if (Can_rise_up(mtmp->mx, mtmp->my, &u.uz)) {
2009 register int tolev = depth(&u.uz) - 1;
2012 get_level(&tolevel, tolev);
2013 /* insurance against future changes... */
2014 if (on_level(&tolevel, &u.uz))
2018 pline("%s rises up, through the %s!", Monnam(mtmp),
2019 ceiling(mtmp->mx, mtmp->my));
2021 pline("%s
\82Í%s
\82ð
\93Ë
\82«
\94²
\82¯
\82½
\81I", Monnam(mtmp),
2022 ceiling(mtmp->mx, mtmp->my));
2024 if (!objects[POT_GAIN_LEVEL].oc_name_known
2025 && !objects[POT_GAIN_LEVEL].oc_uname)
2028 m_useup(mtmp, otmp);
2029 migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM,
2036 pline("%s looks uneasy.", Monnam(mtmp));
2038 pline("%s
\82Í
\95s
\88À
\82°
\82É
\8c©
\82¦
\82é
\81D", Monnam(mtmp));
2039 if (!objects[POT_GAIN_LEVEL].oc_name_known
2040 && !objects[POT_GAIN_LEVEL].oc_uname)
2043 m_useup(mtmp, otmp);
2049 pline("%s seems more experienced.", Monnam(mtmp));
2051 pline("%s
\82Í
\8co
\8c±
\82ð
\90Ï
\82ñ
\82¾
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81D", Monnam(mtmp));
2053 makeknown(POT_GAIN_LEVEL);
2054 m_useup(mtmp, otmp);
2055 if (!grow_up(mtmp, (struct monst *) 0))
2057 /* grew into genocided monster */
2059 case MUSE_WAN_MAKE_INVISIBLE:
2060 case MUSE_POT_INVISIBILITY:
2061 if (otmp->otyp == WAN_MAKE_INVISIBLE) {
2062 mzapmsg(mtmp, otmp, TRUE);
2065 mquaffmsg(mtmp, otmp);
2066 /* format monster's name before altering its visibility */
2067 Strcpy(nambuf, mon_nam(mtmp));
2068 mon_set_minvis(mtmp);
2069 if (vismon && mtmp->minvis) { /* was seen, now invisible */
2070 if (canspotmon(mtmp)) {
2072 pline("%s body takes on a %s transparency.",
2073 upstart(s_suffix(nambuf)),
2074 Hallucination ? "normal" : "strange");
2076 pline("%s%s
\82Ì
\91Ì
\82Í
\93§
\89ß
\90«
\82ð
\82à
\82Á
\82½
\81D",
2077 Hallucination ? "
\82 \82½
\82è
\82Ü
\82¦
\82È
\82±
\82Æ
\82¾
\82ª" : "
\8aï
\96
\82È
\82±
\82Æ
\82É",
2082 pline("Suddenly you cannot see %s.", nambuf);
2084 pline("%s
\82Í
\93Ë
\91R
\8c©
\82¦
\82È
\82
\82È
\82Á
\82½
\81D", nambuf);
2086 map_invisible(mtmp->mx, mtmp->my);
2089 makeknown(otmp->otyp);
2091 if (otmp->otyp == POT_INVISIBILITY) {
2093 you_aggravate(mtmp);
2094 m_useup(mtmp, otmp);
2097 case MUSE_WAN_SPEED_MONSTER:
2098 mzapmsg(mtmp, otmp, TRUE);
2100 mon_adjust_speed(mtmp, 1, otmp);
2102 case MUSE_POT_SPEED:
2103 mquaffmsg(mtmp, otmp);
2104 /* note difference in potion effect due to substantially
2105 different methods of maintaining speed ratings:
2106 player's character becomes "very fast" temporarily;
2107 monster becomes "one stage faster" permanently */
2108 mon_adjust_speed(mtmp, 1, otmp);
2109 m_useup(mtmp, otmp);
2111 case MUSE_WAN_POLYMORPH:
2112 mzapmsg(mtmp, otmp, TRUE);
2114 (void) newcham(mtmp, muse_newcham_mon(mtmp), TRUE, FALSE);
2116 makeknown(WAN_POLYMORPH);
2118 case MUSE_POT_POLYMORPH:
2119 mquaffmsg(mtmp, otmp);
2122 pline("%s suddenly mutates!", Monnam(mtmp));
2124 pline("%s
\82Í
\93Ë
\91R
\95Ï
\89»
\82µ
\82½
\81I", Monnam(mtmp));
2125 (void) newcham(mtmp, muse_newcham_mon(mtmp), FALSE, FALSE);
2127 makeknown(POT_POLYMORPH);
2128 m_useup(mtmp, otmp);
2130 case MUSE_POLY_TRAP:
2132 const char *Mnam = Monnam(mtmp);
2135 pline("%s deliberately %s onto a polymorph trap!", Mnam,
2136 vtense(Mnam, locomotion(mtmp->data, "jump")));
2138 pline("%s
\82Í
\82í
\82´
\82Æ
\95Ï
\89»
\82Ìã©
\82É
\94ò
\82Ñ
\82±
\82ñ
\82¾
\81I", Mnam);
2142 seetrap(t_at(trapx, trapy));
2144 /* don't use rloc() due to worms */
2145 remove_monster(mtmp->mx, mtmp->my);
2146 newsym(mtmp->mx, mtmp->my);
2147 place_monster(mtmp, trapx, trapy);
2150 newsym(trapx, trapy);
2152 (void) newcham(mtmp, (struct permonst *) 0, FALSE, FALSE);
2155 /* attempt to disarm hero */
2158 const char *The_whip = vismon ? "The bullwhip" : "A whip";
2160 const char *The_whip = vismon ? "
\95Ú" : "
\95Ú";
2161 int where_to = rn2(4);
2162 struct obj *obj = uwep;
2164 char the_weapon[BUFSZ];
2166 if (!obj || !canletgo(obj, "")
2167 || (u.twoweap && canletgo(uswapwep, "") && rn2(2)))
2170 break; /* shouldn't happen after find_misc() */
2172 Strcpy(the_weapon, the(xname(obj)));
2173 hand = body_part(HAND);
2175 hand = makeplural(hand);
2179 pline("%s flicks a bullwhip towards your %s!", Monnam(mtmp),
2182 pline("%s
\82Í
\82 \82È
\82½
\82Ì%s
\82É
\8cü
\82©
\82Á
\82Ä
\95Ú
\82ð
\91Å
\82Á
\82½
\81I", Monnam(mtmp),
2185 if (obj->otyp == HEAVY_IRON_BALL) {
2187 pline("%s fails to wrap around %s.", The_whip, the_weapon);
2189 pline("%s
\82Í%s
\82É
\82Í
\82©
\82ç
\82Ý
\82Â
\82©
\82È
\82©
\82Á
\82½
\81D", The_whip, the_weapon);
2193 pline("%s wraps around %s you're wielding!", The_whip,
2196 pline("%s
\82Í
\82 \82È
\82½
\82Ì
\91\95\94õ
\82µ
\82Ä
\82¢
\82é%s
\82É
\82©
\82ç
\82Ý
\82Â
\82¢
\82½
\81I", The_whip,
2201 pline("%s welded to your %s%c",
2202 !is_plural(obj) ? "It is" : "They are", hand,
2203 !obj->bknown ? '!' : '.');
2205 pline("
\82µ
\82©
\82µ
\81C
\82»
\82ê
\82Í
\82Ü
\82¾
\82 \82È
\82½
\82Ì%s
\82Ì
\92\86\82É
\82 \82é%s",
2207 !obj->bknown ? "
\81I" : "
\81D");
2209 /* obj->bknown = 1; */ /* welded() takes care of this */
2214 pline_The("whip slips free."); /* not `The_whip' */
2216 pline("
\95Ú
\82Í
\82Ù
\82Ç
\82¯
\82½
\81D"); /* not `The_whip' */
2219 } else if (where_to == 3 && mon_hates_silver(mtmp)
2220 && objects[obj->otyp].oc_material == SILVER) {
2221 /* this monster won't want to catch a silver
2222 weapon; drop it at hero's feet instead */
2225 remove_worn_item(obj, FALSE);
2228 case 1: /* onto floor beneath mon */
2230 pline("%s yanks %s from your %s!", Monnam(mtmp), the_weapon,
2233 pline("%s
\82Í%s
\82ð
\82 \82È
\82½
\82Ì%s
\82©
\82ç
\82®
\82¢
\82Æ
\82Ð
\82Á
\82Ï
\82Á
\82½
\81I", Monnam(mtmp), the_weapon,
2236 place_object(obj, mtmp->mx, mtmp->my);
2238 case 2: /* onto floor beneath you */
2240 pline("%s yanks %s to the %s!", Monnam(mtmp), the_weapon,
2241 surface(u.ux, u.uy));
2243 pline("%s
\82Í%s
\82ð%s
\82É
\88ø
\82«
\97\8e\82µ
\82½
\81I", Monnam(mtmp), the_weapon,
2244 surface(u.ux, u.uy));
2248 case 3: /* into mon's inventory */
2250 pline("%s snatches %s!", Monnam(mtmp), the_weapon);
2252 pline("%s
\82Í%s
\82ð
\92D
\82Á
\82½
\81I", Monnam(mtmp), the_weapon);
2253 (void) mpickobj(mtmp, obj);
2260 return 0; /* i.e. an exploded wand */
2262 impossible("%s wanted to perform action %d?", Monnam(mtmp),
2274 pline("For some reason, %s presence is known to you.",
2275 s_suffix(noit_mon_nam(mtmp)));
2277 pline("
\82È
\82º
\82©
\81C
\82 \82È
\82½
\82Í%s
\82Ì
\91¶
\8dÝ
\82É
\8bC
\82ª
\82Â
\82¢
\82½
\81D",
2278 noit_mon_nam(mtmp));
2282 cliparound(mtmp->mx, mtmp->my);
2284 show_glyph(mtmp->mx, mtmp->my, mon_to_glyph(mtmp, rn2));
2287 You_feel("aggravated at %s.", noit_mon_nam(mtmp));
2289 You("%s
\82É
\95 \82ª
\82½
\82Á
\82½
\81D", mon_nam(mtmp));
2290 display_nhwindow(WIN_MAP, TRUE);
2292 if (unconscious()) {
2295 nomovemsg = "Aggravated, you are jolted into full consciousness.";
2297 nomovemsg = "
\95 \82ª
\82½
\82Á
\82Ä
\82¢
\82Ä
\81C
\83s
\83\8a\83s
\83\8a\82µ
\82Ä
\82¢
\82é
\81D";
2299 newsym(mtmp->mx, mtmp->my);
2300 if (!canspotmon(mtmp))
2301 map_invisible(mtmp->mx, mtmp->my);
2308 struct permonst *pm = mtmp->data;
2309 int difficulty = mons[(monsndx(pm))].difficulty;
2311 if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
2312 || pm->mlet == S_GHOST || pm->mlet == S_KOP)
2314 /* Unlike other rnd_item functions, we only allow _weak_ monsters
2315 * to have this item; after all, the item will be used to strengthen
2316 * the monster and strong monsters won't use it at all...
2318 if (difficulty < 6 && !rn2(30))
2319 return rn2(6) ? POT_POLYMORPH : WAN_POLYMORPH;
2321 if (!rn2(40) && !nonliving(pm) && !is_vampshifter(mtmp))
2322 return AMULET_OF_LIFE_SAVING;
2328 return rn2(6) ? POT_SPEED : WAN_SPEED_MONSTER;
2330 if (mtmp->mpeaceful && !See_invisible)
2332 return rn2(6) ? POT_INVISIBILITY : WAN_MAKE_INVISIBLE;
2334 return POT_GAIN_LEVEL;
2341 searches_for_item(mon, obj)
2345 int typ = obj->otyp;
2347 if (is_animal(mon->data) || mindless(mon->data)
2348 || mon->data == &mons[PM_GHOST]) /* don't loot bones piles */
2351 if (typ == WAN_MAKE_INVISIBLE || typ == POT_INVISIBILITY)
2352 return (boolean) (!mon->minvis && !mon->invis_blkd
2353 && !attacktype(mon->data, AT_GAZE));
2354 if (typ == WAN_SPEED_MONSTER || typ == POT_SPEED)
2355 return (boolean) (mon->mspeed != MFAST);
2357 switch (obj->oclass) {
2361 if (typ == WAN_DIGGING)
2362 return (boolean) !is_floater(mon->data);
2363 if (typ == WAN_POLYMORPH)
2364 return (boolean) (mons[monsndx(mon->data)].difficulty < 6);
2365 if (objects[typ].oc_dir == RAY || typ == WAN_STRIKING
2366 || typ == WAN_TELEPORTATION || typ == WAN_CREATE_MONSTER)
2370 if (typ == POT_HEALING || typ == POT_EXTRA_HEALING
2371 || typ == POT_FULL_HEALING || typ == POT_POLYMORPH
2372 || typ == POT_GAIN_LEVEL || typ == POT_PARALYSIS
2373 || typ == POT_SLEEPING || typ == POT_ACID || typ == POT_CONFUSION)
2375 if (typ == POT_BLINDNESS && !attacktype(mon->data, AT_GAZE))
2379 if (typ == SCR_TELEPORTATION || typ == SCR_CREATE_MONSTER
2380 || typ == SCR_EARTH || typ == SCR_FIRE)
2384 if (typ == AMULET_OF_LIFE_SAVING)
2385 return (boolean) !(nonliving(mon->data) || is_vampshifter(mon));
2386 if (typ == AMULET_OF_REFLECTION)
2390 if (typ == PICK_AXE)
2391 return (boolean) needspick(mon->data);
2392 if (typ == UNICORN_HORN)
2393 return (boolean) (!obj->cursed && !is_unicorn(mon->data));
2394 if (typ == FROST_HORN || typ == FIRE_HORN)
2395 return (obj->spe > 0 && can_blow(mon));
2399 return (boolean) (((mon->misc_worn_check & W_ARMG) != 0L
2400 && touch_petrifies(&mons[obj->corpsenm]))
2401 || (!resists_ston(mon)
2402 && cures_stoning(mon, obj, FALSE)));
2404 return (boolean) (mcould_eat_tin(mon)
2405 && (!resists_ston(mon)
2406 && cures_stoning(mon, obj, TRUE)));
2408 return (boolean) touch_petrifies(&mons[obj->corpsenm]);
2418 mon_reflects(mon, str)
2422 struct obj *orefl = which_armor(mon, W_ARMS);
2424 if (orefl && orefl->otyp == SHIELD_OF_REFLECTION) {
2427 pline(str, s_suffix(mon_nam(mon)), "shield");
2429 pline(str, mon_nam(mon), "
\8f\82");
2430 makeknown(SHIELD_OF_REFLECTION);
2433 } else if (arti_reflects(MON_WEP(mon))) {
2434 /* due to wielded artifact weapon */
2437 pline(str, s_suffix(mon_nam(mon)), "weapon");
2439 pline(str, mon_nam(mon), "
\95\90\8aí");
2441 } else if ((orefl = which_armor(mon, W_AMUL))
2442 && orefl->otyp == AMULET_OF_REFLECTION) {
2445 pline(str, s_suffix(mon_nam(mon)), "amulet");
2447 pline(str, mon_nam(mon), "
\96\82\8f\9c\82¯");
2448 makeknown(AMULET_OF_REFLECTION);
2451 } else if ((orefl = which_armor(mon, W_ARM))
2452 && (orefl->otyp == SILVER_DRAGON_SCALES
2453 || orefl->otyp == SILVER_DRAGON_SCALE_MAIL)) {
2456 pline(str, s_suffix(mon_nam(mon)), "armor");
2458 pline(str, mon_nam(mon), "
\8aZ");
2460 } else if (mon->data == &mons[PM_SILVER_DRAGON]
2461 || mon->data == &mons[PM_CHROMATIC_DRAGON]) {
2462 /* Silver dragons only reflect when mature; babies do not */
2465 pline(str, s_suffix(mon_nam(mon)), "scales");
2467 pline(str, mon_nam(mon), "
\97Ø");
2475 const char *fmt, *str;
2477 /* Check from outermost to innermost objects */
2478 if (EReflecting & W_ARMS) {
2481 pline(fmt, str, "shield");
2483 pline(fmt, str, "
\8f\82");
2484 makeknown(SHIELD_OF_REFLECTION);
2487 } else if (EReflecting & W_WEP) {
2488 /* Due to wielded artifact weapon */
2491 pline(fmt, str, "weapon");
2493 pline(fmt, str, "
\95\90\8aí");
2495 } else if (EReflecting & W_AMUL) {
2498 pline(fmt, str, "medallion");
2500 pline(fmt, str, "
\83\81\83_
\83\8a\83I
\83\93");
2501 makeknown(AMULET_OF_REFLECTION);
2504 } else if (EReflecting & W_ARM) {
2507 pline(fmt, str, uskin ? "luster" : "armor");
2509 pline(fmt, str, uskin ? "
\82Â
\82â" : "
\8aZ");
2511 } else if (youmonst.data == &mons[PM_SILVER_DRAGON]) {
2514 pline(fmt, str, "scales");
2516 pline(fmt, str, "
\97Ø");
2522 /* cure mon's blindness (use_defensive, dog_eat, meatobj) */
2524 mcureblindness(mon, verbos)
2528 if (!mon->mcansee) {
2531 if (verbos && haseyes(mon->data))
2533 pline("%s can see again.", Monnam(mon));
2535 pline("%s
\82Í
\82Ü
\82½
\8c©
\82¦
\82é
\82æ
\82¤
\82É
\82È
\82Á
\82½
\81D", Monnam(mon));
2539 /* TRUE if the monster ate something */
2541 munstone(mon, by_you)
2548 if (resists_ston(mon))
2550 if (mon->meating || !mon->mcanmove || mon->msleeping)
2552 mon->mstrategy &= ~STRAT_WAITFORU;
2554 tinok = mcould_eat_tin(mon);
2555 for (obj = mon->minvent; obj; obj = obj->nobj) {
2556 if (cures_stoning(mon, obj, tinok)) {
2557 mon_consume_unstone(mon, obj, by_you, TRUE);
2565 mon_consume_unstone(mon, obj, by_you, stoning)
2569 boolean stoning; /* True: stop petrification, False: cure stun && confusion */
2571 boolean vis = canseemon(mon), tinned = obj->otyp == TIN,
2572 food = obj->otyp == CORPSE || tinned,
2573 acid = obj->otyp == POT_ACID
2574 || (food && acidic(&mons[obj->corpsenm])),
2575 lizard = food && obj->corpsenm == PM_LIZARD;
2576 int nutrit = food ? dog_nutrition(mon, obj) : 0; /* also sets meating */
2578 /* give a "<mon> is slowing down" message and also remove
2579 intrinsic speed (comparable to similar effect on the hero) */
2581 mon_adjust_speed(mon, -3, (struct obj *) 0);
2584 long save_quan = obj->quan;
2588 pline("%s %s %s.", Monnam(mon),
2589 (obj->oclass == POTION_CLASS)
2591 : (obj->otyp == TIN) ? "opens and eats the contents of"
2593 distant_name(obj, doname));
2595 pline("%s
\82Í%s
\82ð%s
\81D", Monnam(mon),
2596 distant_name(obj, doname),
2597 (obj->oclass == POTION_CLASS)
2599 : (obj->otyp == TIN) ? "
\8aJ
\82¯
\82Ä
\92\86\90g
\82ð
\90H
\82×
\82½"
2602 obj->quan = save_quan;
2606 (obj->oclass == POTION_CLASS) ? "drinking" : "chewing");
2608 You_hear("%s
\82Æ
\82¢
\82¤
\89¹
\82ð
\95·
\82¢
\82½
\81D",
2609 (obj->otyp == POT_ACID) ? "
\83S
\83N
\83\93" : "
\83N
\83`
\83\83\83N
\83`
\83\83");
2613 /* obj is now gone */
2615 if (acid && !tinned && !resists_acid(mon)) {
2616 mon->mhp -= rnd(15);
2619 pline("%s has a very bad case of stomach acid.", Monnam(mon));
2621 pline("%s
\82Í
\88Ý
\8e_
\82Ì
\92²
\8eq
\82ª
\82Æ
\82Ä
\82à
\88«
\82¢
\81D", Monnam(mon));
2622 if (DEADMONSTER(mon)) {
2624 pline("%s dies!", Monnam(mon));
2626 pline("%s
\82Í
\8e\80\82ñ
\82¾
\81I", Monnam(mon));
2628 /* hero gets credit (experience) and blame (possible loss
2629 of alignment and/or luck and/or telepathy depending on
2630 mon) for the kill but does not break pacifism conduct */
2631 xkilled(mon, XKILL_NOMSG | XKILL_NOCONDUCT);
2637 if (stoning && vis) {
2640 pline("What a pity - %s just ruined a future piece of art!",
2642 pline("
\82È
\82ñ
\82Ä
\82±
\82Æ
\82¾
\81I%s
\82Í
\8c|
\8fp
\8dì
\95i
\82É
\82È
\82ê
\82½
\82©
\82à
\82µ
\82ê
\82È
\82¢
\82Ì
\82É
\81I",
2646 pline("%s seems limber!", Monnam(mon));
2648 pline("%s
\82Í
\91Ì
\82ª
\8f_
\82ç
\82©
\82
\82È
\82Á
\82½
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81I", Monnam(mon));
2650 if (lizard && (mon->mconf || mon->mstun)) {
2653 if (vis && !is_bat(mon->data) && mon->data != &mons[PM_STALKER])
2655 pline("%s seems steadier now.", Monnam(mon));
2657 pline("%s
\82Í
\82æ
\82è
\8fä
\95v
\82É
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mon));
2659 if (mon->mtame && !mon->isminion && nutrit > 0) {
2660 struct edog *edog = EDOG(mon);
2662 if (edog->hungrytime < monstermoves)
2663 edog->hungrytime = monstermoves;
2664 edog->hungrytime += nutrit;
2667 /* use up monster's next move */
2668 mon->movement -= NORMAL_SPEED;
2669 mon->mlstmv = monstermoves;
2672 /* decide whether obj can cure petrification; also used when picking up */
2674 cures_stoning(mon, obj, tinok)
2679 if (obj->otyp == POT_ACID)
2681 if (obj->otyp != CORPSE && (obj->otyp != TIN || !tinok))
2683 /* corpse, or tin that mon can open */
2684 return (boolean) (obj->corpsenm == PM_LIZARD
2685 || (acidic(&mons[obj->corpsenm])
2686 && (obj->corpsenm != PM_GREEN_SLIME
2687 || slimeproof(mon->data))));
2694 struct obj *obj, *mwep;
2697 /* monkeys who manage to steal tins can't open and eat them
2698 even if they happen to also have the appropriate tool */
2699 if (is_animal(mon->data))
2702 mwep = MON_WEP(mon);
2703 welded_wep = mwep && mwelded(mwep);
2704 /* this is different from the player; tin opener or dagger doesn't
2705 have to be wielded, and knife can be used instead of dagger */
2706 for (obj = mon->minvent; obj; obj = obj->nobj) {
2707 /* if stuck with a cursed weapon, don't check rest of inventory */
2708 if (welded_wep && obj != mwep)
2711 if (obj->otyp == TIN_OPENER
2712 || (obj->oclass == WEAPON_CLASS
2713 && (objects[obj->otyp].oc_skill == P_DAGGER
2714 || objects[obj->otyp].oc_skill == P_KNIFE)))
2720 /* TRUE if monster does something to avoid turning into green slime */
2722 munslime(mon, by_you)
2726 struct obj *obj, odummy;
2727 struct permonst *mptr = mon->data;
2730 * muse_unslime() gives "mon starts turning green", "mon zaps
2731 * itself with a wand of fire", and "mon's slime burns away"
2732 * messages. Monsters who don't get any chance at that just have
2733 * (via our caller) newcham()'s "mon turns into slime" feedback.
2736 if (slimeproof(mptr))
2738 if (mon->meating || !mon->mcanmove || mon->msleeping)
2740 mon->mstrategy &= ~STRAT_WAITFORU;
2742 /* if monster can breathe fire, do so upon self; a monster who deals
2743 fire damage by biting, clawing, gazing, and especially exploding
2744 isn't able to cure itself of green slime with its own attack
2745 [possible extension: monst capable of casting high level clerical
2746 spells could toss pillar of fire at self--probably too suicidal] */
2747 if (!mon->mcan && !mon->mspec_used
2748 && attacktype_fordmg(mptr, AT_BREA, AD_FIRE)) {
2749 odummy = zeroobj; /* otyp == STRANGE_OBJECT */
2750 return muse_unslime(mon, &odummy, (struct trap *) 0, by_you);
2753 /* same MUSE criteria as use_defensive() */
2754 if (!is_animal(mptr) && !mindless(mptr)) {
2757 for (obj = mon->minvent; obj; obj = obj->nobj)
2758 if (cures_sliming(mon, obj))
2759 return muse_unslime(mon, obj, (struct trap *) 0, by_you);
2761 if (((t = t_at(mon->mx, mon->my)) == 0 || t->ttyp != FIRE_TRAP)
2762 && mptr->mmove && !mon->mtrapped) {
2763 int xy[2][8], x, y, idx, ridx, nxy = 0;
2765 for (x = mon->mx - 1; x <= mon->mx + 1; ++x)
2766 for (y = mon->my - 1; y <= mon->my + 1; ++y)
2767 if (isok(x, y) && accessible(x, y)
2768 && !m_at(x, y) && (x != u.ux || y != u.uy)) {
2769 xy[0][nxy] = x, xy[1][nxy] = y;
2772 for (idx = 0; idx < nxy; ++idx) {
2773 ridx = rn1(nxy - idx, idx);
2776 xy[0][idx] = xy[0][ridx];
2779 xy[1][idx] = xy[1][ridx];
2782 if ((t = t_at(xy[0][idx], xy[1][idx])) != 0
2783 && t->ttyp == FIRE_TRAP)
2787 if (t && t->ttyp == FIRE_TRAP)
2788 return muse_unslime(mon, (struct obj *) &zeroobj, t, by_you);
2795 /* mon uses an item--selected by caller--to burn away incipient slime */
2797 muse_unslime(mon, obj, trap, by_you)
2801 boolean by_you; /* true: if mon kills itself, hero gets credit/blame */
2802 { /* [by_you not honored if 'mon' triggers fire trap]. */
2803 struct obj *odummyp;
2804 int otyp = obj->otyp, dmg = 0;
2805 boolean vis = canseemon(mon), res = TRUE;
2809 pline("%s starts turning %s.", Monnam(mon),
2810 green_mon(mon) ? "into ooze" : hcolor(NH_GREEN));
2812 pline("%s
\82Í%s
\82É
\82È
\82è
\82Í
\82¶
\82ß
\82½
\81D", Monnam(mon),
2813 green_mon(mon) ? "
\83X
\83\89\83C
\83\80" : hcolor(NH_GREEN));
2815 /* -4 => sliming, causes quiet loss of enhanced speed */
2816 mon_adjust_speed(mon, -4, (struct obj *) 0);
2819 const char *Mnam = vis ? Monnam(mon) : 0;
2821 if (mon->mx == trap->tx && mon->my == trap->ty) {
2824 pline("%s triggers %s fire trap!", Mnam,
2825 trap->tseen ? "the" : "a");
2827 pline("%s
\82Í
\89\8a\82Ìã©
\82ð
\94
\93®
\82³
\82¹
\82½
\81I", Mnam);
2830 remove_monster(mon->mx, mon->my);
2831 newsym(mon->mx, mon->my);
2832 place_monster(mon, trap->tx, trap->ty);
2833 if (mon->wormno) /* won't happen; worms don't MUSE to unslime */
2835 newsym(mon->mx, mon->my);
2838 pline("%s %s %s %s fire trap!", Mnam,
2839 vtense(Mnam, locomotion(mon->data, "move")),
2840 is_floater(mon->data) ? "over" : "onto",
2841 trap->tseen ? "the" : "a");
2843 pline("%s
\82Í
\89\8a\82Ìã©
\82É
\94ò
\82Ñ
\8d\9e\82ñ
\82¾
\81I", Mnam);
2846 /* hack to avoid mintrap()'s chance of avoiding known trap */
2847 mon->mtrapseen &= ~(1 << (FIRE_TRAP - 1));
2849 } else if (otyp == STRANGE_OBJECT) {
2850 /* monster is using fire breath on self */
2853 pline("%s breathes fire on %sself.", Monnam(mon), mhim(mon));
2855 pline("%s
\82Í
\89Î
\82ð
\82Í
\82¢
\82½
\81D", Monnam(mon));
2857 mon->mspec_used = rn1(10, 5);
2858 /* -21 => monster's fire breath; 1 => # of damage dice */
2859 dmg = zhitm(mon, by_you ? 21 : -21, 1, &odummyp);
2860 } else if (otyp == SCR_FIRE) {
2863 if (cansee(mon->mx, mon->my))
2865 pline("Oh, what a pretty fire!");
2867 pline("
\82 \82ç
\81A
\82È
\82ñ
\82Ä
\82©
\82í
\82¢
\82¢
\89Î
\82¾
\81I");
2868 if (vis && !objects[otyp].oc_name_known
2869 && !objects[otyp].oc_uname)
2871 m_useup(mon, obj); /* after docall() */
2872 vis = FALSE; /* skip makeknown() below */
2873 res = FALSE; /* failed to cure sliming */
2875 m_useup(mon, obj); /* before explode() */
2876 dmg = (2 * (rn1(3, 3) + 2 * bcsign(obj)) + 1) / 3;
2877 /* -11 => monster's fireball */
2878 explode(mon->mx, mon->my, -11, dmg, SCROLL_CLASS,
2879 /* by_you: override -11 for mon but not others */
2880 by_you ? -EXPL_FIERY : EXPL_FIERY);
2881 dmg = 0; /* damage has been applied by explode() */
2883 } else { /* wand/horn of fire w/ positive charge count */
2884 mzapmsg(mon, obj, TRUE);
2886 /* -1 => monster's wand of fire; 2 => # of damage dice */
2887 dmg = zhitm(mon, by_you ? 1 : -1, 2, &odummyp);
2891 /* zhitm() applies damage but doesn't kill creature off;
2892 for fire breath, dmg is going to be 0 (fire breathers are
2893 immune to fire damage) but for wand of fire or fire horn,
2894 'mon' could have taken damage so might die */
2895 if (DEADMONSTER(mon)) {
2897 /* mon killed self but hero gets credit and blame (except
2898 for pacifist conduct); xkilled()'s message would say
2899 "You killed/destroyed <mon>" so give our own message */
2902 pline("%s is %s by the fire!", Monnam(mon),
2903 nonliving(mon->data) ? "destroyed" : "killed");
2905 pline("%s
\82Í
\89Î
\82Å%s
\82³
\82ê
\82½
\81I", Monnam(mon),
2906 nonliving(mon->data) ? "
\93|" : "
\8eE");
2908 xkilled(mon, XKILL_NOMSG | XKILL_NOCONDUCT);
2911 monkilled(mon, "fire", AD_FIRE);
2913 monkilled(mon, "
\89Î", AD_FIRE);
2915 /* non-fatal damage occurred */
2918 pline("%s is burned%s", Monnam(mon), exclam(dmg));
2920 pline("%s
\82Í
\94R
\82¦
\82½%s", Monnam(mon), exclam(dmg));
2924 if (res && !DEADMONSTER(mon))
2926 pline("%s slime is burned away!", s_suffix(Monnam(mon)));
2928 pline("%s
\82Ì
\83X
\83\89\83C
\83\80\82Í
\94R
\82¦
\82Â
\82«
\82½
\81I", Monnam(mon));
2929 if (otyp != STRANGE_OBJECT)
2932 /* use up monster's next move */
2933 mon->movement -= NORMAL_SPEED;
2934 mon->mlstmv = monstermoves;
2938 /* decide whether obj can be used to cure green slime */
2940 cures_sliming(mon, obj)
2944 /* scroll of fire, non-empty wand or horn of fire */
2945 if (obj->otyp == SCR_FIRE)
2946 return (haseyes(mon->data) && mon->mcansee);
2947 /* hero doesn't need hands or even limbs to zap, so mon doesn't either */
2948 return ((obj->otyp == WAN_FIRE
2949 || (obj->otyp == FIRE_HORN && can_blow(mon)))
2953 /* TRUE if monster appears to be green; for active TEXTCOLOR, we go by
2954 the display color, otherwise we just pick things that seem plausibly
2955 green (which doesn't necessarily match the TEXTCOLOR categorization) */
2960 struct permonst *ptr = mon->data;
2965 if (iflags.use_color)
2966 return (ptr->mcolor == CLR_GREEN || ptr->mcolor == CLR_BRIGHT_GREEN);
2970 if (strstri(ptr->mname, "green"))
2972 if (strstri(ptr->mname, "
\97Î"))
2975 switch (monsndx(ptr)) {
2976 case PM_FOREST_CENTAUR:
2977 case PM_GARTER_SNAKE:
2988 if (is_elf(ptr) && !is_prince(ptr) && !is_lord(ptr)
2989 && ptr != &mons[PM_GREY_ELF])