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

Function breaktest

src/dothrow.c:2581–2609  ·  view source on GitHub ↗

* Check to see if obj (which has just hit hard something at speed, e.g. * thrown or dropped from height) is going to break, but don't actually * break it. Return 0 if the object isn't going to break, 1 if it is. */

Source from the content-addressed store, hash-verified

2579 * break it. Return 0 if the object isn't going to break, 1 if it is.
2580 */
2581boolean
2582breaktest(struct obj *obj)
2583{
2584 int nonbreakchance = 1; /* chance for non-artifacts to resist */
2585
2586 /* this may need to be changed if actual glass armor gets added someday;
2587 for now, it affects crystal plate mail and helm of brilliance;
2588 either of them will have to be cracked 4 times before breaking */
2589 if (obj->oclass == ARMOR_CLASS && objects[obj->otyp].oc_material == GLASS)
2590 nonbreakchance = 90;
2591
2592 if (obj_resists(obj, nonbreakchance, 99))
2593 return FALSE;
2594 if (objects[obj->otyp].oc_material == GLASS && !obj->oartifact
2595 && obj->oclass != GEM_CLASS)
2596 return TRUE;
2597 switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
2598 case EXPENSIVE_CAMERA:
2599 case POT_WATER: /* really, all potions */
2600 case EGG:
2601 case CREAM_PIE:
2602 case MELON:
2603 case ACID_VENOM:
2604 case BLINDING_VENOM:
2605 return TRUE;
2606 default:
2607 return FALSE;
2608 }
2609}
2610
2611staticfn void
2612breakmsg(struct obj *obj, boolean in_view)

Callers 9

hmon_hitmon_misc_objFunction · 0.85
domove_fight_ironbarsFunction · 0.85
toss_upFunction · 0.85
throwitFunction · 0.85
hero_breaksFunction · 0.85
breaksFunction · 0.85
ship_objectFunction · 0.85
obj_deliveryFunction · 0.85
mktrap_victimFunction · 0.85

Calls 1

obj_resistsFunction · 0.85

Tested by

no test coverage detected