From 5b6e7d9c85f3e48ce84a6fb4b14d4a59f7da086e Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 20 May 2019 10:32:41 -0300 Subject: Rewrite healing item rule and deprecate all existing healing items in a single swoop. --- npc/items/rand_sc_heal.txt | 111 +++++++++++++++++++++++++++++---------------- 1 file changed, 72 insertions(+), 39 deletions(-) (limited to 'npc/items/rand_sc_heal.txt') diff --git a/npc/items/rand_sc_heal.txt b/npc/items/rand_sc_heal.txt index c08d7f271..19d09f62d 100644 --- a/npc/items/rand_sc_heal.txt +++ b/npc/items/rand_sc_heal.txt @@ -7,13 +7,27 @@ // Random heal every x seconds. // // Variables: -// @delay Second of healing -// @min Min amount of healing -// @max Max amount of healing -// @type 1 Heal -// 2 Other -// 3 Special 1 -// 4 Special 2 +// @type +// 0 - Sweeties (lowest) +// 1 - Vegetables +// 2 - Proteins +// 3 - Proccessed +// 4 - Magical (highest) +// @delay +// Overrides the lasting time +// @rarity +// How rare the item is (how much should it effect) +// Ranges from 1 to 10. +// +// Formula: +// MinHeal %: @rarity * ((@type*1) + 1) +// MaxHeal %: @rarity * ((@type*2) + 1) +// Delay: 1 + (@type*2) +// Sweeties: 1s +// Vegetables: 3s +// Proteins: 5s +// Proccessed: 7s +// Magical: 9s // // *getequipoption(EQI_HEAD_TOP,1,168); → Heal Bonus (should be first bonus on Chef Hat) @@ -21,6 +35,7 @@ - script rand_sc_heal -1,{ // Add remaning bonus if the last one hasn't finished + /* function remaining_bonus { if (getstatus(getarg(0))) @@ -48,46 +63,64 @@ } return; } + */ OnUse: - if (@delay <= 0) close; +// @type +// 0 - Sweeties (lowest) +// 1 - Vegetables +// 2 - Proteins +// 3 - Proccessed +// 4 - Magical (highest) +// @delay +// Overrides the lasting time +// @rarity +// How rare the item is (how much should it effect) +// Ranges from 1 to 10. + if (@rarity <= 0) { + Exception("Invalid healing item, deleting without healing effect."); + end; + } - // minimum between @min and bVit / 2 * BaseLevel / 10 - .@vitality_bonus = min(@min, readparam(bVit) * BaseLevel / 20); - .@rand_heal_val = rand(@min, @max); + // Calculate healing value in % + @min=@rarity * ((@type*1) + 1); + @max=@rarity * ((@type*1) + 1); - // val1 used to be the heal value without the vitality bonus - @val1 = (.@rand_heal_val + .@vitality_bonus) / @delay; - @val3 = (.@rand_heal_val + .@vitality_bonus) / @delay; + // Vitality raises the minimum healing value in 1%, capped at maximum vlaue + @min = min(@max, @min+readparam(bVit)); - if (@val3 <= 0) close; + // Make these abstract % in absolute values + @min=max(1, MaxHp*@min/100); + @max=max(3, MaxHp*@max/100); - @delay *= 1000; // Put the delay in ms + // Calculate how much you'll heal + @val1 = rand(@min, @max); - switch (@type) - { - case 1: - .@skill = SC_S_LIFEPOTION; - break; - case 2: - .@skill = SC_L_LIFEPOTION; - break; - case 3: - .@skill = SC_G_LIFEPOTION; - break; - case 4: - .@skill = SC_M_LIFEPOTION; - break; - default : - .@skill = 0; - break; + // Calculate delay if it was not given + if (!@delay) { + @delay=1 + (@type*2); } - if (.@skill != 0) - { - remaining_bonus(.@skill); - sc_end .@skill; - sc_start2 .@skill, @delay, @val1, 1; + + // Put the delay in ms + @delay *= 1000; + + // We now have @val1 (new effect), @delay (new delay) + // But do we have .@v and .@d (old effect and delay)? + .@v=getstatus(getarg(0), 1); + .@d=getstatus(getarg(0), 4) * 1000; + + // If there WAS an effect previously, get ponderate average + if (.@v > 0) + @val1=ponderate_avg(@val1, @delay, .@v, .@d); + + // Decide the healing bonus type. We have four types: S, L, G and M + // By default, we use 'S' + .@skill = SC_S_LIFEPOTION; + + // Apply the effect and finish + sc_end .@skill; + sc_start2 .@skill, @delay, @val1, 1; } - close; + end; } -- cgit v1.2.3-60-g2f50