summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--world/map/npc/functions/teleport_manager.txt100
1 files changed, 18 insertions, 82 deletions
diff --git a/world/map/npc/functions/teleport_manager.txt b/world/map/npc/functions/teleport_manager.txt
index 529bd5e0..244a1548 100644
--- a/world/map/npc/functions/teleport_manager.txt
+++ b/world/map/npc/functions/teleport_manager.txt
@@ -174,39 +174,27 @@ OnInit:
// PUBLIC API. Creates requested teleport NPC. Arg 0..6 are like puppet().
// This function designed to run in ANY context, whether RID attached or not.
// It creates puppet + setups all relevant data in created NPC.
-// arg(0): Teleport's map.
-// arg(1): Teleport's X
-// arg(2): Teleport's Y
-// arg(3): Teleport's NPC label
-// arg(4): Teleport's NPC sprite ID
-// arg(5): Teleport's X size
-// arg(6): Teleport's Y size
-// arg(7): Destination map name.
-// arg(8): Destination X
-// arg(9): Destination Y
-// arg(10):Teleport lifetime ( > 0 or -1 = indefinite)
-// arg(11):Teleport magic cookie, 0 = everyone allowed, otherwise checks match.
-// arg(12):Whether teleport managed, 0 = unmanaged, != 0 means it is.
-// Return: On success: NPC ID of teleport created.
+// Inputs: see code below.
+// Return: On success: NPC ID of teleport created, > 0
// On failure: 0 if puppet failed, -1 if arg check failed.
function|script|teleport_create
{
- set .@map$, getarg(0, ""); // Get args (+failsafe defailts)
- set .@x, getarg(1, -10); // Get args (+failsafe defailts)
- set .@y, getarg(2, -10); // Get args (+failsafe defailts)
- set .@name$, getarg(3, ""); // Get args (+failsafe defailts)
- set .@sprite, getarg(4, -10); // Get args (+failsafe defailts)
- set .@xsz, getarg(5, -10); // Get args (+failsafe defailts)
- set .@ysz, getarg(6, -10); // Get args (+failsafe defailts)
- set .@dstmap$, getarg(7, -10); // Get args (+failsafe defailts)
- set .@dst_x, getarg(8, -10); // Get args (+failsafe defailts)
- set .@dst_y, getarg(9, -10); // Get args (+failsafe defailts)
- set .@lifetime, getarg(10, -10); // Get args (+failsafe defailts)
- set .@cookie, getarg(11, -10); // Get args (+failsafe defailts)
- set .@managed, getarg(12, -10); // Get args (+failsafe defailts)
+ set .@map$, getarg(0, ""); // Teleport's map.
+ set .@x, getarg(1, -10); // Teleport's X
+ set .@y, getarg(2, -10); // Teleport's Y
+ set .@name$, getarg(3, ""); // Teleport's NPC label
+ set .@sprite, getarg(4, -10); // Teleport's NPC sprite ID
+ set .@xsz, getarg(5, -10); // Teleport's X size
+ set .@ysz, getarg(6, -10); // Teleport's Y size
+ set .@dstmap$, getarg(7, -10); // Destination map name.
+ set .@dst_x, getarg(8, -10); // Destination X
+ set .@dst_y, getarg(9, -10); // Destination Y
+ set .@lifetime, getarg(10, -10); // Teleport lifetime (> 0 or -1 = forever)
+ set .@cookie, getarg(11, -10); // Magic cookie, 0 = everyone allowed, otherwise TP checks match.
+ set .@managed, getarg(12, -10); // Mmanaged? 0:unmanaged, >0: tracked by TP Manager
set .@res, -1; // Validate what caller gave
- if !(call("teleport_map_valid", .@map$ )) goto L_Fail; // Validate src map$
- if !(call("teleport_map_valid", .@dstmap$)) goto L_Fail; // Validate dst map$
+ if !(mapexists(.@map$)) goto L_Fail; // Validate src map$
+ if !(mapexists(.@dstmap$)) goto L_Fail; // Validate dst map$
if ((.@x < 0) || (.@y < 0)) goto L_Fail; // SRC X/Y cant be < 0
if ((.@dst_x < 0) || (.@dst_y < 0)) goto L_Fail; // DST X/Y cant be < 0
if ((.@xsz < 0) || (.@ysz < 0)) goto L_Fail; // NPC X/Y size cant be <= 0
@@ -404,7 +392,7 @@ function|script|teleportadd_parseargs
set @NPCSPRITE, @argv[5]; // Teleport's NPC sprite (optional)
// Check DST map is okay
if ((@DSTMAP$ == "help") || (@DSTMAP$ == "")) goto L_DisplayHelp; // @teleportadd help or @teleportadd
- if !(call("teleport_map_valid", @DSTMAP$)) goto L_FailBadmap; // DST: invalid map?
+ if !(mapexists(@DSTMAP$)) goto L_FailBadmap; // DST: invalid map?
// Check DST X,Y sane
if ((@DST_X <= 0) || (@DST_Y <= 0)) goto L_FailBadDstXY1; // DST: invalids coords <= 0?
if ((getmapmaxx(@DSTMAP$) < @DST_X) || (getmapmaxy(@DSTMAP$) < @DST_Y)) goto L_FailBadDstXY2; // Outside of map?
@@ -454,58 +442,6 @@ L_DisplayHelp:
return -7;
}
-// PUBLIC API: This function checks if map name known and OK to use.
-// This function designed to run in any context.
-// Inputs: arg$[0] is map name to check for sanity.
-// Return: 1 for known maps, 0 for unknown
-function|script|teleport_map_valid
-{
- set .@inputmap$, getarg(0, "");
- set .@i, 0;
- setarray .@maps1$, "001-1", "001-2", "001-3", "002-1", "002-2", "002-3",
- "002-4", "002-5", "003-1", "003-4", "004-1", "004-3",
- "004-4", "004-5", "005-3", "006-1", "006-2", "006-3",
- "007-1", "007-2", "008-1", "009-1", "009-2", "009-3",
- "009-4", "009-5", "009-6", "009-7", "009-8", "010-1",
- "010-2", "011-1", "011-3", "011-4", "011-6", "012-1",
- "012-3", "012-4", "013-1", "013-2", "013-3", "014-1",
- "014-3", "015-1", "015-3", "016-1", "016-2", "017-1",
- "017-2", "017-3", "017-4", "017-9", "018-1", "018-2",
- "018-3", "019-1", "019-3", "019-4", "020-1", "020-2",
- "020-3", "021-3", "023-1", "023-2", "023-3", "025-1",
- "025-3", "025-4", "026-1", "026-2", "027-1", "027-2",
- "027-3", "027-4", "027-5", "027-6", "027-7", "027-8",
- "028-1", "028-3", "029-1", "029-2", "029-3", "029-4",
- "030-1", "030-2", "030-3", "030-4", "031-1", "031-2",
- "031-3", "031-4", "032-3", "033-1", "034-1", "034-2",
- "035-2", "036-2", "041-1", "042-1", "043-1", "043-3",
- "043-4", "045-1", "046-1", "046-3", "047-1", "047-3";
-// Had to split to 2 arrays as its too big for array initializer
- setarray .@maps2$, "048-2", "051-1", "051-3", "052-1", "052-2", "055-1",
- "055-3", "056-2", "057-1", "058-1", "058-2", "069-2",
- "070-1", "070-3", "099-1", "099-2", "099-3", "099-4",
- "099-5", "099-6", "099-7", "099-8", "botcheck";
- set .@arr_sz1, getarraysize(.@maps1$[0]);
- set .@arr_sz2, getarraysize(.@maps2$[0]);
- freeloop 1; // Needed to iterate over array of about 150 maps
- goto L_NextMap; // Start iterating over array of maps.
-
-L_NextMap:
- if (.@inputmap$ == .@maps1$[.@i]) goto L_Found; // Found map in arr 1?
- if (.@inputmap$ == .@maps2$[.@i]) goto L_Found; // Found map in arr 2?
- set .@i, (.@i + 1); // increment .@maps$[] index
- if ((.@i >= .@arr_sz1) && (.@i >= .@arr_sz2)) goto L_NotFound; // Abort if whole arrays scanned
- goto L_NextMap; // Try next map in .@maps$[]
-
-L_NotFound:
- freeloop 0;
- return 0;
-
-L_Found:
- freeloop 0;
- return 1;
-}
-
// PRIVATE: This function displays usage help for TeleportManager - @teleportadd
// This function should be invoked by TeleportManager with RID attached.
// Inputs: nothing.