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

Function defends

src/artifact.c:635–683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635boolean
636defends(int adtyp, struct obj *otmp)
637{
638 const struct artifact *weap;
639
640 if (!otmp)
641 return FALSE;
642 if ((weap = get_artifact(otmp)) != &artilist[ART_NONARTIFACT])
643 return (boolean) (weap->defn.adtyp == adtyp);
644 if (Is_dragon_armor(otmp)) {
645 int otyp = otmp->otyp;
646
647 /* convert mail to scales to simplify testing */
648 if (Is_dragon_mail(otmp))
649 otyp += GRAY_DRAGON_SCALES - GRAY_DRAGON_SCALE_MAIL;
650
651 switch (adtyp) {
652 case AD_MAGM: /* magic missiles => general magic resistance */
653 return (otyp == GRAY_DRAGON_SCALES);
654 case AD_HALU: /* confers hallucination resistance */
655 return (otyp == GOLD_DRAGON_SCALES);
656 case AD_FIRE:
657 /*case AD_BLND: -- gives infravision but does not prevent blindness */
658 return (otyp == RED_DRAGON_SCALES); /* red but not gold */
659 case AD_COLD:
660 /*case AD_FAMN: -- slows digestion but does not override Famine */
661 return (otyp == WHITE_DRAGON_SCALES); /* white but not silver */
662 case AD_DRST: /* drain strength => poison */
663 case AD_DISE: /* blocks disease but not slime */
664 return (otyp == GREEN_DRAGON_SCALES);
665 case AD_SLEE: /* sleep */
666 case AD_PLYS: /* paralysis => free action */
667 return (otyp == ORANGE_DRAGON_SCALES);
668 case AD_DISN: /* disintegration */
669 case AD_DRLI: /* level drain resistance */
670 return (otyp == BLACK_DRAGON_SCALES);
671 case AD_ELEC: /* electricity == lightning */
672 case AD_SLOW: /* confers speed so blocks speed removal */
673 return (otyp == BLUE_DRAGON_SCALES);
674 case AD_ACID:
675 case AD_STON: /* petrification resistance */
676 return (otyp == YELLOW_DRAGON_SCALES);
677 default:
678 /* SILVER_DRAGON_SCALES don't resist any particular attack type */
679 break;
680 }
681 }
682 return FALSE;
683}
684
685/* used for monsters */
686boolean

Callers 7

defendedFunction · 0.85
Resists_ElemFunction · 0.85
resists_magmFunction · 0.85
resists_blnd_by_artiFunction · 0.85
mhitm_ad_drinFunction · 0.85
mhitm_ad_wereFunction · 0.85
drain_itemFunction · 0.85

Calls 1

get_artifactFunction · 0.85

Tested by

no test coverage detected