summaryrefslogtreecommitdiff
path: root/npc/craft
diff options
context:
space:
mode:
Diffstat (limited to 'npc/craft')
-rw-r--r--npc/craft/options.txt60
1 files changed, 60 insertions, 0 deletions
diff --git a/npc/craft/options.txt b/npc/craft/options.txt
index 3928adff1..b023a1e19 100644
--- a/npc/craft/options.txt
+++ b/npc/craft/options.txt
@@ -636,6 +636,66 @@ function script csys_Apply {
return;
}
+// Attribute perfect item options
+// For Fortress Island only
+// csys_ApplyPerfect( invindex, lvl{, scope} )
+function script csys_ApplyPerfect {
+ .@id=getarg(0);
+ .@lv=getarg(1);
+ .@sc=getarg(2, CRAFTSYS_CURRENT);
+
+ // Generate lists, disregarding level
+ csys_Generate(.@sc);
+ // @csys_attr → Available attributes
+ // @csys_penalty → Penalty attribute array
+
+ // Remove weapon-only bonuses if it is armor
+ delinventorylist();
+ getinventorylist();
+ .@itemid=@inventorylist_id[.@id];
+ if (getiteminfo(.@itemid, ITEMINFO_TYPE) != IT_WEAPON)
+ csys_ArmorFix(.@itemid);
+ else
+ csys_WeaponFix(.@itemid);
+ .@eqplv=getiteminfo(.@itemid, ITEMINFO_ELV);
+
+ // Shuffle the arrays
+ array_shuffle(@csys_attr);
+ array_shuffle(@csys_penalty);
+
+ // How many bonuses we'll have? Never more than 3 bonus and 2 onus.
+ .@max_attr=getarraysize(@csys_attr);
+ .@max_pena=getarraysize(@csys_penalty);
+
+ if ($@GM_OVERRIDE)
+ debugmes "ApplyPerfect: We have %d attributes and %d penalties",
+ .@max_attr, .@max_pena;
+
+ .@slot=0;
+ while (.@slot < min(3, .@max_attr)) {
+ // Apply a bonus using array_pop (it was shuffled so we're fine)
+ .@vartp=array_pop(@csys_attr);
+ .@bonus=csys_BonusCalc(10, .@lv, .@vartp, .@eqplv);
+ setitemoptionbyindex(.@id, .@slot, .@vartp, .@bonus);
+ //debugmes "Bonus applied: %d at %d (slot: %d)", .@vartp, .@bonus, .@slot;
+ .@slot+=1;
+ }
+
+ if (.@max_pena) {
+ // Apply a malus using array_pop (it was shuffled so we're fine)
+ .@vartp=array_pop(@csys_penalty);
+ .@malus=csys_BonusCalc(10, .@lv, .@vartp);
+ .@malus=.@malus*70/100;
+ if (.@vartp > 0 && .@malus > 0)
+ setitemoptionbyindex(.@id, .@slot, .@vartp, -(.@malus));
+ .@slot+=1;
+ }
+
+ // The options have been attributed, clear temporary variables
+ @csysArmor=false;
+ return;
+}
+