summaryrefslogtreecommitdiff
path: root/npc/items/rand_sc_heal.txt
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2019-05-20 10:32:41 -0300
committerJesusaves <cpntb1@ymail.com>2019-05-20 10:32:41 -0300
commit5b6e7d9c85f3e48ce84a6fb4b14d4a59f7da086e (patch)
tree0de578cc546cd00ae860eae1513fce666ab1a104 /npc/items/rand_sc_heal.txt
parent5259b5b877f7060397e86b205ee8e63f02bee318 (diff)
downloadserverdata-5b6e7d9c85f3e48ce84a6fb4b14d4a59f7da086e.tar.gz
serverdata-5b6e7d9c85f3e48ce84a6fb4b14d4a59f7da086e.tar.bz2
serverdata-5b6e7d9c85f3e48ce84a6fb4b14d4a59f7da086e.tar.xz
serverdata-5b6e7d9c85f3e48ce84a6fb4b14d4a59f7da086e.zip
Rewrite healing item rule and deprecate all existing healing items in a single swoop.
Diffstat (limited to 'npc/items/rand_sc_heal.txt')
-rw-r--r--npc/items/rand_sc_heal.txt111
1 files changed, 72 insertions, 39 deletions
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;
}