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

Function set_trap

src/apply.c:2915–2952  ·  view source on GitHub ↗

occupation routine called each turn while arming a beartrap or landmine */

Source from the content-addressed store, hash-verified

2913
2914/* occupation routine called each turn while arming a beartrap or landmine */
2915staticfn int
2916set_trap(void)
2917{
2918 struct obj *otmp = gt.trapinfo.tobj;
2919 struct trap *ttmp;
2920 int ttyp;
2921
2922 if (!otmp || !carried(otmp) || !u_at(gt.trapinfo.tx, gt.trapinfo.ty)) {
2923 /* trap object might have been stolen or hero teleported */
2924 reset_trapset();
2925 return 0;
2926 }
2927
2928 if (--gt.trapinfo.time_needed > 0)
2929 return 1; /* still busy */
2930
2931 ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP;
2932 ttmp = maketrap(u.ux, u.uy, ttyp);
2933 if (ttmp) {
2934 ttmp->madeby_u = 1;
2935 feeltrap(ttmp);
2936 if (*in_rooms(u.ux, u.uy, SHOPBASE)) {
2937 add_damage(u.ux, u.uy, 0L); /* schedule removal */
2938 }
2939 if (!gt.trapinfo.force_bungle)
2940 You("finish arming %s.", the(trapname(ttyp, FALSE)));
2941 if (((otmp->cursed || Fumbling) && (rnl(10) > 5))
2942 || gt.trapinfo.force_bungle)
2943 dotrap(ttmp,
2944 (unsigned) (gt.trapinfo.force_bungle ? FORCEBUNGLE : 0));
2945 } else {
2946 /* this shouldn't happen */
2947 Your("trap setting attempt fails.");
2948 }
2949 useup(otmp);
2950 reset_trapset();
2951 return 0;
2952}
2953
2954int
2955use_whip(struct obj *obj)

Callers

nothing calls this directly

Calls 12

reset_trapsetFunction · 0.85
maketrapFunction · 0.85
feeltrapFunction · 0.85
in_roomsFunction · 0.85
add_damageFunction · 0.85
YouFunction · 0.85
theFunction · 0.85
trapnameFunction · 0.85
rnlFunction · 0.85
dotrapFunction · 0.85
YourFunction · 0.85
useupFunction · 0.85

Tested by

no test coverage detected