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

Function should_givit

src/eat.c:960–989  ·  view source on GitHub ↗

The "do we or do we not give the intrinsic" logic from givit(), extracted * into its own function. Depends on the monster's level and the type of * intrinsic it is trying to give you. */

Source from the content-addressed store, hash-verified

958 * intrinsic it is trying to give you.
959 */
960boolean
961should_givit(int type, struct permonst *ptr)
962{
963 int chance;
964
965 /* some intrinsics are easier to get than others */
966 switch (type) {
967 case POISON_RES:
968 if ((ptr == &mons[PM_KILLER_BEE] || ptr == &mons[PM_SCORPION])
969 && !rn2(4))
970 chance = 1;
971 else
972 chance = 15;
973 break;
974 case TELEPORT:
975 chance = 10;
976 break;
977 case TELEPORT_CONTROL:
978 chance = 12;
979 break;
980 case TELEPAT:
981 chance = 1;
982 break;
983 default:
984 chance = 15;
985 break;
986 }
987
988 return (ptr->mlevel > rn2(chance));
989}
990
991staticfn boolean
992temp_givit(int type, struct permonst *ptr)

Callers 2

givitFunction · 0.85
mon_givitFunction · 0.85

Calls 1

rn2Function · 0.85

Tested by

no test coverage detected