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

Function destroyable

src/zap.c:5612–5650  ·  view source on GitHub ↗

Return TRUE if obj is eligible to pass to maybe_destroy_item given * the type of elemental damage it's being subjected to. * Note that things like the Book of the Dead are eligible even though they * won't get destroyed, because it will attempt to be destroyed but print a * special message instead. */

Source from the content-addressed store, hash-verified

5610 * won't get destroyed, because it will attempt to be destroyed but print a
5611 * special message instead. */
5612staticfn boolean
5613destroyable(struct obj *obj, int adtyp)
5614{
5615 if (obj->oartifact) {
5616 /* don't destroy artifacts */
5617 return FALSE;
5618 }
5619 if (obj->in_use && obj->quan == 1L) {
5620 /* not available for destroying */
5621 return FALSE;
5622 }
5623 if (adtyp == AD_FIRE) {
5624 /* fire-magic items are immune */
5625 if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL) {
5626 return FALSE;
5627 }
5628 if (obj->otyp == GLOB_OF_GREEN_SLIME || obj->oclass == POTION_CLASS
5629 || obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS) {
5630 return TRUE;
5631 }
5632 } else if (adtyp == AD_COLD) {
5633 /* non-water potions don't freeze and shatter */
5634 if (obj->oclass == POTION_CLASS && obj->otyp != POT_OIL) {
5635 return TRUE;
5636 }
5637 } else if (adtyp == AD_ELEC) {
5638 if (obj->oclass != RING_CLASS && obj->oclass != WAND_CLASS) {
5639 return FALSE;
5640 }
5641 /* electric-magic items are immune */
5642 if (obj->otyp != RIN_SHOCK_RESISTANCE && obj->otyp != WAN_LIGHTNING) {
5643 return TRUE;
5644 }
5645 /* There used to be a commented out bit of code that would exclude
5646 * gc.current_wand, but it wasn't used, so it wasn't moved into this
5647 * function. */
5648 }
5649 return FALSE;
5650}
5651
5652/* convert attack damage AD_foo to property resistance */
5653staticfn int

Callers 1

destroy_itemsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected