1 /* NetHack 3.6 mon.c $NHDT-Date: 1449269918 2015/12/04 22:58:38 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.199 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
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-2016 */
8 /* JNetHack may be freely redistributed. See license for details. */
10 /* If you're using precompiled headers, you don't want this either */
19 STATIC_VAR boolean vamp_rise_msg;
21 STATIC_DCL void FDECL(sanity_check_single_mon, (struct monst *, const char *));
22 STATIC_DCL boolean FDECL(restrap, (struct monst *));
23 STATIC_DCL long FDECL(mm_aggression, (struct monst *, struct monst *));
24 STATIC_DCL long FDECL(mm_displacement, (struct monst *, struct monst *));
25 STATIC_DCL int NDECL(pick_animal);
26 STATIC_DCL void FDECL(kill_eggs, (struct obj *));
27 STATIC_DCL int FDECL(pickvampshape, (struct monst *));
28 STATIC_DCL boolean FDECL(isspecmon, (struct monst *));
29 STATIC_DCL boolean FDECL(validspecmon, (struct monst *, int));
30 STATIC_DCL boolean FDECL(validvamp, (struct monst *, int *, int));
31 STATIC_DCL struct permonst *FDECL(accept_newcham_form, (int));
32 STATIC_DCL struct obj *FDECL(make_corpse, (struct monst *, unsigned));
33 STATIC_DCL void FDECL(m_detach, (struct monst *, struct permonst *));
34 STATIC_DCL void FDECL(lifesaved_monster, (struct monst *));
36 #define LEVEL_SPECIFIC_NOCORPSE(mdat) \
37 (Is_rogue_level(&u.uz) \
38 || (level.flags.graveyard && is_undead(mdat) && rn2(3)))
41 /* part of the original warning code which was replaced in 3.3.1 */
42 const char *warnings[] = {
44 "white", "pink", "red", "ruby", "purple", "black"
46 "
\94\92\82¢", "
\83s
\83\93\83N
\90F
\82Ì", "
\90Ô
\82¢", "
\83\8b\83r
\81[
\90F
\82Ì", "
\8e\87\82Ì", "
\8d\95\82¢"
52 sanity_check_single_mon(mtmp, msg)
56 if (DEADMONSTER(mtmp))
58 if (mtmp->data < &mons[LOW_PM] || mtmp->data >= &mons[NUMMONS])
59 impossible("illegal mon data (%s)", msg);
66 struct monst *mtmp = fmon;
69 sanity_check_single_mon(mtmp, "fmon");
72 for (x = 0; x < COLNO; x++)
73 for (y = 0; y < ROWNO; y++)
74 if ((mtmp = m_at(x,y)) != 0)
75 sanity_check_single_mon(mtmp, "m_at");
77 mtmp = migrating_mons;
79 sanity_check_single_mon(mtmp, "migr");
85 /* convert the monster index of an undead to its living counterpart */
87 undead_to_corpse(mndx)
91 case PM_KOBOLD_ZOMBIE:
112 case PM_VAMPIRE_LORD:
114 case PM_VAMPIRE_MAGE:
116 case PM_HUMAN_ZOMBIE:
120 case PM_GIANT_ZOMBIE:
124 case PM_ETTIN_ZOMBIE:
134 /* Convert the monster index of some monsters (such as quest guardians)
135 * to their generic species type.
137 * Return associated character class monster, rather than species
145 /* Quest guardians */
147 mndx = mode ? PM_ARCHEOLOGIST : PM_HUMAN;
150 mndx = mode ? PM_BARBARIAN : PM_HUMAN;
153 mndx = mode ? PM_CAVEMAN : PM_HUMAN;
156 mndx = mode ? PM_HEALER : PM_HUMAN;
159 mndx = mode ? PM_KNIGHT : PM_HUMAN;
162 mndx = mode ? PM_MONK : PM_HUMAN;
165 mndx = mode ? PM_PRIEST : PM_HUMAN;
168 mndx = mode ? PM_RANGER : PM_HUMAN;
171 mndx = mode ? PM_ROGUE : PM_HUMAN;
174 mndx = mode ? PM_SAMURAI : PM_HUMAN;
177 mndx = mode ? PM_TOURIST : PM_HUMAN;
180 mndx = mode ? PM_WIZARD : PM_HUMAN;
183 mndx = mode ? PM_VALKYRIE : PM_HUMAN;
186 if (mndx >= LOW_PM && mndx < NUMMONS) {
187 struct permonst *ptr = &mons[mndx];
191 else if (is_elf(ptr))
193 else if (is_dwarf(ptr))
195 else if (is_gnome(ptr))
197 else if (is_orc(ptr))
205 /* return monster index if chameleon, or NON_PM if not */
213 * As of 3.6.0 we just check M2_SHAPESHIFTER instead of having a
214 * big switch statement with hardcoded shapeshifter types here.
216 if (mndx >= LOW_PM && is_shapeshifter(&mons[mndx]))
221 /* for deciding whether corpse will carry along full monster data */
222 #define KEEPTRAITS(mon) \
223 ((mon)->isshk || (mon)->mtame || unique_corpstat((mon)->data) \
224 || is_reviver((mon)->data) \
225 /* normally quest leader will be unique, */ \
226 /* but he or she might have been polymorphed */ \
227 || (mon)->m_id == quest_status.leader_m_id \
228 /* special cancellation handling for these */ \
229 || (dmgtype((mon)->data, AD_SEDU) || dmgtype((mon)->data, AD_SSEX)))
231 /* Creates a monster corpse, a "special" corpse, or nothing if it doesn't
232 * leave corpses. Monsters which leave "special" corpses should have
233 * G_NOCORPSE set in order to prevent wishing for one, finding tins of one,
236 STATIC_OVL struct obj *
237 make_corpse(mtmp, corpseflags)
238 register struct monst *mtmp;
239 unsigned corpseflags;
241 register struct permonst *mdat = mtmp->data;
243 struct obj *obj = (struct obj *) 0;
244 struct obj *otmp = (struct obj *) 0;
245 int x = mtmp->mx, y = mtmp->my;
246 int mndx = monsndx(mdat);
247 unsigned corpstatflags = corpseflags;
248 boolean burythem = ((corpstatflags & CORPSTAT_BURIED) != 0);
252 case PM_SILVER_DRAGON:
254 case PM_SHIMMERING_DRAGON:
257 case PM_ORANGE_DRAGON:
258 case PM_WHITE_DRAGON:
259 case PM_BLACK_DRAGON:
261 case PM_GREEN_DRAGON:
262 case PM_YELLOW_DRAGON:
263 /* Make dragon scales. This assumes that the order of the
264 dragons is the same as the order of the scales. */
265 if (!rn2(mtmp->mrevived ? 20 : 3)) {
266 num = GRAY_DRAGON_SCALES + monsndx(mdat) - PM_GRAY_DRAGON;
267 obj = mksobj_at(num, x, y, FALSE, FALSE);
269 obj->cursed = obj->blessed = FALSE;
272 case PM_WHITE_UNICORN:
273 case PM_GRAY_UNICORN:
274 case PM_BLACK_UNICORN:
275 if (mtmp->mrevived && rn2(2)) {
278 pline("%s recently regrown horn crumbles to dust.",
280 pline("
\8dÅ
\8bß
\8dÄ
\90¶
\82µ
\82½%s
\82Ì
\8ap
\82Í
\95²
\81X
\82É
\82È
\82Á
\82½
\81D",
281 s_suffix(Monnam(mtmp)));
283 obj = mksobj_at(UNICORN_HORN, x, y, TRUE, FALSE);
284 if (obj && mtmp->mrevived)
285 obj->degraded_horn = 1;
289 (void) mksobj_at(WORM_TOOTH, x, y, TRUE, FALSE);
292 case PM_VAMPIRE_LORD:
293 /* include mtmp in the mkcorpstat() call */
294 num = undead_to_corpse(mndx);
295 corpstatflags |= CORPSTAT_INIT;
296 obj = mkcorpstat(CORPSE, mtmp, &mons[num], x, y, corpstatflags);
297 obj->age -= 100; /* this is an *OLD* corpse */
299 case PM_KOBOLD_MUMMY:
307 case PM_KOBOLD_ZOMBIE:
308 case PM_DWARF_ZOMBIE:
309 case PM_GNOME_ZOMBIE:
312 case PM_HUMAN_ZOMBIE:
313 case PM_GIANT_ZOMBIE:
314 case PM_ETTIN_ZOMBIE:
315 num = undead_to_corpse(mndx);
316 corpstatflags |= CORPSTAT_INIT;
317 obj = mkcorpstat(CORPSE, mtmp, &mons[num], x, y, corpstatflags);
318 obj->age -= 100; /* this is an *OLD* corpse */
323 obj = mksobj_at(IRON_CHAIN, x, y, TRUE, FALSE);
324 free_mname(mtmp); /* don't christen obj */
327 num = d(2, 4); /* very low chance of creating all glass gems */
329 obj = mksobj_at((LAST_GEM + rnd(9)), x, y, TRUE, FALSE);
333 obj = mksobj_at(ROCK, x, y, FALSE, FALSE);
334 obj->quan = (long) (rn2(20) + 50);
335 obj->owt = weight(obj);
339 corpstatflags &= ~CORPSTAT_INIT;
341 mkcorpstat(STATUE, (struct monst *) 0, mdat, x, y, corpstatflags);
346 obj = mksobj_at(QUARTERSTAFF, x, y, TRUE, FALSE);
350 case PM_LEATHER_GOLEM:
353 obj = mksobj_at(LEATHER_ARMOR, x, y, TRUE, FALSE);
357 /* Good luck gives more coins */
358 obj = mkgold((long) (200 - rnl(101)), x, y);
364 obj = mksobj_at(SCR_BLANK_PAPER, x, y, TRUE, FALSE);
367 /* expired puddings will congeal into a large blob;
368 like dragons, relies on the order remaining consistent */
370 case PM_BROWN_PUDDING:
372 case PM_BLACK_PUDDING:
373 /* we have to do this here because most other places
374 expect there to be an object coming back; not this one */
375 obj = mksobj_at(GLOB_OF_BLACK_PUDDING - (PM_BLACK_PUDDING - mndx),
378 while (obj && (otmp = obj_nexto(obj)) != (struct obj *) 0) {
379 pudding_merge_message(obj, otmp);
380 obj = obj_meld(&obj, &otmp);
387 if (mvitals[mndx].mvflags & G_NOCORPSE) {
388 return (struct obj *) 0;
390 corpstatflags |= CORPSTAT_INIT;
391 /* preserve the unique traits of some creatures */
392 obj = mkcorpstat(CORPSE, KEEPTRAITS(mtmp) ? mtmp : 0,
393 mdat, x, y, corpstatflags);
397 (void) bury_an_obj(obj, &dealloc);
399 return dealloc ? (struct obj *) 0 : obj;
404 /* All special cases should precede the G_NOCORPSE check */
406 if (!obj) return NULL;
408 /* if polymorph or undead turning has killed this monster,
409 prevent the same attack beam from hitting its corpse */
410 if (context.bypasses)
414 obj = oname(obj, MNAME(mtmp));
416 /* Avoid "It was hidden under a green mold corpse!"
417 * during Blind combat. An unseen monster referred to as "it"
418 * could be killed and leave a corpse. If a hider then hid
419 * underneath it, you could be told the corpse type of a
420 * monster that you never knew was there without this.
421 * The code in hitmu() substitutes the word "something"
422 * if the corpses obj->dknown is 0.
424 if (Blind && !sensemon(mtmp))
432 /* check mtmp and water/lava for compatibility, 0 (survived), 1 (died) */
435 register struct monst *mtmp;
437 boolean inpool, inlava, infountain;
439 /* [what about ceiling clingers?] */
440 inpool = (is_pool(mtmp->mx, mtmp->my)
441 && !(is_flyer(mtmp->data) || is_floater(mtmp->data)));
442 inlava = (is_lava(mtmp->mx, mtmp->my)
443 && !(is_flyer(mtmp->data) || is_floater(mtmp->data)));
444 infountain = IS_FOUNTAIN(levl[mtmp->mx][mtmp->my].typ);
446 /* Flying and levitation keeps our steed out of the liquid */
447 /* (but not water-walking or swimming) */
448 if (mtmp == u.usteed && (Flying || Levitation))
451 /* Gremlin multiplying won't go on forever since the hit points
452 * keep going down, and when it gets to 1 hit point the clone
453 * function will fail.
455 if (mtmp->data == &mons[PM_GREMLIN] && (inpool || infountain) && rn2(3)) {
456 if (split_mon(mtmp, (struct monst *) 0))
457 dryup(mtmp->mx, mtmp->my, FALSE);
459 water_damage_chain(mtmp->minvent, FALSE);
461 } else if (mtmp->data == &mons[PM_IRON_GOLEM] && inpool && !rn2(5)) {
464 if (cansee(mtmp->mx, mtmp->my))
466 pline("%s rusts.", Monnam(mtmp));
468 pline("%s
\82Í
\8eK
\82Ñ
\82½
\81D", Monnam(mtmp));
470 if (mtmp->mhpmax > dam)
477 water_damage_chain(mtmp->minvent, FALSE);
483 * Lava effects much as water effects. Lava likers are able to
484 * protect their stuff. Fire resistant monsters can only protect
487 if (!is_clinger(mtmp->data) && !likes_lava(mtmp->data)) {
488 if (!resists_fire(mtmp)) {
489 if (cansee(mtmp->mx, mtmp->my))
491 pline("%s %s.", Monnam(mtmp),
492 mtmp->data == &mons[PM_WATER_ELEMENTAL]
494 : "burns to a crisp");
496 pline("%s
\82Í%s
\82½
\81D", Monnam(mtmp),
497 mtmp->data == &mons[PM_WATER_ELEMENTAL]
499 : "
\94R
\82¦
\82Ä
\83p
\83\8a\83p
\83\8a\82É
\82È
\82Á");
503 if (--mtmp->mhp < 1) {
504 if (cansee(mtmp->mx, mtmp->my))
506 pline("%s surrenders to the fire.", Monnam(mtmp));
508 pline("%s
\82Í
\89\8a\82É
\93Û
\82Ü
\82ê
\82½
\81D", Monnam(mtmp));
510 } else if (cansee(mtmp->mx, mtmp->my))
512 pline("%s burns slightly.", Monnam(mtmp));
514 pline("%s
\82Í
\82¿
\82å
\82Á
\82Æ
\8fÅ
\82°
\82½
\81D", Monnam(mtmp));
517 (void) fire_damage_chain(mtmp->minvent, FALSE, FALSE,
519 (void) rloc(mtmp, FALSE);
525 /* Most monsters drown in pools. flooreffects() will take care of
526 * water damage to dead monsters' inventory, but survivors need to
527 * be handled here. Swimmers are able to protect their stuff...
529 if (!is_clinger(mtmp->data) && !is_swimmer(mtmp->data)
530 && !amphibious(mtmp->data)) {
531 if (cansee(mtmp->mx, mtmp->my)) {
533 pline("%s drowns.", Monnam(mtmp));
535 pline("%s
\82Í
\93M
\82ê
\82½
\81D", Monnam(mtmp));
537 if (u.ustuck && u.uswallow && u.ustuck == mtmp) {
538 /* This can happen after a purple worm plucks you off a
539 flying steed while you are over water. */
541 pline("%s sinks as water rushes in and flushes you out.",
543 pline("%s
\82Í
\90\85\97¬
\82É
\92¾
\82Ý
\81D
\82 \82È
\82½
\82ð
\93f
\82«
\8fo
\82µ
\82½
\81D",
548 water_damage_chain(mtmp->minvent, FALSE);
549 (void) rloc(mtmp, FALSE);
555 /* but eels have a difficult time outside */
556 if (mtmp->data->mlet == S_EEL && !Is_waterlevel(&u.uz)) {
557 /* as mhp gets lower, the rate of further loss slows down */
558 if (mtmp->mhp > 1 && rn2(mtmp->mhp) > rn2(8))
560 monflee(mtmp, 2, FALSE, FALSE);
570 int mmove = mon->data->mmove;
572 /* Note: MSLOW's `+ 1' prevents slowed speed 1 getting reduced to 0;
573 * MFAST's `+ 2' prevents hasted speed 1 from becoming a no-op;
574 * both adjustments have negligible effect on higher speeds.
576 if (mon->mspeed == MSLOW)
577 mmove = (2 * mmove + 1) / 3;
578 else if (mon->mspeed == MFAST)
579 mmove = (4 * mmove + 2) / 3;
581 if (mon == u.usteed) {
582 if (u.ugallop && context.mv) {
583 /* average movement is 1.50 times normal */
584 mmove = ((rn2(2) ? 4 : 5) * mmove) / 3;
587 /* vary movement points allocated to slightly reduce predictability;
588 random increment (avg +2) exceeds random decrement (avg +1) by
589 a small amount; normal speed monsters will occasionally get an
590 extra move and slow ones won't be quite as slow */
591 mmove += rn2(5) - rn2(3); /* + 0..4 - 0..2, average net +1 */
599 /* actions that happen once per ``turn'', regardless of each
600 individual monster's metabolism; some of these might need to
601 be reclassified to occur more in proportion with movement rate */
607 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
608 if (DEADMONSTER(mtmp))
611 /* must check non-moving monsters once/turn in case
612 * they managed to end up in liquid */
613 if (mtmp->data->mmove == 0) {
614 if (vision_full_recalc)
620 /* regenerate hit points */
621 mon_regen(mtmp, FALSE);
623 /* possibly polymorph shapechangers and lycanthropes */
624 if (mtmp->cham >= LOW_PM) {
625 if (is_vampshifter(mtmp) || mtmp->data->mlet == S_VAMPIRE)
626 decide_to_shapeshift(mtmp, 0);
628 (void) newcham(mtmp, (struct permonst *) 0, FALSE, FALSE);
632 /* gradually time out temporary problems */
633 if (mtmp->mblinded && !--mtmp->mblinded)
635 if (mtmp->mfrozen && !--mtmp->mfrozen)
637 if (mtmp->mfleetim && !--mtmp->mfleetim)
640 /* FIXME: mtmp->mlstmv ought to be updated here */
647 register struct monst *mtmp, *nmtmp;
648 register boolean somebody_can_move = FALSE;
651 * Some of you may remember the former assertion here that
652 * because of deaths and other actions, a simple one-pass
653 * algorithm wasn't possible for movemon. Deaths are no longer
654 * removed to the separate list fdmon; they are simply left in
655 * the chain with hit points <= 0, to be cleaned up at the end
658 * The only other actions which cause monsters to be removed from
659 * the chain are level migrations and losedogs(). I believe losedogs()
660 * is a cleanup routine not associated with monster movements, and
661 * monsters can only affect level migrations on themselves, not others
662 * (hence the fetching of nmon before moving the monster). Currently,
663 * monsters can jump into traps, read cursed scrolls of teleportation,
664 * and drink cursed potions of raise level to change levels. These are
665 * all reflexive at this point. Should one monster be able to level
666 * teleport another, this scheme would have problems.
669 for (mtmp = fmon; mtmp; mtmp = nmtmp) {
670 /* end monster movement early if hero is flagged to leave the level */
673 /* or if the program has lost contact with the user */
674 || program_state.done_hup
677 somebody_can_move = FALSE;
681 /* one dead monster needs to perform a move after death:
682 vault guard whose temporary corridor is still on the map */
683 if (mtmp->isgd && !mtmp->mx && mtmp->mhp <= 0)
684 (void) gd_move(mtmp);
685 if (DEADMONSTER(mtmp))
688 /* Find a monster that we have not treated yet. */
689 if (mtmp->movement < NORMAL_SPEED)
692 mtmp->movement -= NORMAL_SPEED;
693 if (mtmp->movement >= NORMAL_SPEED)
694 somebody_can_move = TRUE;
696 if (vision_full_recalc)
697 vision_recalc(0); /* vision! */
699 /* reset obj bypasses before next monster moves */
700 if (context.bypasses)
706 if (is_hider(mtmp->data)) {
707 /* unwatched mimics and piercers may hide again [MRS] */
710 if (mtmp->m_ap_type == M_AP_FURNITURE
711 || mtmp->m_ap_type == M_AP_OBJECT)
713 if (mtmp->mundetected)
715 } else if (mtmp->data->mlet == S_EEL && !mtmp->mundetected
716 && (mtmp->mflee || distu(mtmp->mx, mtmp->my) > 2)
717 && !canseemon(mtmp) && !rn2(4)) {
718 /* some eels end up stuck in isolated pools, where they
719 can't--or at least won't--move, so they never reach
720 their post-move chance to re-hide */
725 /* continue if the monster died fighting */
726 if (Conflict && !mtmp->iswiz && mtmp->mcansee) {
728 * Conflict does not take effect in the first round.
729 * Therefore, A monster when stepping into the area will
730 * get to swing at you.
732 * The call to fightm() must be _last_. The monster might
733 * have died if it returns 1.
735 if (couldsee(mtmp->mx, mtmp->my)
736 && (distu(mtmp->mx, mtmp->my) <= BOLT_LIM * BOLT_LIM)
738 continue; /* mon might have died */
740 if (dochugw(mtmp)) /* otherwise just move the monster */
744 if (any_light_source())
745 vision_full_recalc = 1; /* in case a mon moved with a light source */
746 /* reset obj bypasses after last monster has moved */
747 if (context.bypasses)
750 /* remove dead monsters; dead vault guard will be left at <0,0>
751 if temporary corridor out of vault hasn't been removed yet */
754 /* a monster may have levteleported player -dlc */
757 /* changed levels, so these monsters are dormant */
758 somebody_can_move = FALSE;
761 return somebody_can_move;
764 #define mstoning(obj) \
765 (ofood(obj) && (touch_petrifies(&mons[(obj)->corpsenm]) \
766 || (obj)->corpsenm == PM_MEDUSA))
769 * Maybe eat a metallic object (not just gold).
770 * Return value: 0 => nothing happened, 1 => monster ate something,
771 * 2 => monster died (it must have grown into a genocided form, but
772 * that can't happen at present because nothing which eats objects
773 * has young and old forms).
777 register struct monst *mtmp;
779 register struct obj *otmp;
780 struct permonst *ptr;
781 int poly, grow, heal, mstone;
783 /* If a pet, eating is handled separately, in dog.c */
787 /* Eats topmost metal object if it is there */
788 for (otmp = level.objects[mtmp->mx][mtmp->my]; otmp;
789 otmp = otmp->nexthere) {
790 /* Don't eat indigestible/choking/inappropriate objects */
791 if ((mtmp->data == &mons[PM_RUST_MONSTER] && !is_rustprone(otmp))
792 || (otmp->otyp == AMULET_OF_STRANGULATION)
793 || (otmp->otyp == RIN_SLOW_DIGESTION))
795 if (is_metallic(otmp) && !obj_resists(otmp, 5, 95)
796 && touch_artifact(otmp, mtmp)) {
797 if (mtmp->data == &mons[PM_RUST_MONSTER] && otmp->oerodeproof) {
798 if (canseemon(mtmp) && flags.verbose) {
800 pline("%s eats %s!", Monnam(mtmp),
801 distant_name(otmp, doname));
803 pline("%s
\82Í%s
\82ð
\90H
\82×
\82Ä
\82¢
\82é
\81I", Monnam(mtmp),
804 distant_name(otmp,doname));
807 /* The object's rustproofing is gone now */
808 otmp->oerodeproof = 0;
810 if (canseemon(mtmp) && flags.verbose) {
812 pline("%s spits %s out in disgust!", Monnam(mtmp),
813 distant_name(otmp, doname));
815 pline("%s
\82Í%s
\82ð
\83y
\83b
\82Æ
\93f
\82«
\8fo
\82µ
\82½
\81I", Monnam(mtmp),
816 distant_name(otmp,doname));
820 if (cansee(mtmp->mx, mtmp->my) && flags.verbose)
822 pline("%s eats %s!", Monnam(mtmp),
823 distant_name(otmp, doname));
825 pline("%s
\82Í%s
\82ð
\90H
\82×
\82Ä
\82¢
\82é
\81I", Monnam(mtmp),
826 distant_name(otmp,doname));
828 else if (flags.verbose)
830 You_hear("a crunching sound.");
832 You_hear("
\83o
\83\8a\83o
\83\8a\82Æ
\90H
\82×
\82é
\89¹
\82ð
\95·
\82¢
\82½
\81D");
833 mtmp->meating = otmp->owt / 2 + 1;
834 /* Heal up to the object's weight in hp */
835 if (mtmp->mhp < mtmp->mhpmax) {
836 mtmp->mhp += objects[otmp->otyp].oc_weight;
837 if (mtmp->mhp > mtmp->mhpmax)
838 mtmp->mhp = mtmp->mhpmax;
843 } else if (otmp == uchain) {
844 unpunish(); /* frees uchain */
846 poly = polyfodder(otmp);
847 grow = mlevelgain(otmp);
848 heal = mhealup(otmp);
849 mstone = mstoning(otmp);
853 if (newcham(mtmp, (struct permonst *) 0, FALSE, FALSE))
856 ptr = grow_up(mtmp, (struct monst *) 0);
858 if (poly_when_stoned(ptr)) {
861 } else if (!resists_ston(mtmp)) {
864 pline("%s turns to stone!", Monnam(mtmp));
866 pline("%s
\82Í
\90Î
\82É
\82È
\82Á
\82½
\81I", Monnam(mtmp));
868 ptr = (struct permonst *) 0;
871 mtmp->mhp = mtmp->mhpmax;
874 return 2; /* it died */
876 /* Left behind a pile? */
878 (void) mksobj_at(ROCK, mtmp->mx, mtmp->my, TRUE, FALSE);
879 newsym(mtmp->mx, mtmp->my);
887 /* monster eats a pile of objects */
889 meatobj(mtmp) /* for gelatinous cubes */
892 register struct obj *otmp, *otmp2;
893 struct permonst *ptr, *original_ptr = mtmp->data;
894 int poly, grow, heal, count = 0, ecount = 0;
898 /* If a pet, eating is handled separately, in dog.c */
902 /* eat organic objects, including cloth and wood, if present;
903 engulf others, except huge rocks and metal attached to player
904 [despite comment at top, doesn't assume that eater is a g.cube] */
905 for (otmp = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) {
906 otmp2 = otmp->nexthere;
908 /* touch sensitive items */
909 if (otmp->otyp == CORPSE && is_rider(&mons[otmp->corpsenm])) {
910 /* Rider corpse isn't just inedible; can't engulf it either */
911 (void) revive_corpse(otmp);
913 /* untouchable (or inaccessible) items */
914 } else if ((otmp->otyp == CORPSE
915 && touch_petrifies(&mons[otmp->corpsenm])
916 && !resists_ston(mtmp))
917 /* don't engulf boulders and statues or ball&chain */
918 || otmp->oclass == ROCK_CLASS
919 || otmp == uball || otmp == uchain) {
920 /* do nothing--neither eaten nor engulfed */
923 /* inedible items -- engulf these */
924 } else if (!is_organic(otmp) || obj_resists(otmp, 5, 95)
925 || !touch_artifact(otmp, mtmp)
926 /* redundant due to non-organic composition but
927 included for emphasis */
928 || (otmp->otyp == AMULET_OF_STRANGULATION
929 || otmp->otyp == RIN_SLOW_DIGESTION)
930 /* cockatrice corpses handled above; this
931 touch_petrifies() check catches eggs */
932 || ((otmp->otyp == CORPSE || otmp->otyp == EGG)
933 && ((touch_petrifies(&mons[otmp->corpsenm])
934 && !resists_ston(mtmp))
935 || (otmp->corpsenm == PM_GREEN_SLIME
936 && !slimeproof(mtmp->data))))) {
941 Sprintf(buf, "%s engulfs %s.", Monnam(mtmp),
942 distant_name(otmp, doname));
944 Sprintf(buf, "%s
\82Í%s
\82ð
\88ù
\82Ý
\8d\9e\82ñ
\82¾
\81D", Monnam(mtmp),
945 distant_name(otmp,doname));
947 else if (ecount == 2)
949 Sprintf(buf, "%s engulfs several objects.", Monnam(mtmp));
951 Sprintf(buf, "%s
\82Í
\82¢
\82
\82Â
\82©
\82Ì
\95¨
\82ð
\88ù
\82Ý
\8d\9e\82ñ
\82¾
\81D", Monnam(mtmp));
952 obj_extract_self(otmp);
953 (void) mpickobj(mtmp, otmp); /* slurp */
955 /* lastly, edible items; yum! */
959 if (cansee(mtmp->mx, mtmp->my) && flags.verbose)
961 pline("%s eats %s!", Monnam(mtmp),
962 distant_name(otmp, doname));
964 pline("%s
\82Í%s
\82ð
\90H
\82×
\82Ä
\82¢
\82é
\81I", Monnam(mtmp),
965 distant_name(otmp, doname));
967 else if (flags.verbose)
969 You_hear("a slurping sound.");
971 You_hear("
\82²
\82
\82ñ
\82Æ
\88ù
\82Ý
\8d\9e\82Þ
\89¹
\82ð
\95·
\82¢
\82½
\81D");
972 /* Heal up to the object's weight in hp */
973 if (mtmp->mhp < mtmp->mhpmax) {
974 mtmp->mhp += objects[otmp->otyp].oc_weight;
975 if (mtmp->mhp > mtmp->mhpmax)
976 mtmp->mhp = mtmp->mhpmax;
978 if (Has_contents(otmp)) {
979 register struct obj *otmp3;
981 /* contents of eaten containers become engulfed; this
982 is arbitrary, but otherwise g.cubes are too powerful */
983 while ((otmp3 = otmp->cobj) != 0) {
984 obj_extract_self(otmp3);
985 if (otmp->otyp == ICE_BOX && otmp3->otyp == CORPSE) {
986 otmp3->age = monstermoves - otmp3->age;
987 start_corpse_timeout(otmp3);
989 (void) mpickobj(mtmp, otmp3);
992 poly = polyfodder(otmp);
993 grow = mlevelgain(otmp);
994 heal = mhealup(otmp);
995 delobj(otmp); /* munch */
998 if (newcham(mtmp, (struct permonst *) 0, FALSE, FALSE))
1001 ptr = grow_up(mtmp, (struct monst *) 0);
1003 mtmp->mhp = mtmp->mhpmax;
1005 /* in case it polymorphed or died */
1006 if (ptr != original_ptr)
1007 return !ptr ? 2 : 1;
1010 /* Engulf & devour is instant, so don't set meating */
1012 newsym(mtmp->mx, mtmp->my);
1016 if (cansee(mtmp->mx, mtmp->my) && flags.verbose && buf[0])
1018 else if (flags.verbose)
1020 You_hear("%s slurping sound%s.",
1021 (ecount == 1) ? "a" : "several", plur(ecount));
1023 You_hear("
\83Y
\83\8b\83Y
\83\8b\82Æ
\82¢
\82¤
\89¹
\82ð
\95·
\82¢
\82½
\81D");
1026 return (count > 0 || ecount > 0) ? 1 : 0;
1031 register struct monst *mtmp;
1033 register struct obj *gold;
1036 if ((gold = g_at(mtmp->mx, mtmp->my)) != 0) {
1037 mat_idx = objects[gold->otyp].oc_material;
1038 obj_extract_self(gold);
1039 add_to_minv(mtmp, gold);
1040 if (cansee(mtmp->mx, mtmp->my)) {
1041 if (flags.verbose && !mtmp->isgd)
1043 pline("%s picks up some %s.", Monnam(mtmp),
1044 mat_idx == GOLD ? "gold" : "money");
1046 pline("%s
\82Í
\82¨
\8bà
\82ð
\8fE
\82Á
\82½
\81D", Monnam(mtmp));
1048 newsym(mtmp->mx, mtmp->my);
1054 mpickstuff(mtmp, str)
1055 register struct monst *mtmp;
1056 register const char *str;
1058 register struct obj *otmp, *otmp2, *otmp3;
1061 /* prevent shopkeepers from leaving the door of their shop */
1062 if (mtmp->isshk && inhishop(mtmp))
1065 for (otmp = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) {
1066 otmp2 = otmp->nexthere;
1067 /* Nymphs take everything. Most monsters don't pick up corpses. */
1068 if (!str ? searches_for_item(mtmp, otmp)
1069 : !!(index(str, otmp->oclass))) {
1070 if (otmp->otyp == CORPSE && mtmp->data->mlet != S_NYMPH
1071 /* let a handful of corpse types thru to can_carry() */
1072 && !touch_petrifies(&mons[otmp->corpsenm])
1073 && otmp->corpsenm != PM_LIZARD
1074 && !acidic(&mons[otmp->corpsenm]))
1076 if (!touch_artifact(otmp, mtmp))
1078 carryamt = can_carry(mtmp, otmp);
1081 if (is_pool(mtmp->mx, mtmp->my))
1083 /* handle cases where the critter can only get some */
1085 if (carryamt != otmp->quan) {
1086 otmp3 = splitobj(otmp, carryamt);
1088 if (cansee(mtmp->mx, mtmp->my) && flags.verbose)
1090 pline("%s picks up %s.", Monnam(mtmp),
1091 (distu(mtmp->mx, mtmp->my) <= 5)
1093 : distant_name(otmp3, doname));
1095 pline("%s
\82Í%s
\82ð
\8fE
\82Á
\82½
\81D", Monnam(mtmp),
1096 (distu(mtmp->mx, mtmp->my) <= 5)
1098 : distant_name(otmp3, doname));
1100 obj_extract_self(otmp3); /* remove from floor */
1101 (void) mpickobj(mtmp, otmp3); /* may merge and free otmp3 */
1102 m_dowear(mtmp, FALSE);
1103 newsym(mtmp->mx, mtmp->my);
1104 return TRUE; /* pick only one object */
1117 for (obj = mtmp->minvent; obj; obj = obj->nobj) {
1118 if (obj->otyp != BOULDER || !throws_rocks(mtmp->data))
1119 curload += obj->owt;
1131 /* Base monster carrying capacity is equal to human maximum
1132 * carrying capacity, or half human maximum if not strong.
1133 * (for a polymorphed player, the value used would be the
1134 * non-polymorphed carrying capacity instead of max/half max).
1135 * This is then modified by the ratio between the monster weights
1136 * and human weights. Corpseless monsters are given a capacity
1137 * proportional to their size instead of weight.
1139 if (!mtmp->data->cwt)
1140 maxload = (MAX_CARR_CAP * (long) mtmp->data->msize) / MZ_HUMAN;
1141 else if (!strongmonst(mtmp->data)
1142 || (strongmonst(mtmp->data) && (mtmp->data->cwt > WT_HUMAN)))
1143 maxload = (MAX_CARR_CAP * (long) mtmp->data->cwt) / WT_HUMAN;
1145 maxload = MAX_CARR_CAP; /*strong monsters w/cwt <= WT_HUMAN*/
1147 if (!strongmonst(mtmp->data))
1153 return (int) maxload;
1156 /* for restricting monsters' object-pickup.
1158 * to support the new pet behavior, this now returns the max # of objects
1159 * that a given monster could pick up from a pile. frequently this will be
1160 * otmp->quan, but special cases for 'only one' now exist so.
1162 * this will probably cause very amusing behavior with pets and gold coins.
1164 * TODO: allow picking up 2-N objects from a pile of N based on weight.
1165 * Change from 'int' to 'long' to accomate big stacks of gold.
1166 * Right now we fake it by reporting a partial quantity, but the
1167 * likesgold handling m_move results in picking up the whole stack.
1170 can_carry(mtmp, otmp)
1174 int iquan, otyp = otmp->otyp, newload = otmp->owt;
1175 struct permonst *mdat = mtmp->data;
1179 return 0; /* can't carry anything */
1181 if (otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])
1182 && !(mtmp->misc_worn_check & W_ARMG) && !resists_ston(mtmp))
1184 if (otyp == CORPSE && is_rider(&mons[otmp->corpsenm]))
1186 if (objects[otyp].oc_material == SILVER && mon_hates_silver(mtmp)
1187 && (otyp != BELL_OF_OPENING || !is_covetous(mdat)))
1190 /* hostile monsters who like gold will pick up the whole stack;
1191 tame mosnters with hands will pick up the partial stack */
1192 iquan = (otmp->quan > (long) LARGEST_INT)
1193 ? 20000 + rn2(LARGEST_INT - 20000 + 1)
1196 /* monsters without hands can't pick up multiple objects at once
1197 * unless they have an engulfing attack
1199 * ...dragons, of course, can always carry gold pieces and gems somehow
1202 boolean glomper = FALSE;
1204 if (mtmp->data->mlet == S_DRAGON
1205 && (otmp->oclass == COIN_CLASS
1206 || otmp->oclass == GEM_CLASS))
1209 for (nattk = 0; nattk < NATTK; nattk++)
1210 if (mtmp->data->mattk[nattk].aatyp == AT_ENGL) {
1214 if ((mtmp->data->mflags1 & M1_NOHANDS) && !glomper)
1218 /* steeds don't pick up stuff (to avoid shop abuse) */
1219 if (mtmp == u.usteed)
1222 return iquan; /* no limit */
1223 if (mtmp->mpeaceful && !mtmp->mtame)
1225 /* otherwise players might find themselves obligated to violate
1226 * their alignment if the monster takes something they need
1229 /* special--boulder throwers carry unlimited amounts of boulders */
1230 if (throws_rocks(mdat) && otyp == BOULDER)
1233 /* nymphs deal in stolen merchandise, but not boulders or statues */
1234 if (mdat->mlet == S_NYMPH)
1235 return (otmp->oclass == ROCK_CLASS) ? 0 : iquan;
1237 if (curr_mon_load(mtmp) + newload > max_mon_load(mtmp))
1243 /* return number of acceptable neighbour positions */
1245 mfndpos(mon, poss, info, flag)
1247 coord *poss; /* coord poss[9] */
1248 long *info; /* long info[9] */
1251 struct permonst *mdat = mon->data;
1252 register struct trap *ttmp;
1257 boolean wantpool, poolok, lavaok, nodiag;
1258 boolean rockok = FALSE, treeok = FALSE, thrudoor;
1263 nowtyp = levl[x][y].typ;
1265 nodiag = NODIAG(mdat - mons);
1266 wantpool = mdat->mlet == S_EEL;
1267 poolok = (is_flyer(mdat) || is_clinger(mdat)
1268 || (is_swimmer(mdat) && !wantpool));
1269 lavaok = (is_flyer(mdat) || is_clinger(mdat) || likes_lava(mdat));
1270 thrudoor = ((flag & (ALLOW_WALL | BUSTDOOR)) != 0L);
1271 if (flag & ALLOW_DIG) {
1274 /* need to be specific about what can currently be dug */
1275 if (!needspick(mdat)) {
1276 rockok = treeok = TRUE;
1277 } else if ((mw_tmp = MON_WEP(mon)) && mw_tmp->cursed
1278 && mon->weapon_check == NO_WEAPON_WANTED) {
1279 rockok = is_pick(mw_tmp);
1280 treeok = is_axe(mw_tmp);
1282 rockok = (m_carrying(mon, PICK_AXE)
1283 || (m_carrying(mon, DWARVISH_MATTOCK)
1284 && !which_armor(mon, W_ARMS)));
1285 treeok = (m_carrying(mon, AXE) || (m_carrying(mon, BATTLE_AXE)
1286 && !which_armor(mon, W_ARMS)));
1288 if (rockok || treeok)
1292 nexttry: /* eels prefer the water, but if there is no water nearby,
1293 they will crawl over land */
1300 maxx = min(x + 1, COLNO - 1);
1301 maxy = min(y + 1, ROWNO - 1);
1302 for (nx = max(1, x - 1); nx <= maxx; nx++)
1303 for (ny = max(0, y - 1); ny <= maxy; ny++) {
1304 if (nx == x && ny == y)
1306 ntyp = levl[nx][ny].typ;
1308 && !((flag & ALLOW_WALL) && may_passwall(nx, ny))
1309 && !((IS_TREE(ntyp) ? treeok : rockok) && may_dig(nx, ny)))
1311 /* KMH -- Added iron bars */
1312 if (ntyp == IRONBARS && !(flag & ALLOW_BARS))
1314 if (IS_DOOR(ntyp) && !(amorphous(mdat) || can_fog(mon))
1315 && (((levl[nx][ny].doormask & D_CLOSED) && !(flag & OPENDOOR))
1316 || ((levl[nx][ny].doormask & D_LOCKED)
1317 && !(flag & UNLOCKDOOR))) && !thrudoor)
1319 /* first diagonal checks (tight squeezes handled below) */
1320 if (nx != x && ny != y
1322 || (IS_DOOR(nowtyp) && (levl[x][y].doormask & ~D_BROKEN))
1323 || (IS_DOOR(ntyp) && (levl[nx][ny].doormask & ~D_BROKEN))
1324 || ((IS_DOOR(nowtyp) || IS_DOOR(ntyp))
1325 && Is_rogue_level(&u.uz))
1326 /* mustn't pass between adjacent long worm segments,
1327 but can attack that way */
1328 || (m_at(x, ny) && m_at(nx, y) && worm_cross(x, y, nx, ny)
1329 && !m_at(nx, ny) && (nx != u.ux || ny != u.uy))))
1331 if ((is_pool(nx, ny) == wantpool || poolok)
1332 && (lavaok || !is_lava(nx, ny))) {
1334 boolean monseeu = (mon->mcansee
1335 && (!Invis || perceives(mdat)));
1336 boolean checkobj = OBJ_AT(nx, ny);
1338 /* Displacement also displaces the Elbereth/scare monster,
1339 * as long as you are visible.
1341 if (Displaced && monseeu && mon->mux == nx && mon->muy == ny) {
1350 if (onscary(dispx, dispy, mon)) {
1351 if (!(flag & ALLOW_SSM))
1353 info[cnt] |= ALLOW_SSM;
1355 if ((nx == u.ux && ny == u.uy)
1356 || (nx == mon->mux && ny == mon->muy)) {
1357 if (nx == u.ux && ny == u.uy) {
1358 /* If it's right next to you, it found you,
1359 * displaced or no. We must set mux and muy
1360 * right now, so when we return we can tell
1361 * that the ALLOW_U means to attack _you_ and
1367 if (!(flag & ALLOW_U))
1369 info[cnt] |= ALLOW_U;
1371 if (MON_AT(nx, ny)) {
1372 struct monst *mtmp2 = m_at(nx, ny);
1373 long mmflag = flag | mm_aggression(mon, mtmp2);
1375 if (mmflag & ALLOW_M) {
1376 info[cnt] |= ALLOW_M;
1378 if (!(mmflag & ALLOW_TM))
1380 info[cnt] |= ALLOW_TM;
1383 mmflag = flag | mm_displacement(mon, mtmp2);
1384 if (!(mmflag & ALLOW_MDISP))
1386 info[cnt] |= ALLOW_MDISP;
1389 /* Note: ALLOW_SANCT only prevents movement, not
1390 attack, into a temple. */
1391 if (level.flags.has_temple && *in_rooms(nx, ny, TEMPLE)
1392 && !*in_rooms(x, y, TEMPLE)
1393 && in_your_sanctuary((struct monst *) 0, nx, ny)) {
1394 if (!(flag & ALLOW_SANCT))
1396 info[cnt] |= ALLOW_SANCT;
1399 if (checkobj && sobj_at(CLOVE_OF_GARLIC, nx, ny)) {
1400 if (flag & NOGARLIC)
1402 info[cnt] |= NOGARLIC;
1404 if (checkobj && sobj_at(BOULDER, nx, ny)) {
1405 if (!(flag & ALLOW_ROCK))
1407 info[cnt] |= ALLOW_ROCK;
1409 if (monseeu && onlineu(nx, ny)) {
1412 info[cnt] |= NOTONL;
1414 /* check for diagonal tight squeeze */
1415 if (nx != x && ny != y && bad_rock(mdat, x, ny)
1416 && bad_rock(mdat, nx, y) && cant_squeeze_thru(mon))
1418 /* The monster avoids a particular type of trap if it's
1419 * familiar with the trap type. Pets get ALLOW_TRAPS
1420 * and checking is done in dogmove.c. In either case,
1421 * "harmless" traps are neither avoided nor marked in info[].
1423 if ((ttmp = t_at(nx, ny)) != 0) {
1424 if (ttmp->ttyp >= TRAPNUM || ttmp->ttyp == 0) {
1426 "A monster looked at a very strange trap of type %d.",
1430 if ((ttmp->ttyp != RUST_TRAP
1431 || mdat == &mons[PM_IRON_GOLEM])
1432 && ttmp->ttyp != STATUE_TRAP
1433 && ((ttmp->ttyp != PIT && ttmp->ttyp != SPIKED_PIT
1434 && ttmp->ttyp != TRAPDOOR && ttmp->ttyp != HOLE)
1435 || (!is_flyer(mdat) && !is_floater(mdat)
1436 && !is_clinger(mdat)) || Sokoban)
1437 && (ttmp->ttyp != SLP_GAS_TRAP || !resists_sleep(mon))
1438 && (ttmp->ttyp != BEAR_TRAP
1439 || (mdat->msize > MZ_SMALL && !amorphous(mdat)
1440 && !is_flyer(mdat) && !is_floater(mdat)
1441 && !is_whirly(mdat) && !unsolid(mdat)))
1442 && (ttmp->ttyp != FIRE_TRAP || !resists_fire(mon))
1443 && (ttmp->ttyp != SQKY_BOARD || !is_flyer(mdat))
1444 && (ttmp->ttyp != WEB
1445 || (!amorphous(mdat) && !webmaker(mdat)))
1446 && (ttmp->ttyp != ANTI_MAGIC || !resists_magm(mon))) {
1447 if (!(flag & ALLOW_TRAPS)) {
1448 if (mon->mtrapseen & (1L << (ttmp->ttyp - 1)))
1451 info[cnt] |= ALLOW_TRAPS;
1459 if (!cnt && wantpool && !is_pool(x, y)) {
1466 /* Monster against monster special attacks; for the specified monster
1467 combinations, this allows one monster to attack another adjacent one
1468 in the absence of Conflict. There is no provision for targetting
1469 other monsters; just hand to hand fighting when they happen to be
1470 next to each other. */
1472 mm_aggression(magr, mdef)
1473 struct monst *magr, /* monster that is currently deciding where to move */
1474 *mdef; /* another monster which is next to it */
1476 /* supposedly purple worms are attracted to shrieking because they
1477 like to eat shriekers, so attack the latter when feasible */
1478 if (magr->data == &mons[PM_PURPLE_WORM]
1479 && mdef->data == &mons[PM_SHRIEKER])
1480 return ALLOW_M | ALLOW_TM;
1481 /* Various other combinations such as dog vs cat, cat vs rat, and
1482 elf vs orc have been suggested. For the time being we don't
1487 /* Monster displacing another monster out of the way */
1489 mm_displacement(magr, mdef)
1490 struct monst *magr, /* monster that is currently deciding where to move */
1491 *mdef; /* another monster which is next to it */
1493 struct permonst *pa = magr->data, *pd = mdef->data;
1495 /* if attacker can't barge through, there's nothing to do;
1496 or if defender can barge through too, don't let attacker
1497 do so, otherwise they might just end up swapping places
1498 again when defender gets its chance to move */
1499 if ((pa->mflags3 & M3_DISPLACES) != 0 && (pd->mflags3 & M3_DISPLACES) == 0
1500 /* no displacing grid bugs diagonally */
1501 && !(magr->mx != mdef->mx && magr->my != mdef->my
1502 && NODIAG(monsndx(pd)))
1503 /* no displacing trapped monsters or multi-location longworms */
1504 && !mdef->mtrapped && (!mdef->wormno || !count_wsegs(mdef))
1505 /* riders can move anything; others, same size or smaller only */
1506 && (is_rider(pa) || pa->msize >= pd->msize))
1511 /* Is the square close enough for the monster to move or attack into? */
1517 int distance = dist2(mon->mx, mon->my, x, y);
1519 if (distance == 2 && NODIAG(mon->data - mons))
1521 return (boolean) (distance < 3);
1524 /* really free dead monsters */
1528 struct monst **mtmp, *freetmp;
1531 for (mtmp = &fmon; *mtmp;) {
1533 if (freetmp->mhp <= 0 && !freetmp->isgd) {
1534 *mtmp = freetmp->nmon;
1535 freetmp->nmon = NULL;
1536 dealloc_monst(freetmp);
1539 mtmp = &(freetmp->nmon);
1542 if (count != iflags.purge_monsters)
1543 impossible("dmonsfree: %d removed doesn't match %d pending",
1544 count, iflags.purge_monsters);
1545 iflags.purge_monsters = 0;
1548 /* called when monster is moved to larger structure */
1550 replmon(mtmp, mtmp2)
1551 struct monst *mtmp, *mtmp2;
1555 /* transfer the monster's inventory */
1556 for (otmp = mtmp2->minvent; otmp; otmp = otmp->nobj) {
1557 if (otmp->where != OBJ_MINVENT || otmp->ocarry != mtmp)
1558 impossible("replmon: minvent inconsistency");
1559 otmp->ocarry = mtmp2;
1563 /* remove the old monster from the map and from `fmon' list */
1564 relmon(mtmp, (struct monst **) 0);
1566 /* finish adding its replacement */
1567 if (mtmp != u.usteed) /* don't place steed onto the map */
1568 place_monster(mtmp2, mtmp2->mx, mtmp2->my);
1569 if (mtmp2->wormno) /* update level.monsters[wseg->wx][wseg->wy] */
1570 place_wsegs(mtmp2); /* locations to mtmp2 not mtmp. */
1571 if (emits_light(mtmp2->data)) {
1572 /* since this is so rare, we don't have any `mon_move_light_source' */
1573 new_light_source(mtmp2->mx, mtmp2->my, emits_light(mtmp2->data),
1574 LS_MONSTER, monst_to_any(mtmp2));
1575 /* here we rely on fact that `mtmp' hasn't actually been deleted */
1576 del_light_source(LS_MONSTER, monst_to_any(mtmp));
1580 if (u.ustuck == mtmp)
1582 if (u.usteed == mtmp)
1585 replshk(mtmp, mtmp2);
1587 /* discard the old monster */
1588 dealloc_monst(mtmp);
1591 /* release mon from the display and the map's monster list,
1592 maybe transfer it to one of the other monster lists */
1594 relmon(mon, monst_list)
1596 struct monst **monst_list; /* &migrating_mons or &mydogs or null */
1599 boolean unhide = (monst_list != 0);
1600 int mx = mon->mx, my = mon->my;
1603 panic("relmon: no fmon available.");
1606 /* can't remain hidden across level changes (exception: wizard
1607 clone can continue imitating some other monster form); also,
1608 might be imitating a boulder so need line-of-sight unblocking */
1609 mon->mundetected = 0;
1610 if (mon->m_ap_type && mon->m_ap_type != M_AP_MONSTER)
1614 remove_monster(mx, my);
1619 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
1620 if (mtmp->nmon == mon)
1624 mtmp->nmon = mon->nmon;
1626 panic("relmon: mon not in list.");
1631 /* insert into mydogs or migrating_mons */
1632 mon->nmon = *monst_list;
1635 /* orphan has no next monster */
1641 copy_mextra(mtmp2, mtmp1)
1642 struct monst *mtmp2, *mtmp1;
1644 if (!mtmp2 || !mtmp1 || !mtmp1->mextra)
1648 mtmp2->mextra = newmextra();
1650 new_mname(mtmp2, (int) strlen(MNAME(mtmp1)) + 1);
1651 Strcpy(MNAME(mtmp2), MNAME(mtmp1));
1656 (void) memcpy((genericptr_t) EGD(mtmp2), (genericptr_t) EGD(mtmp1),
1657 sizeof (struct egd));
1662 (void) memcpy((genericptr_t) EPRI(mtmp2), (genericptr_t) EPRI(mtmp1),
1663 sizeof (struct epri));
1668 (void) memcpy((genericptr_t) ESHK(mtmp2), (genericptr_t) ESHK(mtmp1),
1669 sizeof (struct eshk));
1674 (void) memcpy((genericptr_t) EMIN(mtmp2), (genericptr_t) EMIN(mtmp1),
1675 sizeof (struct emin));
1680 (void) memcpy((genericptr_t) EDOG(mtmp2), (genericptr_t) EDOG(mtmp1),
1681 sizeof (struct edog));
1683 if (has_mcorpsenm(mtmp1))
1684 MCORPSENM(mtmp2) = MCORPSENM(mtmp1);
1691 struct mextra *x = m->mextra;
1695 free((genericptr_t) x->mname);
1697 free((genericptr_t) x->egd);
1699 free((genericptr_t) x->epri);
1701 free((genericptr_t) x->eshk);
1703 free((genericptr_t) x->emin);
1705 free((genericptr_t) x->edog);
1706 /* [no action needed for x->mcorpsenm] */
1708 free((genericptr_t) x);
1709 m->mextra = (struct mextra *) 0;
1718 panic("dealloc_monst with nmon");
1720 dealloc_mextra(mon);
1721 free((genericptr_t) mon);
1724 /* remove effects of mtmp from other data structures */
1726 m_detach(mtmp, mptr)
1728 struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */
1730 if (mtmp == context.polearm.hitmon)
1731 context.polearm.hitmon = 0;
1733 m_unleash(mtmp, FALSE);
1734 /* to prevent an infinite relobj-flooreffects-hmon-killed loop */
1736 mtmp->mhp = 0; /* simplify some tests: force mhp to 0 */
1737 relobj(mtmp, 0, FALSE);
1738 remove_monster(mtmp->mx, mtmp->my);
1739 if (emits_light(mptr))
1740 del_light_source(LS_MONSTER, monst_to_any(mtmp));
1741 newsym(mtmp->mx, mtmp->my);
1743 fill_pit(mtmp->mx, mtmp->my);
1749 iflags.purge_monsters++;
1752 /* find the worn amulet of life saving which will save a monster */
1757 if (!nonliving(mon->data) || is_vampshifter(mon)) {
1758 struct obj *otmp = which_armor(mon, W_AMUL);
1760 if (otmp && otmp->otyp == AMULET_OF_LIFE_SAVING)
1763 return (struct obj *) 0;
1767 lifesaved_monster(mtmp)
1771 struct obj *lifesave = mlifesaver(mtmp);
1774 /* not canseemon; amulets are on the head, so you don't want
1775 * to show this for a long worm with only a tail visible.
1776 * Nor do you check invisibility, because glowing and
1777 * disintegrating amulets are always visible. */
1778 if (cansee(mtmp->mx, mtmp->my)) {
1780 pline("But wait...");
1782 pline("
\82¿
\82å
\82Á
\82Æ
\82Ü
\82Á
\82½
\81D
\81D
\81D");
1784 pline("%s medallion begins to glow!", s_suffix(Monnam(mtmp)));
1786 pline("%s
\82Ì
\96\82\8f\9c\82¯
\82ª
\8bP
\82«
\82Í
\82¶
\82ß
\82½
\81I", Monnam(mtmp));
1787 makeknown(AMULET_OF_LIFE_SAVING);
1788 /* amulet is visible, but monster might not be */
1789 if (canseemon(mtmp)) {
1790 if (attacktype(mtmp->data, AT_EXPL)
1791 || attacktype(mtmp->data, AT_BOOM))
1793 pline("%s reconstitutes!", Monnam(mtmp));
1795 pline("%s
\82Í
\8dÄ
\8d\
\90¬
\82³
\82ê
\82½
\81I", Monnam(mtmp));
1798 pline("%s looks much better!", Monnam(mtmp));
1800 pline("%s
\82Í
\82·
\82Á
\82©
\82è
\89ñ
\95\9c\82µ
\82½
\82æ
\82¤
\82¾
\81I", Monnam(mtmp));
1803 pline_The("medallion crumbles to dust!");
1805 pline("
\96\82\8f\9c\82¯
\82Í
\82±
\82È
\82²
\82È
\82É
\82
\82¾
\82¯
\82½
\81I");
1807 m_useup(mtmp, lifesave);
1809 surviver = !(mvitals[monsndx(mtmp->data)].mvflags & G_GENOD);
1812 if (mtmp->mtame && !mtmp->isminion) {
1813 wary_dog(mtmp, !surviver);
1815 if (mtmp->mhpmax <= 0)
1817 mtmp->mhp = mtmp->mhpmax;
1821 /* genocided monster can't be life-saved */
1822 if (cansee(mtmp->mx, mtmp->my))
1824 pline("Unfortunately, %s is still genocided...", mon_nam(mtmp));
1826 pline("
\8ec
\94O
\82È
\82ª
\82ç%s
\82Í
\8bs
\8eE
\82³
\82ê
\82Ä
\82¢
\82é
\81D
\81D
\81D", mon_nam(mtmp));
1833 register struct monst *mtmp;
1835 struct permonst *mptr;
1838 lifesaved_monster(mtmp);
1842 if (is_vampshifter(mtmp)) {
1843 int mndx = mtmp->cham;
1844 int x = mtmp->mx, y = mtmp->my;
1846 /* this only happens if shapeshifted */
1847 if (mndx >= LOW_PM && mndx != monsndx(mtmp->data)) {
1849 boolean in_door = (amorphous(mtmp->data)
1850 && closed_door(mtmp->mx, mtmp->my)),
1851 /* alternate message phrasing for some monster types */
1852 spec_mon = (nonliving(mtmp->data)
1853 || noncorporeal(mtmp->data)
1854 || amorphous(mtmp->data));
1856 /* construct a format string before transformation */
1858 Sprintf(buf, "The %s%s suddenly %s and rises as %%s!",
1859 spec_mon ? "" : "seemingly dead ",
1860 x_monnam(mtmp, ARTICLE_NONE, (char *) 0,
1861 SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION
1862 | SUPPRESS_INVISIBLE | SUPPRESS_IT,
1864 spec_mon ? "reconstitutes" : "transforms");
1866 Sprintf(buf, "%s%s
\82Í
\93Ë
\91R%s
\81C%%s
\82Æ
\82µ
\82Ä
\91h
\82Á
\82½
\81I",
1867 spec_mon ? "" : "
\8e\80\82ñ
\82¾
\82æ
\82¤
\82É
\8ev
\82í
\82ê
\82½",
1868 x_monnam(mtmp, ARTICLE_NONE, (char *) 0,
1869 SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION
1870 | SUPPRESS_INVISIBLE | SUPPRESS_IT,
1872 spec_mon ? "
\8dÄ
\8d\
\90¬
\82³
\82ê" : "
\95Ï
\89»
\82µ");
1876 if (mtmp->mhpmax <= 0)
1878 mtmp->mhp = mtmp->mhpmax;
1879 /* this can happen if previously a fog cloud */
1880 if (u.uswallow && (mtmp == u.ustuck))
1881 expels(mtmp, mtmp->data, FALSE);
1885 if (enexto(&new_xy, mtmp->mx, mtmp->my, &mons[mndx])) {
1886 rloc_to(mtmp, new_xy.x, new_xy.y);
1889 newcham(mtmp, &mons[mndx], FALSE, FALSE);
1890 if (mtmp->data == &mons[mndx])
1891 mtmp->cham = NON_PM;
1894 if (canspotmon(mtmp)) {
1895 pline(buf, a_monnam(mtmp));
1896 vamp_rise_msg = TRUE;
1903 /* dead vault guard is actually kept at coordinate <0,0> until
1904 his temporary corridor to/from the vault has been removed;
1905 need to do this after life-saving and before m_detach() */
1906 if (mtmp->isgd && !grddead(mtmp))
1909 /* Player is thrown from his steed when it dies */
1910 if (mtmp == u.usteed)
1911 dismount_steed(DISMOUNT_GENERIC);
1913 mptr = mtmp->data; /* save this for m_detach() */
1914 /* restore chameleon, lycanthropes to true form at death */
1915 if (mtmp->cham >= LOW_PM) {
1916 set_mon_data(mtmp, &mons[mtmp->cham], -1);
1917 mtmp->cham = NON_PM;
1918 } else if (mtmp->data == &mons[PM_WEREJACKAL])
1919 set_mon_data(mtmp, &mons[PM_HUMAN_WEREJACKAL], -1);
1920 else if (mtmp->data == &mons[PM_WEREWOLF])
1921 set_mon_data(mtmp, &mons[PM_HUMAN_WEREWOLF], -1);
1922 else if (mtmp->data == &mons[PM_WERERAT])
1923 set_mon_data(mtmp, &mons[PM_HUMAN_WERERAT], -1);
1925 /* if MAXMONNO monsters of a given type have died, and it
1926 * can be done, extinguish that monster.
1928 * mvitals[].died does double duty as total number of dead monsters
1929 * and as experience factor for the player killing more monsters.
1930 * this means that a dragon dying by other means reduces the
1931 * experience the player gets for killing a dragon directly; this
1932 * is probably not too bad, since the player likely finagled the
1933 * first dead dragon via ring of conflict or pets, and extinguishing
1934 * based on only player kills probably opens more avenues of abuse
1935 * for rings of conflict and such.
1937 tmp = monsndx(mtmp->data);
1938 if (mvitals[tmp].died < 255)
1939 mvitals[tmp].died++;
1941 /* if it's a (possibly polymorphed) quest leader, mark him as dead */
1942 if (mtmp->m_id == quest_status.leader_m_id)
1943 quest_status.leader_is_dead = TRUE;
1945 /* if the mail daemon dies, no more mail delivery. -3. */
1946 if (tmp == PM_MAIL_DAEMON)
1947 mvitals[tmp].mvflags |= G_GENOD;
1950 if (mtmp->data->mlet == S_KOP) {
1951 /* Dead Kops may come back. */
1953 case 1: /* returns near the stairs */
1954 (void) makemon(mtmp->data, xdnstair, ydnstair, NO_MM_FLAGS);
1956 case 2: /* randomly */
1957 (void) makemon(mtmp->data, 0, 0, NO_MM_FLAGS);
1965 if (mtmp->data->msound == MS_NEMESIS)
1967 if (mtmp->data == &mons[PM_MEDUSA])
1968 u.uachieve.killed_medusa = 1;
1969 if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph))
1970 unmap_object(mtmp->mx, mtmp->my);
1971 m_detach(mtmp, mptr);
1974 /* TRUE if corpse might be dropped, magr may die if mon was swallowed */
1976 corpse_chance(mon, magr, was_swallowed)
1978 struct monst *magr; /* killer, if swallowed */
1979 boolean was_swallowed; /* digestion */
1981 struct permonst *mdat = mon->data;
1984 if (mdat == &mons[PM_VLAD_THE_IMPALER] || mdat->mlet == S_LICH) {
1985 if (cansee(mon->mx, mon->my) && !was_swallowed)
1987 pline("%s body crumbles into dust.", s_suffix(Monnam(mon)));
1989 pline("%s
\82Ì
\91Ì
\82Í
\95²
\81X
\82É
\82È
\82Á
\82½
\81D", Monnam(mon));
1993 /* Gas spores always explode upon death */
1994 for (i = 0; i < NATTK; i++) {
1995 if (mdat->mattk[i].aatyp == AT_BOOM) {
1996 if (mdat->mattk[i].damn)
1997 tmp = d((int) mdat->mattk[i].damn, (int) mdat->mattk[i].damd);
1998 else if (mdat->mattk[i].damd)
1999 tmp = d((int) mdat->mlevel + 1, (int) mdat->mattk[i].damd);
2002 if (was_swallowed && magr) {
2003 if (magr == &youmonst) {
2005 There("is an explosion in your %s!", body_part(STOMACH));
2007 pline("%s
\82Ì
\92\86\82Å
\94\9a\94
\82ª
\8bN
\82«
\82½
\81I", body_part(STOMACH));
2009 Sprintf(killer.name, "%s explosion",
2010 s_suffix(mdat->mname));
2012 Sprintf(killer.name, "%s
\82Ì
\94\9a\94
\82Å", mdat->mname);
2014 losehp(Maybe_Half_Phys(tmp), killer.name, KILLED_BY_AN);
2017 You_hear("an explosion.");
2019 You_hear("
\94\9a\94
\89¹
\82ð
\95·
\82¢
\82½
\81D");
2023 if (magr->mhp < 1) { /* maybe lifesaved */
2024 if (canspotmon(magr))
2026 pline("%s rips open!", Monnam(magr));
2028 pline("%s
\82Í
\83r
\83\8a\82Á
\82Æ
\94j
\82ê
\82½
\81I", Monnam(magr));
2029 } else if (canseemon(magr))
2031 pline("%s seems to have indigestion.", Monnam(magr));
2033 pline("%s
\82Í
\8fÁ
\89»
\95s
\97Ç
\82Ì
\82æ
\82¤
\82¾
\81D", Monnam(magr));
2040 Sprintf(killer.name, "%s explosion", s_suffix(mdat->mname));
2042 Sprintf(killer.name, "%s
\82Ì
\94\9a\94
\82Å", mdat->mname);
2043 killer.format = KILLED_BY_AN;
2044 explode(mon->mx, mon->my, -1, tmp, MON_EXPLODE, EXPL_NOXIOUS);
2049 /* must duplicate this below check in xkilled() since it results in
2050 * creating no objects as well as no corpse
2052 if (LEVEL_SPECIFIC_NOCORPSE(mdat))
2055 if (((bigmonst(mdat) || mdat == &mons[PM_LIZARD]) && !mon->mcloned)
2056 || is_golem(mdat) || is_mplayer(mdat) || is_rider(mdat))
2058 tmp = 2 + ((mdat->geno & G_FREQ) < 2) + verysmall(mdat);
2059 return (boolean) !rn2(tmp);
2062 /* drop (perhaps) a cadaver and remove monster */
2065 register struct monst *mdef;
2069 return; /* lifesaved */
2071 if (corpse_chance(mdef, (struct monst *) 0, FALSE)
2072 && (accessible(mdef->mx, mdef->my) || is_pool(mdef->mx, mdef->my)))
2073 (void) make_corpse(mdef, CORPSTAT_NONE);
2076 /* monster disappears, not dies */
2081 mdef->mhp = 0; /* can skip some inventory bookkeeping */
2083 /* dead vault guard is actually kept at coordinate <0,0> until
2084 his temporary corridor to/from the vault has been removed */
2085 if (mdef->isgd && !grddead(mdef))
2087 /* hero is thrown from his steed when it disappears */
2088 if (mdef == u.usteed)
2089 dismount_steed(DISMOUNT_GENERIC);
2090 /* drop special items like the Amulet so that a dismissed Kop or nurse
2091 can't remove them from the game */
2092 mdrop_special_objs(mdef);
2093 /* release rest of monster's inventory--it is removed from game */
2094 discard_minvent(mdef);
2095 m_detach(mdef, mdef->data);
2098 /* drop a statue or rock and remove monster */
2103 struct obj *otmp, *obj, *oldminvent;
2104 xchar x = mdef->mx, y = mdef->my;
2105 boolean wasinside = FALSE;
2107 /* we have to make the statue before calling mondead, to be able to
2108 * put inventory in it, and we have to check for lifesaving before
2109 * making the statue....
2111 lifesaved_monster(mdef);
2115 mdef->mtrapped = 0; /* (see m_detach) */
2117 if ((int) mdef->data->msize > MZ_TINY
2118 || !rn2(2 + ((int) (mdef->data->geno & G_FREQ) > 2))) {
2120 /* some objects may end up outside the statue */
2121 while ((obj = mdef->minvent) != 0) {
2122 obj_extract_self(obj);
2124 update_mon_intrinsics(mdef, obj, FALSE, TRUE);
2125 obj_no_longer_held(obj);
2126 if (obj->owornmask & W_WEP)
2127 setmnotwielded(mdef, obj);
2128 obj->owornmask = 0L;
2129 if (obj->otyp == BOULDER
2130 #if 0 /* monsters don't carry statues */
2131 || (obj->otyp == STATUE
2132 && mons[obj->corpsenm].msize >= mdef->data->msize)
2134 /* invocation tools resist even with 0% resistance */
2135 || obj_resists(obj, 0, 0)) {
2137 if (flooreffects(obj, x, y, "fall"))
2139 if (flooreffects(obj, x, y, "
\97\8e\82¿
\82é"))
2141 place_object(obj, x, y);
2144 end_burn(obj, TRUE);
2145 obj->nobj = oldminvent;
2149 /* defer statue creation until after inventory removal
2150 so that saved monster traits won't retain any stale
2151 item-conferred attributes */
2152 otmp = mkcorpstat(STATUE, mdef, mdef->data, x, y, CORPSTAT_NONE);
2153 if (has_mname(mdef))
2154 otmp = oname(otmp, MNAME(mdef));
2155 while ((obj = oldminvent) != 0) {
2156 oldminvent = obj->nobj;
2157 (void) add_to_container(otmp, obj);
2159 /* Archeologists should not break unique statues */
2160 if (mdef->data->geno & G_UNIQ)
2162 otmp->owt = weight(otmp);
2164 otmp = mksobj_at(ROCK, x, y, TRUE, FALSE);
2167 /* mondead() already does this, but we must do it before the newsym */
2168 if (glyph_is_invisible(levl[x][y].glyph))
2172 /* We don't currently trap the hero in the statue in this case but we
2174 if (u.uswallow && u.ustuck == mdef)
2178 if (is_animal(mdef->data))
2180 You("%s through an opening in the new %s.",
2181 locomotion(youmonst.data, "jump"), xname(otmp));
2183 You("
\90V
\82µ
\82
\82Å
\82«
\82½%s
\82©
\82ç%s
\81D",
2184 xname(otmp), jumpedthrough(youmonst.data, "
\94ò
\82Ñ
\8fo
\82½"));
2189 /* another monster has killed the monster mdef */
2191 monkilled(mdef, fltxt, how)
2196 boolean be_sad = FALSE; /* true if unseen pet is killed */
2198 if ((mdef->wormno ? worm_known(mdef) : cansee(mdef->mx, mdef->my))
2201 pline("%s is %s%s%s!", Monnam(mdef),
2202 nonliving(mdef->data) ? "destroyed" : "killed",
2203 *fltxt ? " by the " : "", fltxt);
2207 pline("%s
\82Í%s
\82É
\82æ
\82Á
\82Ä%s
\81I", Monnam(mdef), fltxt,
2208 nonliving(mdef->data) ? "
\93|
\82³
\82ê
\82½" : "
\8eE
\82³
\82ê
\82½");
2210 pline("%s
\82Í%s
\81I", Monnam(mdef),
2211 nonliving(mdef->data) ? "
\93|
\82³
\82ê
\82½" : "
\8eE
\82³
\82ê
\82½");
2215 be_sad = (mdef->mtame != 0);
2217 /* no corpses if digested or disintegrated */
2218 if (how == AD_DGST || how == -AD_RBRE)
2223 if (be_sad && mdef->mhp <= 0)
2225 You("have a sad feeling for a moment, then it passes.");
2227 You("
\94ß
\82µ
\82¢
\8bC
\8e\9d\82É
\82¨
\82»
\82í
\82ê
\82½
\82ª
\81C
\82·
\82®
\82É
\89ß
\82¬
\82³
\82Á
\82½
\81D");
2234 if (u.ustuck == mtmp) {
2240 if (Punished && uchain->where != OBJ_FLOOR)
2242 vision_full_recalc = 1;
2256 /* the player has killed the monster mtmp */
2260 int dest; /* dest==1, normal; dest==0, don't print message; dest==2, don't
2261 drop corpse either; dest==3, message but no corpse */
2263 int tmp, mndx, x = mtmp->mx, y = mtmp->my;
2264 struct permonst *mdat;
2267 boolean wasinside = u.uswallow && (u.ustuck == mtmp);
2268 boolean burycorpse = FALSE;
2271 u.uconduct.killer++;
2275 const char *verb = nonliving(mtmp->data) ? "destroy" : "kill";
2278 if (!wasinside && !canspotmon(mtmp))
2280 You("%s it!", verb);
2282 You("
\89½
\8eÒ
\82©
\82ð
\93|
\82µ
\82½
\81I");
2289 (has_mname(mtmp)) ? ARTICLE_NONE : ARTICLE_THE,
2291 (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0,
2294 You("%s%s
\82ð
\93|
\82µ
\82½
\81I",
2295 mtmp->mtame ? "
\82©
\82í
\82¢
\82»
\82¤
\82È" : "",
2301 if (mtmp->mtrapped && (t = t_at(x, y)) != 0
2302 && (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) {
2303 if (sobj_at(BOULDER, x, y))
2305 * Prevent corpses/treasure being created "on top"
2306 * of the boulder that is about to fall in. This is
2307 * out of order, but cannot be helped unless this
2308 * whole routine is rearranged.
2310 if (m_carrying(mtmp, BOULDER))
2314 /* your pet knows who just killed it...watch out */
2315 if (mtmp->mtame && !mtmp->isminion)
2316 EDOG(mtmp)->killed_by_u = 1;
2318 if (wasinside && thrownobj && thrownobj != uball) {
2319 /* thrown object has killed hero's engulfer; add it to mon's
2320 inventory now so that it will be placed with mon's other
2321 stuff prior to lookhere/autopickup when hero is expelled
2322 below (as a side-effect, this missile has immunity from
2323 being consumed [for this shot/throw only]) */
2324 mpickobj(mtmp, thrownobj);
2325 /* let throwing code know that missile has been disposed of */
2329 vamp_rise_msg = FALSE; /* might get set in mondead() */
2330 /* dispose of monster and make cadaver */
2336 if (mtmp->mhp > 0) { /* monster lifesaved */
2337 /* Cannot put the non-visible lifesaving message in
2338 * lifesaved_monster() since the message appears only when you
2339 * kill it (as opposed to visible lifesaving which always
2343 if (!cansee(x, y) && !vamp_rise_msg)
2345 pline("Maybe not...");
2347 pline("
\82¢
\82â
\81C
\88á
\82¤
\82©
\82à
\81D
\81D
\81D");
2351 mdat = mtmp->data; /* note: mondead can change mtmp->data */
2352 mndx = monsndx(mdat);
2359 if ((dest & 2) || LEVEL_SPECIFIC_NOCORPSE(mdat))
2363 if (mdat == &mons[PM_MAIL_DAEMON]) {
2364 stackobj(mksobj_at(SCR_MAIL, x, y, FALSE, FALSE));
2367 if (accessible(x, y) || is_pool(x, y)) {
2368 struct obj *cadaver;
2371 /* illogical but traditional "treasure drop" */
2372 if (!rn2(6) && !(mvitals[mndx].mvflags & G_NOCORPSE)
2373 /* no extra item from swallower or steed */
2374 && (x != u.ux || y != u.uy)
2375 /* no extra item from kops--too easy to abuse */
2376 && mdat->mlet != S_KOP
2377 /* no items from cloned monsters */
2378 && !mtmp->mcloned) {
2379 otmp = mkobj(RANDOM_CLASS, TRUE);
2380 /* don't create large objects from small monsters */
2382 if (mdat->msize < MZ_HUMAN && otyp != FIGURINE
2383 /* oc_big is also oc_bimanual and oc_bulky */
2384 && (otmp->owt > 30 || objects[otyp].oc_big)) {
2387 } else if (!flooreffects(otmp, x, y, (dest & 1) ? "fall" : "")) {
2389 } else if (!flooreffects(otmp, x, y, (dest & 1) ? "
\97\8e\82¿
\82é" : "")) {
2391 place_object(otmp, x, y);
2395 /* corpse--none if hero was inside the monster */
2396 if (!wasinside && corpse_chance(mtmp, (struct monst *) 0, FALSE)) {
2397 cadaver = make_corpse(mtmp, burycorpse ? CORPSTAT_BURIED
2399 if (burycorpse && cadaver && cansee(x, y) && !mtmp->minvis
2400 && cadaver->where == OBJ_BURIED && (dest & 1)) {
2402 pline("%s corpse ends up buried.", s_suffix(Monnam(mtmp)));
2404 pline("%s
\82Ì
\8e\80\91Ì
\82Í
\96\84\82Ü
\82Á
\82Ä
\82µ
\82Ü
\82Á
\82½
\81D", s_suffix(Monnam(mtmp)));
2409 spoteffects(TRUE); /* poor man's expels() */
2410 /* monster is gone, corpse or other object might now be visible */
2414 /* punish bad behaviour */
2415 if (is_human(mdat) && (!always_hostile(mdat) && mtmp->malign <= 0)
2416 && (mndx < PM_ARCHEOLOGIST || mndx > PM_WIZARD)
2417 && u.ualign.type != A_CHAOTIC) {
2418 HTelepat &= ~INTRINSIC;
2423 You("
\8eE
\90l
\8bS
\82¾
\81I");
2424 if (Blind && !Blind_telepat)
2425 see_monsters(); /* Can't sense monsters any more. */
2427 if ((mtmp->mpeaceful && !rn2(2)) || mtmp->mtame)
2429 if (is_unicorn(mdat) && sgn(u.ualign.type) == sgn(mdat->maligntyp)) {
2432 You_feel("guilty...");
2434 You("
\8dß
\82ð
\8a´
\82¶
\82½
\81D
\81D
\81D");
2437 /* give experience points */
2438 tmp = experience(mtmp, (int) mvitals[mndx].died);
2439 more_experienced(tmp, 0);
2440 newexplevel(); /* will decide if you go up */
2442 /* adjust alignment points */
2443 if (mtmp->m_id == quest_status.leader_m_id) { /* REAL BAD! */
2444 adjalign(-(u.ualign.record + (int) ALIGNLIM / 2));
2446 pline("That was %sa bad idea...",
2447 u.uevent.qcompleted ? "probably " : "");
2449 pline("%s
\82æ
\82
\82È
\82¢
\8ds
\88×
\82¾
\82Á
\82½
\81D
\81D
\81D",
2450 u.uevent.qcompleted ? "
\82½
\82Ô
\82ñ" : "");
2452 } else if (mdat->msound == MS_NEMESIS) { /* Real good! */
2453 adjalign((int) (ALIGNLIM / 4));
2454 } else if (mdat->msound == MS_GUARDIAN) { /* Bad */
2455 adjalign(-(int) (ALIGNLIM / 8));
2458 pline("That was probably a bad idea...");
2460 pline("
\82æ
\82
\82È
\82¢
\8ds
\88×
\82¾
\82Á
\82½
\81D
\81D
\81D");
2463 pline("Whoopsie-daisy!");
2465 pline("
\83V
\83\93\83W
\83}
\83b
\83^
\81[
\81I");
2466 } else if (mtmp->ispriest) {
2467 adjalign((p_coaligned(mtmp)) ? -2 : 2);
2468 /* cancel divine protection for killing your priest */
2469 if (p_coaligned(mtmp))
2471 if (mdat->maligntyp == A_NONE)
2472 adjalign((int) (ALIGNLIM / 4)); /* BIG bonus */
2473 } else if (mtmp->mtame) {
2474 adjalign(-15); /* bad!! */
2475 /* your god is mighty displeased... */
2478 You_hear("the rumble of distant thunder...");
2480 You_hear("
\89\93\82
\82Å
\97\8b\96Â
\82ð
\95·
\82¢
\82½
\81D
\81D
\81D");
2483 You_hear("the studio audience applaud!");
2485 pline("
\92®
\8fO
\82Ì
\8a\85\8dÑ
\82ð
\97\81\82Ñ
\82½
\81I");
2486 } else if (mtmp->mpeaceful)
2489 /* malign was already adjusted for u.ualign.type and randomization */
2490 adjalign(mtmp->malign);
2493 /* changes the monster into a stone monster of the same type
2494 this should only be called when poly_when_stoned() is true */
2499 if (mtmp->data->mlet == S_GOLEM) {
2500 /* it's a golem, and not a stone golem */
2501 if (canseemon(mtmp))
2503 pline("%s solidifies...", Monnam(mtmp));
2505 pline("%s
\82Í
\8bÃ
\8cÅ
\82µ
\82½
\81D
\81D
\81D", Monnam(mtmp));
2506 if (newcham(mtmp, &mons[PM_STONE_GOLEM], FALSE, FALSE)) {
2507 if (canseemon(mtmp))
2509 pline("Now it's %s.", an(mtmp->data->mname));
2511 pline("
\82È
\82ñ
\82Æ%s
\82É
\82È
\82Á
\82Ä
\82µ
\82Ü
\82Á
\82½
\81D", mtmp->data->mname);
2513 if (canseemon(mtmp))
2515 pline("... and returns to normal.");
2517 pline("
\81D
\81D
\81D
\82»
\82µ
\82Ä
\95\81\92Ê
\82É
\96ß
\82Á
\82½
\81D");
2520 impossible("Can't polystone %s!", a_monnam(mtmp));
2523 /* make monster mtmp next to you (if possible);
2524 might place monst on far side of a wall or boulder */
2530 boolean couldspot = canspotmon(mtmp);
2532 if (mtmp == u.usteed) {
2533 /* Keep your steed in sync with you instead */
2539 if (!enexto(&mm, u.ux, u.uy, mtmp->data))
2541 rloc_to(mtmp, mm.x, mm.y);
2542 if (!in_mklev && (mtmp->mstrategy & STRAT_APPEARMSG)) {
2543 mtmp->mstrategy &= ~STRAT_APPEARMSG; /* one chance only */
2544 if (!couldspot && canspotmon(mtmp))
2546 pline("%s suddenly %s!", Amonnam(mtmp),
2547 !Blind ? "appears" : "arrives");
2549 pline("
\93Ë
\91R%s
\82ª
\8c»
\82ê
\82½
\81I", Amonnam(mtmp));
2555 /* like mnexto() but requires destination to be directly accessible */
2561 struct permonst *ptr = mtmp->data;
2562 boolean diagok = !NODIAG(ptr - mons);
2566 if (!enexto(&mm, u.ux, u.uy, ptr))
2568 if (couldsee(mm.x, mm.y)
2569 /* don't move grid bugs diagonally */
2570 && (diagok || mm.x == mtmp->mx || mm.y == mtmp->my)) {
2571 rloc_to(mtmp, mm.x, mm.y);
2574 } while (--tryct > 0);
2578 * Put monster near (or at) location if possible.
2580 * 1 - if a monster was moved from x, y to put mtmp at x, y.
2581 * 0 - in most cases.
2584 mnearto(mtmp, x, y, move_other)
2585 register struct monst *mtmp;
2587 boolean move_other; /* make sure mtmp gets to x, y! so move m_at(x, y) */
2589 struct monst *othermon = (struct monst *) 0;
2593 if (mtmp->mx == x && mtmp->my == y)
2596 if (move_other && (othermon = m_at(x, y)) != 0) {
2597 if (othermon->wormno)
2598 remove_worm(othermon);
2600 remove_monster(x, y);
2605 if (!goodpos(newx, newy, mtmp, 0)) {
2606 /* Actually we have real problems if enexto ever fails.
2607 * Migrating_mons that need to be placed will cause
2608 * no end of trouble.
2610 if (!enexto(&mm, newx, newy, mtmp->data))
2615 rloc_to(mtmp, newx, newy);
2617 if (move_other && othermon) {
2618 xchar oldx = othermon->mx, oldy = othermon->my;
2620 othermon->mx = othermon->my = 0;
2621 (void) mnearto(othermon, x, y, FALSE);
2622 if (othermon->mx == 0 && othermon->my == 0) {
2623 /* reloc failed, dump monster into "limbo"
2624 (aka migrate to current level) */
2625 othermon->mx = oldx;
2626 othermon->my = oldy;
2627 mdrop_special_objs(othermon);
2628 migrate_to_level(othermon, ledger_no(&u.uz), MIGR_APPROX_XY, NULL);
2635 /* monster responds to player action; not the same as a passive attack;
2636 assumes reason for response has been tested, and response _must_ be made */
2641 if (mtmp->data->msound == MS_SHRIEK) {
2644 pline("%s shrieks.", Monnam(mtmp));
2646 pline("%s
\82Í
\8bà
\90Ø
\82è
\90º
\82ð
\82 \82°
\82½
\81D", Monnam(mtmp));
2651 (void) makemon(&mons[PM_PURPLE_WORM], 0, 0, NO_MM_FLAGS);
2653 (void) makemon((struct permonst *) 0, 0, 0, NO_MM_FLAGS);
2657 if (mtmp->data == &mons[PM_MEDUSA]) {
2660 for (i = 0; i < NATTK; i++)
2661 if (mtmp->data->mattk[i].aatyp == AT_GAZE) {
2662 (void) gazemu(mtmp, &mtmp->data->mattk[i]);
2672 mtmp->mstrategy &= ~STRAT_WAITMASK;
2673 if (!mtmp->mpeaceful)
2677 mtmp->mpeaceful = 0;
2678 if (mtmp->ispriest) {
2679 if (p_coaligned(mtmp))
2680 adjalign(-5); /* very bad */
2684 adjalign(-1); /* attacking peaceful monsters is bad */
2685 if (couldsee(mtmp->mx, mtmp->my)) {
2686 if (humanoid(mtmp->data) || mtmp->isshk || mtmp->isgd)
2688 pline("%s gets angry!", Monnam(mtmp));
2690 pline("%s
\82Í
\93{
\82Á
\82½
\81I", Monnam(mtmp));
2691 else if (flags.verbose && !Deaf)
2695 /* attacking your own quest leader will anger his or her guardians */
2696 if (!context.mon_moving /* should always be the case here */
2697 && mtmp->data == &mons[quest_info(MS_LEADER)]) {
2699 struct permonst *q_guardian = &mons[quest_info(MS_GUARDIAN)];
2702 /* guardians will sense this attack even if they can't see it */
2703 for (mon = fmon; mon; mon = mon->nmon) {
2704 if (DEADMONSTER(mon))
2706 if (mon->data == q_guardian && mon->mpeaceful) {
2712 if (got_mad && !Hallucination)
2714 pline_The("%s appear%s to be angry too...",
2715 got_mad == 1 ? q_guardian->mname
2716 : makeplural(q_guardian->mname),
2717 got_mad == 1 ? "s" : "");
2719 pline("%s
\82à
\93{
\82Á
\82½
\81D
\81D
\81D", q_guardian->mname);
2724 /* wake up a monster, usually making it angry in the process */
2727 register struct monst *mtmp;
2729 mtmp->msleeping = 0;
2730 finish_meating(mtmp);
2732 if (mtmp->m_ap_type) {
2734 } else if (context.forcefight && !context.mon_moving
2735 && mtmp->mundetected) {
2736 mtmp->mundetected = 0;
2737 newsym(mtmp->mx, mtmp->my);
2741 /* Wake up nearby monsters without angering them. */
2745 register struct monst *mtmp;
2747 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
2748 if (DEADMONSTER(mtmp))
2750 if (distu(mtmp->mx, mtmp->my) < u.ulevel * 20) {
2751 mtmp->msleeping = 0;
2752 if (!unique_corpstat(mtmp->data))
2753 mtmp->mstrategy &= ~STRAT_WAITMASK;
2754 if (mtmp->mtame && !mtmp->isminion)
2755 EDOG(mtmp)->whistletime = moves;
2760 /* Wake up monsters near some particular location. */
2762 wake_nearto(x, y, distance)
2763 register int x, y, distance;
2765 register struct monst *mtmp;
2767 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
2768 if (DEADMONSTER(mtmp))
2770 if (distance == 0 || dist2(mtmp->mx, mtmp->my, x, y) < distance) {
2771 mtmp->msleeping = 0;
2772 if (!unique_corpstat(mtmp->data))
2773 mtmp->mstrategy &= ~STRAT_WAITMASK;
2778 /* NOTE: we must check for mimicry before calling this routine */
2781 register struct monst *mtmp;
2783 boolean is_blocker_appear = (is_door_mappear(mtmp)
2784 || is_obj_mappear(mtmp, BOULDER));
2786 if (has_mcorpsenm(mtmp))
2787 freemcorpsenm(mtmp);
2789 mtmp->m_ap_type = M_AP_NOTHING;
2790 mtmp->mappearance = 0;
2793 * Discovered mimics don't block light.
2795 if (is_blocker_appear
2796 && !does_block(mtmp->mx, mtmp->my, &levl[mtmp->mx][mtmp->my]))
2797 unblock_point(mtmp->mx, mtmp->my);
2799 newsym(mtmp->mx, mtmp->my);
2802 /* force all chameleons to become normal */
2806 register struct monst *mtmp;
2809 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
2810 if (DEADMONSTER(mtmp))
2812 mcham = (int) mtmp->cham;
2813 if (mcham >= LOW_PM) {
2814 (void) newcham(mtmp, &mons[mcham], FALSE, FALSE);
2815 mtmp->cham = NON_PM;
2817 if (is_were(mtmp->data) && mtmp->data->mlet != S_HUMAN)
2819 if (mtmp->m_ap_type && cansee(mtmp->mx, mtmp->my)) {
2821 /* we pretend that the mimic doesn't
2822 know that it has been unmasked */
2823 mtmp->msleeping = 1;
2828 /* Let the chameleons change again -dgk */
2832 register struct monst *mtmp;
2834 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
2835 if (DEADMONSTER(mtmp))
2837 mtmp->cham = pm_to_cham(monsndx(mtmp->data));
2838 if (mtmp->data->mlet == S_MIMIC && mtmp->msleeping
2839 && cansee(mtmp->mx, mtmp->my)) {
2840 set_mimic_sym(mtmp);
2841 newsym(mtmp->mx, mtmp->my);
2846 /* called when restoring a monster from a saved level; protection
2847 against shape-changing might be different now than it was at the
2848 time the level was saved. */
2855 if (Protection_from_shape_changers) {
2856 mcham = (int) mon->cham;
2857 if (mcham >= LOW_PM) {
2859 (void) newcham(mon, &mons[mcham], FALSE, FALSE);
2860 } else if (is_were(mon->data) && !is_human(mon->data)) {
2863 } else if (mon->cham == NON_PM) {
2864 mon->cham = pm_to_cham(monsndx(mon->data));
2868 /* unwatched hiders may hide again; if so, returns True */
2871 register struct monst *mtmp;
2875 if (mtmp->mcan || mtmp->m_ap_type || cansee(mtmp->mx, mtmp->my)
2876 || rn2(3) || mtmp == u.ustuck
2877 /* can't hide while trapped except in pits */
2878 || (mtmp->mtrapped && (t = t_at(mtmp->mx, mtmp->my)) != 0
2879 && !(t->ttyp == PIT || t->ttyp == SPIKED_PIT))
2880 || (sensemon(mtmp) && distu(mtmp->mx, mtmp->my) <= 2))
2883 if (mtmp->data->mlet == S_MIMIC) {
2884 set_mimic_sym(mtmp);
2886 } else if (levl[mtmp->mx][mtmp->my].typ == ROOM) {
2887 mtmp->mundetected = 1;
2894 /* monster/hero tries to hide under something at the current location */
2900 boolean undetected = FALSE, is_u = (mtmp == &youmonst);
2901 xchar x = is_u ? u.ux : mtmp->mx, y = is_u ? u.uy : mtmp->my;
2903 if (mtmp == u.ustuck) {
2904 ; /* can't hide if holding you or held by you */
2905 } else if (is_u ? (u.utrap && u.utraptype != TT_PIT)
2906 : (mtmp->mtrapped && (t = t_at(x, y)) != 0
2907 && !(t->ttyp == PIT || t->ttyp == SPIKED_PIT))) {
2908 ; /* can't hide while stuck in a non-pit trap */
2909 } else if (mtmp->data->mlet == S_EEL) {
2910 undetected = (is_pool(x, y) && !Is_waterlevel(&u.uz));
2911 } else if (hides_under(mtmp->data) && OBJ_AT(x, y)) {
2912 struct obj *otmp = level.objects[x][y];
2914 /* most monsters won't hide under cockatrice corpse */
2915 if (otmp->nexthere || otmp->otyp != CORPSE
2916 || (mtmp == &youmonst ? Stone_resistance : resists_ston(mtmp))
2917 || !touch_petrifies(&mons[otmp->corpsenm]))
2922 u.uundetected = undetected;
2924 mtmp->mundetected = undetected;
2928 /* called when returning to a previously visited level */
2933 boolean hider_under = hides_under(mon->data) || mon->data->mlet == S_EEL;
2935 if ((is_hider(mon->data) || hider_under)
2936 && !(mon->mundetected || mon->m_ap_type)) {
2937 xchar x = mon->mx, y = mon->my;
2938 char save_viz = viz_array[y][x];
2940 /* override vision, forcing hero to be unable to see monster's spot */
2941 viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE);
2942 if (is_hider(mon->data))
2943 (void) restrap(mon);
2944 /* try again if mimic missed its 1/3 chance to hide */
2945 if (mon->data->mlet == S_MIMIC && !mon->m_ap_type)
2946 (void) restrap(mon);
2948 (void) hideunder(mon);
2949 viz_array[y][x] = save_viz;
2953 static short *animal_list = 0; /* list of PM values for animal monsters */
2954 static int animal_list_count;
2957 mon_animal_list(construct)
2961 short animal_temp[SPECIAL_PM];
2964 /* if (animal_list) impossible("animal_list already exists"); */
2966 for (n = 0, i = LOW_PM; i < SPECIAL_PM; i++)
2967 if (is_animal(&mons[i]))
2968 animal_temp[n++] = i;
2969 /* if (n == 0) animal_temp[n++] = NON_PM; */
2971 animal_list = (short *) alloc(n * sizeof *animal_list);
2972 (void) memcpy((genericptr_t) animal_list, (genericptr_t) animal_temp,
2973 n * sizeof *animal_list);
2974 animal_list_count = n;
2975 } else { /* release */
2977 free((genericptr_t) animal_list), animal_list = 0;
2978 animal_list_count = 0;
2988 mon_animal_list(TRUE);
2990 res = animal_list[rn2(animal_list_count)];
2991 /* rogue level should use monsters represented by uppercase letters
2992 only, but since chameleons aren't generated there (not uppercase!)
2993 we don't perform a lot of retries */
2994 if (Is_rogue_level(&u.uz) && !isupper((uchar) mons[res].mlet))
2995 res = animal_list[rn2(animal_list_count)];
3000 decide_to_shapeshift(mon, shiftflags)
3004 struct permonst *ptr;
3005 unsigned was_female = mon->female;
3006 boolean msg = FALSE;
3008 if ((shiftflags & SHIFT_MSG)
3009 || ((shiftflags & SHIFT_SEENMSG) && sensemon(mon)))
3012 if (is_vampshifter(mon)) {
3013 /* The vampire has to be in good health (mhp) to maintain
3016 * If we're shifted and getting low on hp, maybe shift back.
3017 * If we're not already shifted and in good health, maybe shift.
3019 if ((mon->mhp <= mon->mhpmax / 6) && rn2(4) && (mon->cham >= LOW_PM))
3020 (void) newcham(mon, &mons[mon->cham], FALSE, msg);
3021 } else if (mon->data->mlet == S_VAMPIRE && mon->cham == NON_PM && !rn2(6)
3022 && (mon->mhp > mon->mhpmax - ((mon->mhpmax / 10) + 1))) {
3023 (void) newcham(mon, (struct permonst *) 0, FALSE, msg);
3025 /* override the 10% chance for sex change */
3027 if (!is_male(ptr) && !is_female(ptr) && !is_neuter(ptr))
3028 mon->female = was_female;
3035 int mndx = mon->cham;
3036 /* avoid picking monsters with lowercase display symbols ('d' for wolf
3037 and 'v' for fog cloud) on rogue level*/
3038 boolean uppercase_only = Is_rogue_level(&u.uz);
3041 case PM_VLAD_THE_IMPALER:
3042 /* ensure Vlad can keep carrying the Candelabrum */
3043 if (mon_has_special(mon))
3044 break; /* leave mndx as is */
3046 case PM_VAMPIRE_LORD: /* vampire lord or Vlad can become wolf */
3047 if (!rn2(10) && !uppercase_only) {
3052 case PM_VAMPIRE: /* any vampire can become fog or bat */
3053 mndx = (!rn2(4) && !uppercase_only) ? PM_FOG_CLOUD : PM_VAMPIRE_BAT;
3059 /* nonshapechangers who warrant special polymorph handling */
3064 return (mon->isshk || mon->ispriest || mon->isgd
3065 || mon->m_id == quest_status.leader_m_id);
3068 /* restrict certain special monsters (shopkeepers, aligned priests,
3069 vault guards) to forms that allow them to behave sensibly (catching
3070 gold, speaking?) so that they don't need too much extra code */
3072 validspecmon(mon, mndx)
3077 return TRUE; /* caller wants random */
3079 if (!accept_newcham_form(mndx))
3080 return FALSE; /* geno'd or !polyok */
3082 if (isspecmon(mon)) {
3083 struct permonst *ptr = &mons[mndx];
3085 /* reject notake because object manipulation is expected
3086 and nohead because speech capability is expected */
3087 if (notake(ptr) || !has_head(ptr))
3089 /* [should we check ptr->msound here too?] */
3091 return TRUE; /* potential new form is ok */
3094 /* prevent wizard mode user from specifying invalid vampshifter shape */
3096 validvamp(mon, mndx_p, monclass)
3098 int *mndx_p, monclass;
3100 /* simplify caller's usage */
3101 if (!is_vampshifter(mon))
3102 return validspecmon(mon, *mndx_p);
3104 if (*mndx_p == PM_VAMPIRE || *mndx_p == PM_VAMPIRE_LORD
3105 || *mndx_p == PM_VLAD_THE_IMPALER) {
3106 /* player picked some type of vampire; use mon's self */
3107 *mndx_p = mon->cham;
3110 if (mon->cham == PM_VLAD_THE_IMPALER && mon_has_special(mon)) {
3111 /* Vlad with Candelabrum; override choice, then accept it */
3112 *mndx_p = PM_VLAD_THE_IMPALER;
3115 /* basic vampires can't become wolves; any can become fog or bat
3116 (we don't enforce upper-case only for rogue level here) */
3117 if (*mndx_p == PM_WOLF)
3118 return (boolean) (mon->cham != PM_VAMPIRE);
3119 if (*mndx_p == PM_FOG_CLOUD || *mndx_p == PM_VAMPIRE_BAT)
3122 /* if we get here, specific type was no good; try by class */
3125 *mndx_p = mon->cham;
3128 *mndx_p = PM_VAMPIRE_BAT;
3131 *mndx_p = PM_FOG_CLOUD;
3134 if (mon->cham != PM_VAMPIRE) {
3143 return (boolean) (*mndx_p != NON_PM);
3147 select_newcham_form(mon)
3150 int mndx = NON_PM, tryct;
3152 switch (mon->cham) {
3155 mndx = pick_nasty();
3157 case PM_DOPPELGANGER:
3159 mndx = pick_nasty();
3160 } else if (rn2(3)) { /* role monsters */
3161 mndx = rn1(PM_WIZARD - PM_ARCHEOLOGIST + 1, PM_ARCHEOLOGIST);
3162 } else if (!rn2(3)) { /* quest guardians */
3163 mndx = rn1(PM_APPRENTICE - PM_STUDENT + 1, PM_STUDENT);
3164 /* avoid own role's guardian */
3165 if (mndx == urole.guardnum)
3167 } else { /* general humanoids */
3170 mndx = rn1(SPECIAL_PM - LOW_PM, LOW_PM);
3171 if (humanoid(&mons[mndx]) && polyok(&mons[mndx]))
3173 } while (--tryct > 0);
3180 mndx = pick_animal();
3182 case PM_VLAD_THE_IMPALER:
3183 case PM_VAMPIRE_LORD:
3185 mndx = pickvampshape(mon);
3187 case NON_PM: /* ordinary */
3189 struct obj *m_armr = which_armor(mon, W_ARM);
3191 if (m_armr && Is_dragon_scales(m_armr))
3192 mndx = (int) (Dragon_scales_to_pm(m_armr) - mons);
3193 else if (m_armr && Is_dragon_mail(m_armr))
3194 mndx = (int) (Dragon_mail_to_pm(m_armr) - mons);
3198 /* for debugging: allow control of polymorphed monster */
3199 if (wizard && iflags.mon_polycontrol) {
3200 char pprompt[BUFSZ], buf[BUFSZ];
3203 Sprintf(pprompt, "Change %s @ <%d,%d> into what kind of monster?",
3204 noit_mon_nam(mon), (int) mon->mx, (int) mon->my);
3208 getlin(pprompt, buf);
3210 /* for ESC, take form selected above (might be NON_PM) */
3213 /* for "*", use NON_PM to pick an arbitrary shape below */
3214 if (!strcmp(buf, "*") || !strcmp(buf, "random")) {
3218 mndx = name_to_mon(buf);
3219 if (mndx == NON_PM) {
3220 /* didn't get a type, so check whether it's a class
3221 (single letter or text match with def_monsyms[]) */
3222 monclass = name_to_monclass(buf, &mndx);
3223 if (monclass && mndx == NON_PM)
3224 mndx = mkclass_poly(monclass);
3226 if (mndx >= LOW_PM) {
3227 /* got a specific type of monster; use it if we can */
3228 if (validvamp(mon, &mndx, monclass))
3230 /* can't; revert to random in case we exhaust tryct */
3234 pline("It can't become that.");
3235 } while (--tryct > 0);
3237 pline1(thats_enough_tries);
3238 if (is_vampshifter(mon) && !validvamp(mon, &mndx, monclass))
3239 mndx = pickvampshape(mon); /* don't resort to arbitrary */
3242 /* if no form was specified above, pick one at random now */
3243 if (mndx == NON_PM) {
3246 mndx = rn1(SPECIAL_PM - LOW_PM, LOW_PM);
3247 } while (--tryct > 0 && !validspecmon(mon, mndx)
3248 /* try harder to select uppercase monster on rogue level */
3249 && (tryct > 40 && Is_rogue_level(&u.uz)
3250 && !isupper((uchar) mons[mndx].mlet)));
3255 /* this used to be inline within newcham() but monpolycontrol needs it too */
3256 STATIC_OVL struct permonst *
3257 accept_newcham_form(mndx)
3260 struct permonst *mdat;
3265 if ((mvitals[mndx].mvflags & G_GENOD) != 0)
3267 if (is_placeholder(mdat))
3269 /* select_newcham_form() might deliberately pick a player
3270 character type (random selection never does) which
3271 polyok() rejects, so we need a special case here */
3272 if (is_mplayer(mdat))
3274 /* polyok() rules out M2_PNAME, M2_WERE, and all humans except Kops */
3275 return polyok(mdat) ? mdat : 0;
3279 mgender_from_permonst(mtmp, mdat)
3281 struct permonst *mdat;
3283 if (is_male(mdat)) {
3285 mtmp->female = FALSE;
3286 } else if (is_female(mdat)) {
3288 mtmp->female = TRUE;
3289 } else if (!is_neuter(mdat)) {
3291 mtmp->female = !mtmp->female;
3295 /* make a chameleon take on another shape, or a polymorph target
3296 (possibly self-inflicted) become a different monster;
3297 returns 1 if it actually changes form */
3299 newcham(mtmp, mdat, polyspot, msg)
3301 struct permonst *mdat;
3302 boolean polyspot; /* change is the result of wand or spell of polymorph */
3303 boolean msg; /* "The oldmon turns into a newmon!" */
3307 struct permonst *olddata = mtmp->data;
3308 char oldname[BUFSZ], newname[BUFSZ];
3310 /* Riders are immune to polymorph and green slime */
3311 if (is_rider(mtmp->data))
3315 /* like Monnam() but never mention saddle */
3316 Strcpy(oldname, x_monnam(mtmp, ARTICLE_THE, (char *) 0,
3317 SUPPRESS_SADDLE, FALSE));
3318 oldname[0] = highc(oldname[0]);
3321 /* mdat = 0 -> caller wants a random monster shape */
3323 /* select_newcham_form() loops when resorting to random but
3324 it doesn't always pick that so we still retry here too */
3327 mndx = select_newcham_form(mtmp);
3328 mdat = accept_newcham_form(mndx);
3329 /* for the first several tries we require upper-case on
3330 the rogue level (after that, we take whatever we get) */
3331 if (tryct > 15 && Is_rogue_level(&u.uz)
3332 && mdat && !isupper((uchar) mdat->mlet))
3336 } while (--tryct > 0);
3339 } else if (mvitals[monsndx(mdat)].mvflags & G_GENOD)
3340 return 0; /* passed in mdat is genocided */
3342 mgender_from_permonst(mtmp, mdat);
3344 if (In_endgame(&u.uz) && is_mplayer(olddata) && has_mname(mtmp)) {
3345 /* mplayers start out as "Foo the Bar", but some of the
3346 * titles are inappropriate when polymorphed, particularly
3347 * into the opposite sex. players don't use ranks when
3348 * polymorphed, so dropping the rank for mplayers seems
3351 char *p = index(MNAME(mtmp), ' ');
3357 if (mdat == mtmp->data)
3358 return 0; /* still the same monster */
3360 if (mtmp->wormno) { /* throw tail away */
3362 place_monster(mtmp, mtmp->mx, mtmp->my);
3364 if (mtmp->m_ap_type && mdat->mlet != S_MIMIC)
3365 seemimic(mtmp); /* revert to normal monster */
3367 /* (this code used to try to adjust the monster's health based on
3368 a normal one of its type but there are too many special cases
3369 which need to handled in order to do that correctly, so just
3370 give the new form the same proportion of HP as its old one had) */
3373 /* set level and hit points */
3374 newmonhp(mtmp, monsndx(mdat));
3375 /* new hp: same fraction of max as before */
3377 mtmp->mhp = (int) (((long) hpn * (long) mtmp->mhp) / (long) hpd);
3379 /* sanity check (potential overflow) */
3380 if (mtmp->mhp < 0 || mtmp->mhp > mtmp->mhpmax)
3381 mtmp->mhp = mtmp->mhpmax;
3382 /* unlikely but not impossible; a 1HD creature with 1HP that changes
3383 into a 0HD creature will require this statement */
3387 /* take on the new form... */
3388 set_mon_data(mtmp, mdat, 0);
3390 if (emits_light(olddata) != emits_light(mtmp->data)) {
3391 /* used to give light, now doesn't, or vice versa,
3392 or light's range has changed */
3393 if (emits_light(olddata))
3394 del_light_source(LS_MONSTER, monst_to_any(mtmp));
3395 if (emits_light(mtmp->data))
3396 new_light_source(mtmp->mx, mtmp->my, emits_light(mtmp->data),
3397 LS_MONSTER, monst_to_any(mtmp));
3399 if (!mtmp->perminvis || pm_invisible(olddata))
3400 mtmp->perminvis = pm_invisible(mdat);
3401 mtmp->minvis = mtmp->invis_blkd ? 0 : mtmp->perminvis;
3402 if (mtmp->mundetected)
3403 (void) hideunder(mtmp);
3404 if (u.ustuck == mtmp) {
3406 if (!attacktype(mdat, AT_ENGL)) {
3407 /* Does mdat care? */
3408 if (!noncorporeal(mdat) && !amorphous(mdat)
3409 && !is_whirly(mdat) && (mdat != &mons[PM_YELLOW_LIGHT])) {
3411 You("break out of %s%s!", mon_nam(mtmp),
3412 (is_animal(mdat) ? "'s stomach" : ""));
3414 You("%s%s
\82ð
\94j
\82è
\8fo
\82½
\81I", mon_nam(mtmp),
3415 (is_animal(mdat) ? "
\82Ì
\88Ý
\91Ü" : ""));
3417 mtmp->mhp = 1; /* almost dead */
3419 expels(mtmp, olddata, FALSE);
3421 /* update swallow glyphs for new monster */
3424 } else if (!sticks(mdat) && !sticks(youmonst.data))
3429 if (mdat == &mons[PM_LONG_WORM] && (mtmp->wormno = get_wormno()) != 0) {
3431 /* DICE 3.0 doesn't like assigning and comparing mtmp->wormno in the
3434 if (mdat == &mons[PM_LONG_WORM]
3435 && (mtmp->wormno = get_wormno(), mtmp->wormno != 0)) {
3437 /* we can now create worms with tails - 11/91 */
3438 initworm(mtmp, rn2(5));
3439 if (count_wsegs(mtmp))
3440 place_worm_tail_randomly(mtmp, mtmp->mx, mtmp->my);
3443 newsym(mtmp->mx, mtmp->my);
3446 char *save_mname = 0;
3448 if (has_mname(mtmp)) {
3449 save_mname = MNAME(mtmp);
3450 MNAME(mtmp) = (char *) 0;
3453 Strcpy(newname, (mdat == &mons[PM_GREEN_SLIME])
3455 : x_monnam(mtmp, ARTICLE_A, (char *) 0,
3456 SUPPRESS_SADDLE, FALSE));
3458 Strcpy(newname, (mdat == &mons[PM_GREEN_SLIME])
3459 ? "
\83X
\83\89\83C
\83\80"
3460 : x_monnam(mtmp, ARTICLE_A, (char *) 0,
3461 SUPPRESS_SADDLE, FALSE));
3464 if (!strcmpi(oldname, "it") && !strcmpi(newname, "it"))
3466 if (!strcmpi(oldname, "
\89½
\8eÒ
\82©") && !strcmpi(newname, "
\89½
\8eÒ
\82©"))
3467 (void) usmellmon(mdat);
3470 pline("%s turns into %s!", oldname, newname);
3472 pline("%s
\82Í%s
\82É
\82È
\82Á
\82½
\81I", oldname, newname);
3474 MNAME(mtmp) = save_mname;
3477 possibly_unwield(mtmp, polyspot); /* might lose use of weapon */
3478 mon_break_armor(mtmp, polyspot);
3479 if (!(mtmp->misc_worn_check & W_ARMG))
3481 mselftouch(mtmp, "No longer petrify-resistant, ",
3482 !context.mon_moving);
3484 mselftouch(mtmp, "
\90Î
\89»
\82Ö
\82Ì
\92ï
\8dR
\97Í
\82ª
\82È
\82
\82È
\82Á
\82Ä
\81C",
3485 !context.mon_moving);
3487 m_dowear(mtmp, FALSE);
3489 /* This ought to re-test can_carry() on each item in the inventory
3490 * rather than just checking ex-giants & boulders, but that'd be
3491 * pretty expensive to perform. If implemented, then perhaps
3492 * minvent should be sorted in order to drop heaviest items first.
3494 /* former giants can't continue carrying boulders */
3495 if (mtmp->minvent && !throws_rocks(mdat)) {
3496 register struct obj *otmp, *otmp2;
3498 for (otmp = mtmp->minvent; otmp; otmp = otmp2) {
3500 if (otmp->otyp == BOULDER) {
3501 /* this keeps otmp from being polymorphed in the
3502 same zap that the monster that held it is polymorphed */
3505 obj_extract_self(otmp);
3506 /* probably ought to give some "drop" message here */
3507 if (flooreffects(otmp, mtmp->mx, mtmp->my, ""))
3509 place_object(otmp, mtmp->mx, mtmp->my);
3517 /* sometimes an egg will be special */
3518 #define BREEDER_EGG (!rn2(77))
3521 * Determine if the given monster number can be hatched from an egg.
3522 * Return the monster number to use as the egg's corpsenm. Return
3523 * NON_PM if the given monster can't be hatched.
3526 can_be_hatched(mnum)
3529 /* ranger quest nemesis has the oviparous bit set, making it
3530 be possible to wish for eggs of that unique monster; turn
3531 such into ordinary eggs rather than forbidding them outright */
3532 if (mnum == PM_SCORPIUS)
3535 mnum = little_to_big(mnum);
3537 * Queen bees lay killer bee eggs (usually), but killer bees don't
3538 * grow into queen bees. Ditto for [winged-]gargoyles.
3540 if (mnum == PM_KILLER_BEE || mnum == PM_GARGOYLE
3541 || (lays_eggs(&mons[mnum])
3543 || (mnum != PM_QUEEN_BEE && mnum != PM_WINGED_GARGOYLE))))
3548 /* type of egg laid by #sit; usually matches parent */
3550 egg_type_from_parent(mnum, force_ordinary)
3551 int mnum; /* parent monster; caller must handle lays_eggs() check */
3552 boolean force_ordinary;
3554 if (force_ordinary || !BREEDER_EGG) {
3555 if (mnum == PM_QUEEN_BEE)
3556 mnum = PM_KILLER_BEE;
3557 else if (mnum == PM_WINGED_GARGOYLE)
3563 /* decide whether an egg of the indicated monster type is viable;
3564 also used to determine whether an egg or tin can be created... */
3566 dead_species(m_idx, egg)
3572 /* generic eggs are unhatchable and have corpsenm of NON_PM */
3576 * For monsters with both baby and adult forms, genociding either
3577 * form kills all eggs of that monster. Monsters with more than
3578 * two forms (small->large->giant mimics) are more or less ignored;
3579 * fortunately, none of them have eggs. Species extinction due to
3580 * overpopulation does not kill eggs.
3582 alt_idx = egg ? big_to_little(m_idx) : m_idx;
3583 return (boolean) ((mvitals[m_idx].mvflags & G_GENOD) != 0
3584 || (mvitals[alt_idx].mvflags & G_GENOD) != 0);
3587 /* kill off any eggs of genocided monsters */
3590 struct obj *obj_list;
3594 for (otmp = obj_list; otmp; otmp = otmp->nobj)
3595 if (otmp->otyp == EGG) {
3596 if (dead_species(otmp->corpsenm, TRUE)) {
3598 * It seems we could also just catch this when
3599 * it attempted to hatch, so we wouldn't have to
3600 * search all of the objlists.. or stop all
3601 * hatch timers based on a corpsenm.
3605 #if 0 /* not used */
3606 } else if (otmp->otyp == TIN) {
3607 if (dead_species(otmp->corpsenm, FALSE))
3608 otmp->corpsenm = NON_PM; /* empty tin */
3609 } else if (otmp->otyp == CORPSE) {
3610 if (dead_species(otmp->corpsenm, FALSE))
3611 ; /* not yet implemented... */
3613 } else if (Has_contents(otmp)) {
3614 kill_eggs(otmp->cobj);
3618 /* kill all members of genocided species */
3620 kill_genocided_monsters()
3622 struct monst *mtmp, *mtmp2;
3627 * Called during genocide, and again upon level change. The latter
3628 * catches up with any migrating monsters as they finally arrive at
3629 * their intended destinations, so possessions get deposited there.
3631 * Chameleon handling:
3632 * 1) if chameleons have been genocided, destroy them
3633 * regardless of current form;
3634 * 2) otherwise, force every chameleon which is imitating
3635 * any genocided species to take on a new form.
3637 for (mtmp = fmon; mtmp; mtmp = mtmp2) {
3639 if (DEADMONSTER(mtmp))
3641 mndx = monsndx(mtmp->data);
3642 kill_cham = (mtmp->cham >= LOW_PM
3643 && (mvitals[mtmp->cham].mvflags & G_GENOD));
3644 if ((mvitals[mndx].mvflags & G_GENOD) || kill_cham) {
3645 if (mtmp->cham >= LOW_PM && !kill_cham)
3646 (void) newcham(mtmp, (struct permonst *) 0, FALSE, FALSE);
3651 kill_eggs(mtmp->minvent);
3656 kill_eggs(migrating_objs);
3657 kill_eggs(level.buriedobjlist);
3661 golemeffects(mon, damtype, dam)
3662 register struct monst *mon;
3665 int heal = 0, slow = 0;
3667 if (mon->data == &mons[PM_FLESH_GOLEM]) {
3668 if (damtype == AD_ELEC)
3669 heal = (dam + 5) / 6;
3670 else if (damtype == AD_FIRE || damtype == AD_COLD)
3672 } else if (mon->data == &mons[PM_IRON_GOLEM]) {
3673 if (damtype == AD_ELEC)
3675 else if (damtype == AD_FIRE)
3681 if (mon->mspeed != MSLOW)
3682 mon_adjust_speed(mon, -1, (struct obj *) 0);
3685 if (mon->mhp < mon->mhpmax) {
3687 if (mon->mhp > mon->mhpmax)
3688 mon->mhp = mon->mhpmax;
3689 if (cansee(mon->mx, mon->my))
3691 pline("%s seems healthier.", Monnam(mon));
3693 pline("%s
\82Í
\8c³
\8bC
\82É
\82È
\82Á
\82½
\82æ
\82¤
\82É
\8c©
\82¦
\82é
\81D", Monnam(mon));
3699 angry_guards(silent)
3703 int ct = 0, nct = 0, sct = 0, slct = 0;
3705 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
3706 if (DEADMONSTER(mtmp))
3708 if (is_watch(mtmp->data) && mtmp->mpeaceful) {
3710 if (cansee(mtmp->mx, mtmp->my) && mtmp->mcanmove) {
3711 if (distu(mtmp->mx, mtmp->my) == 2)
3716 if (mtmp->msleeping || mtmp->mfrozen) {
3718 mtmp->msleeping = mtmp->mfrozen = 0;
3720 mtmp->mpeaceful = 0;
3724 if (!silent) { /* do we want pline msgs? */
3727 pline_The("guard%s wake%s up!", slct > 1 ? "s" : "",
3728 slct == 1 ? "s" : "");
3730 pline("
\94Ô
\95º
\82Í
\96Ú
\82ð
\8ao
\82Ü
\82µ
\82½
\81I");
3735 pline_The("guard%s get%s angry!", nct == 1 ? "" : "s",
3736 nct == 1 ? "s" : "");
3738 pline("
\94Ô
\95º
\82Í
\93{
\82Á
\82½
\81I");
3742 You_see("%sangry guard%s approaching!",
3743 sct == 1 ? "an " : "", sct > 1 ? "s" : "");
3745 You("
\93{
\82Á
\82½
\94Ô
\95º
\82ª
\8bß
\8añ
\82Á
\82Ä
\82
\82é
\82Ì
\82ð
\8c©
\82½
\81I");
3749 You_hear("the shrill sound of a guard's whistle.");
3751 You_hear("
\94Ô
\95º
\82Ì
\93J
\82ª
\82¯
\82½
\82½
\82Ü
\82µ
\82
\96Â
\82é
\82Ì
\82ð
\95·
\82¢
\82½
\81D");
3763 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
3764 if (DEADMONSTER(mtmp))
3766 if (is_watch(mtmp->data))
3767 mtmp->mpeaceful = 1;
3772 mimic_hit_msg(mtmp, otyp)
3776 short ap = mtmp->mappearance;
3778 switch (mtmp->m_ap_type) {
3780 case M_AP_FURNITURE:
3784 if (otyp == SPE_HEALING || otyp == SPE_EXTRA_HEALING) {
3786 pline("%s seems a more vivid %s than before.",
3787 The(simple_typename(ap)),
3788 c_obj_colors[objects[ap].oc_color]);
3790 pline("%s
\82Í
\88È
\91O
\82æ
\82è
\82æ
\82è
\91N
\82â
\82©
\82È%s
\82É
\82È
\82Á
\82½
\82æ
\82¤
\82¾
\81D",
3791 The(simple_typename(ap)),
3792 c_obj_colors[objects[ap].oc_color]);
3801 struct permonst *mdat;
3804 boolean nonspecific = FALSE;
3805 boolean msg_given = FALSE;
3808 if (!olfaction(youmonst.data))
3810 mndx = monsndx(mdat);
3815 You("notice a bovine smell.");
3817 You("
\8b\8d\82Ì
\82æ
\82¤
\82È
\82É
\82¨
\82¢
\82É
\8bC
\95t
\82¢
\82½
\81D");
3823 case PM_NEANDERTHAL:
3825 You("smell body odor.");
3827 pline("
\91Ì
\8fL
\82Ì
\82æ
\82¤
\82È
\82É
\82¨
\82¢
\82ª
\82µ
\82½
\81D");
3836 case PM_HORNED_DEVIL:
3843 case PM_HUMAN_WEREJACKAL:
3844 case PM_HUMAN_WERERAT:
3845 case PM_HUMAN_WEREWOLF:
3851 You("detect an odor reminiscent of an animal's den.");
3853 pline("
\93®
\95¨
\82Ì
\82Ë
\82®
\82ç
\82ð
\8ev
\82¢
\8fo
\82·
\82æ
\82¤
\82È
\82É
\82¨
\82¢
\82ª
\82µ
\82½
\81D");
3857 case PM_PURPLE_WORM:
3860 case PM_STEAM_VORTEX:
3862 You("smell steam.");
3864 pline("
\8fö
\8bC
\82Ì
\82É
\82¨
\82¢
\82ª
\82µ
\82½
\81D");
3867 case PM_GREEN_SLIME:
3869 pline("%s stinks.", Something);
3871 pline("
\88«
\8fL
\82ª
\82µ
\82½
\81D");
3874 case PM_VIOLET_FUNGUS:
3877 You("smell mushrooms.");
3879 pline("
\82«
\82Ì
\82±
\82Ì
\82É
\82¨
\82¢
\82ª
\82µ
\82½
\81D");
3882 /* These are here to avoid triggering the
3883 nonspecific treatment through the default case below*/
3884 case PM_WHITE_UNICORN:
3885 case PM_GRAY_UNICORN:
3886 case PM_BLACK_UNICORN:
3895 switch (mdat->mlet) {
3898 You("notice a dog smell.");
3900 You("
\8c¢
\82Ì
\82É
\82¨
\82¢
\82É
\8bC
\95t
\82¢
\82½
\81D");
3905 You("smell a dragon!");
3907 pline("
\83h
\83\89\83S
\83\93\82Ì
\82É
\82¨
\82¢
\82ª
\82·
\82é
\81I");
3912 pline("%s smells moldy.", Something);
3914 pline("
\89½
\82©
\91Û
\82Ì
\82æ
\82¤
\82È
\82É
\82¨
\82¢
\82ª
\82·
\82é
\81D");
3919 You("detect a%s odor reminiscent of a stable.",
3920 (mndx == PM_PONY) ? "n" : " strong");
3922 pline("
\94n
\8f¬
\89®
\82ð
\8ev
\82¢
\8fo
\82·
\82æ
\82¤
\82È%s
\82É
\82¨
\82¢
\82ª
\82µ
\82½
\81D",
3923 (mndx == PM_PONY) ? "" : "
\8b
\82¢");
3929 You("smell rotting flesh.");
3931 pline("
\95\85\82Á
\82½
\93÷
\82Ì
\82É
\82¨
\82¢
\82ª
\82µ
\82½
\81D");
3938 pline("
\8b\9b\82Ì
\82É
\82¨
\82¢
\82ª
\82µ
\82½
\81D");
3942 if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC)))
3944 You("notice an attractive smell.");
3946 You("
\96£
\97Í
\93I
\82È
\82É
\82¨
\82¢
\82É
\8bC
\95t
\82¢
\82½
\81D");
3949 pline("A foul stench makes you feel a little nauseated.");
3951 pline("
\82Þ
\82©
\82Â
\82
\82æ
\82¤
\82È
\88«
\8fL
\82Å
\8f
\82µ
\8bC
\95ª
\82ª
\88«
\82
\82È
\82Á
\82½
\81D");
3958 return msg_given ? TRUE : FALSE;