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

Function breakobj

src/dothrow.c:2479–2574  ·  view source on GitHub ↗

* Break an object. Breakable armor goes through erosion steps; other * items break unconditionally. Assumes all resistance checks * and break messages have been delivered prior to getting here. * (No longer true; breakmsg() is silent for crackable armor and we * call erode_obj() for it and that delivers a damaged-the-item message.) */

Source from the content-addressed store, hash-verified

2477 * call erode_obj() for it and that delivers a damaged-the-item message.)
2478 */
2479int
2480breakobj(
2481 struct obj *obj,
2482 coordxy x, coordxy y, /* object location (ox, oy may not be right) */
2483 boolean hero_caused, /* is this the hero's fault? */
2484 boolean from_invent)
2485{
2486 boolean fracture = FALSE;
2487 boolean explosion = FALSE;
2488
2489 if (is_crackable(obj)) /* if erodeproof, erode_obj() will say so */
2490 return (erode_obj(obj, armor_simple_name(obj), ERODE_CRACK,
2491 EF_DESTROY | EF_VERBOSE) == ER_DESTROYED);
2492
2493 switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
2494 case MIRROR:
2495 if (hero_caused)
2496 change_luck(-2);
2497 break;
2498 case POT_WATER: /* really, all potions */
2499 obj->in_use = 1; /* in case it's fatal */
2500 if (obj->otyp == POT_OIL && obj->lamplit) {
2501 explode_oil(obj, x, y);
2502 } else if (next2u(x, y)) {
2503 if (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data)) {
2504 /* wet towel protects both eyes and breathing */
2505 if (obj->otyp != POT_WATER && !Half_gas_damage) {
2506 if (!breathless(gy.youmonst.data)) {
2507 /* [what about "familiar odor" when known?] */
2508 You("smell a peculiar odor...");
2509 } else {
2510 const char *eyes = body_part(EYE);
2511
2512 if (eyecount(gy.youmonst.data) != 1)
2513 eyes = makeplural(eyes);
2514 Your("%s %s.", eyes, vtense(eyes, "water"));
2515 }
2516 }
2517 potionbreathe(obj);
2518 }
2519 }
2520 /* monster breathing isn't handled... [yet?] */
2521 break;
2522 case EXPENSIVE_CAMERA:
2523 release_camera_demon(obj, x, y);
2524 break;
2525 case EGG:
2526 /* breaking your own eggs is bad luck */
2527 if (hero_caused && obj->spe && ismnum(obj->corpsenm))
2528 change_luck((schar) -min(obj->quan, 5L));
2529 if (obj->corpsenm == PM_PYROLISK)
2530 explosion = TRUE;
2531 break;
2532 case BOULDER:
2533 case STATUE:
2534 /* caller will handle object disposition;
2535 we're just doing the shop theft handling */
2536 fracture = TRUE;

Callers 6

flooreffectsFunction · 0.85
toss_upFunction · 0.85
throwitFunction · 0.85
hero_breaksFunction · 0.85
breaksFunction · 0.85
fracture_rockFunction · 0.85

Calls 15

erode_objFunction · 0.85
armor_simple_nameFunction · 0.85
change_luckFunction · 0.85
explode_oilFunction · 0.85
YouFunction · 0.85
body_partFunction · 0.85
makepluralFunction · 0.85
YourFunction · 0.85
vtenseFunction · 0.85
potionbreatheFunction · 0.85
release_camera_demonFunction · 0.85
check_shop_objFunction · 0.85

Tested by

no test coverage detected