summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-05-25 14:56:44 -0300
committerJesusaves <cpntb1@ymail.com>2021-05-25 14:56:44 -0300
commitd634049de89821eacd03460eac1b8aeab4dbc1b8 (patch)
treed28e164a1a05984db6d4815919211d42c750d592
parenteec8dbf33ac565608445346054bbe605d7afda32 (diff)
downloadserverdata-d634049de89821eacd03460eac1b8aeab4dbc1b8.tar.gz
serverdata-d634049de89821eacd03460eac1b8aeab4dbc1b8.tar.bz2
serverdata-d634049de89821eacd03460eac1b8aeab4dbc1b8.tar.xz
serverdata-d634049de89821eacd03460eac1b8aeab4dbc1b8.zip
Reintroduce @w command, with Fermi target
-rw-r--r--npc/commands/warp.txt86
-rw-r--r--npc/fermi/_warps.txt2
-rw-r--r--npc/scripts.conf1
3 files changed, 88 insertions, 1 deletions
diff --git a/npc/commands/warp.txt b/npc/commands/warp.txt
new file mode 100644
index 00000000..ddd0449d
--- /dev/null
+++ b/npc/commands/warp.txt
@@ -0,0 +1,86 @@
+// @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;
+
+ if (getmapinfo(MAPINFO_ID, .@map$) < 0)
+ {
+ if (getmapinfo(MAPINFO_ID, .@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))
+ {
+ // 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
+
+ if (.@e == 50) break; // FIXME: triggers a console warning
+ .@x = rand(20, 20 + (.@e * 5));
+ .@y = rand(20, 20 + (.@e * 5));
+ ++.@e;
+ }
+
+ warp(.@map$, .@x, .@y);
+ end;
+
+OnInit:
+ if (debug) {
+ bindatcmd("w", "@w::OnCall", 0, 20, 0);
+ bindatcmd("go", "@w::OnCall", 0, 20, 0);
+ bindatcmd("to", "@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);
+ }
+ end;
+}
diff --git a/npc/fermi/_warps.txt b/npc/fermi/_warps.txt
index 9da4df68..bd877484 100644
--- a/npc/fermi/_warps.txt
+++ b/npc/fermi/_warps.txt
@@ -1,3 +1,3 @@
// This file is generated automatically. All manually added changes will be removed when running the Converter.
// Map fermi: Three Fermi Land warps
-fermi,29,19,0 warp #fermi_29_19 0,0,marine,43,27
+fermi,29,19,0 warp #fermi_29_19 0,0,000-1,22,22
diff --git a/npc/scripts.conf b/npc/scripts.conf
index 938eaea7..94266b4a 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -100,6 +100,7 @@
"npc/commands/rate-management.txt",
"npc/commands/resync.txt",
"npc/commands/scheduled-broadcasts.txt",
+"npc/commands/warp.txt",
// Events
"npc/functions/gm_island.txt",