diff options
author | Haru <haru@dotalux.com> | 2014-11-02 01:30:33 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2014-11-02 01:34:58 +0100 |
commit | 6b20c5b6988c889df35b890d93c338f8b87fa430 (patch) | |
tree | 470f3ae3255ed4211687db27b2d187c6f03fde0f /src/map/script.c | |
parent | 19e6b0f9de7280770f0dd98d9431d3337b9a6e7c (diff) | |
download | hercules-6b20c5b6988c889df35b890d93c338f8b87fa430.tar.gz hercules-6b20c5b6988c889df35b890d93c338f8b87fa430.tar.bz2 hercules-6b20c5b6988c889df35b890d93c338f8b87fa430.tar.xz hercules-6b20c5b6988c889df35b890d93c338f8b87fa430.zip |
Added min() and max() script commands
- Special thanks to Streusel, Xgear
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index 1516a0234..006f275eb 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14835,6 +14835,36 @@ BUILDIN(distance) // <--- [zBuffer] List of mathematics commands +BUILDIN(min) +{ + int i, min; + + min = script_getnum(st, 2); + for (i = 3; script_hasdata(st, i); i++) { + int next = script_getnum(st, i); + if (next < min) + min = next; + } + script_pushint(st, min); + + return true; +} + +BUILDIN(max) +{ + int i, max; + + max = script_getnum(st, 2); + for (i = 3; script_hasdata(st, i); i++) { + int next = script_getnum(st, i); + if (next > max) + max = next; + } + script_pushint(st, max); + + return true; +} + BUILDIN(md5) { const char *tmpstr; @@ -19283,6 +19313,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(pow,"ii"), BUILDIN_DEF(distance,"iiii"), // <--- [zBuffer] List of mathematics commands + BUILDIN_DEF(min, "i*"), + BUILDIN_DEF(max, "i*"), BUILDIN_DEF(md5,"s"), // [zBuffer] List of dynamic var commands ---> BUILDIN_DEF(getd,"s"), |