diff options
author | gumi <git@gumi.ca> | 2018-03-25 12:47:57 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2018-03-25 13:54:10 -0400 |
commit | 8049f5470fbb0c2dc2cf23e5aee5fd450f45a776 (patch) | |
tree | 2a0f64987c663d8a2f3a4614524380f9bae5cacd | |
parent | 3605ca68d55461cb1da9b01f41f5d2c0ff514503 (diff) | |
download | serverdata-8049f5470fbb0c2dc2cf23e5aee5fd450f45a776.tar.gz serverdata-8049f5470fbb0c2dc2cf23e5aee5fd450f45a776.tar.bz2 serverdata-8049f5470fbb0c2dc2cf23e5aee5fd450f45a776.tar.xz serverdata-8049f5470fbb0c2dc2cf23e5aee5fd450f45a776.zip |
get map anchors directly from maps
-rw-r--r-- | npc/_anchors.txt | 6 | ||||
-rw-r--r-- | npc/_import.txt | 1 | ||||
-rw-r--r-- | npc/commands/warp.txt | 93 | ||||
-rw-r--r-- | npc/functions/warp.txt | 7 |
4 files changed, 33 insertions, 74 deletions
diff --git a/npc/_anchors.txt b/npc/_anchors.txt new file mode 100644 index 00000000..6321274a --- /dev/null +++ b/npc/_anchors.txt @@ -0,0 +1,6 @@ +// This file is generated automatically. All manually added changes will be removed when running the Converter. + +- script __anchors__ 32767,{ +OnInit: + .ht = htnew(); +} diff --git a/npc/_import.txt b/npc/_import.txt index 1718dc71..92d7f2a0 100644 --- a/npc/_import.txt +++ b/npc/_import.txt @@ -73,3 +73,4 @@ @include "npc/008-2-9/_import.txt" @include "npc/test/_import.txt" @include "npc/testbg/_import.txt" +"npc/_anchors.txt", diff --git a/npc/commands/warp.txt b/npc/commands/warp.txt index 397e621b..03c32803 100644 --- a/npc/commands/warp.txt +++ b/npc/commands/warp.txt @@ -17,37 +17,37 @@ end; OnCall: - .@request$ = strtoupper(strip(.@atcmd_parameters$[0])); // sanitize - .@map$ = ""; - .@x = 0; - .@y = 0; + .@params$ = strtoupper(strip(implode(.@atcmd_parameters$[0], " "))); + .@request$ = replacestr(.@params$, " ", ""); - for (.@i = 0; .@i < .count; .@i += 2) + cleararray($@regexmatch$[1], "", 3); + if (.@params$ ~= "^(.+) ([0-9]+) ([0-9]+)$") { - if (.@request$ ~= .aliases$[.@i]) - { - sscanf(.aliases$[.@i + 1], "%s %d %d", .@map$, .@x, .@y); - break; - } + .@request$ = replacestr(strip($@regexmatch$[1]), " ", ""); + .@req_x = atoi(strip($@regexmatch$[2])); + .@req_y = atoi(strip($@regexmatch$[3])); } - if (.@map$ == "") + .@ht = getvariableofnpc(.ht, "__anchors__"); + .@it = htiterator(.@ht); + for (.@key$ = htinextkey(.@it); hticheck(.@it); .@key$ = htinextkey(.@it)) { - .@map$ = .@atcmd_parameters$[0]; + if (.@request$ ~= .@key$) + { + sscanf(htget(.@ht, .@key$, ""), "%s %d %d", .@map$, .@x, .@y); + break; + } } + htidelete(.@it); - if (.@atcmd_parameters$[2] != "") - { - .@x = atoi(.@atcmd_parameters$[1]); - .@y = atoi(.@atcmd_parameters$[2]); - } + .@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) - { end; // invalid map - } while (!checkcell(.@map$, .@x, .@y, cell_chkpass)) { @@ -61,57 +61,8 @@ OnCall: end; OnInit: - setarray .aliases$[0], - - // ARTIS - "^ART", "001-1 89 86", // artis town square - "^LIGHT", "001-2-0 37 32", // light armor shop - "^NOBLE1?$", "001-2-1 37 37", // noble house 1 - "^NOBLE2$", "001-2-10 40 38", // noble house 2 - "^NOBLE3$", "001-2-11 45 33", // noble house 3 - "^NOBLE4$", "001-2-12 34 32", // noble house 4 - "^NOBLE5$", "001-2-15 34 38", // noble house 5 - "^MOON", "001-2-2 39 34", // moon's house - "^LIB", "001-2-4 49 37", // library - "^CITY|^HALL", "001-2-7 36 38", // city hall - "^HARB|^MASTER", "001-2-16 32 33", // harbourmaster - "^WARE", "001-2-18 39 31", // warehouse - "^MERCH|^BANK", "001-2-19 29 31", // merchant hall - "^SHIP2$", "001-2-21 30 28", // la johanne (artis) - "^ALCH", "001-2-26 30 32", // alchemist - "^BLACK|SMITH", "001-2-27 35 32", // blacksmith - "^RED|PLUSH|^INN", "001-2-28 32 32", // red plush inn - "^LEG", "001-2-33 34 36", // legion - - // PROLOGUE - "^START|^BEGIN", "000-0 22 24", // starting point - "^START2$", "000-0-0 26 28", // starting point step 2 - "^START3$", "000-0-1 26 28", // starting point step 3 - "^DRA|ISLAND", "000-1 77 110", // drasil island - "^FIRST|^DECK1?$", "000-2-0 27 27", // first deck - "^SECOND|^DECK2$", "000-2-1 53 33", // second deck - "^HOLD$", "000-2-2 43 30", // hold - "^NARD", "000-2-3 21 27", // nard's room - "^ALIG|^HID", "000-2-4 36 29", // alige's hideout - - // WOODLAND - "^HURN", "008-1 79 64", // hurnscald: town square - "^CELE", "008-2-0 25 27", // hurnscald: celestia - "^HMER", "008-2-1 33 39", // hurnscald: merchant guild - "^RUST", "008-2-2 37 30", // hurnscald: inn - "^ARRO|^ARCH", "008-2-6 27 29", // hurnscald: archery shop - "^A?POT", "008-2-7 34 27", // hurnscald: potion shop - "^HBLA", "008-2-8 36 34", // hurnscald: forge - "^HHAL|^HCIT", "008-2-10 36 31", // hurnscald: city hall - "HOSP|CLIN", "008-2-13 25 31"; // hurnscald: clinic / hospital - - .count = getarraysize(.aliases$[0]); - if (debug > 0) - { - bindatcmd "w", "@w::OnCall", 0, 2, 0; - end; - } - - bindatcmd "w", "@w::OnCall", 1, 2, 1; + bindatcmd("w", "@w::OnCall", 0, 2, 0); + else + bindatcmd("w", "@w::OnCall", 1, 2, 1); } diff --git a/npc/functions/warp.txt b/npc/functions/warp.txt index 844baf7d..dd09d713 100644 --- a/npc/functions/warp.txt +++ b/npc/functions/warp.txt @@ -27,21 +27,22 @@ function script slide_or_warp { } if (!isloggedin(.@aid)) { - if (.@aid = playerattached() == 0) { + if ((.@aid = playerattached()) == 0) { debugmes("slide_or_warp: no player attached!"); return false; } } getmapxy(.@pc_map$, .@pc_x, .@pc_y, UNITTYPE_PC, .@aid); // get char location + .@cid = getcharid(CHAR_ID_CHAR, strcharinfo(PC_NAME, .@aid)); // FIXME: [Hercules] make it so you can pass account id directly to getcharid if (getargcount() < 1) { - warpchar(.@pc_map$, .@pc_x, .@pc_y, .@aid); // no arguments, just refresh + warpchar(.@pc_map$, .@pc_x, .@pc_y, .@cid); // no arguments, just refresh } else if (.@map$ == .@pc_map$ && (.@pc_x != .@x || .@pc_y != .@y)) { slide(.@x, .@y); // same map, slide instead of full warp // FIXME: make slide take GID as optional arg } else { - warpchar(.@map$, .@x, .@y, .@aid); // different map, warp to given location + warpchar(.@map$, .@x, .@y, .@cid); // different map, warp to given location } return true; } |