summaryrefslogtreecommitdiff
path: root/npc/commands/warp.txt
blob: d2eee4e2c1aa596577265ce28eb0562d9bdae54a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-	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;

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;

OnWarp:
    warp @GMWARP_map$, @GMWARP_x, @GMWARP_y;
    @GMWARP_map$ = "";
    @GMWARP_x = 0;
    @GMWARP_y = 0;
    end;

L_Failed:
    message strcharinfo(0), .@n$+" : Impossible to attach to the target player. Did you try putting the name in \"quotation marks\"?";
    end;

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:
    registercmd chr(ATCMD_SYMBOL) + "warp", strnpcinfo(0);
    registercmd chr(ATCMD_SYMBOL) + "charwarp", strnpcinfo(0);
    end;
}