diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-01-13 23:20:35 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-02-01 08:22:25 +0000 |
commit | b33a203735fc847da773e42a7460118aca2ee6fb (patch) | |
tree | 6776f2837dbe46d69331d2ce34113d4dffddf669 | |
parent | 7b5e99c153b03fa7ceb448f79ed0718092b7f781 (diff) | |
download | serverdata-b33a203735fc847da773e42a7460118aca2ee6fb.tar.gz serverdata-b33a203735fc847da773e42a7460118aca2ee6fb.tar.bz2 serverdata-b33a203735fc847da773e42a7460118aca2ee6fb.tar.xz serverdata-b33a203735fc847da773e42a7460118aca2ee6fb.zip |
Bring Moubootaur Legends Controlled Status Boosting Framework.
By Jesusalva. Dependencies included (randomness randomizer and ponderate average)
Function name: SC_Bonus() or inc_sc_bonus::OnUse
-rw-r--r-- | npc/functions/RNGesus.txt | 16 | ||||
-rw-r--r-- | npc/functions/math.txt | 15 | ||||
-rw-r--r-- | npc/items/inc_sc_bonus.txt | 70 | ||||
-rw-r--r-- | npc/scripts.conf | 1 |
4 files changed, 102 insertions, 0 deletions
diff --git a/npc/functions/RNGesus.txt b/npc/functions/RNGesus.txt index 6883f8f1..f3bf18ed 100644 --- a/npc/functions/RNGesus.txt +++ b/npc/functions/RNGesus.txt @@ -1,6 +1,7 @@ // Evol functions. // Authors: // gumi +// Jesusalva // Description: // Randomization helper functions. @@ -71,3 +72,18 @@ function script relative_array_random { freeloop(false); return getelementofarray(getarg(0), .@i); } + + +// pseudo-fix randomness +// rand2( min, max ) +function script rand2 { + if (getargcount() == 2) { + .@min=getarg(0)*100; + .@max=getarg(1)*100+99; + } else { + .@min=0; + .@max=getarg(0)*100-1; + } + return rand(.@min, .@max)/100; +} + diff --git a/npc/functions/math.txt b/npc/functions/math.txt index 357407da..90304fd8 100644 --- a/npc/functions/math.txt +++ b/npc/functions/math.txt @@ -48,3 +48,18 @@ function script is_between { return (getarg(0) < .@val && getarg(1) >= .@val); } +// result is the ponderate average. +// ponderate_avg ( arg1, sub1, arg2, sub2) +function script ponderate_avg { + .@a1=getarg(0); + .@s1=getarg(1); + .@a2=getarg(2); + .@s2=getarg(3); + + .@h1=.@a1*.@s1; + .@h2=.@a2*.@s2; + .@dd=.@s1+.@s2; + + return (.@h1+.@h2)/.@dd; +} + diff --git a/npc/items/inc_sc_bonus.txt b/npc/items/inc_sc_bonus.txt new file mode 100644 index 00000000..c165f632 --- /dev/null +++ b/npc/items/inc_sc_bonus.txt @@ -0,0 +1,70 @@ +// TMW-2 Script. +// Author: +// Jesusalva +// Description: +// 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 +/// Untested Values: WALKSPEED (reverse logic) INVINCIBLE (broken) +// +// Variables: +// .@delay Second of buffing +// .@type SC_* +// .@min Min amount of type +// .@max Max amount of type (optional) + +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) + consolemes(CONSOLEMES_DEBUG, "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; +} + diff --git a/npc/scripts.conf b/npc/scripts.conf index 16619850..fee96434 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -105,6 +105,7 @@ "npc/items/croconut.txt", "npc/items/shovel.txt", "npc/items/rand_sc_heal.txt", +"npc/items/inc_sc_bonus.txt", "npc/items/recipes.txt", "npc/items/master_skillbook.txt", |