summaryrefslogtreecommitdiff
path: root/npc/functions/inc_sc_bonus.txt
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-04-10 03:00:20 -0300
committerJesusaves <cpntb1@ymail.com>2021-04-10 03:00:20 -0300
commitba1e827b6b4c17c35a163e6b55be8c122de632b8 (patch)
tree819f93d0ffee3697e336471710afb9681f0b8d86 /npc/functions/inc_sc_bonus.txt
parent6e7f3113c0faad9edd4367d100ba9dd77e8d3130 (diff)
downloadserverdata-ba1e827b6b4c17c35a163e6b55be8c122de632b8.tar.gz
serverdata-ba1e827b6b4c17c35a163e6b55be8c122de632b8.tar.bz2
serverdata-ba1e827b6b4c17c35a163e6b55be8c122de632b8.tar.xz
serverdata-ba1e827b6b4c17c35a163e6b55be8c122de632b8.zip
Add several convenience functions. Fix some bugs regarding misuse of readparam()
Diffstat (limited to 'npc/functions/inc_sc_bonus.txt')
-rw-r--r--npc/functions/inc_sc_bonus.txt72
1 files changed, 72 insertions, 0 deletions
diff --git a/npc/functions/inc_sc_bonus.txt b/npc/functions/inc_sc_bonus.txt
new file mode 100644
index 00000000..8e6b6e5b
--- /dev/null
+++ b/npc/functions/inc_sc_bonus.txt
@@ -0,0 +1,72 @@
+// TMW-2 Script.
+// Author:
+// Jesusalva
+// Description:
+// Applies effects for INC_* (STR doesn't exist)
+// Valid values: INCAGI INCVIT INCINT INCDEX INCLUK INCHIT INCFLEE SC_FURY
+// Doesn't works: SC_STRUP
+// Works if .@min == .@max: INCMHP INCMHPRATE INCMSP INCMSPRATE
+/// Untested Values: WALKSPEED (reverse logic) INVINCIBLE (broken)
+// PS. SC_FURY causes crit rate to increase
+//
+// Variables:
+// .@delay Second of buffing
+// .@type SC_*
+// .@min Min amount of type
+// .@max Max amount of type (optional)
+
+// SC_Bonus(delay, SC, min{, max})
+function script SC_Bonus {
+ .@delay=getarg(0);
+ .@type=getarg(1);
+ .@min=getarg(2);
+ .@max=getarg(3, .@min);
+ if (.@delay <= 0)
+ return false;
+
+ // Get the bonus value
+ if (.@min != .@max)
+ .@bonus=rand2(.@min, .@max);
+ else
+ .@bonus=.@min;
+
+ // Remaining time and effect conversion
+ .@v=getstatus(.@type, 1);
+ .@t=getstatus(.@type, 5);
+
+ // Convert remaining time to seconds, rounded down
+ if (.@t > 1000)
+ .@t=.@t/1000;
+ else
+ .@t=0;
+
+ // If there was effect previously, get ponderate average
+ if (.@v > 0)
+ .@v=ponderate_avg(.@bonus, .@delay, .@v, .@t);
+ else
+ .@v=.@bonus;
+
+ // Update time value to ms and to stack
+ .@t+=.@delay;
+ .@t*=1000;
+
+ // Debug print if needed
+ if (debug || $@GM_OVERRIDE)
+ debugmes "Effect %d (+%d percent) for %d ms", .@type, .@bonus, .@t;
+
+ // Restart the bonus
+ sc_end .@type;
+ sc_start .@type,.@t,.@v;
+ return true;
+}
+
+- script inc_sc_bonus -1,{
+OnUse:
+ SC_Bonus(@delay, @type, @min, @max);
+ @delay=0;
+ @type=0;
+ @min=0;
+ @max=0;
+ end;
+}
+