From 0e046a0fc6c2a37084dddbb83d0b58cfa4d01052 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 16 Jul 2020 23:23:24 -0300 Subject: And, for players general happiness, I added a re-roll when result is too low. This re-roll is based on equipment level, and do not happen on maluses. Legendary Wand, for example, will get a re-roll if result < 20% of maximum. --- npc/craft/options.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'npc/craft') diff --git a/npc/craft/options.txt b/npc/craft/options.txt index cb9b28068..fb23c7fd2 100644 --- a/npc/craft/options.txt +++ b/npc/craft/options.txt @@ -494,12 +494,13 @@ function script csys_WeaponFix { return; } -// csys_BonusCalc( lv1, lv2, vartp ) +// csys_BonusCalc( lv1, lv2, vartp{, equip lvl} ) // Calculates the due bonus function script csys_BonusCalc { .@craft=getarg(0); .@skill=getarg(1); .@var=getarg(2); + .@eqlv=getarg(3, 0); .@mult=csys_Multiplier(.@var); .@avmult=(.@craft+.@skill)*.@mult; @@ -507,6 +508,13 @@ function script csys_BonusCalc { .@avg=.@avmult/10; .@base=rand2(1, .@avg+1); + // Re-roll if you got a too bad result: + // Each equip level will yield 0.2% reroll + // Means a lv 100 equip gets 20% of grace-reroll. + // By default, this rule is skipped for maluses! + if (.@base < (.@avg+1)*.@eqlv/500) + .@base=rand2(1, .@avg+1); + // If you are in the upper 70%, we do a re-roll // It usually will lower the result, but is up to luck if (.@base >= (.@avg+1)*7/10) @@ -577,6 +585,7 @@ function script csys_Apply { csys_ArmorFix(.@itemid); else csys_WeaponFix(.@itemid); + .@eqplv=getiteminfo(.@itemid, ITEMINFO_ELV); // Shuffle the arrays array_shuffle(@csys_attr); @@ -599,7 +608,7 @@ function script csys_Apply { // Apply a bonus using array_pop (it was shuffled so we're fine) .@vartp=array_pop(@csys_attr); - .@bonus=csys_BonusCalc(.@lv, .@lv2, .@vartp); + .@bonus=csys_BonusCalc(.@lv, .@lv2, .@vartp, .@eqplv); setitemoptionbyindex(.@id, .@slot, .@vartp, .@bonus); //debugmes "Bonus applied: %d at %d (slot: %d)", .@vartp, .@bonus, .@slot; .@slot+=1; -- cgit v1.2.3-70-g09d2