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

Function should_mulch_missile

src/dothrow.c:1975–2002  ·  view source on GitHub ↗

whether or not object should be destroyed when it hits its target */

Source from the content-addressed store, hash-verified

1973
1974/* whether or not object should be destroyed when it hits its target */
1975boolean
1976should_mulch_missile(struct obj *obj)
1977{
1978 boolean broken;
1979 int chance;
1980
1981 /* only ammo (excluding magic stones) or missiles will break */
1982 if (!obj || !(is_ammo(obj) || is_missile(obj))
1983 || obj->otyp == BOOMERANG
1984 || objects[obj->otyp].oc_magic)
1985 return FALSE;
1986
1987 /* we had been breaking 2/3 of everything unconditionally. we still don't
1988 want anything to survive unconditionally, but we need ammo to stay
1989 around longer on average. */
1990 chance = 3 + greatest_erosion(obj) - obj->spe;
1991 broken = chance > 1 ? rn2(chance) : !rn2(4);
1992 if (obj->blessed && (svc.context.mon_moving ? !rn2(3) : !rnl(4)))
1993 broken = FALSE;
1994
1995 /* Flint and hard gems don't break easily */
1996 if (((obj->oclass == GEM_CLASS && objects[obj->otyp].oc_tough)
1997 || obj->otyp == FLINT)
1998 && !rn2(2))
1999 broken = FALSE;
2000
2001 return broken;
2002}
2003
2004/*
2005 * Object thrown by player arrives at monster's location.

Callers 2

thitmonstFunction · 0.85
drop_throwFunction · 0.85

Calls 2

rn2Function · 0.85
rnlFunction · 0.85

Tested by

no test coverage detected