* The hero causes breakage of an object (throwing, dropping it, etc.) * Return 0 if the object didn't break, 1 if the object broke. */
| 2414 | * Return 0 if the object didn't break, 1 if the object broke. |
| 2415 | */ |
| 2416 | int |
| 2417 | hero_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 |