summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2020-03-08 23:31:25 +0100
committerGitHub <noreply@github.com>2020-03-08 23:31:25 +0100
commit6c15f3350056419feeb071ff871864bb5184d28d (patch)
treeaf2aa899cfebbefae440396ee91defd9757d7aed
parent21e3a41e912336914d0456257b6737dd2e9be0ef (diff)
parent1a410d241918f85010c59827dfd2fa3b1952d238 (diff)
downloadhercules-6c15f3350056419feeb071ff871864bb5184d28d.tar.gz
hercules-6c15f3350056419feeb071ff871864bb5184d28d.tar.bz2
hercules-6c15f3350056419feeb071ff871864bb5184d28d.tar.xz
hercules-6c15f3350056419feeb071ff871864bb5184d28d.zip
Merge pull request #2628 from Kenpachi2k13/unitiswalking
Add unitiswalking() script command
-rw-r--r--doc/script_commands.txt31
-rw-r--r--src/map/script.c33
2 files changed, 64 insertions, 0 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index d9efa299f..cb0314ac5 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -6987,6 +6987,37 @@ Examples:
---------------------------------------
+*unitiswalking({<GID>})
+
+This command checks, if a unit is walking or not.
+If <GID> is omitted, the currently attached character is used.
+Returns 1 if the unit is walking, 0 if the unit is not walking and -1 on error.
+
+Note: There's no differentiation between script and client initiated walking.
+
+Example:
+
+prontera,155,185,5 script Check Walking 1_F_MARIA,{
+ mes("Enter character name.");
+ mes("");
+ input(.@name$);
+ .@GID = getcharid(CHAR_ID_ACCOUNT, .@name$);
+ if (.@GID != 0) {
+ .@iswalking = unitiswalking(.@GID);
+ if (.@iswalking == 1)
+ mesf("%s is walking.", .@name$);
+ else if (.@iswalking == 0)
+ mesf("%s is not walking.", .@name$);
+ else
+ mesf("Can't get %s's walking state.", .@name$);
+ } else {
+ mesf("%s not found!", .@name$);
+ }
+ close();
+}
+
+---------------------------------------
+
*unitkill(<GID>)
*unitwarp(<GID>, <Mapname>, <x>, <y>)
*unitattack(<GID>, <Target ID>)
diff --git a/src/map/script.c b/src/map/script.c
index 3bf0464e7..0cfd6da73 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -21134,6 +21134,38 @@ static BUILDIN(unitwalk)
return true;
}
+/**
+ * Checks if a unit is walking.
+ *
+ * Returns 1 if unit is walking, 0 if unit is not walking and -1 on error.
+ *
+ * @code{.herc}
+ * unitiswalking({<GID>});
+ * @endcode
+ *
+ **/
+static BUILDIN(unitiswalking)
+{
+ int gid = script_hasdata(st, 2) ? script_getnum(st, 2) : st->rid;
+ struct block_list *bl = map->id2bl(gid);
+
+ if (bl == NULL) {
+ ShowWarning("buildin_unitiswalking: Error in finding object for GID %d!\n", gid);
+ script_pushint(st, -1);
+ return false;
+ }
+
+ if (unit->bl2ud(bl) == NULL) {
+ ShowWarning("buildin_unitiswalking: Error in finding unit_data for GID %d!\n", gid);
+ script_pushint(st, -1);
+ return false;
+ }
+
+ script_pushint(st, unit->is_walking(bl));
+
+ return true;
+}
+
/// Kills the unit
///
/// unitkill <unit_id>;
@@ -27036,6 +27068,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(getunittitle,"i"),
BUILDIN_DEF(setunittitle,"is"),
BUILDIN_DEF(unitwalk,"ii?"),
+ BUILDIN_DEF(unitiswalking, "?"),
BUILDIN_DEF(unitkill,"i"),
BUILDIN_DEF(unitwarp,"isii"),
BUILDIN_DEF(unitattack,"iv?"),