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

Function untrap_box

src/trap.c:5820–5844  ·  view source on GitHub ↗

check a particular container for a trap and optionally disarm it */

Source from the content-addressed store, hash-verified

5818
5819/* check a particular container for a trap and optionally disarm it */
5820staticfn void
5821untrap_box(
5822 struct obj *box,
5823 boolean force,
5824 boolean confused)
5825{
5826 if ((box->otrapped
5827 && (force || (!confused && rn2(MAXULEV + 1 - u.ulevel) < 10)))
5828 || box->tknown
5829 || (!force && confused && !rn2(3))) {
5830 if (!(box->tknown && box->dknown))
5831 You("find a trap on %s!", the(xname(box)));
5832 else
5833 pline("There's a trap on %s.", the(xname(box)));
5834 box->tknown = 1;
5835 observe_object(box);
5836 if (!confused)
5837 exercise(A_WIS, TRUE);
5838
5839 if (ynq("Disarm it?") == 'y')
5840 disarm_box(box, force, confused);
5841 } else {
5842 You("find no traps on %s.", the(xname(box)));
5843 }
5844}
5845
5846/* hero is able to attempt untrap, so do so */
5847int

Callers 1

untrapFunction · 0.85

Calls 8

rn2Function · 0.85
YouFunction · 0.85
theFunction · 0.85
xnameFunction · 0.85
observe_objectFunction · 0.85
exerciseFunction · 0.85
disarm_boxFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected