called when hero is wielding/applying/invoking a carried item, or after undergoing a transformation (alignment change, lycanthropy, polymorph) which might affect item access */
| 2505 | after undergoing a transformation (alignment change, lycanthropy, |
| 2506 | polymorph) which might affect item access */ |
| 2507 | int |
| 2508 | retouch_object( |
| 2509 | struct obj **objp, /* might be destroyed or unintentionally dropped */ |
| 2510 | boolean loseit) /* whether to drop it if hero can longer touch it */ |
| 2511 | { |
| 2512 | struct obj *obj = *objp; |
| 2513 | |
| 2514 | /* allow hero in silver-hating form to try to perform invocation ritual */ |
| 2515 | if (obj->otyp == BELL_OF_OPENING |
| 2516 | && invocation_pos(u.ux, u.uy) && !On_stairs(u.ux, u.uy)) { |
| 2517 | return 1; |
| 2518 | } |
| 2519 | |
| 2520 | if (touch_artifact(obj, &gy.youmonst)) { |
| 2521 | char buf[BUFSZ]; |
| 2522 | int dmg = 0, tmp; |
| 2523 | boolean ag = (objects[obj->otyp].oc_material == SILVER && Hate_silver), |
| 2524 | bane = bane_applies(get_artifact(obj), &gy.youmonst); |
| 2525 | |
| 2526 | /* nothing else to do if hero can successfully handle this object */ |
| 2527 | if (!ag && !bane) |
| 2528 | return 1; |
| 2529 | |
| 2530 | /* hero can't handle this object, but didn't get touch_artifact()'s |
| 2531 | "<obj> evades your grasp|control" message; give an alternate one */ |
| 2532 | You_cant("handle %s%s!", yname(obj), |
| 2533 | obj->owornmask ? " anymore" : ""); |
| 2534 | /* also inflict damage unless touch_artifact() already did so */ |
| 2535 | if (!touch_blasted) { |
| 2536 | const char *what = killer_xname(obj); |
| 2537 | |
| 2538 | if (ag && !obj->oartifact && !bane) { |
| 2539 | /* 'obj' is silver; for rings and wands it ended up that |
| 2540 | way due to randomization at start of game; showing this |
| 2541 | game's silver item without stating that it is silver |
| 2542 | potentially leads to confusion about cause of death */ |
| 2543 | if (obj->oclass == RING_CLASS) |
| 2544 | what = "a silver ring"; |
| 2545 | else if (obj->oclass == WAND_CLASS) |
| 2546 | what = "a silver wand"; |
| 2547 | /* for anything else, stick with killer_xname() */ |
| 2548 | } |
| 2549 | /* damage is somewhat arbitrary; half the usual 1d20 physical |
| 2550 | for silver, 1d10 magical for <foo>bane, potentially both */ |
| 2551 | if (ag) |
| 2552 | tmp = rnd(10), dmg += Maybe_Half_Phys(tmp); |
| 2553 | if (bane) |
| 2554 | dmg += rnd(10); |
| 2555 | Sprintf(buf, "handling %s", what); |
| 2556 | losehp(dmg, buf, KILLED_BY); |
| 2557 | exercise(A_CON, FALSE); |
| 2558 | } |
| 2559 | } |
| 2560 | |
| 2561 | /* removing a worn item might result in loss of levitation, |
| 2562 | dropping the hero onto a polymorph trap or into water or |
| 2563 | lava and potentially dropping or destroying the item */ |
| 2564 | if (obj->owornmask) { |
no test coverage detected