hero has changed form or alignment; an item which is worn/wielded or an artifact which conveys something via being carried or which has an #invoke effect currently in operation undergoes a touch test; if it fails, it will be unworn/unwielded and maybe dropped */
| 2595 | has an #invoke effect currently in operation undergoes a touch test; |
| 2596 | if it fails, it will be unworn/unwielded and maybe dropped */ |
| 2597 | staticfn boolean |
| 2598 | untouchable( |
| 2599 | struct obj *obj, /* object to test; in invent or is steed's saddle */ |
| 2600 | boolean drop_untouchable) /* whether to drop it if it can't be touched */ |
| 2601 | { |
| 2602 | struct artifact *art; |
| 2603 | boolean beingworn, carryeffect, invoked; |
| 2604 | long wearmask = ~(W_QUIVER | (u.twoweap ? 0L : W_SWAPWEP) | W_BALL); |
| 2605 | |
| 2606 | beingworn = (obj /* never Null; this pacifies static analysis when |
| 2607 | * the get_artifact() macro tests 'obj' for Null */ |
| 2608 | && ((obj->owornmask & wearmask) != 0L |
| 2609 | /* some items in use don't have any wornmask setting */ |
| 2610 | || (obj->oclass == TOOL_CLASS |
| 2611 | && (obj->lamplit |
| 2612 | || (obj->otyp == LEASH && obj->leashmon) |
| 2613 | || (Is_container(obj) && Has_contents(obj)))))); |
| 2614 | |
| 2615 | if ((art = get_artifact(obj)) != &artilist[ART_NONARTIFACT]) { |
| 2616 | carryeffect = (art->cary.adtyp || art->cspfx); |
| 2617 | invoked = (art->inv_prop > 0 && art->inv_prop <= LAST_PROP |
| 2618 | && (u.uprops[art->inv_prop].extrinsic & W_ARTI) != 0L); |
| 2619 | } else { |
| 2620 | carryeffect = invoked = FALSE; |
| 2621 | } |
| 2622 | |
| 2623 | if (beingworn || carryeffect || invoked) { |
| 2624 | if (!retouch_object(&obj, drop_untouchable)) { |
| 2625 | /* "<artifact> is beyond your control" or "you can't handle |
| 2626 | <object>" has been given and it is now unworn/unwielded |
| 2627 | and possibly dropped (depending upon caller); if dropped, |
| 2628 | carried effect was turned off, else we leave that alone; |
| 2629 | we turn off invocation property here if still carried */ |
| 2630 | if (invoked && obj) |
| 2631 | (void) arti_invoke(obj); /* reverse #invoke */ |
| 2632 | return TRUE; |
| 2633 | } |
| 2634 | } |
| 2635 | return FALSE; |
| 2636 | } |
| 2637 | |
| 2638 | /* check all items currently in use (mostly worn) for touchability */ |
| 2639 | void |
no test coverage detected