summaryrefslogtreecommitdiff
path: root/npc/functions/warp.txt
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2018-02-15 10:53:32 -0500
committergumi <git@gumi.ca>2018-03-20 21:22:00 -0400
commit3605ca68d55461cb1da9b01f41f5d2c0ff514503 (patch)
tree8c21604bef095c4a5fc5c6b3bd4f2dcc1bc4ac27 /npc/functions/warp.txt
parent99f4e1606e8e4bd5c476d81758803da82476c5f4 (diff)
downloadserverdata-3605ca68d55461cb1da9b01f41f5d2c0ff514503.tar.gz
serverdata-3605ca68d55461cb1da9b01f41f5d2c0ff514503.tar.bz2
serverdata-3605ca68d55461cb1da9b01f41f5d2c0ff514503.tar.xz
serverdata-3605ca68d55461cb1da9b01f41f5d2c0ff514503.zip
yeah... this got very messy (my bad!). let's not use custom terminators after all
Diffstat (limited to 'npc/functions/warp.txt')
-rw-r--r--npc/functions/warp.txt47
1 files changed, 47 insertions, 0 deletions
diff --git a/npc/functions/warp.txt b/npc/functions/warp.txt
new file mode 100644
index 00000000..844baf7d
--- /dev/null
+++ b/npc/functions/warp.txt
@@ -0,0 +1,47 @@
+// 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
+
+ if (getargcount() < 1) {
+ warpchar(.@pc_map$, .@pc_x, .@pc_y, .@aid); // 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
+ }
+ return true;
+}