diff options
author | Jesusaves <cpntb1@ymail.com> | 2018-03-26 00:34:18 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2018-03-26 00:34:18 -0300 |
commit | 35056b7702f0f21f84d4d16f15e807a545a34b54 (patch) | |
tree | 6a3af4856214e60cb96be6faac9d11260f91feda /npc/functions/warp.txt | |
parent | 9d2fd73cef8de24d03121bdde2fd4fb3b803a2f9 (diff) | |
parent | 7233ced3d5edaf1799e7bf5fa2961111128b9e5d (diff) | |
download | serverdata-jesusalva/fishing.tar.gz serverdata-jesusalva/fishing.tar.bz2 serverdata-jesusalva/fishing.tar.xz serverdata-jesusalva/fishing.zip |
Merge branch 'master' into jesusalva/fishingjesusalva/fishing
Diffstat (limited to 'npc/functions/warp.txt')
-rw-r--r-- | npc/functions/warp.txt | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/npc/functions/warp.txt b/npc/functions/warp.txt new file mode 100644 index 00000000..dd09d713 --- /dev/null +++ b/npc/functions/warp.txt @@ -0,0 +1,48 @@ +// Evol functions. +// Authors: +// gumi + + +// slide_or_warp +// Slides the player instead of warping, when possible. +// usage: +// slide_or_warp({<aid>}); +// slide_or_warp(<x>, <y>{, <aid>}); +// slide_or_warp("<map>", <x>, <y>{, <aid>}); + +function script slide_or_warp { + if (getargcount() <= 1) { + .@aid = getarg(1, 0); + } else { + if (getargcount() >= 3 && getdatatype(getarg(0)) & DATATYPE_STR) { + .@map$ = getarg(0); + .@x = getarg(1); + .@y = getarg(2); + .@aid = getarg(3, 0); + } else { + .@x = getarg(0); + .@y = getarg(1); + .@aid = getarg(2, 0); + } + } + + if (!isloggedin(.@aid)) { + 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, .@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, .@cid); // different map, warp to given location + } + return true; +} |