diff options
Diffstat (limited to 'npc/craft/options.txt')
-rw-r--r-- | npc/craft/options.txt | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/npc/craft/options.txt b/npc/craft/options.txt index 76862cee5..284d57ead 100644 --- a/npc/craft/options.txt +++ b/npc/craft/options.txt @@ -367,6 +367,21 @@ function script csys_Multiplier { return 0; } +// csys_BonusCalc( lv1, lv2, vartp ) +// Calculates the due bonus +function script csys_BonusCalc { + .@craft=getarg(0); + .@skill=getarg(1); + .@var=getarg(2); + + .@avg=(.@craft+.@skill)/2; + .@base=rand2(1, .@avg+1); + .@mult=csys_Multiplier(.@var); + + return .@base*.@mult+1; + +} + // Attribute item options // Does NOT performs success chance check, and can be used by NPC // csys_Apply( invindex{, lvl, scope} ) @@ -398,7 +413,7 @@ function script csys_Apply { // Apply a bonus using array_pop (it was shuffled so we're fine) .@vartp=array_pop(@csys_attr); - .@bonus=rand(1, (.@lv+.@lv2)/2+1)*csys_Multiplier(.@vartp)+1; + .@bonus=csys_BonusCalc(.@lv, .@lv2, .@vartp); setitemoptionbyindex(.@id, .@slot, .@vartp, .@bonus); //debugmes "Bonus applied: %d at %d (slot: %d)", .@vartp, .@bonus, .@slot; .@slot+=1; @@ -414,7 +429,7 @@ function script csys_Apply { // Apply a malus using array_pop (it was shuffled so we're fine) .@vartp=array_pop(@csys_penalty); - .@malus=rand(1, (.@lv+.@lv2)/2+1)*csys_Multiplier(.@vartp)+1; + .@malus=csys_BonusCalc(.@lv, .@lv2, .@vartp); setitemoptionbyindex(.@id, .@slot, .@vartp, -(.@malus)); .@slot+=1; .@slt+=1; |