diff options
-rw-r--r-- | npc/craft/options.txt | 197 |
1 files changed, 115 insertions, 82 deletions
diff --git a/npc/craft/options.txt b/npc/craft/options.txt index 3f3822d9e..2442060db 100644 --- a/npc/craft/options.txt +++ b/npc/craft/options.txt @@ -27,98 +27,131 @@ // Max Level for ultimate tier: 1 // csys_Generate( cr_id{, preserve} ) +// Return average level function script csys_Generate { .@gid=getarg(0); if (!getarg(1, false)) { deletearray(@csys_attr); deletearray(@csys_penalty); } - .@lvl=getd("CRAFTSYS["+.@gid+"]"); - - switch (.@gid) { - case CRGROUP_BASE: - if (.@lvl >= 1) - array_push(@csys_attr, VAR_STRAMOUNT); - if (.@lvl >= 2) - array_push(@csys_attr, VAR_AGIAMOUNT); - if (.@lvl >= 3) - array_push(@csys_attr, VAR_VITAMOUNT); - if (.@lvl >= 4) - array_push(@csys_attr, VAR_INTAMOUNT); - if (.@lvl >= 5) - array_push(@csys_attr, VAR_DEXAMOUNT); - if (.@lvl >= 6) - array_push(@csys_attr, VAR_LUKAMOUNT); - if (.@lvl >= 8) - array_push(@csys_attr, VAR_MAXHPAMOUNT); - if (.@lvl >= 10) - array_push(@csys_attr, VAR_MAXSPAMOUNT); - break; + //.@lvl=getd("CRAFTSYS["+.@gid+"]"); + .@avg=0; + .@stk=0; + + if (.@gid & CRGROUP_BASE) { + .@lvl=CRAFTSYS[CRGROUP_BASE]; + if (.@lvl >= 1) + array_push(@csys_attr, VAR_STRAMOUNT); + if (.@lvl >= 2) + array_push(@csys_attr, VAR_AGIAMOUNT); + if (.@lvl >= 3) + array_push(@csys_attr, VAR_VITAMOUNT); + if (.@lvl >= 4) + array_push(@csys_attr, VAR_INTAMOUNT); + if (.@lvl >= 5) + array_push(@csys_attr, VAR_DEXAMOUNT); + if (.@lvl >= 6) + array_push(@csys_attr, VAR_LUKAMOUNT); + if (.@lvl >= 8) + array_push(@csys_attr, VAR_MAXHPAMOUNT); + if (.@lvl >= 10) + array_push(@csys_attr, VAR_MAXSPAMOUNT); + + // Update averages + .@avg+=.@lvl; + .@stk+=1; + } // First tier - case CRGROUP_ATK: - if (.@lvl >= 1) { - array_push(@csys_attr, VAR_ATTPOWER); - array_push(@csys_attr, VAR_ATTMPOWER); - } - if (.@lvl >= 5) { - array_push(@csys_attr, VAR_MAGICATKPERCENT); - array_push(@csys_attr, VAR_ATKPERCENT); - } - array_push(@csys_penalty, VAR_ITEMDEFPOWER); - array_push(@csys_penalty, VAR_MDEFPOWER); - break; - case CRGROUP_DEF: - if (.@lvl >= 1) { - array_push(@csys_attr, VAR_ITEMDEFPOWER); - array_push(@csys_attr, VAR_MDEFPOWER); - } - if (.@lvl >= 5) { - array_push(@csys_attr, DAMAGE_CRI_USER); - array_push(@csys_attr, RANGE_ATTACK_DAMAGE_USER); - } - array_push(@csys_penalty, VAR_ATTPOWER); - array_push(@csys_penalty, VAR_ATTMPOWER); - break; - case CRGROUP_ACC: - if (.@lvl >= 1) { - array_push(@csys_attr, VAR_HITSUCCESSVALUE); - } - if (.@lvl >= 5) { - array_push(@csys_attr, VAR_CRITICALSUCCESSVALUE); - } - array_push(@csys_penalty, VAR_ATTPOWER); - array_push(@csys_penalty, VAR_ATTMPOWER); - break; - break; - case CRGROUP_EVD: - if (.@lvl >= 1) { - array_push(@csys_attr, VAR_AVOIDSUCCESSVALUE); - } - if (.@lvl >= 5) { - array_push(@csys_attr, VAR_PLUSAVOIDSUCCESSVALUE); - } - array_push(@csys_penalty, VAR_ATTPOWER); - array_push(@csys_penalty, VAR_ATTMPOWER); - break; - break; + if (.@gid & CRGROUP_ATK) { + .@lvl=CRAFTSYS[CRGROUP_ATK]; + if (.@lvl >= 1) { + array_push(@csys_attr, VAR_ATTPOWER); + array_push(@csys_attr, VAR_ATTMPOWER); + } + if (.@lvl >= 5) { + array_push(@csys_attr, VAR_MAGICATKPERCENT); + array_push(@csys_attr, VAR_ATKPERCENT); + } + array_push(@csys_penalty, VAR_ITEMDEFPOWER); + array_push(@csys_penalty, VAR_MDEFPOWER); + + // Update averages + .@avg+=.@lvl; + .@stk+=1; + } + if (.@gid & CRGROUP_DEF) { + .@lvl=CRAFTSYS[CRGROUP_DEF]; + if (.@lvl >= 1) { + array_push(@csys_attr, VAR_ITEMDEFPOWER); + array_push(@csys_attr, VAR_MDEFPOWER); + } + if (.@lvl >= 5) { + array_push(@csys_attr, DAMAGE_CRI_USER); + array_push(@csys_attr, RANGE_ATTACK_DAMAGE_USER); + } + array_push(@csys_penalty, VAR_ATTPOWER); + array_push(@csys_penalty, VAR_ATTMPOWER); + + // Update averages + .@avg+=.@lvl; + .@stk+=1; + } + if (.@gid & CRGROUP_ACC) { + .@lvl=CRAFTSYS[CRGROUP_ACC]; + if (.@lvl >= 1) { + array_push(@csys_attr, VAR_HITSUCCESSVALUE); + } + if (.@lvl >= 5) { + array_push(@csys_attr, VAR_CRITICALSUCCESSVALUE); + } + array_push(@csys_penalty, VAR_ATTPOWER); + array_push(@csys_penalty, VAR_ATTMPOWER); + + // Update averages + .@avg+=.@lvl; + .@stk+=1; + } + if (.@gid & CRGROUP_EVD) { + .@lvl=CRAFTSYS[CRGROUP_EVD]; + if (.@lvl >= 1) { + array_push(@csys_attr, VAR_AVOIDSUCCESSVALUE); + } + if (.@lvl >= 5) { + array_push(@csys_attr, VAR_PLUSAVOIDSUCCESSVALUE); + } + array_push(@csys_penalty, VAR_ATTPOWER); + array_push(@csys_penalty, VAR_ATTMPOWER); + + // Update averages + .@avg+=.@lvl; + .@stk+=1; + } + // Second tier - case CRGROUP_REGEN: - if (.@lvl >= 1) { - array_push(@csys_attr, VAR_HPACCELERATION); - } - if (.@lvl >= 5) { - array_push(@csys_attr, VAR_SPACCELERATION); - } - array_push(@csys_penalty, VAR_ATTPOWER); - array_push(@csys_penalty, VAR_ATTMPOWER); - break; + if (.@gid & CRGROUP_REGEN) { + .@lvl=CRAFTSYS[CRGROUP_REGEN]; + if (.@lvl >= 1) { + array_push(@csys_attr, VAR_HPACCELERATION); + } + if (.@lvl >= 5) { + array_push(@csys_attr, VAR_SPACCELERATION); + } + array_push(@csys_penalty, VAR_ATTPOWER); + array_push(@csys_penalty, VAR_ATTMPOWER); + + // Update averages + .@avg+=.@lvl; + .@stk+=1; } // Clear the dummies array_remove(@csys_attr, DeathPenalty); array_remove(@csys_penalty, DeathPenalty); - return; - //return Exception("Invalid ID"); + + // Return the average level + if (!.@stk) + return 0; + return (.@avg/.@stk); } // Confirms if player really wants to tweak a craft. @@ -173,7 +206,7 @@ function script csys_Apply { .@lv=getarg(1, getskilllv(TMW2_CRAFT)); .@sc=getarg(1, CRAFTSYS_CURRENT); - csys_Generate(.@sc); + .@lv2=csys_Generate(.@sc); // @csys_attr → Available attributes // @csys_penalty → Penalty attribute array @@ -197,7 +230,7 @@ function script csys_Apply { // Apply a bonus using array_pop (it was shuffled so we're fine) // A pity 1 str and 1 hp is so different. .@vartp=array_pop(@csys_attr); - .@bonus=rand(1, .@lv); + .@bonus=rand(1, .@lv+.@lv2); setitemoptionbyindex(.@id, .@slot, .@vartp, .@bonus); //debugmes "Bonus applied: %d at %d (slot: %d)", .@vartp, .@bonus, .@slot; .@slot+=1; @@ -214,7 +247,7 @@ function script csys_Apply { // Apply a bonus using array_pop (it was shuffled so we're fine) // A pity 1 str and 1 hp is so different. .@vartp=array_pop(@csys_penalty); - .@bonus=rand(1, .@lv); + .@bonus=rand(1, .@lv+.@lv2); setitemoptionbyindex(.@id, .@slot, .@vartp, .@bonus); .@slot+=1; .@slt+=1; |