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

Function hitmm

src/mhitm.c:643–732  ·  view source on GitHub ↗

Returns the result of mdamagem(). */

Source from the content-addressed store, hash-verified

641
642/* Returns the result of mdamagem(). */
643staticfn int
644hitmm(
645 struct monst *magr,
646 struct monst *mdef,
647 struct attack *mattk,
648 struct obj *mwep,
649 int dieroll)
650{
651 int compat;
652 boolean weaponhit = (mattk->aatyp == AT_WEAP
653 || (mattk->aatyp == AT_CLAW && mwep)),
654 silverhit = (weaponhit && mwep
655 && objects[mwep->otyp].oc_material == SILVER);
656
657 pre_mm_attack(magr, mdef);
658
659 compat = !magr->mcan ? could_seduce(magr, mdef, mattk) : 0;
660 if (!compat && shade_miss(magr, mdef, mwep, FALSE, gv.vis))
661 return M_ATTK_MISS; /* bypass mdamagem() */
662
663 if (gv.vis) {
664 char buf[BUFSZ], magr_name[BUFSZ];
665
666 Strcpy(magr_name, Monnam(magr));
667 if (compat) {
668 Snprintf(buf, sizeof buf, "%s %s", magr_name,
669 mdef->mcansee ? "smiles at" : "talks to");
670 pline("%s %s %s.", buf, mon_nam(mdef),
671 (compat == 2) ? "engagingly" : "seductively");
672 } else {
673 buf[0] = '\0';
674 switch (mattk->aatyp) {
675 case AT_BITE:
676 Snprintf(buf, sizeof buf, "%s bites", magr_name);
677 break;
678 case AT_STNG:
679 Snprintf(buf, sizeof buf, "%s stings", magr_name);
680 break;
681 case AT_BUTT:
682 Snprintf(buf, sizeof buf, "%s butts", magr_name);
683 break;
684 case AT_TUCH:
685 Snprintf(buf, sizeof buf, "%s touches", magr_name);
686 break;
687 case AT_TENT:
688 Snprintf(buf, sizeof buf, "%s tentacles suck",
689 s_suffix(magr_name));
690 break;
691 case AT_HUGS:
692 if (magr != u.ustuck) {
693 Snprintf(buf, sizeof buf, "%s squeezes", magr_name);
694 break;
695 }
696 FALLTHROUGH;
697 /*FALLTHRU*/
698 default:
699 if (!weaponhit || !mwep || !mwep->oartifact)
700 Snprintf(buf, sizeof buf, "%s hits", magr_name);

Callers 1

mattackmFunction · 0.85

Calls 13

pre_mm_attackFunction · 0.85
could_seduceFunction · 0.85
shade_missFunction · 0.85
MonnamFunction · 0.85
mon_namFunction · 0.85
s_suffixFunction · 0.85
mon_nam_tooFunction · 0.85
mon_hates_silverFunction · 0.85
strsubstFunction · 0.85
simpleonamesFunction · 0.85
noisesFunction · 0.85
mdamagemFunction · 0.85

Tested by

no test coverage detected