diff options
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/math.txt | 24 |
1 files changed, 24 insertions, 0 deletions
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; +} + |