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

Function help_monster_out

src/trap.c:5699–5791  ·  view source on GitHub ↗

Help trapped monster (out of a (spiked) pit) */

Source from the content-addressed store, hash-verified

5697
5698/* Help trapped monster (out of a (spiked) pit) */
5699staticfn int
5700help_monster_out(
5701 struct monst *mtmp,
5702 struct trap *ttmp)
5703{
5704 int xtra_wt;
5705 struct obj *otmp;
5706 boolean uprob;
5707
5708 /*
5709 * This works when levitating too -- consistent with the ability
5710 * to hit monsters while levitating.
5711 *
5712 * Should perhaps check that our hero has arms/hands at the
5713 * moment. Helping can also be done by engulfing...
5714 *
5715 * Test the monster first - monsters are displayed before traps.
5716 */
5717 if (!mtmp->mtrapped) {
5718 pline("%s isn't trapped.", Monnam(mtmp));
5719 return 0;
5720 }
5721 /* Do you have the necessary capacity to lift anything? */
5722 if (check_capacity((char *) 0))
5723 return 1;
5724
5725 /* Will our hero succeed? */
5726 if ((uprob = untrap_prob(ttmp)) != 0 && !helpless(mtmp)) {
5727 You("try to reach out your %s, but %s backs away skeptically.",
5728 makeplural(body_part(ARM)), mon_nam(mtmp));
5729 return 1;
5730 }
5731
5732 /* is it a cockatrice?... */
5733 if (touch_petrifies(mtmp->data) && !uarmg && !Stone_resistance) {
5734 const char *mtmp_pmname = mon_pmname(mtmp);
5735
5736 You("grab the trapped %s using your bare %s.",
5737 mtmp_pmname, makeplural(body_part(HAND)));
5738
5739 if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) {
5740 display_nhwindow(WIN_MESSAGE, FALSE);
5741 } else {
5742 char kbuf[BUFSZ];
5743
5744 Sprintf(kbuf, "trying to help %s out of a pit", an(mtmp_pmname));
5745 instapetrify(kbuf);
5746 return 1;
5747 }
5748 }
5749 /* need to do cockatrice check first if sleeping or paralyzed */
5750 if (uprob) {
5751 You("try to grab %s, but cannot get a firm grasp.", mon_nam(mtmp));
5752 if (mtmp->msleeping) {
5753 mtmp->msleeping = 0;
5754 pline("%s awakens.", Monnam(mtmp));
5755 }
5756 return 1;

Callers 1

untrapFunction · 0.85

Calls 15

MonnamFunction · 0.85
check_capacityFunction · 0.85
untrap_probFunction · 0.85
YouFunction · 0.85
makepluralFunction · 0.85
body_partFunction · 0.85
mon_namFunction · 0.85
mon_pmnameFunction · 0.85
poly_when_stonedFunction · 0.85
polymonFunction · 0.85
anFunction · 0.85
instapetrifyFunction · 0.85

Tested by

no test coverage detected