From 487fe31613270893a6cec38673ecc15b3814fb22 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 18 Apr 2021 03:46:14 -0300 Subject: Remove deprecated event script, and add SCBonus2 (unused, but cool to have) --- npc/functions/inc_sc_bonus.txt | 49 +++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/npc/functions/inc_sc_bonus.txt b/npc/functions/inc_sc_bonus.txt index 8e6b6e5b..7bd24331 100644 --- a/npc/functions/inc_sc_bonus.txt +++ b/npc/functions/inc_sc_bonus.txt @@ -60,13 +60,46 @@ function script SC_Bonus { return true; } -- script inc_sc_bonus -1,{ -OnUse: - SC_Bonus(@delay, @type, @min, @max); - @delay=0; - @type=0; - @min=0; - @max=0; - end; +// SC_Bonus2(delay, SC1, val1, val2) +function script SC_Bonus2 { + .@delay=getarg(0); + .@type=getarg(1); + .@val1=getarg(2); + .@val2=getarg(3); + if (.@delay <= 0) + return false; + + // Remaining time and effect conversion + .@v1=getstatus(.@type, 1); + .@v2=getstatus(.@type, 2); + .@ts=getstatus(.@type, 5); + + // Convert remaining time to seconds, rounded down + .@ts=.@ts/1000; + + // If there was effect previously, get ponderate average (val1) + if (.@v1 > 0) + .@v1=ponderate_avg(.@val1, .@delay, .@v1, .@ts); + else + .@v1=.@val1; + + // If there was effect previously, get ponderate average (val2) + if (.@v2 > 0) + .@v2=ponderate_avg(.@val2, .@delay, .@v2, .@ts); + else + .@v2=.@val2; + + // Update time value to ms and to stack + .@t+=.@delay; + .@t*=1000; + + // Debug print if needed + if (debug || $@GM_OVERRIDE) + debugmes "Effect %d (%d/%d bonus) for %d ms", .@type, .@v1, .@v2, .@ts; + + // Restart the bonus + sc_end .@type; + sc_start2 .@type, .@ts, .@v1, .@v2; + return true; } -- cgit v1.2.3-60-g2f50