summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
Diffstat (limited to 'npc')
-rw-r--r--npc/functions/inc_sc_bonus.txt49
1 files 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;
}