| 1031 | } |
| 1032 | |
| 1033 | int |
| 1034 | dotele( |
| 1035 | boolean break_the_rules) /* True: wizard mode ^T */ |
| 1036 | { |
| 1037 | struct trap *trap; |
| 1038 | const char *cantdoit; |
| 1039 | boolean trap_once = FALSE; |
| 1040 | |
| 1041 | trap = t_at(u.ux, u.uy); |
| 1042 | if (trap && !trap->tseen) |
| 1043 | trap = 0; |
| 1044 | |
| 1045 | if (trap) { |
| 1046 | if (trap->ttyp == LEVEL_TELEP && trap->tseen) { |
| 1047 | if (y_n("There is a level teleporter here. Trigger it?") == 'y') { |
| 1048 | level_tele_trap(trap, FORCETRAP); |
| 1049 | /* deliberate jumping will always take time even if it doesn't |
| 1050 | * work */ |
| 1051 | return 1; |
| 1052 | } else |
| 1053 | trap = 0; /* continue with normal horizontal teleport */ |
| 1054 | } else if (trap->ttyp == TELEP_TRAP) { |
| 1055 | trap_once = trap->once; /* trap may get deleted, save this */ |
| 1056 | if (trap->once) { |
| 1057 | pline("This is a vault teleport, usable once only."); |
| 1058 | if (y_n("Jump in?") == 'n') { |
| 1059 | trap = 0; |
| 1060 | } else { |
| 1061 | deltrap(trap); |
| 1062 | newsym(u.ux, u.uy); |
| 1063 | } |
| 1064 | } |
| 1065 | if (trap) |
| 1066 | You("%s onto the teleportation trap.", u_locomotion("jump")); |
| 1067 | } else |
| 1068 | trap = 0; |
| 1069 | } |
| 1070 | if (!trap && !break_the_rules) { |
| 1071 | boolean castit = FALSE; |
| 1072 | int energy = 0; |
| 1073 | |
| 1074 | if (!Teleportation || (u.ulevel < (Role_if(PM_WIZARD) ? 8 : 12) |
| 1075 | && !can_teleport(gy.youmonst.data))) { |
| 1076 | /* Try to use teleport away spell. */ |
| 1077 | int knownsp = known_spell(SPE_TELEPORT_AWAY); |
| 1078 | |
| 1079 | /* casting isn't inhibited by being Stunned (...it ought to be) */ |
| 1080 | castit = (knownsp >= spe_Fresh && !Confusion); |
| 1081 | if (!castit && !break_the_rules) { |
| 1082 | You("%s.", (!Teleportation ? ((knownsp != spe_Unknown) |
| 1083 | ? "can't cast that spell" |
| 1084 | : "don't know that spell") |
| 1085 | : "are not able to teleport at will")); |
| 1086 | return 0; |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | cantdoit = 0; |
no test coverage detected