diff options
author | mekolat <mekolat@users.noreply.github.com> | 2016-05-04 11:38:52 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2016-05-04 13:30:13 -0400 |
commit | e968701f1063e6d15212752b8485becd3c969bcb (patch) | |
tree | 6b3bc398b6f012e479066ddf1adc7b5e24c73754 | |
parent | f8924867ee3e1020cb9fc73df98c22218a52ad2f (diff) | |
download | serverdata-e968701f1063e6d15212752b8485becd3c969bcb.tar.gz serverdata-e968701f1063e6d15212752b8485becd3c969bcb.tar.bz2 serverdata-e968701f1063e6d15212752b8485becd3c969bcb.tar.xz serverdata-e968701f1063e6d15212752b8485becd3c969bcb.zip |
add wrapper around `warp` atcommand
-rw-r--r-- | world/map/conf/permissions.txt | 2 | ||||
-rw-r--r-- | world/map/conf/permissions_local.txt.example | 1 | ||||
-rw-r--r-- | world/map/npc/commands/_import.txt | 1 | ||||
-rw-r--r-- | world/map/npc/commands/_procedures.txt | 98 | ||||
-rw-r--r-- | world/map/npc/commands/warp.txt | 57 |
5 files changed, 159 insertions, 0 deletions
diff --git a/world/map/conf/permissions.txt b/world/map/conf/permissions.txt index 0b8cb79a..7215942c 100644 --- a/world/map/conf/permissions.txt +++ b/world/map/conf/permissions.txt @@ -8,6 +8,8 @@ CMD_CLASS 40 CMD_CHARCLASS 50 CMD_DESTROYNPC 99 CMD_REMOTECMD 40 +CMD_WARP 40 +CMD_CHARWARP 60 // special permissions below MAP_LOUNGE 20 // level to enter the GM Lounge & talk to Numa diff --git a/world/map/conf/permissions_local.txt.example b/world/map/conf/permissions_local.txt.example index 422da753..93bba913 100644 --- a/world/map/conf/permissions_local.txt.example +++ b/world/map/conf/permissions_local.txt.example @@ -6,5 +6,6 @@ //CMD_DEBUG 0 //CMD_CHANGESEX 0 //CMD_CLASS 0 +//CMD_WARP 0 //MAP_LOUNGE 0 //DBG_VALIA 0 diff --git a/world/map/npc/commands/_import.txt b/world/map/npc/commands/_import.txt index b2fe92a1..1362d66d 100644 --- a/world/map/npc/commands/_import.txt +++ b/world/map/npc/commands/_import.txt @@ -9,3 +9,4 @@ npc: npc/commands/numa.txt npc: npc/commands/destroynpc.txt npc: npc/commands/remotecmd.txt npc: npc/commands/hug.txt +npc: npc/commands/warp.txt diff --git a/world/map/npc/commands/_procedures.txt b/world/map/npc/commands/_procedures.txt index 732b496f..9f26a7cd 100644 --- a/world/map/npc/commands/_procedures.txt +++ b/world/map/npc/commands/_procedures.txt @@ -8,6 +8,8 @@ function|script|argv_splitter set .@e, 0; set .@total, getarraysize(.@fragments$); set .@NULL$, chr(3); // HACK: we use .@NULL$ as a workaround because we can't do "\0" + cleararray @argv$[0], "", 20; // I don't think any atcommand will EVER need more than 20 args, and 20 is already generous + cleararray @argv[0], 0, 20; goto L_Check; L_Check: @@ -51,3 +53,99 @@ L_CheckAfter: L_Done: return; } + +// Map2Anchor +// translates map aliases to actual maps +function|script|map2anchor +{ + if (@map_anchor$[0] == "" && @argv$[0] != "") + set @map_anchor$[0], @argv$[0]; + + if (@map_anchor$[2] == "" && @argv[1] > 1 && @argv[2] > 1) + set @map_anchor$[1], @argv[1], @argv[2]; + + set .@a$, @map_anchor$[0]; // anchor name // FIXME: I really want a str2lower() builtin + + if (.@a$ == "hurnscald" || .@a$ == "hurn" || .@a$ == "hurns") + setarray @map_anchor$[0], "009-1", 55, 37; + + elif (.@a$ == "nivalis" || .@a$ == "niv") + setarray @map_anchor$[0], "020-1", 74, 83; + + elif (.@a$ == "tulimshar" || .@a$ == "tulim" || .@a$ == "tul") + setarray @map_anchor$[0], "001-1", 64, 101; + + elif (.@a$ == "candor" || .@a$ == "newbington" || .@a$ == "noob") + setarray @map_anchor$[0], "029-1", 52, 93; + + elif (.@a$ == "oldwizard" || .@a$ == "wizard" || .@a$ == "oldwiz") + setarray @map_anchor$[0], "013-1", 41, 92; + + elif (.@a$ == "desert" || .@a$ == "pachua") + setarray @map_anchor$[0], "006-1", 34, 99; + + elif (.@a$ == "forest" || .@a$ == "katze") + setarray @map_anchor$[0], "015-1", 58, 35; + + elif (.@a$ == "dimond" || .@a$ == "dimondscove") + setarray @map_anchor$[0], "010-2", 31, 39; + + elif (.@a$ == "asphodel" || .@a$ == "swamp" || .@a$ == "swampvillage" || .@a$ == "undeadtown") + setarray @map_anchor$[0], "026-1", 32, 33; + + elif (.@a$ == "gy" || .@a$ == "graveyard") + setarray @map_anchor$[0], "027-1", 71, 87; + + elif (.@a$ == "krukan" || .@a$ == "generalkrukan") + setarray @map_anchor$[0], "027-6", 39, 47; + + elif (.@a$ == "razha" || .@a$ == "generalrazha") + setarray @map_anchor$[0], "027-7", 39, 35; + + elif (.@a$ == "terogan" || .@a$ == "generalterogan") + setarray @map_anchor$[0], "027-8", 39, 52; + + elif (.@a$ == "gmisland" || .@a$ == "eventisland" || .@a$ == "easterisland" || .@a$ == "island") + setarray @map_anchor$[0], "028-1", 99, 40; + + elif (.@a$ == "auditorium" || .@a$ == "scene") + setarray @map_anchor$[0], "028-1", 119, 69; + + elif (.@a$ == "theater") + setarray @map_anchor$[0], "017-2", 26, 23; + + elif (.@a$ == "lounge" || .@a$ == "gmlounge" || .@a$ == "gm" || .@a$ == "backstage") + setarray @map_anchor$[0], "017-9", 26, 23; + + elif (.@a$ == "cindy" || .@a$ == "cindycave") + setarray @map_anchor$[0], "031-3", 47, 26; + + elif (.@a$ == "terranite" || .@a$ == "terra" || .@a$ == "terracave") + setarray @map_anchor$[0], "012-3", 448, 65; + + elif (.@a$ == "terranitesafe" || .@a$ == "terrasafe" || .@a$ == "safeterra") + setarray @map_anchor$[0], "012-4", 473, 184; + + elif (.@a$ == "bluesage" || .@a$ == "blue") + setarray @map_anchor$[0], "048-2", 40, 46; + + elif (.@a$ == "xmasinn" || .@a$ == "xmas") + setarray @map_anchor$[0], "030-2", 85, 46; + + elif (.@a$ == "barbarians" || .@a$ == "barbarian" || .@a$ == "fluffy") + setarray @map_anchor$[0], "033-1", 71, 33; + + elif (.@a$ == "park" || .@a$ == "porttown" || .@a$ == "farms") + setarray @map_anchor$[0], "057-1", 100, 77; + + elif (.@a$ == "hills" || .@a$ == "orum") + setarray @map_anchor$[0], "017-1", 112, 49; + + elif (.@a$ == "batcave" || .@a$ == "bat") + setarray @map_anchor$[0], "011-3", 30, 26; + + else + set @map_anchor$[3], "no"; // did not use an anchor + + return; +} diff --git a/world/map/npc/commands/warp.txt b/world/map/npc/commands/warp.txt new file mode 100644 index 00000000..8fee3c16 --- /dev/null +++ b/world/map/npc/commands/warp.txt @@ -0,0 +1,57 @@ +-|script|@warp|32767 +{ + callfunc "argv_splitter"; + if (@argv$[3] == "" && @argv$[2] == "" && @argv$[1] != "" && @argv[1] < 2) + set @argv$[3], @argv$[1]; + + set .@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 + set .@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] == "") + set @argv$[0], getmap(); + + setarray @map_anchor$[0], "", "", "", ""; + callfunc "map2anchor"; + + gmlog "@"+.@n$+" " + @args$; + if (.@target_id != BL_ID) + message strcharinfo(0), .@n$+" : The operation succeeded."; + + set @GMWARP_map$, @map_anchor$[0]; + set @GMWARP_x, if_then_else(@argv[1] > 1, @argv[1], @map_anchor$[1]); + set @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@@]."; + set @knows_anchors, 1; + end; + +OnWarp: + warp @GMWARP_map$, @GMWARP_x, @GMWARP_y; + set @GMWARP_map$, ""; + set @GMWARP_x, 0; + set @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; +} |