| 2651 | } |
| 2652 | |
| 2653 | int |
| 2654 | rnd_misc_item(struct monst *mtmp) |
| 2655 | { |
| 2656 | struct permonst *pm = mtmp->data; |
| 2657 | int difficulty = mons[(monsndx(pm))].difficulty; |
| 2658 | |
| 2659 | if (is_animal(pm) || attacktype(pm, AT_EXPL) || mindless(mtmp->data) |
| 2660 | || pm->mlet == S_GHOST || pm->mlet == S_KOP) |
| 2661 | return 0; |
| 2662 | /* Unlike other rnd_item functions, we only allow _weak_ monsters |
| 2663 | * to have this item; after all, the item will be used to strengthen |
| 2664 | * the monster and strong monsters won't use it at all... |
| 2665 | */ |
| 2666 | if (difficulty < 6 && !rn2(30)) |
| 2667 | return rn2(6) ? POT_POLYMORPH : WAN_POLYMORPH; |
| 2668 | |
| 2669 | if (!rn2(40) && !nonliving(pm) && !is_vampshifter(mtmp)) |
| 2670 | return AMULET_OF_LIFE_SAVING; |
| 2671 | |
| 2672 | switch (rn2(3)) { |
| 2673 | case 0: |
| 2674 | if (mtmp->isgd) |
| 2675 | return 0; |
| 2676 | return rn2(6) ? POT_SPEED : WAN_SPEED_MONSTER; |
| 2677 | case 1: |
| 2678 | if (mtmp->mpeaceful && !See_invisible) |
| 2679 | return 0; |
| 2680 | return rn2(6) ? POT_INVISIBILITY : WAN_MAKE_INVISIBLE; |
| 2681 | case 2: |
| 2682 | return POT_GAIN_LEVEL; |
| 2683 | } |
| 2684 | /*NOTREACHED*/ |
| 2685 | return 0; |
| 2686 | } |
| 2687 | |
| 2688 | #if 0 |
| 2689 | /* check whether hero is carrying a corpse or contained petrifier corpse */ |
no test coverage detected