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

Function repair_damage

src/shk.c:4731–4845  ·  view source on GitHub ↗

* 0: repair postponed, 1: silent repair (no messages), 2: normal repair * 3: untrap */

Source from the content-addressed store, hash-verified

4729 * 3: untrap
4730 */
4731staticfn int
4732repair_damage(
4733 struct monst *shkp,
4734 struct damage *tmp_dam,
4735 boolean catchup)
4736{
4737 coordxy x, y;
4738 uint8 litter[9];
4739 struct obj *otmp;
4740 struct trap *ttmp;
4741 int disposition = 1;
4742 boolean seeit, stop_picking = FALSE;
4743
4744 if (!repairable_damage(tmp_dam, shkp))
4745 return 0;
4746
4747 x = tmp_dam->place.x;
4748 y = tmp_dam->place.y;
4749 seeit = cansee(x, y);
4750
4751 ttmp = t_at(x, y);
4752 if (ttmp) {
4753 switch (ttmp->ttyp) {
4754 case LANDMINE:
4755 case BEAR_TRAP:
4756 /* convert to an object */
4757 otmp = mksobj((ttmp->ttyp == LANDMINE) ? LAND_MINE : BEARTRAP,
4758 TRUE, FALSE);
4759 otmp->quan = 1L;
4760 otmp->owt = weight(otmp);
4761 if (!catchup) {
4762 if (canseemon(shkp) && dist2(x, y, shkp->mx, shkp->my) <= 2)
4763 pline("%s untraps %s.", Shknam(shkp), ansimpleoname(otmp));
4764 else if (ttmp->tseen && cansee(ttmp->tx, ttmp->ty))
4765 pline("The %s vanishes.", trapname(ttmp->ttyp, TRUE));
4766 }
4767 (void) mpickobj(shkp, otmp);
4768 break;
4769 case HOLE:
4770 case PIT:
4771 case SPIKED_PIT:
4772 if (!catchup && ttmp->tseen && cansee(ttmp->tx, ttmp->ty))
4773 pline("The %s is filled in.", trapname(ttmp->ttyp, TRUE));
4774 break;
4775 default:
4776 if (!catchup && ttmp->tseen && cansee(ttmp->tx, ttmp->ty))
4777 pline("The %s vanishes.", trapname(ttmp->ttyp, TRUE));
4778 break;
4779 }
4780 deltrap(ttmp);
4781 del_engr_at(x, y);
4782 if (seeit)
4783 newsym(x, y);
4784 if (!catchup)
4785 disposition = 3;
4786 }
4787 if (IS_ROOM(tmp_dam->typ)
4788 || (tmp_dam->typ == levl[x][y].typ

Callers 2

shk_fixes_damageFunction · 0.85
fix_shop_damageFunction · 0.85

Calls 15

repairable_damageFunction · 0.85
t_atFunction · 0.85
mksobjFunction · 0.85
weightFunction · 0.85
canseemonFunction · 0.85
dist2Function · 0.85
ShknamFunction · 0.85
ansimpleonameFunction · 0.85
trapnameFunction · 0.85
mpickobjFunction · 0.85
deltrapFunction · 0.85
del_engr_atFunction · 0.85

Tested by

no test coverage detected