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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// @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,{
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;
// FIXME: here getmapusers() is used only to check if the map exists
// replace this when/if we get a dedicated function for that
if (getmapusers(.@map$) < 0)
{
if (getmapusers(.@atcmd_parameters$[0]) >= 0)
{
.@map$ = .@atcmd_parameters$[0];
}
else
{
dispbottom(l("Map or anchor not found: %s", .@atcmd_parameters$[0]));
end;
}
}
while (!checkcell(.@map$, .@x, .@y, cell_chkpass))
{
if (.@e == 50) end;
.@x = rand(20, 250);
.@y = rand(20, 250);
++.@e;
}
slide_or_warp(.@map$, .@x, .@y);
end;
OnInit:
if (debug > 0)
{
bindatcmd("w", "@w::OnCall", 0, 2, 0);
bindatcmd("go", "@w::OnCall", 0, 2, 0);
bindatcmd("to", "@w::OnCall", 0, 2, 0);
bindatcmd("warp", "@w::OnCall", 0, 2, 0);
}
else
{
bindatcmd("w", "@w::OnCall", 2, 2, 1);
bindatcmd("go", "@w::OnCall", 2, 2, 1);
bindatcmd("to", "@w::OnCall", 2, 2, 1);
bindatcmd("warp", "@w::OnCall", 2, 2, 1);
}
}
|