From de1ab31800a499d760b52275bc264bed21ac672c Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 22 Apr 2019 11:17:17 -0300 Subject: Make my math rules more clear --- npc/functions/math.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'npc/functions/math.txt') diff --git a/npc/functions/math.txt b/npc/functions/math.txt index ebb9ee069..a07b46280 100644 --- a/npc/functions/math.txt +++ b/npc/functions/math.txt @@ -68,3 +68,27 @@ function script log2 { return .@i; } + +// result is: lower < target <= higher +// is_between ( lower, higher, target) +function script is_between { + .@val=getarg(2); + return (getarg(0) < .@val && getarg(1) >= .@val); +} + + +// result is the ponderate average. +// ponderate_avg ( arg1, sub1, arg2, sub2) +function script ponderate_avg { + .@a1=getarg(0); + .@s1=getarg(1); + .@a2=getarg(2); + .@s2=getarg(3); + + .@h1=.@a1*.@s1; + .@h2=.@a1*.@s1; + .@dd=.@s1+.@s2; + + return (.@h1+.@h2)/.@dd; +} + -- cgit v1.2.3-60-g2f50