summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorEmistry Haoyan <equinox1991@gmail.com>2019-05-14 23:44:20 +0800
committerEmistry Haoyan <equinox1991@gmail.com>2019-05-14 23:44:20 +0800
commit1f9c83ef453741b7029b5706c7cd52edc7ce9039 (patch)
tree2f97f8e9ab5f62476fb3c18d80e02023d9a8d3e4 /src/map
parent647a3d2513746a17636bea354ad5a56c1db853e1 (diff)
downloadhercules-1f9c83ef453741b7029b5706c7cd52edc7ce9039.tar.gz
hercules-1f9c83ef453741b7029b5706c7cd52edc7ce9039.tar.bz2
hercules-1f9c83ef453741b7029b5706c7cd52edc7ce9039.tar.xz
hercules-1f9c83ef453741b7029b5706c7cd52edc7ce9039.zip
Add *cap_value script command
- add `cap_value(value, min, max)` script command. - avoid the ugly nested `min()` and `max()` combo if needed.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/script.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 5843ac292..8f56b8ee1 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -17778,6 +17778,17 @@ static BUILDIN(max)
return true;
}
+static BUILDIN(cap_value)
+{
+ int value = script_getnum(st, 2);
+ int min = script_getnum(st, 3);
+ int max = script_getnum(st, 4);
+
+ script_pushint(st, (int)cap_value(value, min, max));
+
+ return true;
+}
+
static BUILDIN(md5)
{
const char *tmpstr;
@@ -25797,6 +25808,7 @@ static void script_parse_builtin(void)
// <--- List of mathematics commands
BUILDIN_DEF(min, "i*"),
BUILDIN_DEF(max, "i*"),
+ BUILDIN_DEF(cap_value, "iii"),
BUILDIN_DEF(md5,"s"),
BUILDIN_DEF(swap,"rr"),
// [zBuffer] List of dynamic var commands --->