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

Function failed_grab

src/mhitm.c:596–640  ·  view source on GitHub ↗

can't hold an unsolid target (ghosts, lights, vortices, most elementals) or a long worm tail */

Source from the content-addressed store, hash-verified

594/* can't hold an unsolid target (ghosts, lights, vortices, most elementals)
595 or a long worm tail */
596boolean
597failed_grab(
598 struct monst *magr,
599 struct monst *mdef,
600 struct attack *mattk)
601{
602 if ((unsolid(mdef->data) || gn.notonhead)
603 /* hug attack: most holders (owlbear, python, pit fiend, &c);
604 wrap damage: eel grabbing, trapper/lurker-above engulfing;
605 stick-to damage: mimic, lichen;
606 digestion damage: purple worm swallowing */
607 && (mattk->aatyp == AT_HUGS || mattk->adtyp == AD_WRAP
608 || mattk->adtyp == AD_STCK || mattk->adtyp == AD_DGST)) {
609 if ((gv.vis && canspotmon(mdef)) /* mon-vs-mon */
610 || magr == &gy.youmonst || mdef == &gy.youmonst) {
611 char magrnam[BUFSZ], mdefnam[BUFSZ];
612 boolean tailmiss = gn.notonhead;
613 const char *verb = (mattk->adtyp == AD_DGST) ? "gulp"
614 : (mattk->adtyp == AD_STCK) ? "adhere"
615 : "grab";
616
617 /* beware of "Foo's grab passes through Bar's ghost";
618 mon_nam(x_monnam) calls s_suffix() for named ghosts and
619 s_suffix() uses a single static buffer; make copies of both
620 names to overcome that [note: comment predates 'tailmiss'] */
621 Strcpy(magrnam, (magr == &gy.youmonst) ? "Your"
622 : s_suffix(Monnam(magr)));
623 if (!tailmiss) {
624 Strcpy(mdefnam, (mdef == &gy.youmonst) ? "you"
625 : mon_nam(mdef));
626 } else {
627 /* hero poly'd into long worm can't grow tail
628 so no 'youmonst' handling is needed here */
629 Sprintf(mdefnam, "%s tail", s_suffix(some_mon_nam(mdef)));
630 }
631 /* unsolid grab misses are actually somewhat iffy--how come
632 ordinary attacks don't also pass right through? */
633 pline("%.99s %s attempt %s %.99s!", magrnam, verb,
634 !tailmiss ? "passes right through" : "fails to hold",
635 mdefnam);
636 }
637 return TRUE;
638 }
639 return FALSE;
640}
641
642/* Returns the result of mdamagem(). */
643staticfn int

Callers 4

hmonasFunction · 0.85
mattackmFunction · 0.85
mattackuFunction · 0.85
gulpmuFunction · 0.85

Calls 5

s_suffixFunction · 0.85
MonnamFunction · 0.85
mon_namFunction · 0.85
some_mon_namFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected