summaryrefslogtreecommitdiff
path: root/npc/functions/util.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/functions/util.txt')
-rw-r--r--npc/functions/util.txt9
1 files changed, 9 insertions, 0 deletions
diff --git a/npc/functions/util.txt b/npc/functions/util.txt
index 4e6494d34..2d834ea2d 100644
--- a/npc/functions/util.txt
+++ b/npc/functions/util.txt
@@ -1220,6 +1220,15 @@ function script TPToLoc {
// Warps home and updates LOCATION$
function script teleporthome {
warp "Save", 0, 0;
+ if (getmap() == "000-1") {
+ consolewarn("[WARN] Failed to teleporthome, map %s savepoint %s. Fallback to %s", getmap(), getsavepoint(0), LOCATION$);
+ // Fallback - attempt to spoof the original location as a last resort
+ .@lx=array_find($@LOCMASTER_LOC$, LOCATION$);
+ if (.@lx >= 0) {
+ warp $@LOCMASTER_MAP$[.@lx], $@LOCMASTER_X[.@lx], $@LOCMASTER_Y[.@lx];
+ end;
+ }
+ }
.@i=array_find($@LOCMASTER_MAP$, getmap());
if (.@i >= 0)
EnterTown($@LOCMASTER_LOC$[.@i]);