summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/script_commands.txt28
-rw-r--r--src/map/script.c50
2 files changed, 68 insertions, 10 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 831e0a744..13b154560 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -7646,6 +7646,34 @@ Example:
---------------------------------------
+
+*floor(<number>)
+
+Returns the number rounded down.
+
+Example:
+ .@i = floor(2.5); // .@i will be 2
+
+---------------------------------------
+
+*ceil(<number>)
+
+Returns the number rounded up.
+
+Example:
+ .@i = ceil(2.5); // .@i will be 3
+
+---------------------------------------
+
+*log(<number>)
+
+Returns log base 10 of the number.
+
+Example:
+ .@i = log(100); // .@i will be 2
+
+---------------------------------------
+
*sqrt(<number>)
Returns square-root of number.
diff --git a/src/map/script.c b/src/map/script.c
index ed4f9e918..03f5b13a3 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15476,8 +15476,35 @@ BUILDIN(compare)
return true;
}
-// [zBuffer] List of mathematics commands --->
-BUILDIN(sqrt)
+// List of mathematics commands --->
+BUILDIN(floor)
+{
+ double i, a;
+ i = script_getnum(st,2);
+ a = floor(i);
+ script_pushint(st,(int)a);
+ return true;
+}
+
+BUILDIN(ceil)
+{
+ double i, a;
+ i = script_getnum(st,2);
+ a = ceil(i);
+ script_pushint(st,(int)a);
+ return true;
+}
+
+BUILDIN(log)
+{
+ double i, a;
+ i = script_getnum(st,2);
+ a = log(i);
+ script_pushint(st,(int)a);
+ return true;
+}
+
+BUILDIN(sqrt) //[zBuffer]
{
double i, a;
i = script_getnum(st,2);
@@ -15486,7 +15513,7 @@ BUILDIN(sqrt)
return true;
}
-BUILDIN(pow)
+BUILDIN(pow) //[zBuffer]
{
double i, a, b;
a = script_getnum(st,2);
@@ -15496,7 +15523,7 @@ BUILDIN(pow)
return true;
}
-BUILDIN(distance)
+BUILDIN(distance) //[zBuffer]
{
int x0, y0, x1, y1;
@@ -15509,7 +15536,7 @@ BUILDIN(distance)
return true;
}
-// <--- [zBuffer] List of mathematics commands
+// <--- List of mathematics commands
BUILDIN(min)
{
@@ -20052,11 +20079,14 @@ void script_parse_builtin(void) {
BUILDIN_DEF(getiteminfo,"ii"), //[Lupus] returns Items Buy / sell Price, etc info
BUILDIN_DEF(setiteminfo,"iii"), //[Lupus] set Items Buy / sell Price, etc info
BUILDIN_DEF(getequipcardid,"ii"), //[Lupus] returns CARD ID or other info from CARD slot N of equipped item
- // [zBuffer] List of mathematics commands --->
- BUILDIN_DEF(sqrt,"i"),
- BUILDIN_DEF(pow,"ii"),
- BUILDIN_DEF(distance,"iiii"),
- // <--- [zBuffer] List of mathematics commands
+ // List of mathematics commands --->
+ BUILDIN_DEF(floor,"i"),
+ BUILDIN_DEF(ceil,"i"),
+ BUILDIN_DEF(log,"i"),
+ BUILDIN_DEF(sqrt,"i"), //[zBuffer]
+ BUILDIN_DEF(pow,"ii"), //[zBuffer]
+ BUILDIN_DEF(distance,"iiii"), //[zBuffer]
+ // <--- List of mathematics commands
BUILDIN_DEF(min, "i*"),
BUILDIN_DEF(max, "i*"),
BUILDIN_DEF(md5,"s"),