From a8680c39fbc3aea65a2185b07e3987a8bf1ca102 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sun, 14 Apr 2019 22:54:09 -0300 Subject: Luck Increasing Potions (A, B and C) --- npc/items/inc_sc_bonus.txt | 48 ++++++++++++++++++++++++++++++++++++++++++++++ npc/scripts.conf | 1 + 2 files changed, 49 insertions(+) create mode 100644 npc/items/inc_sc_bonus.txt (limited to 'npc') diff --git a/npc/items/inc_sc_bonus.txt b/npc/items/inc_sc_bonus.txt new file mode 100644 index 000000000..a4f7cdac5 --- /dev/null +++ b/npc/items/inc_sc_bonus.txt @@ -0,0 +1,48 @@ +// TMW-2 Script. +// Author: +// Jesusalva +// Description: +// Applies effects for INC_* (STR doesn't exist) +// Valid values: INCAGI INCVIT INCINT INCDEX INCLUK INCHIT +/// Untested Values: INCHIT INCFLEE INCMHP INCMSP WALKSPEED INVINCIBLE +// +// Variables: +// @delay Second of buffing +// @min Min amount of type +// @max Max amount of type +// @type SC_* + +- script inc_sc_bonus -1,{ +OnUse: + if (@delay <= 0) close; + + // Get the bonus value + .@bonus=rand(@min, @max); + + // 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=(.@bonus*@delay+@v*@t)/(@t+@delay); + else + @v=.@bonus; + + // Update time value to ms and to stack + @t+=@delay; + @t*=1000; + + // Restart the bonus + sc_end @type; + sc_start @type,@t,@v; + + close; +} + diff --git a/npc/scripts.conf b/npc/scripts.conf index 4bf722fdf..05a55604c 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -27,6 +27,7 @@ "npc/functions/scoreboards.txt", "npc/functions/random-talk.txt", "npc/items/rand_sc_heal.txt", +"npc/items/inc_sc_bonus.txt", "npc/commands/event.txt", // config script -- cgit v1.2.3-60-g2f50