return 1 if the wand is broken, hence some time elapsed */
| 3906 | |
| 3907 | /* return 1 if the wand is broken, hence some time elapsed */ |
| 3908 | staticfn int |
| 3909 | do_break_wand(struct obj *obj) |
| 3910 | { |
| 3911 | #define BY_OBJECT ((struct monst *) 0) |
| 3912 | static const char nothing_else_happens[] = "But nothing else happens..."; |
| 3913 | int i; |
| 3914 | coordxy x, y; |
| 3915 | struct monst *mon; |
| 3916 | int dmg, damage; |
| 3917 | boolean affects_objects; |
| 3918 | boolean shop_damage = FALSE; |
| 3919 | boolean fillmsg = FALSE; |
| 3920 | char confirm[QBUFSZ], buf[BUFSZ]; |
| 3921 | boolean is_fragile = (objdescr_is(obj, "balsa") |
| 3922 | || objdescr_is(obj, "glass")); |
| 3923 | |
| 3924 | if (nohands(gy.youmonst.data)) { |
| 3925 | You_cant("break %s without hands!", yname(obj)); |
| 3926 | return ECMD_OK; |
| 3927 | } else if (!freehand()) { |
| 3928 | Your("%s are occupied!", makeplural(body_part(HAND))); |
| 3929 | return ECMD_OK; |
| 3930 | } else if (ACURR(A_STR) < (is_fragile ? 5 : 10)) { |
| 3931 | You("don't have the strength to break %s!", yname(obj)); |
| 3932 | return ECMD_OK; |
| 3933 | } |
| 3934 | if (!paranoid_query(ParanoidBreakwand, |
| 3935 | safe_qbuf(confirm, |
| 3936 | "Are you really sure you want to break ", |
| 3937 | "?", obj, yname, ysimple_name, "the wand"))) |
| 3938 | return ECMD_OK; |
| 3939 | pline("Raising %s high above your %s, you %s it in two!", yname(obj), |
| 3940 | body_part(HEAD), is_fragile ? "snap" : "break"); |
| 3941 | |
| 3942 | /* [ALI] Do this first so that wand is removed from bill. Otherwise, |
| 3943 | * the freeinv() below also hides it from setpaid() which causes problems. |
| 3944 | */ |
| 3945 | if (obj->unpaid) { |
| 3946 | check_unpaid(obj); /* Extra charge for use */ |
| 3947 | costly_alteration(obj, COST_DSTROY); |
| 3948 | } |
| 3949 | |
| 3950 | gc.current_wand = obj; /* destroy_items might reset this */ |
| 3951 | freeinv(obj); /* hide it from destroy_items instead... */ |
| 3952 | setnotworn(obj); /* so we need to do this ourselves */ |
| 3953 | |
| 3954 | if (!zappable(obj)) { |
| 3955 | pline(nothing_else_happens); |
| 3956 | discard_broken_wand(); |
| 3957 | return ECMD_TIME; |
| 3958 | } |
| 3959 | /* successful call to zappable() consumes a charge; put it back */ |
| 3960 | obj->spe++; |
| 3961 | /* might have "wrested" a final charge, taking it from 0 to -1; |
| 3962 | if so, we just brought it back up to 0, which wouldn't do much |
| 3963 | below so give it 1..3 charges now, usually making it stronger |
| 3964 | than an ordinary last charge (the wand is already gone from |
| 3965 | inventory, so perm_invent can't accidentally reveal this) */ |
no test coverage detected