teleport the hero; usually discover scroll of teleportation if via scroll */
| 846 | |
| 847 | /* teleport the hero; usually discover scroll of teleportation if via scroll */ |
| 848 | void |
| 849 | scrolltele(struct obj *scroll) |
| 850 | { |
| 851 | coord cc; |
| 852 | |
| 853 | /* Disable teleportation in stronghold && Vlad's Tower */ |
| 854 | if (noteleport_level(&gy.youmonst) && !wizard) { |
| 855 | pline("A mysterious force prevents you from teleporting!"); |
| 856 | if (scroll) |
| 857 | learnscroll(scroll); /* this is obviously a teleport scroll */ |
| 858 | return; |
| 859 | } |
| 860 | |
| 861 | /* don't show trap if "Sorry..." */ |
| 862 | if (!Blinded) |
| 863 | make_blinded(0L, FALSE); |
| 864 | |
| 865 | if ((u.uhave.amulet || On_W_tower_level(&u.uz)) && !rn2(3)) { |
| 866 | You_feel("disoriented for a moment."); |
| 867 | /* don't discover the scroll [at least not yet for wizard override]; |
| 868 | disorientation doesn't reveal that this is a teleport attempt */ |
| 869 | if (!wizard || y_n("Override?") != 'y') |
| 870 | return; |
| 871 | } |
| 872 | if (((Teleport_control || (scroll && scroll->blessed)) && !Stunned) |
| 873 | || wizard) { |
| 874 | if (unconscious()) { |
| 875 | pline("Being unconscious, you cannot control your teleport."); |
| 876 | } else { |
| 877 | char whobuf[BUFSZ]; |
| 878 | |
| 879 | Strcpy(whobuf, "you"); |
| 880 | if (u.usteed) |
| 881 | Sprintf(eos(whobuf), " and %s", mon_nam(u.usteed)); |
| 882 | pline("Where do %s want to be teleported?", whobuf); |
| 883 | if (scroll) |
| 884 | learnscroll(scroll); |
| 885 | cc.x = u.ux; |
| 886 | cc.y = u.uy; |
| 887 | if (isok(iflags.travelcc.x, iflags.travelcc.y)) { |
| 888 | /* The player showed some interest in traveling here; |
| 889 | * pre-suggest this coordinate. */ |
| 890 | cc = iflags.travelcc; |
| 891 | } |
| 892 | if (getpos(&cc, TRUE, "the desired position") < 0) |
| 893 | return; /* abort */ |
| 894 | /* possible extensions: introduce a small error if |
| 895 | magic power is low; allow transfer to solid rock */ |
| 896 | if (teleok(cc.x, cc.y, FALSE)) { |
| 897 | /* for scroll, discover it regardless of destination */ |
| 898 | teleds(cc.x, cc.y, TELEDS_TELEPORT); |
| 899 | if (u_at(iflags.travelcc.x, iflags.travelcc.y)) |
| 900 | iflags.travelcc.x = iflags.travelcc.y = 0; |
| 901 | return; |
| 902 | } |
| 903 | pline("Sorry..."); |
| 904 | } |
| 905 | } |
no test coverage detected