MCPcopy Index your code
hub / github.com/NetHack/NetHack / scrolltele

Function scrolltele

src/teleport.c:848–915  ·  view source on GitHub ↗

teleport the hero; usually discover scroll of teleportation if via scroll */

Source from the content-addressed store, hash-verified

846
847/* teleport the hero; usually discover scroll of teleportation if via scroll */
848void
849scrolltele(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 }

Callers 2

teleFunction · 0.85
seffect_teleportationFunction · 0.85

Calls 15

noteleport_levelFunction · 0.85
learnscrollFunction · 0.85
make_blindedFunction · 0.85
On_W_tower_levelFunction · 0.85
rn2Function · 0.85
You_feelFunction · 0.85
unconsciousFunction · 0.85
eosFunction · 0.85
mon_namFunction · 0.85
isokFunction · 0.85
getposFunction · 0.85
teleokFunction · 0.85

Tested by

no test coverage detected