MCPcopy Create free account
hub / github.com/NetHack/NetHack / rnd_misc_item

Function rnd_misc_item

src/muse.c:2653–2686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2651}
2652
2653int
2654rnd_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 */

Callers 2

mk_mplayerFunction · 0.85
m_initinvFunction · 0.85

Calls 2

attacktypeFunction · 0.85
rn2Function · 0.85

Tested by

no test coverage detected