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

Function disarm_holdingtrap

src/trap.c:5552–5591  ·  view source on GitHub ↗

Help a monster out of a bear trap or web, or if no monster is present, disarm a bear trap or destroy a web. Helge Hafting */

Source from the content-addressed store, hash-verified

5550/* Help a monster out of a bear trap or web, or if no monster is
5551 present, disarm a bear trap or destroy a web. Helge Hafting */
5552staticfn int
5553disarm_holdingtrap(struct trap *ttmp)
5554{
5555 struct monst *mtmp;
5556 const char *which = the_your[ttmp->madeby_u];
5557 int fails = try_disarm(ttmp, FALSE);
5558
5559 if (fails < 2)
5560 return fails;
5561
5562 /* ok, disarm it. */
5563
5564 /* untrap the monster, if any.
5565 There's no need for a cockatrice test, only the trap is touched */
5566 if ((mtmp = m_at(ttmp->tx, ttmp->ty)) != 0) {
5567 mtmp->mtrapped = 0;
5568 You("extract %s from %s %s.", mon_nam(mtmp),
5569 which, (ttmp->ttyp == BEAR_TRAP) ? "bear trap" : "web");
5570 reward_untrap(ttmp, mtmp);
5571 } else if (ttmp->ttyp == BEAR_TRAP) {
5572 You("disarm %s bear trap.", which);
5573 cnv_trap_obj(BEARTRAP, 1, ttmp, FALSE);
5574 } else if (ttmp->ttyp == WEB) {
5575 struct obj *wep = (uwep && is_blade(uwep)) ? uwep
5576 : (uswapwep && u.twoweap && is_blade(uswapwep))
5577 ? uswapwep : NULL;
5578
5579 if (wep && wep->oartifact
5580 && (u_wield_art(ART_STING) || attacks(AD_FIRE, wep)))
5581 pline("%s %s through %s web!", bare_artifactname(uwep),
5582 u_wield_art(ART_STING) ? "cuts" : "burns", which);
5583 else if (wep)
5584 You("cut through %s web.", which);
5585 else
5586 You("succeed in removing %s web.", which);
5587 deltrap(ttmp);
5588 }
5589 newsym(u.ux + u.dx, u.uy + u.dy);
5590 return 1;
5591}
5592
5593staticfn int
5594disarm_landmine(struct trap *ttmp) /* Helge Hafting */

Callers 1

untrapFunction · 0.85

Calls 10

try_disarmFunction · 0.85
YouFunction · 0.85
mon_namFunction · 0.85
reward_untrapFunction · 0.85
cnv_trap_objFunction · 0.85
attacksFunction · 0.85
bare_artifactnameFunction · 0.85
deltrapFunction · 0.85
newsymFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected