occupation routine called each turn while arming a beartrap or landmine */
| 2913 | |
| 2914 | /* occupation routine called each turn while arming a beartrap or landmine */ |
| 2915 | staticfn int |
| 2916 | set_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 | |
| 2954 | int |
| 2955 | use_whip(struct obj *obj) |
nothing calls this directly
no test coverage detected