1 /* NetHack 3.6 muse.c $NHDT-Date: 1505181522 2017/09/12 01:58:42 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.80 $ */
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-2018 */
8 /* JNetHack may be freely redistributed. See license for details. */
11 * Monster item usage routines.
16 extern const int monstr[];
18 boolean m_using = FALSE;
20 /* Let monsters use magic items. Arbitrary assumptions: Monsters only use
21 * scrolls when they can see, monsters know when wands have 0 charges,
22 * monsters cannot recognize if items are cursed are not, monsters which
23 * are confused don't know not to read scrolls, etc....
26 STATIC_DCL struct permonst *FDECL(muse_newcham_mon, (struct monst *));
27 STATIC_DCL int FDECL(precheck, (struct monst *, struct obj *));
28 STATIC_DCL void FDECL(mzapmsg, (struct monst *, struct obj *, BOOLEAN_P));
29 STATIC_DCL void FDECL(mreadmsg, (struct monst *, struct obj *));
30 STATIC_DCL void FDECL(mquaffmsg, (struct monst *, struct obj *));
31 STATIC_DCL boolean FDECL(m_use_healing, (struct monst *));
32 STATIC_PTR int FDECL(mbhitm, (struct monst *, struct obj *));
33 STATIC_DCL void FDECL(mbhit, (struct monst *, int,
34 int FDECL((*), (MONST_P, OBJ_P)),
35 int FDECL((*), (OBJ_P, OBJ_P)), struct obj *));
36 STATIC_DCL void FDECL(you_aggravate, (struct monst *));
37 STATIC_DCL void FDECL(mon_consume_unstone, (struct monst *, struct obj *,
38 BOOLEAN_P, BOOLEAN_P));
39 STATIC_DCL boolean FDECL(cures_stoning, (struct monst *, struct obj *,
41 STATIC_DCL boolean FDECL(mcould_eat_tin, (struct monst *));
42 STATIC_DCL boolean FDECL(muse_unslime, (struct monst *, struct obj *,
43 struct trap *, BOOLEAN_P));
44 STATIC_DCL int FDECL(cures_sliming, (struct monst *, struct obj *));
45 STATIC_DCL boolean FDECL(green_mon, (struct monst *));
47 static struct musable {
48 struct obj *offensive;
49 struct obj *defensive;
51 int has_offense, has_defense, has_misc;
52 /* =0, no capability; otherwise, different numbers.
53 * If it's an object, the object is also set (it's 0 otherwise).
56 static int trapx, trapy;
57 static boolean zap_oseen; /* for wands which use mbhitm and are zapped at
58 * players. We usually want an oseen local to
59 * the function, but this is impossible since the
60 * function mbhitm has to be compatible with the
61 * normal zap routines, and those routines don't
62 * remember who zapped the wand. */
64 /* Any preliminary checks which may result in the monster being unable to use
65 * the item. Returns 0 if nothing happened, 2 if the monster can't do
66 * anything (i.e. it teleported) and 1 if it's dead.
77 vis = cansee(mon->mx, mon->my);
79 if (obj->oclass == POTION_CLASS) {
82 static const char *empty = "The potion turns out to be empty.";
84 static const char *empty = "
\96ò
\82Í
\8bó
\82Á
\82Û
\82Å
\82 \82é
\82±
\82Æ
\82ª
\82í
\82©
\82Á
\82½
\81D";
85 const char *potion_descr;
88 potion_descr = OBJ_DESCR(objects[obj->otyp]);
90 if (potion_descr && !strcmp(potion_descr, "milky")) {
92 if (potion_descr && !strcmp(potion_descr, "
\83~
\83\8b\83N
\90F
\82Ì")) {
93 if (!(mvitals[PM_GHOST].mvflags & G_GONE)
94 && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_GHOST].born))) {
95 if (!enexto(&cc, mon->mx, mon->my, &mons[PM_GHOST]))
99 mtmp = makemon(&mons[PM_GHOST], cc.x, cc.y, NO_MM_FLAGS);
107 "As %s opens the bottle, an enormous %s emerges!",
109 Hallucination ? rndmonnam(NULL)
110 : (const char *) "ghost");
113 "%s
\82ª
\95r
\82ð
\8aJ
\82¯
\82é
\82Æ
\81C
\8b\90\91å
\82È%s
\82ª
\8fo
\82Ä
\82«
\82½
\81I",
115 Hallucination ? rndmonnam(NULL)
116 : (const char *)"
\97H
\97ì");
119 pline("%s is frightened to death, and unable to move.",
121 pline("%s
\82Í
\82Ü
\82Á
\82³
\82¨
\82É
\82È
\82Á
\82Ä
\8bÁ
\82«
\81C
\93®
\82¯
\82È
\82
\82È
\82Á
\82½
\81D",
124 paralyze_monst(mon, 3);
130 if (potion_descr && !strcmp(potion_descr, "smoky")
132 if (potion_descr && !strcmp(potion_descr, "
\89\8c\82Ì
\8fo
\82Ä
\82¢
\82é")
133 && !(mvitals[PM_DJINNI].mvflags & G_GONE)
134 && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_DJINNI].born))) {
135 if (!enexto(&cc, mon->mx, mon->my, &mons[PM_DJINNI]))
139 mtmp = makemon(&mons[PM_DJINNI], cc.x, cc.y, NO_MM_FLAGS);
146 pline("In a cloud of smoke, %s emerges!", a_monnam(mtmp));
148 pline("
\89\8c\82Ì
\92\86\82©
\82ç
\81C%s
\82ª
\8c»
\82í
\82ê
\82½
\81I", a_monnam(mtmp));
150 pline("%s speaks.", vis ? Monnam(mtmp) : Something);
152 pline("%s
\82Í
\98b
\82µ
\82½
\81D", vis ? Monnam(mtmp) : Something);
153 /* I suspect few players will be upset that monsters */
154 /* can't wish for wands of death here.... */
157 verbalize("You freed me!");
159 verbalize("
\89ð
\95ú
\82µ
\82Ä
\82
\82ê
\82½
\82Ì
\82Í
\82¨
\91O
\82©
\81I");
164 verbalize("It is about time.");
166 verbalize("
\82³
\82ç
\82Î
\82¾
\81I");
169 pline("%s vanishes.", Monnam(mtmp));
171 pline("%s
\82Í
\8fÁ
\82¦
\82½
\81D", Monnam(mtmp));
178 if (obj->oclass == WAND_CLASS && obj->cursed
179 && !rn2(WAND_BACKFIRE_CHANCE)) {
180 int dam = d(obj->spe + 2, 6);
182 /* 3.6.1: no Deaf filter; 'if' message doesn't warrant it, 'else'
183 message doesn't need it since You_hear() has one of its own */
186 pline("%s zaps %s, which suddenly explodes!", Monnam(mon),
189 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),
193 /* same near/far threshold as mzapmsg() */
194 int range = couldsee(mon->mx, mon->my) /* 9 or 5 */
195 ? (BOLT_LIM + 1) : (BOLT_LIM - 3);
198 You_hear("a zap and an explosion %s.",
199 (distu(mon->mx, mon->my) <= range * range)
200 ? "nearby" : "in the distance");
202 You_hear("%s
\82
\82Ì
\8fñ
\82Ì
\89¹
\82Æ
\94\9a\94
\89¹
\82ð
\95·
\82¢
\82½
\81D",
203 (distu(mon->mx, mon->my) <= range * range)
204 ? "
\8bß" : "
\89\93");
210 monkilled(mon, "", AD_RBRE);
213 m.has_defense = m.has_offense = m.has_misc = 0;
214 /* Only one needed to be set to 0 but the others are harmless */
220 mzapmsg(mtmp, otmp, self)
225 if (!canseemon(mtmp)) {
226 int range = couldsee(mtmp->mx, mtmp->my) /* 9 or 5 */
227 ? (BOLT_LIM + 1) : (BOLT_LIM - 3);
230 You_hear("a %s zap.", (distu(mtmp->mx, mtmp->my) <= range * range)
231 ? "nearby" : "distant");
233 You_hear("%s
\82
\82Å
\8fñ
\82Ì
\89¹
\82ð
\95·
\82¢
\82½
\81D",
234 (distu(mtmp->mx, mtmp->my) <= range * range)
235 ? "
\8bß" : "
\89\93");
239 pline("%s zaps %sself with %s!", Monnam(mtmp), mhim(mtmp),
242 pline("%s
\82Í
\8e©
\95ª
\8e©
\90g
\82É%s
\82ð
\82Ó
\82è
\82©
\82´
\82µ
\82½
\81I", Monnam(mtmp),
247 pline("%s zaps %s!", Monnam(mtmp), an(xname(otmp)));
249 pline("%s
\82Í%s
\82ð
\82Ó
\82è
\82©
\82´
\82µ
\82½
\81I", Monnam(mtmp), an(xname(otmp)));
259 boolean vismon = canseemon(mtmp);
265 return; /* no feedback */
267 otmp->dknown = 1; /* seeing or hearing it read reveals its label */
268 /* shouldn't be able to hear curse/bless status of unseen scrolls;
269 for priest characters, bknown will always be set during naming */
270 savebknown = otmp->bknown;
271 saverole = Role_switch;
274 if (Role_if(PM_PRIEST))
277 Strcpy(onambuf, singular(otmp, doname));
278 Role_switch = saverole;
279 otmp->bknown = savebknown;
283 pline("%s reads %s!", Monnam(mtmp), onambuf);
285 pline("%s
\82Í%s
\82ð
\93Ç
\82ñ
\82¾
\81I", Monnam(mtmp), onambuf);
288 You_hear("%s reading %s.",
289 x_monnam(mtmp, ARTICLE_A, (char *) 0,
290 (SUPPRESS_IT | SUPPRESS_INVISIBLE | SUPPRESS_SADDLE),
294 You_hear("%s
\82ª%s
\82ð
\93Ç
\82ñ
\82Å
\82¢
\82é
\90º
\82ð
\95·
\82¢
\82½
\81D",
295 x_monnam(mtmp, ARTICLE_A, (char *)0,
296 (SUPPRESS_IT|SUPPRESS_INVISIBLE|SUPPRESS_SADDLE),
303 pline("Being confused, %s mispronounces the magic words...",
305 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",
306 vismon ? mon_nam(mtmp) : mhe(mtmp));
310 mquaffmsg(mtmp, otmp)
314 if (canseemon(mtmp)) {
317 pline("%s drinks %s!", Monnam(mtmp), singular(otmp, doname));
319 pline("%s
\82Í%s
\82ð
\88ù
\82ñ
\82¾
\81I", Monnam(mtmp), singular(otmp, doname));
322 You_hear("a chugging sound.");
324 You_hear("
\83S
\83N
\83b
\81I
\82Æ
\82¢
\82¤
\89¹
\82ð
\95·
\82¢
\82½
\81D");
327 /* Defines for various types of stuff. The order in which monsters prefer
328 * to use them is determined by the order of the code logic, not the
329 * numerical order in which they are defined.
331 #define MUSE_SCR_TELEPORTATION 1
332 #define MUSE_WAN_TELEPORTATION_SELF 2
333 #define MUSE_POT_HEALING 3
334 #define MUSE_POT_EXTRA_HEALING 4
335 #define MUSE_WAN_DIGGING 5
336 #define MUSE_TRAPDOOR 6
337 #define MUSE_TELEPORT_TRAP 7
338 #define MUSE_UPSTAIRS 8
339 #define MUSE_DOWNSTAIRS 9
340 #define MUSE_WAN_CREATE_MONSTER 10
341 #define MUSE_SCR_CREATE_MONSTER 11
342 #define MUSE_UP_LADDER 12
343 #define MUSE_DN_LADDER 13
344 #define MUSE_SSTAIRS 14
345 #define MUSE_WAN_TELEPORTATION 15
346 #define MUSE_BUGLE 16
347 #define MUSE_UNICORN_HORN 17
348 #define MUSE_POT_FULL_HEALING 18
349 #define MUSE_LIZARD_CORPSE 19
351 #define MUSE_INNATE_TPT 9999
352 * We cannot use this. Since monsters get unlimited teleportation, if they
353 * were allowed to teleport at will you could never catch them. Instead,
354 * assume they only teleport at random times, despite the inconsistency
355 * that if you polymorph into one you teleport at will.
363 if ((obj = m_carrying(mtmp, POT_FULL_HEALING)) != 0) {
365 m.has_defense = MUSE_POT_FULL_HEALING;
368 if ((obj = m_carrying(mtmp, POT_EXTRA_HEALING)) != 0) {
370 m.has_defense = MUSE_POT_EXTRA_HEALING;
373 if ((obj = m_carrying(mtmp, POT_HEALING)) != 0) {
375 m.has_defense = MUSE_POT_HEALING;
381 /* Select a defensive item/action for a monster. Returns TRUE iff one is
387 register struct obj *obj = 0;
389 int x = mtmp->mx, y = mtmp->my;
390 boolean stuck = (mtmp == u.ustuck);
391 boolean immobile = (mtmp->data->mmove == 0);
394 if (is_animal(mtmp->data) || mindless(mtmp->data))
396 if (dist2(x, y, mtmp->mux, mtmp->muy) > 25)
398 if (u.uswallow && stuck)
401 m.defensive = (struct obj *) 0;
404 /* since unicorn horns don't get used up, the monster would look
405 * silly trying to use the same cursed horn round after round
407 if (mtmp->mconf || mtmp->mstun || !mtmp->mcansee) {
408 if (!is_unicorn(mtmp->data) && !nohands(mtmp->data)) {
409 for (obj = mtmp->minvent; obj; obj = obj->nobj)
410 if (obj->otyp == UNICORN_HORN && !obj->cursed)
413 if (obj || is_unicorn(mtmp->data)) {
415 m.has_defense = MUSE_UNICORN_HORN;
420 if (mtmp->mconf || mtmp->mstun) {
421 struct obj *liztin = 0;
423 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
424 if (obj->otyp == CORPSE && obj->corpsenm == PM_LIZARD) {
426 m.has_defense = MUSE_LIZARD_CORPSE;
428 } else if (obj->otyp == TIN && obj->corpsenm == PM_LIZARD) {
432 /* confused or stunned monster might not be able to open tin */
433 if (liztin && mcould_eat_tin(mtmp) && rn2(3)) {
434 m.defensive = liztin;
435 /* tin and corpse ultimately end up being handled the same */
436 m.has_defense = MUSE_LIZARD_CORPSE;
441 /* It so happens there are two unrelated cases when we might want to
442 * check specifically for healing alone. The first is when the monster
443 * is blind (healing cures blindness). The second is when the monster
444 * is peaceful; then we don't want to flee the player, and by
445 * coincidence healing is all there is that doesn't involve fleeing.
446 * These would be hard to combine because of the control flow.
447 * Pestilence won't use healing even when blind.
449 if (!mtmp->mcansee && !nohands(mtmp->data)
450 && mtmp->data != &mons[PM_PESTILENCE]) {
451 if (m_use_healing(mtmp))
455 fraction = u.ulevel < 10 ? 5 : u.ulevel < 14 ? 4 : 3;
456 if (mtmp->mhp >= mtmp->mhpmax
457 || (mtmp->mhp >= 10 && mtmp->mhp * fraction >= mtmp->mhpmax))
460 if (mtmp->mpeaceful) {
461 if (!nohands(mtmp->data)) {
462 if (m_use_healing(mtmp))
468 if (stuck || immobile) {
469 ; /* fleeing by stairs or traps is not possible */
470 } else if (levl[x][y].typ == STAIRS) {
471 if (x == xdnstair && y == ydnstair) {
472 if (!is_floater(mtmp->data))
473 m.has_defense = MUSE_DOWNSTAIRS;
474 } else if (x == xupstair && y == yupstair) {
475 m.has_defense = MUSE_UPSTAIRS;
476 } else if (sstairs.sx && x == sstairs.sx && y == sstairs.sy) {
477 if (sstairs.up || !is_floater(mtmp->data))
478 m.has_defense = MUSE_SSTAIRS;
480 } else if (levl[x][y].typ == LADDER) {
481 if (x == xupladder && y == yupladder) {
482 m.has_defense = MUSE_UP_LADDER;
483 } else if (x == xdnladder && y == ydnladder) {
484 if (!is_floater(mtmp->data))
485 m.has_defense = MUSE_DN_LADDER;
486 } else if (sstairs.sx && x == sstairs.sx && y == sstairs.sy) {
487 if (sstairs.up || !is_floater(mtmp->data))
488 m.has_defense = MUSE_SSTAIRS;
491 /* Note: trap doors take precedence over teleport traps. */
492 int xx, yy, i, locs[10][2];
493 boolean ignore_boulders = (verysmall(mtmp->data)
494 || throws_rocks(mtmp->data)
495 || passes_walls(mtmp->data)),
496 diag_ok = !NODIAG(monsndx(mtmp->data));
498 for (i = 0; i < 10; ++i) /* 10: 9 spots plus sentinel */
499 locs[i][0] = locs[i][1] = 0;
500 /* collect viable spots; monster's <mx,my> comes first */
501 locs[0][0] = x, locs[0][1] = y;
503 for (xx = x - 1; xx <= x + 1; xx++)
504 for (yy = y - 1; yy <= y + 1; yy++)
505 if (isok(xx, yy) && (xx != x || yy != y)) {
506 locs[i][0] = xx, locs[i][1] = yy;
509 /* look for a suitable trap among the viable spots */
510 for (i = 0; i < 10; ++i) {
511 xx = locs[i][0], yy = locs[i][1];
513 break; /* we've run out of spots */
514 /* skip if it's hero's location
515 or a diagonal spot and monster can't move diagonally
516 or some other monster is there */
517 if ((xx == u.ux && yy == u.uy)
518 || (xx != x && yy != y && !diag_ok)
519 || (level.monsters[xx][yy] && !(xx == x && yy == y)))
521 /* skip if there's no trap or can't/won't move onto trap */
522 if ((t = t_at(xx, yy)) == 0
523 || (!ignore_boulders && sobj_at(BOULDER, xx, yy))
524 || onscary(xx, yy, mtmp))
526 /* use trap if it's the correct type */
527 if ((t->ttyp == TRAPDOOR || t->ttyp == HOLE)
528 && !is_floater(mtmp->data)
529 && !mtmp->isshk && !mtmp->isgd && !mtmp->ispriest
530 && Can_fall_thru(&u.uz)) {
533 m.has_defense = MUSE_TRAPDOOR;
534 break; /* no need to look at any other spots */
535 } else if (t->ttyp == TELEP_TRAP) {
538 m.has_defense = MUSE_TELEPORT_TRAP;
543 if (nohands(mtmp->data)) /* can't use objects */
546 if (is_mercenary(mtmp->data) && (obj = m_carrying(mtmp, BUGLE)) != 0) {
550 /* Distance is arbitrary. What we really want to do is
551 * have the soldier play the bugle when it sees or
552 * remembers soldiers nearby...
554 for (xx = x - 3; xx <= x + 3; xx++) {
555 for (yy = y - 3; yy <= y + 3; yy++) {
556 if (!isok(xx, yy) || (xx == x && yy == y))
558 if ((mon = m_at(xx, yy)) != 0 && is_mercenary(mon->data)
559 && mon->data != &mons[PM_GUARD]
560 && (mon->msleeping || !mon->mcanmove)) {
562 m.has_defense = MUSE_BUGLE;
563 goto toot; /* double break */
571 /* use immediate physical escape prior to attempting magic */
572 if (m.has_defense) /* stairs, trap door or tele-trap, bugle alert */
575 /* kludge to cut down on trap destruction (particularly portals) */
577 if (t && (t->ttyp == PIT || t->ttyp == SPIKED_PIT || t->ttyp == WEB
578 || t->ttyp == BEAR_TRAP))
579 t = 0; /* ok for monster to dig here */
581 #define nomore(x) if (m.has_defense == x) continue;
582 /* selection could be improved by collecting all possibilities
583 into an array and then picking one at random */
584 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
585 /* don't always use the same selection pattern */
586 if (m.has_defense && !rn2(3))
589 /* nomore(MUSE_WAN_DIGGING); */
590 if (m.has_defense == MUSE_WAN_DIGGING)
592 if (obj->otyp == WAN_DIGGING && obj->spe > 0 && !stuck && !t
593 && !mtmp->isshk && !mtmp->isgd && !mtmp->ispriest
594 && !is_floater(mtmp->data)
595 /* monsters digging in Sokoban can ruin things */
597 /* digging wouldn't be effective; assume they know that */
598 && !(levl[x][y].wall_info & W_NONDIGGABLE)
599 && !(Is_botlevel(&u.uz) || In_endgame(&u.uz))
600 && !(is_ice(x, y) || is_pool(x, y) || is_lava(x, y))
601 && !(mtmp->data == &mons[PM_VLAD_THE_IMPALER]
602 && In_V_tower(&u.uz))) {
604 m.has_defense = MUSE_WAN_DIGGING;
606 nomore(MUSE_WAN_TELEPORTATION_SELF);
607 nomore(MUSE_WAN_TELEPORTATION);
608 if (obj->otyp == WAN_TELEPORTATION && obj->spe > 0) {
609 /* use the TELEP_TRAP bit to determine if they know
610 * about noteleport on this level or not. Avoids
611 * ineffective re-use of teleportation. This does
612 * mean if the monster leaves the level, they'll know
613 * about teleport traps.
615 if (!level.flags.noteleport
616 || !(mtmp->mtrapseen & (1 << (TELEP_TRAP - 1)))) {
618 m.has_defense = (mon_has_amulet(mtmp))
619 ? MUSE_WAN_TELEPORTATION
620 : MUSE_WAN_TELEPORTATION_SELF;
623 nomore(MUSE_SCR_TELEPORTATION);
624 if (obj->otyp == SCR_TELEPORTATION && mtmp->mcansee
625 && haseyes(mtmp->data)
626 && (!obj->cursed || (!(mtmp->isshk && inhishop(mtmp))
627 && !mtmp->isgd && !mtmp->ispriest))) {
628 /* see WAN_TELEPORTATION case above */
629 if (!level.flags.noteleport
630 || !(mtmp->mtrapseen & (1 << (TELEP_TRAP - 1)))) {
632 m.has_defense = MUSE_SCR_TELEPORTATION;
636 if (mtmp->data != &mons[PM_PESTILENCE]) {
637 nomore(MUSE_POT_FULL_HEALING);
638 if (obj->otyp == POT_FULL_HEALING) {
640 m.has_defense = MUSE_POT_FULL_HEALING;
642 nomore(MUSE_POT_EXTRA_HEALING);
643 if (obj->otyp == POT_EXTRA_HEALING) {
645 m.has_defense = MUSE_POT_EXTRA_HEALING;
647 nomore(MUSE_WAN_CREATE_MONSTER);
648 if (obj->otyp == WAN_CREATE_MONSTER && obj->spe > 0) {
650 m.has_defense = MUSE_WAN_CREATE_MONSTER;
652 nomore(MUSE_POT_HEALING);
653 if (obj->otyp == POT_HEALING) {
655 m.has_defense = MUSE_POT_HEALING;
657 } else { /* Pestilence */
658 nomore(MUSE_POT_FULL_HEALING);
659 if (obj->otyp == POT_SICKNESS) {
661 m.has_defense = MUSE_POT_FULL_HEALING;
663 nomore(MUSE_WAN_CREATE_MONSTER);
664 if (obj->otyp == WAN_CREATE_MONSTER && obj->spe > 0) {
666 m.has_defense = MUSE_WAN_CREATE_MONSTER;
669 nomore(MUSE_SCR_CREATE_MONSTER);
670 if (obj->otyp == SCR_CREATE_MONSTER) {
672 m.has_defense = MUSE_SCR_CREATE_MONSTER;
676 return (boolean) !!m.has_defense;
680 /* Perform a defensive action for a monster. Must be called immediately
681 * after find_defensive(). Return values are 0: did something, 1: died,
682 * 2: did something and can't attack again (i.e. teleported).
688 int i, fleetim, how = 0;
689 struct obj *otmp = m.defensive;
690 boolean vis, vismon, oseen;
693 if ((i = precheck(mtmp, otmp)) != 0)
695 vis = cansee(mtmp->mx, mtmp->my);
696 vismon = canseemon(mtmp);
697 oseen = otmp && vismon;
699 /* when using defensive choice to run away, we want monster to avoid
700 rushing right straight back; don't override if already scared */
701 fleetim = !mtmp->mflee ? (33 - (30 * mtmp->mhp / mtmp->mhpmax)) : 0;
703 if (fleetim && !m->iswiz) { \
704 monflee(m, fleetim, FALSE, FALSE); \
707 switch (m.has_defense) {
708 case MUSE_UNICORN_HORN:
712 pline("%s uses a unicorn horn!", Monnam(mtmp));
714 pline("%s
\82Í
\83\86\83j
\83R
\81[
\83\93\82Ì
\8ap
\82ð
\8eg
\82Á
\82½
\81I", Monnam(mtmp));
717 pline_The("tip of %s's horn glows!", mon_nam(mtmp));
719 pline("%s
\82Ì
\8ap
\82Ì
\90æ
\92[
\82ª
\8bP
\82¢
\82½
\81I", mon_nam(mtmp));
721 if (!mtmp->mcansee) {
722 mcureblindness(mtmp, vismon);
723 } else if (mtmp->mconf || mtmp->mstun) {
724 mtmp->mconf = mtmp->mstun = 0;
727 pline("%s seems steadier now.", Monnam(mtmp));
729 pline("%s
\82Í
\95½
\90Ã
\82ð
\82Æ
\82è
\82à
\82Ç
\82µ
\82½
\81D", Monnam(mtmp));
731 impossible("No need for unicorn horn?");
736 pline("%s plays %s!", Monnam(mtmp), doname(otmp));
738 pline("%s
\82Í%s
\82ð
\90\81\82¢
\82½
\81I", Monnam(mtmp), doname(otmp));
741 You_hear("a bugle playing reveille!");
743 You_hear("
\8bN
\8f°
\83\89\83b
\83p
\82Ì
\89¹
\82ð
\95·
\82¢
\82½
\81I");
744 awaken_soldiers(mtmp);
746 case MUSE_WAN_TELEPORTATION_SELF:
747 if ((mtmp->isshk && inhishop(mtmp)) || mtmp->isgd || mtmp->ispriest)
750 mzapmsg(mtmp, otmp, TRUE);
752 how = WAN_TELEPORTATION;
754 if (tele_restrict(mtmp)) { /* mysterious force... */
755 if (vismon && how) /* mentions 'teleport' */
757 /* monster learns that teleportation isn't useful here */
758 if (level.flags.noteleport)
759 mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1));
762 if ((mon_has_amulet(mtmp) || On_W_tower_level(&u.uz)) && !rn2(3)) {
765 pline("%s seems disoriented for a moment.", Monnam(mtmp));
767 pline("%s
\82Í
\88ê
\8fu
\95û
\8cü
\8a´
\8ao
\82ð
\8e¸
\82Á
\82½
\81D", Monnam(mtmp));
772 (void) rloc(mtmp, TRUE);
774 case MUSE_WAN_TELEPORTATION:
776 mzapmsg(mtmp, otmp, FALSE);
779 mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp);
780 /* monster learns that teleportation isn't useful here */
781 if (level.flags.noteleport)
782 mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1));
785 case MUSE_SCR_TELEPORTATION: {
786 int obj_is_cursed = otmp->cursed;
788 if (mtmp->isshk || mtmp->isgd || mtmp->ispriest)
791 mreadmsg(mtmp, otmp);
792 m_useup(mtmp, otmp); /* otmp might be free'ed */
793 how = SCR_TELEPORTATION;
794 if (obj_is_cursed || mtmp->mconf) {
798 if (mon_has_amulet(mtmp) || In_endgame(&u.uz)) {
801 pline("%s seems very disoriented for a moment.",
803 pline("%s
\82Í
\88ê
\8fu
\95û
\8cü
\8a´
\8ao
\82ð
\8e¸
\82Á
\82½
\81D",
807 nlev = random_teleport_level();
808 if (nlev == depth(&u.uz)) {
811 pline("%s shudders for a moment.", Monnam(mtmp));
813 pline("%s
\82Í
\88ê
\8fu
\90k
\82¦
\82½
\81D", Monnam(mtmp));
816 get_level(&flev, nlev);
817 migrate_to_level(mtmp, ledger_no(&flev), MIGR_RANDOM,
820 makeknown(SCR_TELEPORTATION);
825 case MUSE_WAN_DIGGING: {
829 mzapmsg(mtmp, otmp, FALSE);
832 makeknown(WAN_DIGGING);
833 if (IS_FURNITURE(levl[mtmp->mx][mtmp->my].typ)
834 || IS_DRAWBRIDGE(levl[mtmp->mx][mtmp->my].typ)
835 || (is_drawbridge_wall(mtmp->mx, mtmp->my) >= 0)
836 || (sstairs.sx && sstairs.sx == mtmp->mx
837 && sstairs.sy == mtmp->my)) {
839 pline_The("digging ray is ineffective.");
841 pline("
\8c@
\8dí
\8cõ
\90ü
\82Í
\8cø
\89Ê
\82ª
\82È
\82¢
\81D");
844 if (!Can_dig_down(&u.uz) && !levl[mtmp->mx][mtmp->my].candig) {
847 pline_The("%s here is too hard to dig in.",
849 pline("
\82±
\82±
\82Ì%s
\82Í
\8cÅ
\82
\82Ä
\8c@
\82ê
\82È
\82¢
\81D",
850 surface(mtmp->mx, mtmp->my));
853 ttmp = maketrap(mtmp->mx, mtmp->my, HOLE);
859 pline("%s has made a hole in the %s.", Monnam(mtmp),
860 surface(mtmp->mx, mtmp->my));
862 pline("%s
\82Í%s
\82É
\8c\8a\82ð
\8aJ
\82¯
\82½
\81D", Monnam(mtmp),
863 surface(mtmp->mx, mtmp->my));
866 pline("%s %s through...", Monnam(mtmp),
867 is_flyer(mtmp->data) ? "dives" : "falls");
869 pline("%s
\82Í
\92Ê
\82è
\94²
\82¯
\82Ä%s
\81D
\81D
\81D", Monnam(mtmp),
870 is_flyer(mtmp->data) ? "
\94ò
\82Ñ
\82±
\82ñ
\82¾" : "
\97\8e\82¿
\82½");
874 You_hear("%s crash through the %s.", something,
875 surface(mtmp->mx, mtmp->my));
877 You_hear("
\89½
\82©
\82ª%s
\82ð
\92Ê
\82è
\94²
\82¯
\82Ä
\97\8e\82¿
\82é
\89¹
\82ð
\95·
\82¢
\82½
\81D
\81D
\81D",
878 surface(mtmp->mx, mtmp->my));
880 /* we made sure that there is a level for mtmp to go to */
881 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_RANDOM,
885 case MUSE_WAN_CREATE_MONSTER: {
887 /* pm: 0 => random, eel => aquatic, croc => amphibious */
888 struct permonst *pm =
889 !is_pool(mtmp->mx, mtmp->my)
891 : &mons[u.uinwater ? PM_GIANT_EEL : PM_CROCODILE];
894 if (!enexto(&cc, mtmp->mx, mtmp->my, pm))
896 mzapmsg(mtmp, otmp, FALSE);
898 mon = makemon((struct permonst *) 0, cc.x, cc.y, NO_MM_FLAGS);
899 if (mon && canspotmon(mon) && oseen)
900 makeknown(WAN_CREATE_MONSTER);
903 case MUSE_SCR_CREATE_MONSTER: {
905 struct permonst *pm = 0, *fish = 0;
908 boolean known = FALSE;
912 if (mtmp->mconf || otmp->cursed)
915 pm = fish = &mons[PM_ACID_BLOB];
916 else if (is_pool(mtmp->mx, mtmp->my))
917 fish = &mons[u.uinwater ? PM_GIANT_EEL : PM_CROCODILE];
918 mreadmsg(mtmp, otmp);
920 /* `fish' potentially gives bias towards water locations;
921 `pm' is what to actually create (0 => random) */
922 if (!enexto(&cc, mtmp->mx, mtmp->my, fish))
924 mon = makemon(pm, cc.x, cc.y, NO_MM_FLAGS);
925 if (mon && canspotmon(mon))
928 /* The only case where we don't use oseen. For wands, you
929 * have to be able to see the monster zap the wand to know
930 * what type it is. For teleport scrolls, you have to see
931 * the monster to know it teleported.
934 makeknown(SCR_CREATE_MONSTER);
935 else if (!objects[SCR_CREATE_MONSTER].oc_name_known
936 && !objects[SCR_CREATE_MONSTER].oc_uname)
942 /* trap doors on "bottom" levels of dungeons are rock-drop
943 * trap doors, not holes in the floor. We check here for
946 if (Is_botlevel(&u.uz))
950 struct trap *t = t_at(trapx, trapy);
954 pline("%s %s into a %s!", Mnam,
955 vtense(Mnam, locomotion(mtmp->data, "jump")),
956 (t->ttyp == TRAPDOOR) ? "trap door" : "hole");
958 pline("%s
\82Í%s
\82É%s
\93ü
\82Á
\82½
\81I", Mnam,
959 t->ttyp == TRAPDOOR ? "
\97\8e\82µ
\94à" : "
\8c\8a",
960 jconj(locomotion(mtmp->data, "
\94ò
\82Ô"), "
\82Ä"));
962 if (levl[trapx][trapy].typ == SCORR) {
963 levl[trapx][trapy].typ = CORR;
964 unblock_point(trapx, trapy);
966 seetrap(t_at(trapx, trapy));
969 /* don't use rloc_to() because worm tails must "move" */
970 remove_monster(mtmp->mx, mtmp->my);
971 newsym(mtmp->mx, mtmp->my); /* update old location */
972 place_monster(mtmp, trapx, trapy);
975 newsym(trapx, trapy);
977 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_RANDOM,
982 if (ledger_no(&u.uz) == 1)
983 goto escape; /* impossible; level 1 upstairs are SSTAIRS */
984 if (Inhell && mon_has_amulet(mtmp) && !rn2(4)
985 && (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz) - 3)) {
989 "As %s climbs the stairs, a mysterious force momentarily surrounds %s...",
990 mon_nam(mtmp), mhim(mtmp));
993 "%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",
994 mon_nam(mtmp), mhim(mtmp));
996 /* simpler than for the player; this will usually be
997 the Wizard and he'll immediately go right to the
998 upstairs, so there's not much point in having any
999 chance for a random position on the current level */
1000 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_RANDOM,
1005 pline("%s escapes upstairs!", Monnam(mtmp));
1007 pline("%s
\82Í
\8aK
\92i
\82ð
\82Ì
\82Ú
\82Á
\82Ä
\93¦
\82°
\82½
\81I", Monnam(mtmp));
1008 migrate_to_level(mtmp, ledger_no(&u.uz) - 1, MIGR_STAIRS_DOWN,
1012 case MUSE_DOWNSTAIRS:
1016 pline("%s escapes downstairs!", Monnam(mtmp));
1018 pline("%s
\82Í
\8aK
\92i
\82ð
\8d~
\82è
\82Ä
\93¦
\82°
\82½
\81I", Monnam(mtmp));
1019 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_STAIRS_UP,
1022 case MUSE_UP_LADDER:
1026 pline("%s escapes up the ladder!", Monnam(mtmp));
1028 pline("%s
\82Í
\82Í
\82µ
\82²
\82ð
\82Ì
\82Ú
\82Á
\82Ä
\93¦
\82°
\82½
\81I", Monnam(mtmp));
1029 migrate_to_level(mtmp, ledger_no(&u.uz) - 1, MIGR_LADDER_DOWN,
1032 case MUSE_DN_LADDER:
1036 pline("%s escapes down the ladder!", Monnam(mtmp));
1038 pline("%s
\82Í
\82Í
\82µ
\82²
\82ð
\8d~
\82è
\82Ä
\93¦
\82°
\82½
\81I", Monnam(mtmp));
1039 migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_LADDER_UP,
1044 if (ledger_no(&u.uz) == 1) {
1046 /* Monsters without the Amulet escape the dungeon and
1047 * are gone for good when they leave up the up stairs.
1048 * A monster with the Amulet would leave it behind
1049 * (mongone -> mdrop_special_objs) but we force any
1050 * monster who manages to acquire it or the invocation
1051 * tools to stick around instead of letting it escape.
1053 if (mon_has_special(mtmp))
1057 pline("%s escapes the dungeon!", Monnam(mtmp));
1059 pline("%s
\82Í
\96À
\8b{
\82©
\82ç
\93¦
\91\96\82µ
\82½
\81I", Monnam(mtmp));
1065 pline("%s escapes %sstairs!", Monnam(mtmp),
1066 sstairs.up ? "up" : "down");
1068 pline("%s
\82Í
\8aK
\92i
\82ð%s
\93¦
\82°
\82½
\81I", Monnam(mtmp),
1069 sstairs.up ? "
\82Ì
\82Ú
\82Á
\82Ä" : "
\8d~
\82è
\82Ä");
1071 /* going from the Valley to Castle (Stronghold) has no sstairs
1072 to target, but having sstairs.<sx,sy> == <0,0> will work the
1073 same as specifying MIGR_RANDOM when mon_arrive() eventually
1074 places the monster, so we can use MIGR_SSTAIRS unconditionally */
1075 migrate_to_level(mtmp, ledger_no(&sstairs.tolev), MIGR_SSTAIRS,
1078 case MUSE_TELEPORT_TRAP:
1081 Mnam = Monnam(mtmp);
1083 pline("%s %s onto a teleport trap!", Mnam,
1084 vtense(Mnam, locomotion(mtmp->data, "jump")));
1085 #else /*
\93ú
\96{
\8cê
\82Å
\82Í
\91S
\82Ä
\81u
\94ò
\82Ñ
\8d\9e\82ñ
\82¾
\81v */
1086 pline("%s
\82Í
\8fu
\8aÔ
\88Ú
\93®
\82Ìã©
\82É
\94ò
\82Ñ
\8d\9e\82ñ
\82¾
\81I", Mnam);
1088 seetrap(t_at(trapx, trapy));
1090 /* don't use rloc_to() because worm tails must "move" */
1091 remove_monster(mtmp->mx, mtmp->my);
1092 newsym(mtmp->mx, mtmp->my); /* update old location */
1093 place_monster(mtmp, trapx, trapy);
1096 newsym(trapx, trapy);
1099 case MUSE_POT_HEALING:
1100 mquaffmsg(mtmp, otmp);
1101 i = d(6 + 2 * bcsign(otmp), 4);
1103 if (mtmp->mhp > mtmp->mhpmax)
1104 mtmp->mhp = ++mtmp->mhpmax;
1105 if (!otmp->cursed && !mtmp->mcansee)
1106 mcureblindness(mtmp, vismon);
1109 pline("%s looks better.", Monnam(mtmp));
1111 pline("%s
\82Í
\8bC
\95ª
\82ª
\82æ
\82
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mtmp));
1113 makeknown(POT_HEALING);
1114 m_useup(mtmp, otmp);
1116 case MUSE_POT_EXTRA_HEALING:
1117 mquaffmsg(mtmp, otmp);
1118 i = d(6 + 2 * bcsign(otmp), 8);
1120 if (mtmp->mhp > mtmp->mhpmax)
1121 mtmp->mhp = (mtmp->mhpmax += (otmp->blessed ? 5 : 2));
1123 mcureblindness(mtmp, vismon);
1126 pline("%s looks much better.", Monnam(mtmp));
1128 pline("%s
\82Í
\82Æ
\82Ä
\82à
\8bC
\95ª
\82ª
\82æ
\82
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mtmp));
1130 makeknown(POT_EXTRA_HEALING);
1131 m_useup(mtmp, otmp);
1133 case MUSE_POT_FULL_HEALING:
1134 mquaffmsg(mtmp, otmp);
1135 if (otmp->otyp == POT_SICKNESS)
1136 unbless(otmp); /* Pestilence */
1137 mtmp->mhp = (mtmp->mhpmax += (otmp->blessed ? 8 : 4));
1138 if (!mtmp->mcansee && otmp->otyp != POT_SICKNESS)
1139 mcureblindness(mtmp, vismon);
1142 pline("%s looks completely healed.", Monnam(mtmp));
1144 pline("%s
\82Í
\8a®
\91S
\82É
\89ñ
\95\9c\82µ
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mtmp));
1146 makeknown(otmp->otyp);
1147 m_useup(mtmp, otmp);
1149 case MUSE_LIZARD_CORPSE:
1150 /* not actually called for its unstoning effect */
1151 mon_consume_unstone(mtmp, otmp, FALSE, FALSE);
1154 return 0; /* i.e. an exploded wand */
1156 impossible("%s wanted to perform action %d?", Monnam(mtmp),
1165 rnd_defensive_item(mtmp)
1168 struct permonst *pm = mtmp->data;
1169 int difficulty = monstr[(monsndx(pm))];
1172 if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
1173 || pm->mlet == S_GHOST || pm->mlet == S_KOP)
1176 switch (rn2(8 + (difficulty > 3) + (difficulty > 6) + (difficulty > 8))) {
1179 if (level.flags.noteleport && ++trycnt < 2)
1182 return WAN_TELEPORTATION;
1186 return SCR_TELEPORTATION;
1190 return WAN_CREATE_MONSTER;
1193 return SCR_CREATE_MONSTER;
1197 return POT_EXTRA_HEALING;
1199 return (mtmp->data != &mons[PM_PESTILENCE]) ? POT_FULL_HEALING
1202 if (is_floater(pm) || mtmp->isshk || mtmp->isgd || mtmp->ispriest)
1211 #define MUSE_WAN_DEATH 1
1212 #define MUSE_WAN_SLEEP 2
1213 #define MUSE_WAN_FIRE 3
1214 #define MUSE_WAN_COLD 4
1215 #define MUSE_WAN_LIGHTNING 5
1216 #define MUSE_WAN_MAGIC_MISSILE 6
1217 #define MUSE_WAN_STRIKING 7
1218 #define MUSE_SCR_FIRE 8
1219 #define MUSE_POT_PARALYSIS 9
1220 #define MUSE_POT_BLINDNESS 10
1221 #define MUSE_POT_CONFUSION 11
1222 #define MUSE_FROST_HORN 12
1223 #define MUSE_FIRE_HORN 13
1224 #define MUSE_POT_ACID 14
1225 /*#define MUSE_WAN_TELEPORTATION 15*/
1226 #define MUSE_POT_SLEEPING 16
1227 #define MUSE_SCR_EARTH 17
1229 /* Select an offensive item/action for a monster. Returns TRUE iff one is
1233 find_offensive(mtmp)
1236 register struct obj *obj;
1237 boolean reflection_skip = (Reflecting && rn2(2));
1238 struct obj *helmet = which_armor(mtmp, W_ARMH);
1240 m.offensive = (struct obj *) 0;
1242 if (mtmp->mpeaceful || is_animal(mtmp->data) || mindless(mtmp->data)
1243 || nohands(mtmp->data))
1247 if (in_your_sanctuary(mtmp, 0, 0))
1249 if (dmgtype(mtmp->data, AD_HEAL)
1250 && !uwep && !uarmu && !uarm && !uarmh
1251 && !uarms && !uarmg && !uarmc && !uarmf)
1253 /* all offensive items require orthogonal or diagonal targetting */
1254 if (!lined_up(mtmp))
1257 #define nomore(x) if (m.has_offense == x) continue;
1258 /* this picks the last viable item rather than prioritizing choices */
1259 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
1260 if (!reflection_skip) {
1261 nomore(MUSE_WAN_DEATH);
1262 if (obj->otyp == WAN_DEATH && obj->spe > 0) {
1264 m.has_offense = MUSE_WAN_DEATH;
1266 nomore(MUSE_WAN_SLEEP);
1267 if (obj->otyp == WAN_SLEEP && obj->spe > 0 && multi >= 0) {
1269 m.has_offense = MUSE_WAN_SLEEP;
1271 nomore(MUSE_WAN_FIRE);
1272 if (obj->otyp == WAN_FIRE && obj->spe > 0) {
1274 m.has_offense = MUSE_WAN_FIRE;
1276 nomore(MUSE_FIRE_HORN);
1277 if (obj->otyp == FIRE_HORN && obj->spe > 0 && can_blow(mtmp)) {
1279 m.has_offense = MUSE_FIRE_HORN;
1281 nomore(MUSE_WAN_COLD);
1282 if (obj->otyp == WAN_COLD && obj->spe > 0) {
1284 m.has_offense = MUSE_WAN_COLD;
1286 nomore(MUSE_FROST_HORN);
1287 if (obj->otyp == FROST_HORN && obj->spe > 0 && can_blow(mtmp)) {
1289 m.has_offense = MUSE_FROST_HORN;
1291 nomore(MUSE_WAN_LIGHTNING);
1292 if (obj->otyp == WAN_LIGHTNING && obj->spe > 0) {
1294 m.has_offense = MUSE_WAN_LIGHTNING;
1296 nomore(MUSE_WAN_MAGIC_MISSILE);
1297 if (obj->otyp == WAN_MAGIC_MISSILE && obj->spe > 0) {
1299 m.has_offense = MUSE_WAN_MAGIC_MISSILE;
1302 nomore(MUSE_WAN_STRIKING);
1303 if (obj->otyp == WAN_STRIKING && obj->spe > 0) {
1305 m.has_offense = MUSE_WAN_STRIKING;
1307 #if 0 /* use_offensive() has had some code to support wand of teleportation
1308 * for a long time, but find_offensive() never selected one;
1309 * so for the time being, this is still disabled */
1310 nomore(MUSE_WAN_TELEPORTATION);
1311 if (obj->otyp == WAN_TELEPORTATION && obj->spe > 0
1312 /* don't give controlled hero a free teleport */
1313 && !Teleport_control
1314 /* do try to move hero to a more vulnerable spot */
1315 && (onscary(u.ux, u.uy, mtmp)
1316 || (u.ux == xupstair && u.uy == yupstair)
1317 || (u.ux == xdnstair && u.uy == ydnstair)
1318 || (u.ux == sstairs.sx && u.uy == sstairs.sy)
1319 || (u.ux == xupladder && u.uy == yupladder)
1320 || (u.ux == xdnladder && u.uy == ydnladder))) {
1322 m.has_offense = MUSE_WAN_TELEPORTATION;
1325 nomore(MUSE_POT_PARALYSIS);
1326 if (obj->otyp == POT_PARALYSIS && multi >= 0) {
1328 m.has_offense = MUSE_POT_PARALYSIS;
1330 nomore(MUSE_POT_BLINDNESS);
1331 if (obj->otyp == POT_BLINDNESS && !attacktype(mtmp->data, AT_GAZE)) {
1333 m.has_offense = MUSE_POT_BLINDNESS;
1335 nomore(MUSE_POT_CONFUSION);
1336 if (obj->otyp == POT_CONFUSION) {
1338 m.has_offense = MUSE_POT_CONFUSION;
1340 nomore(MUSE_POT_SLEEPING);
1341 if (obj->otyp == POT_SLEEPING) {
1343 m.has_offense = MUSE_POT_SLEEPING;
1345 nomore(MUSE_POT_ACID);
1346 if (obj->otyp == POT_ACID) {
1348 m.has_offense = MUSE_POT_ACID;
1350 /* we can safely put this scroll here since the locations that
1351 * are in a 1 square radius are a subset of the locations that
1352 * are in wand or throwing range (in other words, always lined_up())
1354 nomore(MUSE_SCR_EARTH);
1355 if (obj->otyp == SCR_EARTH
1356 && ((helmet && is_metallic(helmet)) || mtmp->mconf
1357 || amorphous(mtmp->data) || passes_walls(mtmp->data)
1358 || noncorporeal(mtmp->data) || unsolid(mtmp->data)
1360 && dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= 2
1361 && mtmp->mcansee && haseyes(mtmp->data)
1362 && !Is_rogue_level(&u.uz)
1363 && (!In_endgame(&u.uz) || Is_earthlevel(&u.uz))) {
1365 m.has_offense = MUSE_SCR_EARTH;
1368 nomore(MUSE_SCR_FIRE);
1369 if (obj->otyp == SCR_FIRE && resists_fire(mtmp)
1370 && dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= 2
1371 && mtmp->mcansee && haseyes(mtmp->data)) {
1373 m.has_offense = MUSE_SCR_FIRE;
1377 return (boolean) !!m.has_offense;
1384 register struct monst *mtmp;
1385 register struct obj *otmp;
1388 boolean reveal_invis = FALSE;
1390 if (mtmp != &youmonst) {
1391 mtmp->msleeping = 0;
1392 if (mtmp->m_ap_type)
1395 switch (otmp->otyp) {
1397 reveal_invis = TRUE;
1398 if (mtmp == &youmonst) {
1400 makeknown(WAN_STRIKING);
1402 shieldeff(u.ux, u.uy);
1406 pline("
\83{
\83C
\83\93\81I");
1407 } else if (rnd(20) < 10 + u.uac) {
1409 pline_The("wand hits you!");
1411 pline("
\8fñ
\82Í
\82 \82È
\82½
\82É
\96½
\92\86\82µ
\82½
\81I");
1413 if (Half_spell_damage)
1414 tmp = (tmp + 1) / 2;
1416 losehp(tmp, "wand", KILLED_BY_AN);
1418 losehp(tmp, "
\8fÕ
\8c\82\82Ì
\8fñ
\82É
\82æ
\82Á
\82Ä", KILLED_BY_AN);
1421 pline_The("wand misses you.");
1423 pline("
\8fñ
\82Í
\82Í
\82¸
\82ê
\82½
\81D");
1426 } else if (resists_magm(mtmp)) {
1427 shieldeff(mtmp->mx, mtmp->my);
1431 pline("
\83{
\83C
\83\93\81I");
1432 } else if (rnd(20) < 10 + find_mac(mtmp)) {
1435 hit("wand", mtmp, exclam(tmp));
1437 hit("
\8fñ", mtmp, exclam(tmp));
1438 (void) resist(mtmp, otmp->oclass, tmp, TELL);
1439 if (cansee(mtmp->mx, mtmp->my) && zap_oseen)
1440 makeknown(WAN_STRIKING);
1446 if (cansee(mtmp->mx, mtmp->my) && zap_oseen)
1447 makeknown(WAN_STRIKING);
1450 #if 0 /* disabled because find_offensive() never picks WAN_TELEPORTATION */
1451 case WAN_TELEPORTATION:
1452 if (mtmp == &youmonst) {
1454 makeknown(WAN_TELEPORTATION);
1457 /* for consistency with zap.c, don't identify */
1458 if (mtmp->ispriest && *in_rooms(mtmp->mx, mtmp->my, TEMPLE)) {
1459 if (cansee(mtmp->mx, mtmp->my))
1461 pline("%s resists the magic!", Monnam(mtmp));
1463 pline("%s
\82Í
\96\82\96@
\82ð
\96h
\82¢
\82¾
\81I", Monnam(mtmp));
1464 } else if (!tele_restrict(mtmp))
1465 (void) rloc(mtmp, TRUE);
1469 case WAN_CANCELLATION:
1470 case SPE_CANCELLATION:
1471 (void) cancel_monst(mtmp, otmp, FALSE, TRUE, FALSE);
1475 if (mtmp->mhp > 0 && cansee(bhitpos.x, bhitpos.y)
1476 && !canspotmon(mtmp))
1477 map_invisible(bhitpos.x, bhitpos.y);
1482 /* A modified bhit() for monsters. Based on bhit() in zap.c. Unlike
1483 * buzz(), bhit() doesn't take into account the possibility of a monster
1484 * zapping you, so we need a special function for it. (Unless someone wants
1485 * to merge the two functions...)
1488 mbhit(mon, range, fhitm, fhito, obj)
1489 struct monst *mon; /* monster shooting the wand */
1490 register int range; /* direction and range */
1491 int FDECL((*fhitm), (MONST_P, OBJ_P));
1492 int FDECL((*fhito), (OBJ_P, OBJ_P)); /* fns called when mon/obj hit */
1493 struct obj *obj; /* 2nd arg to fhitm/fhito */
1495 register struct monst *mtmp;
1496 register struct obj *otmp;
1500 bhitpos.x = mon->mx;
1501 bhitpos.y = mon->my;
1502 ddx = sgn(mon->mux - mon->mx);
1503 ddy = sgn(mon->muy - mon->my);
1505 while (range-- > 0) {
1518 if (find_drawbridge(&x, &y))
1519 switch (obj->otyp) {
1521 destroy_drawbridge(x, y);
1523 if (bhitpos.x == u.ux && bhitpos.y == u.uy) {
1524 (*fhitm)(&youmonst, obj);
1526 } else if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) {
1527 if (cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp))
1528 map_invisible(bhitpos.x, bhitpos.y);
1529 (*fhitm)(mtmp, obj);
1532 /* modified by GAN to hit all objects */
1534 int hitanything = 0;
1535 register struct obj *next_obj;
1537 for (otmp = level.objects[bhitpos.x][bhitpos.y]; otmp;
1539 /* Fix for polymorph bug, Tim Wright */
1540 next_obj = otmp->nexthere;
1541 hitanything += (*fhito)(otmp, obj);
1546 typ = levl[bhitpos.x][bhitpos.y].typ;
1547 if (IS_DOOR(typ) || typ == SDOOR) {
1548 switch (obj->otyp) {
1549 /* note: monsters don't use opening or locking magic
1550 at present, but keep these as placeholders */
1554 if (doorlock(obj, bhitpos.x, bhitpos.y)) {
1556 makeknown(obj->otyp);
1557 /* if a shop door gets broken, add it to
1558 the shk's fix list (no cost to player) */
1559 if (levl[bhitpos.x][bhitpos.y].doormask == D_BROKEN
1560 && *in_rooms(bhitpos.x, bhitpos.y, SHOPBASE))
1561 add_damage(bhitpos.x, bhitpos.y, 0L);
1567 || (IS_DOOR(typ) && (levl[bhitpos.x][bhitpos.y].doormask
1568 & (D_LOCKED | D_CLOSED)))) {
1576 /* Perform an offensive action for a monster. Must be called immediately
1577 * after find_offensive(). Return values are same as use_defensive().
1584 struct obj *otmp = m.offensive;
1587 /* offensive potions are not drunk, they're thrown */
1588 if (otmp->oclass != POTION_CLASS && (i = precheck(mtmp, otmp)) != 0)
1590 oseen = otmp && canseemon(mtmp);
1592 switch (m.has_offense) {
1593 case MUSE_WAN_DEATH:
1594 case MUSE_WAN_SLEEP:
1597 case MUSE_WAN_LIGHTNING:
1598 case MUSE_WAN_MAGIC_MISSILE:
1599 mzapmsg(mtmp, otmp, FALSE);
1602 makeknown(otmp->otyp);
1604 buzz((int) (-30 - (otmp->otyp - WAN_MAGIC_MISSILE)),
1605 (otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my,
1606 sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my));
1608 return (mtmp->mhp <= 0) ? 1 : 2;
1609 case MUSE_FIRE_HORN:
1610 case MUSE_FROST_HORN:
1612 makeknown(otmp->otyp);
1614 pline("%s plays a %s!", Monnam(mtmp), xname(otmp));
1616 pline("%s
\82Í%s
\82ð
\90\81\82¢
\82½
\81I", Monnam(mtmp), xname(otmp));
1619 You_hear("a horn being played.");
1621 You_hear("
\83z
\83\8b\83\93\82Ì
\89¹
\82ð
\95·
\82¢
\82½
\81D");
1624 buzz(-30 - ((otmp->otyp == FROST_HORN) ? AD_COLD - 1 : AD_FIRE - 1),
1625 rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
1626 sgn(mtmp->muy - mtmp->my));
1628 return (mtmp->mhp <= 0) ? 1 : 2;
1629 case MUSE_WAN_TELEPORTATION:
1630 case MUSE_WAN_STRIKING:
1632 mzapmsg(mtmp, otmp, FALSE);
1635 mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp);
1638 case MUSE_SCR_EARTH: {
1639 /* TODO: handle steeds */
1641 /* don't use monster fields after killing it */
1642 boolean confused = (mtmp->mconf ? TRUE : FALSE);
1643 int mmx = mtmp->mx, mmy = mtmp->my;
1644 boolean is_cursed = otmp->cursed;
1646 mreadmsg(mtmp, otmp);
1647 /* Identify the scroll */
1648 if (canspotmon(mtmp)) {
1650 pline_The("%s rumbles %s %s!", ceiling(mtmp->mx, mtmp->my),
1651 otmp->blessed ? "around" : "above", mon_nam(mtmp));
1653 pline("%s
\82Ì%s
\82Ì%s
\82©
\82ç
\83S
\83\8d\83S
\83\8d\82Æ
\89¹
\82ª
\95·
\82±
\82¦
\82Ä
\82«
\82½
\81D",
1655 otmp->blessed ? "
\82Ü
\82í
\82è" : "
\90^
\8fã",
1656 ceiling(mtmp->mx, mtmp->my));
1659 makeknown(otmp->otyp);
1660 } else if (cansee(mtmp->mx, mtmp->my)) {
1662 pline_The("%s rumbles in the middle of nowhere!",
1664 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",
1665 ceiling(mtmp->mx, mtmp->my));
1667 map_invisible(mtmp->mx, mtmp->my);
1669 makeknown(otmp->otyp);
1672 /* Loop through the surrounding squares */
1673 for (x = mmx - 1; x <= mmx + 1; x++) {
1674 for (y = mmy - 1; y <= mmy + 1; y++) {
1675 /* Is this a suitable spot? */
1676 if (isok(x, y) && !closed_door(x, y)
1677 && !IS_ROCK(levl[x][y].typ) && !IS_AIR(levl[x][y].typ)
1678 && (((x == mmx) && (y == mmy)) ? !otmp->blessed
1680 && (x != u.ux || y != u.uy)) {
1681 (void) drop_boulder_on_monster(x, y, confused, FALSE);
1685 m_useup(mtmp, otmp);
1686 /* Attack the player */
1687 if (distmin(mmx, mmy, u.ux, u.uy) == 1 && !is_cursed) {
1688 drop_boulder_on_player(confused, !is_cursed, FALSE, TRUE);
1691 return (mtmp->mhp <= 0) ? 1 : 2;
1694 case MUSE_SCR_FIRE: {
1695 boolean vis = cansee(mtmp->mx, mtmp->my);
1697 mreadmsg(mtmp, otmp);
1701 pline("Oh, what a pretty fire!");
1703 pline("
\82í
\82\9f\81C
\82«
\82ê
\82¢
\82È
\89\8a\82¾
\81I");
1705 struct monst *mtmp2;
1710 pline_The("scroll erupts in a tower of flame!");
1712 pline("
\8aª
\95¨
\82©
\82ç
\89Î
\92\8c\82ª
\97§
\82¿
\8f¸
\82Á
\82½
\81I");
1713 shieldeff(mtmp->mx, mtmp->my);
1715 pline("%s is uninjured.", Monnam(mtmp));
1717 pline("%s
\82Í
\8f\9d\82Â
\82©
\82È
\82©
\82Á
\82½
\81D", Monnam(mtmp));
1718 (void) destroy_mitem(mtmp, SCROLL_CLASS, AD_FIRE);
1719 (void) destroy_mitem(mtmp, SPBOOK_CLASS, AD_FIRE);
1720 (void) destroy_mitem(mtmp, POTION_CLASS, AD_FIRE);
1721 num = (2 * (rn1(3, 3) + 2 * bcsign(otmp)) + 1) / 3;
1722 if (Fire_resistance)
1724 You("are not harmed.");
1726 You("
\8f\9d\82Â
\82©
\82È
\82©
\82Á
\82½
\81D");
1728 if (Half_spell_damage)
1729 num = (num + 1) / 2;
1732 losehp(num, "scroll of fire", KILLED_BY_AN);
1734 losehp(num, "
\89\8a\82Ì
\8aª
\95¨
\82Å", KILLED_BY_AN);
1735 for (mtmp2 = fmon; mtmp2; mtmp2 = mtmp2->nmon) {
1736 if (DEADMONSTER(mtmp2))
1740 if (dist2(mtmp2->mx, mtmp2->my, mtmp->mx, mtmp->my) < 3) {
1741 if (resists_fire(mtmp2))
1744 if (resists_cold(mtmp2))
1745 mtmp2->mhp -= 3 * num;
1746 if (mtmp2->mhp < 1) {
1756 case MUSE_POT_PARALYSIS:
1757 case MUSE_POT_BLINDNESS:
1758 case MUSE_POT_CONFUSION:
1759 case MUSE_POT_SLEEPING:
1761 /* Note: this setting of dknown doesn't suffice. A monster
1762 * which is out of sight might throw and it hits something _in_
1763 * sight, a problem not existing with wands because wand rays
1764 * are not objects. Also set dknown in mthrowu.c.
1766 if (cansee(mtmp->mx, mtmp->my)) {
1769 pline("%s hurls %s!", Monnam(mtmp), singular(otmp, doname));
1771 pline("%s
\82Í%s
\82ð
\8b
\82
\93\8a\82°
\82Â
\82¯
\82½
\81I", Monnam(mtmp), singular(otmp, doname));
1773 m_throw(mtmp, mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
1774 sgn(mtmp->muy - mtmp->my),
1775 distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy), otmp);
1778 return 0; /* i.e. an exploded wand */
1780 impossible("%s wanted to perform action %d?", Monnam(mtmp),
1788 rnd_offensive_item(mtmp)
1791 struct permonst *pm = mtmp->data;
1792 int difficulty = monstr[(monsndx(pm))];
1794 if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
1795 || pm->mlet == S_GHOST || pm->mlet == S_KOP)
1797 if (difficulty > 7 && !rn2(35))
1799 switch (rn2(9 - (difficulty < 4) + 4 * (difficulty > 6))) {
1801 struct obj *helmet = which_armor(mtmp, W_ARMH);
1803 if ((helmet && is_metallic(helmet)) || amorphous(pm)
1804 || passes_walls(pm) || noncorporeal(pm) || unsolid(pm))
1806 } /* fall through */
1808 return WAN_STRIKING;
1812 return POT_CONFUSION;
1814 return POT_BLINDNESS;
1816 return POT_SLEEPING;
1818 return POT_PARALYSIS;
1821 return WAN_MAGIC_MISSILE;
1829 return WAN_LIGHTNING;
1835 #define MUSE_POT_GAIN_LEVEL 1
1836 #define MUSE_WAN_MAKE_INVISIBLE 2
1837 #define MUSE_POT_INVISIBILITY 3
1838 #define MUSE_POLY_TRAP 4
1839 #define MUSE_WAN_POLYMORPH 5
1840 #define MUSE_POT_SPEED 6
1841 #define MUSE_WAN_SPEED_MONSTER 7
1842 #define MUSE_BULLWHIP 8
1843 #define MUSE_POT_POLYMORPH 9
1849 register struct obj *obj;
1850 struct permonst *mdat = mtmp->data;
1851 int x = mtmp->mx, y = mtmp->my;
1853 int xx, yy, pmidx = NON_PM;
1854 boolean immobile = (mdat->mmove == 0);
1855 boolean stuck = (mtmp == u.ustuck);
1857 m.misc = (struct obj *) 0;
1859 if (is_animal(mdat) || mindless(mdat))
1861 if (u.uswallow && stuck)
1864 /* We arbitrarily limit to times when a player is nearby for the
1865 * same reason as Junior Pac-Man doesn't have energizers eaten until
1866 * you can see them...
1868 if (dist2(x, y, mtmp->mux, mtmp->muy) > 36)
1871 if (!stuck && !immobile && (mtmp->cham == NON_PM)
1872 && monstr[(pmidx = monsndx(mdat))] < 6) {
1873 boolean ignore_boulders = (verysmall(mdat) || throws_rocks(mdat)
1874 || passes_walls(mdat)),
1875 diag_ok = !NODIAG(pmidx);
1877 for (xx = x - 1; xx <= x + 1; xx++)
1878 for (yy = y - 1; yy <= y + 1; yy++)
1879 if (isok(xx, yy) && (xx != u.ux || yy != u.uy)
1880 && (diag_ok || xx == x || yy == y)
1881 && ((xx == x && yy == y) || !level.monsters[xx][yy]))
1882 if ((t = t_at(xx, yy)) != 0
1883 && (ignore_boulders || !sobj_at(BOULDER, xx, yy))
1884 && !onscary(xx, yy, mtmp)) {
1885 /* use trap if it's the correct type */
1886 if (t->ttyp == POLY_TRAP) {
1889 m.has_misc = MUSE_POLY_TRAP;
1897 #define nomore(x) if (m.has_misc == x) continue
1899 * [bug?] Choice of item is not prioritized; the last viable one
1900 * in the monster's inventory will be chosen.
1901 * 'nomore()' is nearly worthless because it only screens checking
1902 * of duplicates when there is no alternate type in between them.
1904 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
1905 /* Monsters shouldn't recognize cursed items; this kludge is
1906 necessary to prevent serious problems though... */
1907 if (obj->otyp == POT_GAIN_LEVEL
1909 || (!mtmp->isgd && !mtmp->isshk && !mtmp->ispriest))) {
1911 m.has_misc = MUSE_POT_GAIN_LEVEL;
1913 nomore(MUSE_BULLWHIP);
1914 if (obj->otyp == BULLWHIP && !mtmp->mpeaceful
1915 /* the random test prevents whip-wielding
1916 monster from attempting disarm every turn */
1917 && uwep && !rn2(5) && obj == MON_WEP(mtmp)
1918 /* hero's location must be known and adjacent */
1919 && mtmp->mux == u.ux && mtmp->muy == u.uy
1920 && distu(mtmp->mx, mtmp->my) <= 2
1921 /* don't bother if it can't work (this doesn't
1922 prevent cursed weapons from being targetted) */
1923 && (canletgo(uwep, "")
1924 || (u.twoweap && canletgo(uswapwep, "")))) {
1926 m.has_misc = MUSE_BULLWHIP;
1928 /* Note: peaceful/tame monsters won't make themselves
1929 * invisible unless you can see them. Not really right, but...
1931 nomore(MUSE_WAN_MAKE_INVISIBLE);
1932 if (obj->otyp == WAN_MAKE_INVISIBLE && obj->spe > 0 && !mtmp->minvis
1933 && !mtmp->invis_blkd && (!mtmp->mpeaceful || See_invisible)
1934 && (!attacktype(mtmp->data, AT_GAZE) || mtmp->mcan)) {
1936 m.has_misc = MUSE_WAN_MAKE_INVISIBLE;
1938 nomore(MUSE_POT_INVISIBILITY);
1939 if (obj->otyp == POT_INVISIBILITY && !mtmp->minvis
1940 && !mtmp->invis_blkd && (!mtmp->mpeaceful || See_invisible)
1941 && (!attacktype(mtmp->data, AT_GAZE) || mtmp->mcan)) {
1943 m.has_misc = MUSE_POT_INVISIBILITY;
1945 nomore(MUSE_WAN_SPEED_MONSTER);
1946 if (obj->otyp == WAN_SPEED_MONSTER && obj->spe > 0
1947 && mtmp->mspeed != MFAST && !mtmp->isgd) {
1949 m.has_misc = MUSE_WAN_SPEED_MONSTER;
1951 nomore(MUSE_POT_SPEED);
1952 if (obj->otyp == POT_SPEED && mtmp->mspeed != MFAST && !mtmp->isgd) {
1954 m.has_misc = MUSE_POT_SPEED;
1956 nomore(MUSE_WAN_POLYMORPH);
1957 if (obj->otyp == WAN_POLYMORPH && obj->spe > 0
1958 && (mtmp->cham == NON_PM) && monstr[monsndx(mdat)] < 6) {
1960 m.has_misc = MUSE_WAN_POLYMORPH;
1962 nomore(MUSE_POT_POLYMORPH);
1963 if (obj->otyp == POT_POLYMORPH && (mtmp->cham == NON_PM)
1964 && monstr[monsndx(mdat)] < 6) {
1966 m.has_misc = MUSE_POT_POLYMORPH;
1969 return (boolean) !!m.has_misc;
1973 /* type of monster to polymorph into; defaults to one suitable for the
1974 current level rather than the totally arbitrary choice of newcham() */
1975 static struct permonst *
1976 muse_newcham_mon(mon)
1981 if ((m_armr = which_armor(mon, W_ARM)) != 0) {
1982 if (Is_dragon_scales(m_armr))
1983 return Dragon_scales_to_pm(m_armr);
1984 else if (Is_dragon_mail(m_armr))
1985 return Dragon_mail_to_pm(m_armr);
1995 struct obj *otmp = m.misc;
1996 boolean vis, vismon, oseen;
1999 if ((i = precheck(mtmp, otmp)) != 0)
2001 vis = cansee(mtmp->mx, mtmp->my);
2002 vismon = canseemon(mtmp);
2003 oseen = otmp && vismon;
2005 switch (m.has_misc) {
2006 case MUSE_POT_GAIN_LEVEL:
2007 mquaffmsg(mtmp, otmp);
2009 if (Can_rise_up(mtmp->mx, mtmp->my, &u.uz)) {
2010 register int tolev = depth(&u.uz) - 1;
2013 get_level(&tolevel, tolev);
2014 /* insurance against future changes... */
2015 if (on_level(&tolevel, &u.uz))
2019 pline("%s rises up, through the %s!", Monnam(mtmp),
2020 ceiling(mtmp->mx, mtmp->my));
2022 pline("%s
\82Í%s
\82ð
\93Ë
\82«
\94²
\82¯
\82½
\81I", Monnam(mtmp),
2023 ceiling(mtmp->mx, mtmp->my));
2025 if (!objects[POT_GAIN_LEVEL].oc_name_known
2026 && !objects[POT_GAIN_LEVEL].oc_uname)
2029 m_useup(mtmp, otmp);
2030 migrate_to_level(mtmp, ledger_no(&tolevel), MIGR_RANDOM,
2037 pline("%s looks uneasy.", Monnam(mtmp));
2039 pline("%s
\82Í
\95s
\88À
\82°
\82É
\8c©
\82¦
\82é
\81D", Monnam(mtmp));
2040 if (!objects[POT_GAIN_LEVEL].oc_name_known
2041 && !objects[POT_GAIN_LEVEL].oc_uname)
2044 m_useup(mtmp, otmp);
2050 pline("%s seems more experienced.", Monnam(mtmp));
2052 pline("%s
\82Í
\8co
\8c±
\82ð
\90Ï
\82ñ
\82¾
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81D", Monnam(mtmp));
2054 makeknown(POT_GAIN_LEVEL);
2055 m_useup(mtmp, otmp);
2056 if (!grow_up(mtmp, (struct monst *) 0))
2058 /* grew into genocided monster */
2060 case MUSE_WAN_MAKE_INVISIBLE:
2061 case MUSE_POT_INVISIBILITY:
2062 if (otmp->otyp == WAN_MAKE_INVISIBLE) {
2063 mzapmsg(mtmp, otmp, TRUE);
2066 mquaffmsg(mtmp, otmp);
2067 /* format monster's name before altering its visibility */
2068 Strcpy(nambuf, mon_nam(mtmp));
2069 mon_set_minvis(mtmp);
2070 if (vismon && mtmp->minvis) { /* was seen, now invisible */
2071 if (canspotmon(mtmp)) {
2073 pline("%s body takes on a %s transparency.",
2074 upstart(s_suffix(nambuf)),
2075 Hallucination ? "normal" : "strange");
2077 pline("%s%s
\82Ì
\91Ì
\82Í
\93§
\89ß
\90«
\82ð
\82à
\82Á
\82½
\81D",
2078 Hallucination ? "
\82 \82½
\82è
\82Ü
\82¦
\82È
\82±
\82Æ
\82¾
\82ª" : "
\8aï
\96
\82È
\82±
\82Æ
\82É",
2083 pline("Suddenly you cannot see %s.", nambuf);
2085 pline("%s
\82Í
\93Ë
\91R
\8c©
\82¦
\82È
\82
\82È
\82Á
\82½
\81D", nambuf);
2087 map_invisible(mtmp->mx, mtmp->my);
2090 makeknown(otmp->otyp);
2092 if (otmp->otyp == POT_INVISIBILITY) {
2094 you_aggravate(mtmp);
2095 m_useup(mtmp, otmp);
2098 case MUSE_WAN_SPEED_MONSTER:
2099 mzapmsg(mtmp, otmp, TRUE);
2101 mon_adjust_speed(mtmp, 1, otmp);
2103 case MUSE_POT_SPEED:
2104 mquaffmsg(mtmp, otmp);
2105 /* note difference in potion effect due to substantially
2106 different methods of maintaining speed ratings:
2107 player's character becomes "very fast" temporarily;
2108 monster becomes "one stage faster" permanently */
2109 mon_adjust_speed(mtmp, 1, otmp);
2110 m_useup(mtmp, otmp);
2112 case MUSE_WAN_POLYMORPH:
2113 mzapmsg(mtmp, otmp, TRUE);
2115 (void) newcham(mtmp, muse_newcham_mon(mtmp), TRUE, FALSE);
2117 makeknown(WAN_POLYMORPH);
2119 case MUSE_POT_POLYMORPH:
2120 mquaffmsg(mtmp, otmp);
2123 pline("%s suddenly mutates!", Monnam(mtmp));
2125 pline("%s
\82Í
\93Ë
\91R
\95Ï
\89»
\82µ
\82½
\81I", Monnam(mtmp));
2126 (void) newcham(mtmp, muse_newcham_mon(mtmp), FALSE, FALSE);
2128 makeknown(POT_POLYMORPH);
2129 m_useup(mtmp, otmp);
2131 case MUSE_POLY_TRAP:
2133 const char *Mnam = Monnam(mtmp);
2136 pline("%s deliberately %s onto a polymorph trap!", Mnam,
2137 vtense(Mnam, locomotion(mtmp->data, "jump")));
2139 pline("%s
\82Í
\82í
\82´
\82Æ
\95Ï
\89»
\82Ìã©
\82É
\94ò
\82Ñ
\82±
\82ñ
\82¾
\81I", Mnam);
2143 seetrap(t_at(trapx, trapy));
2145 /* don't use rloc() due to worms */
2146 remove_monster(mtmp->mx, mtmp->my);
2147 newsym(mtmp->mx, mtmp->my);
2148 place_monster(mtmp, trapx, trapy);
2151 newsym(trapx, trapy);
2153 (void) newcham(mtmp, (struct permonst *) 0, FALSE, FALSE);
2156 /* attempt to disarm hero */
2159 const char *The_whip = vismon ? "The bullwhip" : "A whip";
2161 const char *The_whip = vismon ? "
\95Ú" : "
\95Ú";
2162 int where_to = rn2(4);
2163 struct obj *obj = uwep;
2165 char the_weapon[BUFSZ];
2167 if (!obj || !canletgo(obj, "")
2168 || (u.twoweap && canletgo(uswapwep, "") && rn2(2)))
2171 break; /* shouldn't happen after find_misc() */
2173 Strcpy(the_weapon, the(xname(obj)));
2174 hand = body_part(HAND);
2176 hand = makeplural(hand);
2180 pline("%s flicks a bullwhip towards your %s!", Monnam(mtmp),
2183 pline("%s
\82Í
\82 \82È
\82½
\82Ì%s
\82É
\8cü
\82©
\82Á
\82Ä
\95Ú
\82ð
\91Å
\82Á
\82½
\81I", Monnam(mtmp),
2186 if (obj->otyp == HEAVY_IRON_BALL) {
2188 pline("%s fails to wrap around %s.", The_whip, the_weapon);
2190 pline("%s
\82Í%s
\82É
\82Í
\82©
\82ç
\82Ý
\82Â
\82©
\82È
\82©
\82Á
\82½
\81D", The_whip, the_weapon);
2194 pline("%s wraps around %s you're wielding!", The_whip,
2197 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,
2202 pline("%s welded to your %s%c",
2203 !is_plural(obj) ? "It is" : "They are", hand,
2204 !obj->bknown ? '!' : '.');
2206 pline("
\82µ
\82©
\82µ
\81C
\82»
\82ê
\82Í
\82Ü
\82¾
\82 \82È
\82½
\82Ì%s
\82Ì
\92\86\82É
\82 \82é%s",
2208 !obj->bknown ? "
\81I" : "
\81D");
2210 /* obj->bknown = 1; */ /* welded() takes care of this */
2215 pline_The("whip slips free."); /* not `The_whip' */
2217 pline("
\95Ú
\82Í
\82Ù
\82Ç
\82¯
\82½
\81D"); /* not `The_whip' */
2220 } else if (where_to == 3 && mon_hates_silver(mtmp)
2221 && objects[obj->otyp].oc_material == SILVER) {
2222 /* this monster won't want to catch a silver
2223 weapon; drop it at hero's feet instead */
2226 remove_worn_item(obj, FALSE);
2229 case 1: /* onto floor beneath mon */
2231 pline("%s yanks %s from your %s!", Monnam(mtmp), the_weapon,
2234 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,
2237 place_object(obj, mtmp->mx, mtmp->my);
2239 case 2: /* onto floor beneath you */
2241 pline("%s yanks %s to the %s!", Monnam(mtmp), the_weapon,
2242 surface(u.ux, u.uy));
2244 pline("%s
\82Í%s
\82ð%s
\82É
\88ø
\82«
\97\8e\82µ
\82½
\81I", Monnam(mtmp), the_weapon,
2245 surface(u.ux, u.uy));
2249 case 3: /* into mon's inventory */
2251 pline("%s snatches %s!", Monnam(mtmp), the_weapon);
2253 pline("%s
\82Í%s
\82ð
\92D
\82Á
\82½
\81I", Monnam(mtmp), the_weapon);
2254 (void) mpickobj(mtmp, obj);
2261 return 0; /* i.e. an exploded wand */
2263 impossible("%s wanted to perform action %d?", Monnam(mtmp),
2275 pline("For some reason, %s presence is known to you.",
2276 s_suffix(noit_mon_nam(mtmp)));
2278 pline("
\82È
\82º
\82©
\81C
\82 \82È
\82½
\82Í%s
\82Ì
\91¶
\8dÝ
\82É
\8bC
\82ª
\82Â
\82¢
\82½
\81D",
2279 noit_mon_nam(mtmp));
2283 cliparound(mtmp->mx, mtmp->my);
2285 show_glyph(mtmp->mx, mtmp->my, mon_to_glyph(mtmp));
2288 You_feel("aggravated at %s.", noit_mon_nam(mtmp));
2290 You("%s
\82É
\95 \82ª
\82½
\82Á
\82½
\81D", mon_nam(mtmp));
2291 display_nhwindow(WIN_MAP, TRUE);
2293 if (unconscious()) {
2296 nomovemsg = "Aggravated, you are jolted into full consciousness.";
2298 nomovemsg = "
\95 \82ª
\82½
\82Á
\82Ä
\82¢
\82Ä
\81C
\83s
\83\8a\83s
\83\8a\82µ
\82Ä
\82¢
\82é
\81D";
2300 newsym(mtmp->mx, mtmp->my);
2301 if (!canspotmon(mtmp))
2302 map_invisible(mtmp->mx, mtmp->my);
2309 struct permonst *pm = mtmp->data;
2310 int difficulty = monstr[(monsndx(pm))];
2312 if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data)
2313 || pm->mlet == S_GHOST || pm->mlet == S_KOP)
2315 /* Unlike other rnd_item functions, we only allow _weak_ monsters
2316 * to have this item; after all, the item will be used to strengthen
2317 * the monster and strong monsters won't use it at all...
2319 if (difficulty < 6 && !rn2(30))
2320 return rn2(6) ? POT_POLYMORPH : WAN_POLYMORPH;
2322 if (!rn2(40) && !nonliving(pm) && !is_vampshifter(mtmp))
2323 return AMULET_OF_LIFE_SAVING;
2329 return rn2(6) ? POT_SPEED : WAN_SPEED_MONSTER;
2331 if (mtmp->mpeaceful && !See_invisible)
2333 return rn2(6) ? POT_INVISIBILITY : WAN_MAKE_INVISIBLE;
2335 return POT_GAIN_LEVEL;
2342 searches_for_item(mon, obj)
2346 int typ = obj->otyp;
2348 if (is_animal(mon->data) || mindless(mon->data)
2349 || mon->data == &mons[PM_GHOST]) /* don't loot bones piles */
2352 if (typ == WAN_MAKE_INVISIBLE || typ == POT_INVISIBILITY)
2353 return (boolean) (!mon->minvis && !mon->invis_blkd
2354 && !attacktype(mon->data, AT_GAZE));
2355 if (typ == WAN_SPEED_MONSTER || typ == POT_SPEED)
2356 return (boolean) (mon->mspeed != MFAST);
2358 switch (obj->oclass) {
2362 if (typ == WAN_DIGGING)
2363 return (boolean) !is_floater(mon->data);
2364 if (typ == WAN_POLYMORPH)
2365 return (boolean) (monstr[monsndx(mon->data)] < 6);
2366 if (objects[typ].oc_dir == RAY || typ == WAN_STRIKING
2367 || typ == WAN_TELEPORTATION || typ == WAN_CREATE_MONSTER)
2371 if (typ == POT_HEALING || typ == POT_EXTRA_HEALING
2372 || typ == POT_FULL_HEALING || typ == POT_POLYMORPH
2373 || typ == POT_GAIN_LEVEL || typ == POT_PARALYSIS
2374 || typ == POT_SLEEPING || typ == POT_ACID || typ == POT_CONFUSION)
2376 if (typ == POT_BLINDNESS && !attacktype(mon->data, AT_GAZE))
2380 if (typ == SCR_TELEPORTATION || typ == SCR_CREATE_MONSTER
2381 || typ == SCR_EARTH || typ == SCR_FIRE)
2385 if (typ == AMULET_OF_LIFE_SAVING)
2386 return (boolean) !(nonliving(mon->data) || is_vampshifter(mon));
2387 if (typ == AMULET_OF_REFLECTION)
2391 if (typ == PICK_AXE)
2392 return (boolean) needspick(mon->data);
2393 if (typ == UNICORN_HORN)
2394 return (boolean) (!obj->cursed && !is_unicorn(mon->data));
2395 if (typ == FROST_HORN || typ == FIRE_HORN)
2396 return (obj->spe > 0 && can_blow(mon));
2400 return (boolean) (((mon->misc_worn_check & W_ARMG) != 0L
2401 && touch_petrifies(&mons[obj->corpsenm]))
2402 || (!resists_ston(mon)
2403 && cures_stoning(mon, obj, FALSE)));
2405 return (boolean) (mcould_eat_tin(mon)
2406 && (!resists_ston(mon)
2407 && cures_stoning(mon, obj, TRUE)));
2409 return (boolean) touch_petrifies(&mons[obj->corpsenm]);
2419 mon_reflects(mon, str)
2423 struct obj *orefl = which_armor(mon, W_ARMS);
2425 if (orefl && orefl->otyp == SHIELD_OF_REFLECTION) {
2428 pline(str, s_suffix(mon_nam(mon)), "shield");
2430 pline(str, mon_nam(mon), "
\8f\82");
2431 makeknown(SHIELD_OF_REFLECTION);
2434 } else if (arti_reflects(MON_WEP(mon))) {
2435 /* due to wielded artifact weapon */
2438 pline(str, s_suffix(mon_nam(mon)), "weapon");
2440 pline(str, mon_nam(mon), "
\95\90\8aí");
2442 } else if ((orefl = which_armor(mon, W_AMUL))
2443 && orefl->otyp == AMULET_OF_REFLECTION) {
2446 pline(str, s_suffix(mon_nam(mon)), "amulet");
2448 pline(str, mon_nam(mon), "
\96\82\8f\9c\82¯");
2449 makeknown(AMULET_OF_REFLECTION);
2452 } else if ((orefl = which_armor(mon, W_ARM))
2453 && (orefl->otyp == SILVER_DRAGON_SCALES
2454 || orefl->otyp == SILVER_DRAGON_SCALE_MAIL)) {
2457 pline(str, s_suffix(mon_nam(mon)), "armor");
2459 pline(str, mon_nam(mon), "
\8aZ");
2461 } else if (mon->data == &mons[PM_SILVER_DRAGON]
2462 || mon->data == &mons[PM_CHROMATIC_DRAGON]) {
2463 /* Silver dragons only reflect when mature; babies do not */
2466 pline(str, s_suffix(mon_nam(mon)), "scales");
2468 pline(str, mon_nam(mon), "
\97Ø");
2476 const char *fmt, *str;
2478 /* Check from outermost to innermost objects */
2479 if (EReflecting & W_ARMS) {
2482 pline(fmt, str, "shield");
2484 pline(fmt, str, "
\8f\82");
2485 makeknown(SHIELD_OF_REFLECTION);
2488 } else if (EReflecting & W_WEP) {
2489 /* Due to wielded artifact weapon */
2492 pline(fmt, str, "weapon");
2494 pline(fmt, str, "
\95\90\8aí");
2496 } else if (EReflecting & W_AMUL) {
2499 pline(fmt, str, "medallion");
2501 pline(fmt, str, "
\83\81\83_
\83\8a\83I
\83\93");
2502 makeknown(AMULET_OF_REFLECTION);
2505 } else if (EReflecting & W_ARM) {
2508 pline(fmt, str, uskin ? "luster" : "armor");
2510 pline(fmt, str, uskin ? "
\82Â
\82â" : "
\8aZ");
2512 } else if (youmonst.data == &mons[PM_SILVER_DRAGON]) {
2515 pline(fmt, str, "scales");
2517 pline(fmt, str, "
\97Ø");
2523 /* cure mon's blindness (use_defensive, dog_eat, meatobj) */
2525 mcureblindness(mon, verbos)
2529 if (!mon->mcansee) {
2532 if (verbos && haseyes(mon->data))
2534 pline("%s can see again.", Monnam(mon));
2536 pline("%s
\82Í
\82Ü
\82½
\8c©
\82¦
\82é
\82æ
\82¤
\82É
\82È
\82Á
\82½
\81D", Monnam(mon));
2540 /* TRUE if the monster ate something */
2542 munstone(mon, by_you)
2549 if (resists_ston(mon))
2551 if (mon->meating || !mon->mcanmove || mon->msleeping)
2553 mon->mstrategy &= ~STRAT_WAITFORU;
2555 tinok = mcould_eat_tin(mon);
2556 for (obj = mon->minvent; obj; obj = obj->nobj) {
2557 if (cures_stoning(mon, obj, tinok)) {
2558 mon_consume_unstone(mon, obj, by_you, TRUE);
2566 mon_consume_unstone(mon, obj, by_you, stoning)
2570 boolean stoning; /* True: stop petrification, False: cure stun && confusion */
2572 boolean vis = canseemon(mon), tinned = obj->otyp == TIN,
2573 food = obj->otyp == CORPSE || tinned,
2574 acid = obj->otyp == POT_ACID
2575 || (food && acidic(&mons[obj->corpsenm])),
2576 lizard = food && obj->corpsenm == PM_LIZARD;
2577 int nutrit = food ? dog_nutrition(mon, obj) : 0; /* also sets meating */
2579 /* give a "<mon> is slowing down" message and also remove
2580 intrinsic speed (comparable to similar effect on the hero) */
2582 mon_adjust_speed(mon, -3, (struct obj *) 0);
2585 long save_quan = obj->quan;
2589 pline("%s %s %s.", Monnam(mon),
2590 (obj->oclass == POTION_CLASS)
2592 : (obj->otyp == TIN) ? "opens and eats the contents of"
2594 distant_name(obj, doname));
2596 pline("%s
\82Í%s
\82ð%s
\81D", Monnam(mon),
2597 distant_name(obj, doname),
2598 (obj->oclass == POTION_CLASS)
2600 : (obj->otyp == TIN) ? "
\8aJ
\82¯
\82Ä
\92\86\90g
\82ð
\90H
\82×
\82½"
2603 obj->quan = save_quan;
2607 (obj->oclass == POTION_CLASS) ? "drinking" : "chewing");
2609 You_hear("%s
\82Æ
\82¢
\82¤
\89¹
\82ð
\95·
\82¢
\82½
\81D",
2610 (obj->otyp == POT_ACID) ? "
\83S
\83N
\83\93" : "
\83N
\83`
\83\83\83N
\83`
\83\83");
2614 /* obj is now gone */
2616 if (acid && !tinned && !resists_acid(mon)) {
2617 mon->mhp -= rnd(15);
2620 pline("%s has a very bad case of stomach acid.", Monnam(mon));
2622 pline("%s
\82Í
\88Ý
\8e_
\82Ì
\92²
\8eq
\82ª
\82Æ
\82Ä
\82à
\88«
\82¢
\81D", Monnam(mon));
2623 if (mon->mhp <= 0) {
2625 pline("%s dies!", Monnam(mon));
2627 pline("%s
\82Í
\8e\80\82ñ
\82¾
\81I", Monnam(mon));
2629 /* hero gets credit (experience) and blame (possible loss
2630 of alignment and/or luck and/or telepathy depending on
2631 mon) for the kill but does not break pacifism conduct */
2632 xkilled(mon, XKILL_NOMSG | XKILL_NOCONDUCT);
2638 if (stoning && vis) {
2641 pline("What a pity - %s just ruined a future piece of art!",
2643 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",
2647 pline("%s seems limber!", Monnam(mon));
2649 pline("%s
\82Í
\91Ì
\82ª
\8f_
\82ç
\82©
\82
\82È
\82Á
\82½
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81I", Monnam(mon));
2651 if (lizard && (mon->mconf || mon->mstun)) {
2654 if (vis && !is_bat(mon->data) && mon->data != &mons[PM_STALKER])
2656 pline("%s seems steadier now.", Monnam(mon));
2658 pline("%s
\82Í
\82æ
\82è
\8fä
\95v
\82É
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D", Monnam(mon));
2660 if (mon->mtame && !mon->isminion && nutrit > 0) {
2661 struct edog *edog = EDOG(mon);
2663 if (edog->hungrytime < monstermoves)
2664 edog->hungrytime = monstermoves;
2665 edog->hungrytime += nutrit;
2668 /* use up monster's next move */
2669 mon->movement -= NORMAL_SPEED;
2670 mon->mlstmv = monstermoves;
2673 /* decide whether obj can cure petrification; also used when picking up */
2675 cures_stoning(mon, obj, tinok)
2680 if (obj->otyp == POT_ACID)
2682 if (obj->otyp != CORPSE && (obj->otyp != TIN || !tinok))
2684 /* corpse, or tin that mon can open */
2685 return (boolean) (obj->corpsenm == PM_LIZARD
2686 || (acidic(&mons[obj->corpsenm])
2687 && (obj->corpsenm != PM_GREEN_SLIME
2688 || slimeproof(mon->data))));
2695 struct obj *obj, *mwep;
2698 /* monkeys who manage to steal tins can't open and eat them
2699 even if they happen to also have the appropriate tool */
2700 if (is_animal(mon->data))
2703 mwep = MON_WEP(mon);
2704 welded_wep = mwep && mwelded(mwep);
2705 /* this is different from the player; tin opener or dagger doesn't
2706 have to be wielded, and knife can be used instead of dagger */
2707 for (obj = mon->minvent; obj; obj = obj->nobj) {
2708 /* if stuck with a cursed weapon, don't check rest of inventory */
2709 if (welded_wep && obj != mwep)
2712 if (obj->otyp == TIN_OPENER
2713 || (obj->oclass == WEAPON_CLASS
2714 && (objects[obj->otyp].oc_skill == P_DAGGER
2715 || objects[obj->otyp].oc_skill == P_KNIFE)))
2721 /* TRUE if monster does something to avoid turning into green slime */
2723 munslime(mon, by_you)
2727 struct obj *obj, odummy;
2728 struct permonst *mptr = mon->data;
2731 * muse_unslime() gives "mon starts turning green", "mon zaps
2732 * itself with a wand of fire", and "mon's slime burns away"
2733 * messages. Monsters who don't get any chance at that just have
2734 * (via our caller) newcham()'s "mon turns into slime" feedback.
2737 if (slimeproof(mptr))
2739 if (mon->meating || !mon->mcanmove || mon->msleeping)
2741 mon->mstrategy &= ~STRAT_WAITFORU;
2743 /* if monster can breathe fire, do so upon self; a monster who deals
2744 fire damage by biting, clawing, gazing, and especially exploding
2745 isn't able to cure itself of green slime with its own attack
2746 [possible extension: monst capable of casting high level clerical
2747 spells could toss pillar of fire at self--probably too suicidal] */
2748 if (!mon->mcan && !mon->mspec_used
2749 && attacktype_fordmg(mptr, AT_BREA, AD_FIRE)) {
2750 odummy = zeroobj; /* otyp == STRANGE_OBJECT */
2751 return muse_unslime(mon, &odummy, (struct trap *) 0, by_you);
2754 /* same MUSE criteria as use_defensive() */
2755 if (!is_animal(mptr) && !mindless(mptr)) {
2758 for (obj = mon->minvent; obj; obj = obj->nobj)
2759 if (cures_sliming(mon, obj))
2760 return muse_unslime(mon, obj, (struct trap *) 0, by_you);
2762 if (((t = t_at(mon->mx, mon->my)) == 0 || t->ttyp != FIRE_TRAP)
2763 && mptr->mmove && !mon->mtrapped) {
2764 int xy[2][8], x, y, idx, ridx, nxy = 0;
2766 for (x = mon->mx - 1; x <= mon->mx + 1; ++x)
2767 for (y = mon->my - 1; y <= mon->my + 1; ++y)
2768 if (isok(x, y) && accessible(x, y)
2769 && !m_at(x, y) && (x != u.ux || y != u.uy)) {
2770 xy[0][nxy] = x, xy[1][nxy] = y;
2773 for (idx = 0; idx < nxy; ++idx) {
2774 ridx = rn1(nxy - idx, idx);
2777 xy[0][idx] = xy[0][ridx];
2780 xy[1][idx] = xy[1][ridx];
2783 if ((t = t_at(xy[0][idx], xy[1][idx])) != 0
2784 && t->ttyp == FIRE_TRAP)
2788 if (t && t->ttyp == FIRE_TRAP)
2789 return muse_unslime(mon, &zeroobj, t, by_you);
2796 /* mon uses an item--selected by caller--to burn away incipient slime */
2798 muse_unslime(mon, obj, trap, by_you)
2802 boolean by_you; /* true: if mon kills itself, hero gets credit/blame */
2803 { /* [by_you not honored if 'mon' triggers fire trap]. */
2804 struct obj *odummyp;
2805 int otyp = obj->otyp, dmg = 0;
2806 boolean vis = canseemon(mon), res = TRUE;
2810 pline("%s starts turning %s.", Monnam(mon),
2811 green_mon(mon) ? "into ooze" : hcolor(NH_GREEN));
2813 pline("%s
\82Í%s
\82É
\82È
\82è
\82Í
\82¶
\82ß
\82½
\81D", Monnam(mon),
2814 green_mon(mon) ? "
\83X
\83\89\83C
\83\80" : hcolor(NH_GREEN));
2816 /* -4 => sliming, causes quiet loss of enhanced speed */
2817 mon_adjust_speed(mon, -4, (struct obj *) 0);
2820 const char *Mnam = vis ? Monnam(mon) : 0;
2822 if (mon->mx == trap->tx && mon->my == trap->ty) {
2825 pline("%s triggers %s fire trap!", Mnam,
2826 trap->tseen ? "the" : "a");
2828 pline("%s
\82Í
\89\8a\82Ìã©
\82ð
\94
\93®
\82³
\82¹
\82½
\81I", Mnam);
2831 remove_monster(mon->mx, mon->my);
2832 newsym(mon->mx, mon->my);
2833 place_monster(mon, trap->tx, trap->ty);
2834 if (mon->wormno) /* won't happen; worms don't MUSE to unslime */
2836 newsym(mon->mx, mon->my);
2839 pline("%s %s %s %s fire trap!", Mnam,
2840 vtense(Mnam, locomotion(mon->data, "move")),
2841 is_floater(mon->data) ? "over" : "onto",
2842 trap->tseen ? "the" : "a");
2844 pline("%s
\82Í
\89\8a\82Ìã©
\82É
\94ò
\82Ñ
\8d\9e\82ñ
\82¾
\81I", Mnam);
2847 /* hack to avoid mintrap()'s chance of avoiding known trap */
2848 mon->mtrapseen &= ~(1 << (FIRE_TRAP - 1));
2850 } else if (otyp == STRANGE_OBJECT) {
2851 /* monster is using fire breath on self */
2854 pline("%s breathes fire on %sself.", Monnam(mon), mhim(mon));
2856 pline("%s
\82Í
\89Î
\82ð
\82Í
\82¢
\82½
\81D", Monnam(mon));
2858 mon->mspec_used = rn1(10, 5);
2859 /* -21 => monster's fire breath; 1 => # of damage dice */
2860 dmg = zhitm(mon, by_you ? 21 : -21, 1, &odummyp);
2861 } else if (otyp == SCR_FIRE) {
2864 if (cansee(mon->mx, mon->my))
2866 pline("Oh, what a pretty fire!");
2868 pline("
\82 \82ç
\81A
\82È
\82ñ
\82Ä
\82©
\82í
\82¢
\82¢
\89Î
\82¾
\81I");
2869 if (vis && !objects[otyp].oc_name_known
2870 && !objects[otyp].oc_uname)
2872 m_useup(mon, obj); /* after docall() */
2873 vis = FALSE; /* skip makeknown() below */
2874 res = FALSE; /* failed to cure sliming */
2876 m_useup(mon, obj); /* before explode() */
2877 dmg = (2 * (rn1(3, 3) + 2 * bcsign(obj)) + 1) / 3;
2878 /* -11 => monster's fireball */
2879 explode(mon->mx, mon->my, -11, dmg, SCROLL_CLASS,
2880 /* by_you: override -11 for mon but not others */
2881 by_you ? -EXPL_FIERY : EXPL_FIERY);
2882 dmg = 0; /* damage has been applied by explode() */
2884 } else { /* wand/horn of fire w/ positive charge count */
2885 mzapmsg(mon, obj, TRUE);
2887 /* -1 => monster's wand of fire; 2 => # of damage dice */
2888 dmg = zhitm(mon, by_you ? 1 : -1, 2, &odummyp);
2892 /* zhitm() applies damage but doesn't kill creature off;
2893 for fire breath, dmg is going to be 0 (fire breathers are
2894 immune to fire damage) but for wand of fire or fire horn,
2895 'mon' could have taken damage so might die */
2896 if (mon->mhp <= 0) {
2898 /* mon killed self but hero gets credit and blame (except
2899 for pacifist conduct); xkilled()'s message would say
2900 "You killed/destroyed <mon>" so give our own message */
2903 pline("%s is %s by the fire!", Monnam(mon),
2904 nonliving(mon->data) ? "destroyed" : "killed");
2906 pline("%s
\82Í
\89Î
\82Å%s
\82³
\82ê
\82½
\81I", Monnam(mon),
2907 nonliving(mon->data) ? "
\93|" : "
\8eE");
2909 xkilled(mon, XKILL_NOMSG | XKILL_NOCONDUCT);
2912 monkilled(mon, "fire", AD_FIRE);
2914 monkilled(mon, "
\89Î", AD_FIRE);
2916 /* non-fatal damage occurred */
2919 pline("%s is burned%s", Monnam(mon), exclam(dmg));
2921 pline("%s
\82Í
\94R
\82¦
\82½%s", Monnam(mon), exclam(dmg));
2925 if (res && mon->mhp > 0)
2927 pline("%s slime is burned away!", s_suffix(Monnam(mon)));
2929 pline("%s
\82Ì
\83X
\83\89\83C
\83\80\82Í
\94R
\82¦
\82Â
\82«
\82½
\81I", Monnam(mon));
2930 if (otyp != STRANGE_OBJECT)
2933 /* use up monster's next move */
2934 mon->movement -= NORMAL_SPEED;
2935 mon->mlstmv = monstermoves;
2939 /* decide whether obj can be used to cure green slime */
2941 cures_sliming(mon, obj)
2945 /* scroll of fire, non-empty wand or horn of fire */
2946 if (obj->otyp == SCR_FIRE)
2947 return (haseyes(mon->data) && mon->mcansee);
2948 /* hero doesn't need hands or even limbs to zap, so mon doesn't either */
2949 return ((obj->otyp == WAN_FIRE
2950 || (obj->otyp == FIRE_HORN && can_blow(mon)))
2954 /* TRUE if monster appears to be green; for active TEXTCOLOR, we go by
2955 the display color, otherwise we just pick things that seem plausibly
2956 green (which doesn't necessarily match the TEXTCOLOR categorization) */
2961 struct permonst *ptr = mon->data;
2966 if (iflags.use_color)
2967 return (ptr->mcolor == CLR_GREEN || ptr->mcolor == CLR_BRIGHT_GREEN);
2971 if (strstri(ptr->mname, "green"))
2973 if (strstri(ptr->mname, "
\97Î"))
2976 switch (monsndx(ptr)) {
2977 case PM_FOREST_CENTAUR:
2978 case PM_GARTER_SNAKE:
2989 if (is_elf(ptr) && !is_prince(ptr) && !is_lord(ptr)
2990 && ptr != &mons[PM_GREY_ELF])