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

Function mon_would_take_item

src/monmove.c:998–1032  ·  view source on GitHub ↗

monster mtmp would love to take object otmp? */

Source from the content-addressed store, hash-verified

996
997/* monster mtmp would love to take object otmp? */
998boolean
999mon_would_take_item(struct monst *mtmp, struct obj *otmp)
1000{
1001 int pctload = (curr_mon_load(mtmp) * 100) / max_mon_load(mtmp);
1002
1003 if (otmp == uball || otmp == uchain)
1004 return FALSE;
1005 if (mtmp->mtame && otmp->cursed)
1006 return FALSE; /* note: will get overridden if mtmp will eat otmp */
1007 if (is_unicorn(mtmp->data) && objects[otmp->otyp].oc_material != GEMSTONE)
1008 return FALSE;
1009 if (!mindless(mtmp->data) && !is_animal(mtmp->data) && pctload < 75
1010 && searches_for_item(mtmp, otmp))
1011 return TRUE;
1012 if (likes_gold(mtmp->data) && otmp->otyp == GOLD_PIECE && pctload < 95)
1013 return TRUE;
1014 if (likes_gems(mtmp->data) && otmp->oclass == GEM_CLASS
1015 && objects[otmp->otyp].oc_material != MINERAL && pctload < 85)
1016 return TRUE;
1017 if (likes_objs(mtmp->data) && strchr(practical, otmp->oclass)
1018 && pctload < 75)
1019 return TRUE;
1020 if (likes_magic(mtmp->data) && strchr(magical, otmp->oclass)
1021 && pctload < 85)
1022 return TRUE;
1023 if (throws_rocks(mtmp->data) && otmp->otyp == BOULDER
1024 && pctload < 50 && !Sokoban)
1025 return TRUE;
1026 if (mtmp->data == &mons[PM_GELATINOUS_CUBE]
1027 && otmp->oclass != ROCK_CLASS && otmp->oclass != BALL_CLASS
1028 && !(otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])))
1029 return TRUE;
1030
1031 return FALSE;
1032}
1033
1034/* monster mtmp would love to consume object otmp, without picking it up */
1035boolean

Callers 3

mpickstuffFunction · 0.85
m_search_itemsFunction · 0.85
mon_likes_objpile_atFunction · 0.85

Calls 3

curr_mon_loadFunction · 0.85
max_mon_loadFunction · 0.85
searches_for_itemFunction · 0.85

Tested by

no test coverage detected