summaryrefslogtreecommitdiff
path: root/npc/commands/warp.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/commands/warp.txt')
-rwxr-xr-x[-rw-r--r--]npc/commands/warp.txt129
1 files changed, 47 insertions, 82 deletions
diff --git a/npc/commands/warp.txt b/npc/commands/warp.txt
index 22eeda39..d2eee4e2 100644..100755
--- a/npc/commands/warp.txt
+++ b/npc/commands/warp.txt
@@ -1,91 +1,56 @@
-// @w atcommand
-// warps using anchors or map name
-//
-// group lv: 1
-// group char lv: 2
-// log: True
-//
-// usage:
-// @w <map or anchor> [, x [, y]]
-// #w "char" <map or anchor> [, x [, y]]
-//
-// example:
-// @w artis
-// #w "char" artis
-
-- script @w 32767,{
+- script @warp NPC32767,{
+ callfunc "argv_splitter";
+ if (@argv$[3] == "" && @argv$[2] == "" && @argv$[1] != "" && @argv[1] < 2)
+ @argv$[3] = @argv$[1];
+
+ .@n$ = if_then_else(@argv$[3] != "", "char", "") + "warp";
+ if (GM < CMD_WARP && GM < G_SYSOP) goto L_GM; // check if you can use it on self
+ .@target_id = BL_ID;
+ if (@argv$[3] != "") set .@target_id, getcharid(3, @argv$[3]);
+ if (@argv$[3] != "" && !(isloggedin(.@target_id))) goto L_Failed; // do NOT fallback to self
+ if (@argv$[3] != "" && GM < CMD_CHARWARP && GM < G_SYSOP) goto L_GM; // when target is not self, use charwarp permission
+
+ if (@argv$[0] == "")
+ @argv$[0] = getmapname();
+
+ setarray @map_anchor$[0], "", "", "", "";
+ callfunc "map2anchor";
+
+ gmlog "@"+.@n$+" " + @args$;
+ if (.@target_id != BL_ID)
+ message strcharinfo(0), .@n$+" : The operation succeeded.";
+
+ @GMWARP_map$ = @map_anchor$[0];
+ @GMWARP_x = if_then_else(@argv[1] > 1, @argv[1], @map_anchor$[1]);
+ @GMWARP_y = if_then_else(@argv[2] > 1, @argv[2], @map_anchor$[2]);
+ addtimer 0, strnpcinfo(0) + "::OnWarp", .@target_id;
+
+ if (@map_anchor$[3] == "no" && @knows_anchors < 1)
+ goto L_SuggestAnchors;
end;
-OnCall:
- .@params$ = strtoupper(strip(implode(.@atcmd_parameters$[0], " ")));
- .@request$ = replacestr(.@params$, " ", "");
-
- cleararray($@regexmatch$[1], "", 3);
- if (.@params$ ~= "^(.+) ([0-9]+) ([0-9]+)$")
- {
- .@request$ = replacestr(strip($@regexmatch$[1]), " ", "");
- .@req_x = atoi(strip($@regexmatch$[2]));
- .@req_y = atoi(strip($@regexmatch$[3]));
- }
-
- .@ht = getvariableofnpc(.ht, "__anchors__");
- .@it = htiterator(.@ht);
- for (.@key$ = htifirstkey(.@it); hticheck(.@it); .@key$ = htinextkey(.@it))
- {
- if (.@request$ ~= .@key$)
- {
- sscanf(htget(.@ht, .@key$, ""), "%s %d %d", .@map$, .@x, .@y);
- break;
- }
- }
- htidelete(.@it);
-
- .@map$ = .@map$ ? .@map$ : .@request$;
- .@x = .@req_y ? .@req_x : .@x;
- .@y = .@req_y ? .@req_y : .@y;
-
- if (!map_exists(.@map$))
- {
- if (map_exists(.@atcmd_parameters$[0]))
- {
- .@map$ = .@atcmd_parameters$[0];
- }
- else
- {
- dispbottom(l("Map or anchor not found: %s", .@atcmd_parameters$[0]));
- end;
- }
- }
+L_SuggestAnchors:
+ message strcharinfo(0), .@n$+" : The warp command has been improved. You might want to consider using [@@https://www.themanaworld.org/index.php/Dev:GM_Commands/anchors|map anchors@@].";
+ @knows_anchors = 1;
+ end;
- while (!checkcell(.@map$, .@x, .@y, cell_chkpass))
- {
- // FIXME: this whole cell finding loop is DIRTY!
- // we should have a command to get a random free coordinate
- // or we should make buildin_warp silently ignore 0,0
+OnWarp:
+ warp @GMWARP_map$, @GMWARP_x, @GMWARP_y;
+ @GMWARP_map$ = "";
+ @GMWARP_x = 0;
+ @GMWARP_y = 0;
+ end;
- if (.@e == 50) break; // FIXME: triggers a console warning
- .@x = rand(20, 20 + (.@e * 5));
- .@y = rand(20, 20 + (.@e * 5));
- ++.@e;
- }
+L_Failed:
+ message strcharinfo(0), .@n$+" : Impossible to attach to the target player. Did you try putting the name in \"quotation marks\"?";
+ end;
- slide_or_warp(.@map$, .@x, .@y);
- updateSpotlight();
+L_GM:
+ message strcharinfo(0), .@n$+" : GM command is level "+ if_then_else(@argv$[1] != "", CMD_CHARWARP, CMD_WARP) +", but you are level " + GM;
end;
OnInit:
- if (debug > 0)
- {
- bindatcmd("w", "@w::OnCall", 0, 20, 0);
- bindatcmd("go", "@w::OnCall", 0, 20, 0);
- bindatcmd("to", "@w::OnCall", 0, 20, 0);
- bindatcmd("warp", "@w::OnCall", 0, 20, 0);
- }
- else
- {
- bindatcmd("w", "@w::OnCall", 20, 60, 1);
- bindatcmd("go", "@w::OnCall", 20, 60, 1);
- bindatcmd("to", "@w::OnCall", 20, 60, 1);
- bindatcmd("warp", "@w::OnCall", 20, 60, 1);
- }
+ registercmd chr(ATCMD_SYMBOL) + "warp", strnpcinfo(0);
+ registercmd chr(ATCMD_SYMBOL) + "charwarp", strnpcinfo(0);
+ end;
}