summaryrefslogtreecommitdiff
path: root/npc/items/inc_sc_bonus.txt
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-07-26 01:16:54 -0300
committerJesusaves <cpntb1@ymail.com>2019-07-26 01:16:54 -0300
commit9d0dbf20d7e9a33e9c1c64227223333a1761b0aa (patch)
treedde28ac8ac0864df445ed7d21d15f10759370c9b /npc/items/inc_sc_bonus.txt
parent8f94c62b7552cc453e38a108e07550ee56953f4a (diff)
downloadserverdata-9d0dbf20d7e9a33e9c1c64227223333a1761b0aa.tar.gz
serverdata-9d0dbf20d7e9a33e9c1c64227223333a1761b0aa.tar.bz2
serverdata-9d0dbf20d7e9a33e9c1c64227223333a1761b0aa.tar.xz
serverdata-9d0dbf20d7e9a33e9c1c64227223333a1761b0aa.zip
Rewrite inc_sc_bonus to a more stable version
Diffstat (limited to 'npc/items/inc_sc_bonus.txt')
-rw-r--r--npc/items/inc_sc_bonus.txt47
1 files changed, 28 insertions, 19 deletions
diff --git a/npc/items/inc_sc_bonus.txt b/npc/items/inc_sc_bonus.txt
index 92a5ae522..32aeec6a0 100644
--- a/npc/items/inc_sc_bonus.txt
+++ b/npc/items/inc_sc_bonus.txt
@@ -5,28 +5,32 @@
// Applies effects for INC_* (STR doesn't exist)
// Valid values: INCAGI INCVIT INCINT INCDEX INCLUK INCHIT INCFLEE
// Doesn't works: SC_STRUP
-// Works if @min == @max: INCMHP INCMHPRATE INCMSP INCMSPRATE
+// Works if .@min == .@max: INCMHP INCMHPRATE INCMSP INCMSPRATE
/// Untested Values: WALKSPEED (reverse logic) INVINCIBLE (broken)
//
// Variables:
-// @delay Second of buffing
-// @min Min amount of type
-// @max Max amount of type
-// @type SC_*
+// .@delay Second of buffing
+// .@type SC_*
+// .@min Min amount of type
+// .@max Max amount of type (optional)
-- script inc_sc_bonus -1,{
-OnUse:
- if (@delay <= 0) close;
+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=rand(@min, @max);
+ if (.@min != .@max)
+ .@bonus=rand2(.@min, .@max);
else
- .@bonus=any(@min, @max);
+ .@bonus=.@min;
// Remaining time and effect conversion
- .@v=getstatus(@type, 1);
- .@t=getstatus(@type, 5);
+ .@v=getstatus(.@type, 1);
+ .@t=getstatus(.@type, 5);
// Convert remaining time to seconds, rounded down
if (.@t > 1000)
@@ -36,22 +40,27 @@ OnUse:
// If there was effect previously, get ponderate average
if (.@v > 0)
- .@v=ponderate_avg(.@bonus, @delay, .@v, .@t);
+ .@v=ponderate_avg(.@bonus, .@delay, .@v, .@t);
else
.@v=.@bonus;
// Update time value to ms and to stack
- .@t+=@delay;
+ .@t+=.@delay;
.@t*=1000;
// Debug print if needed
if (debug || $@GM_OVERRIDE)
- debugmes "Effect %d (+%d percent) for %d ms", @type, .@bonus, .@t;
+ debugmes "Effect %d (+%d percent) for %d ms", .@type, .@bonus, .@t;
// Restart the bonus
- sc_end @type;
- sc_start @type,.@t,.@v;
+ sc_end .@type;
+ sc_start .@type,.@t,.@v;
+ return true;
+}
- close;
+- script inc_sc_bonus -1,{
+OnUse:
+ SC_Bonus(@delay, @type, @min, @max);
+ end;
}