MCPcopy Index your code
hub / github.com/NetHack/NetHack / hero_breaks

Function hero_breaks

src/dothrow.c:2416–2436  ·  view source on GitHub ↗

* The hero causes breakage of an object (throwing, dropping it, etc.) * Return 0 if the object didn't break, 1 if the object broke. */

Source from the content-addressed store, hash-verified

2414 * Return 0 if the object didn't break, 1 if the object broke.
2415 */
2416int
2417hero_breaks(
2418 struct obj *obj,
2419 coordxy x, coordxy y, /* object location (ox, oy may not be right) */
2420 unsigned breakflags)
2421{
2422 /* from_invent: thrown or dropped by player; maybe on shop bill;
2423 by-hero is implicit so callers don't need to specify BRK_BY_HERO */
2424 boolean from_invent = (breakflags & BRK_FROM_INV) != 0,
2425 in_view = Blind ? FALSE : (from_invent || cansee(x, y));
2426 unsigned brk = (breakflags & BRK_KNOWN_OUTCOME);
2427
2428 /* only call breaktest if caller hasn't already specified the outcome */
2429 if (!brk)
2430 brk = breaktest(obj) ? BRK_KNOWN2BREAK : BRK_KNOWN2NOTBREAK;
2431 if (brk == BRK_KNOWN2NOTBREAK)
2432 return 0;
2433
2434 breakmsg(obj, in_view);
2435 return breakobj(obj, x, y, TRUE, from_invent);
2436}
2437
2438/*
2439 * The object is going to break for a reason other than the hero doing

Callers 4

hitfloorFunction · 0.85
bhitoFunction · 0.85
really_kick_objectFunction · 0.85
hit_barsFunction · 0.85

Calls 3

breaktestFunction · 0.85
breakmsgFunction · 0.85
breakobjFunction · 0.85

Tested by

no test coverage detected