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

Function searches_for_item

src/muse.c:2705–2792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2703#endif
2704
2705boolean
2706searches_for_item(struct monst *mon, struct obj *obj)
2707{
2708 int typ = obj->otyp;
2709
2710 /* don't let monsters interact with protected items on the floor */
2711 if (obj->where == OBJ_FLOOR
2712 && (obj->ox == mon->mx && obj->oy == mon->my)
2713 && onscary(obj->ox, obj->oy, mon)) {
2714 return FALSE;
2715 }
2716
2717 if (is_animal(mon->data) || mindless(mon->data)
2718 || mon->data == &mons[PM_GHOST]) /* don't loot bones piles */
2719 return FALSE;
2720
2721 if (typ == WAN_MAKE_INVISIBLE || typ == POT_INVISIBILITY)
2722 return (boolean) (!mon->minvis && !mon->invis_blkd
2723 && !attacktype(mon->data, AT_GAZE));
2724 if (typ == WAN_SPEED_MONSTER || typ == POT_SPEED)
2725 return (boolean) (mon->mspeed != MFAST);
2726
2727 switch (obj->oclass) {
2728 case WAND_CLASS:
2729 if (obj->spe <= 0)
2730 return FALSE;
2731 if (typ == WAN_DIGGING)
2732 return (boolean) !is_floater(mon->data);
2733 if (typ == WAN_POLYMORPH)
2734 return (boolean) (mons[monsndx(mon->data)].difficulty < 6);
2735 if (objects[typ].oc_dir == RAY || typ == WAN_STRIKING
2736 || typ == WAN_UNDEAD_TURNING
2737 || typ == WAN_TELEPORTATION || typ == WAN_CREATE_MONSTER)
2738 return TRUE;
2739 break;
2740 case POTION_CLASS:
2741 if (typ == POT_HEALING || typ == POT_EXTRA_HEALING
2742 || typ == POT_FULL_HEALING || typ == POT_POLYMORPH
2743 || typ == POT_GAIN_LEVEL || typ == POT_PARALYSIS
2744 || typ == POT_SLEEPING || typ == POT_ACID || typ == POT_CONFUSION)
2745 return TRUE;
2746 if (typ == POT_BLINDNESS && !attacktype(mon->data, AT_GAZE))
2747 return TRUE;
2748 break;
2749 case SCROLL_CLASS:
2750 if (typ == SCR_TELEPORTATION || typ == SCR_CREATE_MONSTER
2751 || typ == SCR_EARTH || typ == SCR_FIRE)
2752 return TRUE;
2753 break;
2754 case AMULET_CLASS:
2755 if (typ == AMULET_OF_LIFE_SAVING)
2756 return (boolean) !(nonliving(mon->data) || is_vampshifter(mon));
2757 if (typ == AMULET_OF_REFLECTION || typ == AMULET_OF_GUARDING)
2758 return TRUE;
2759 break;
2760 case TOOL_CLASS:
2761 if (typ == PICK_AXE)
2762 return (boolean) needspick(mon->data);

Callers 1

mon_would_take_itemFunction · 0.85

Calls 5

onscaryFunction · 0.85
attacktypeFunction · 0.85
can_blowFunction · 0.85
cures_stoningFunction · 0.85
mcould_eat_tinFunction · 0.85

Tested by

no test coverage detected