Try just patch this NPC first
npc/merchants/refine.txt | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/npc/merchants/refine.txt b/npc/merchants/refine.txt
index 48a82d7..89e662f 100644
--- a/npc/merchants/refine.txt
+++ b/npc/merchants/refine.txt
@@ -620,6 +620,12 @@ function script refinemain {
default: .@safe = 4; break;
}
+ .@typevar$ = ""; .@levelvar = 0; .@rate = getequippercentrefinery(.@part); // Init dummy val
+ if (callfunc("F_isCustomLevels",.@refineitemid,.@typevar$,.@levelvar,.@price,.@material)) {
+ .@rate = getd("$"+.@typevar$+"L"+.@levelvar+"_Rates["+.@refinerycnt+"]");
+ .@safe = 3; // You can move this like the functions above
+ }
+
// If the VIP system is enabled, the prices for non-VIP players are considerably higher.
if (VIP_SCRIPT && !vip_status(VIP_STATUS_ACTIVE)) {
switch(getequipweaponlv(.@part)) {
@@ -646,7 +652,7 @@ function script refinemain {
mes "rush. Take your time.";
close;
}
- if(getequippercentrefinery(.@part) < 100) {
+ if(.@rate < 100) {
mes "["+ .@npc_name$ +"]";
mes "Oh no! If I continue to";
mes "refine this, there's a risk it could";
@@ -697,7 +703,7 @@ function script refinemain {
close;
}
- if(getequippercentrefinery(.@part) <= rand(100)) {
+ if(.@rate <= rand(100)) {
failedrefitem .@part;
mes "["+ .@npc_name$ +"]";
emotion (!rand(5))?ET_MONEY:ET_HUK;
@@ -745,7 +751,7 @@ function script refinemain {
}
// New Refining Functions ========================
- if(getequiprefinerycnt(.@part) < .@safe) {
+ if(.@rate < .@safe) {
mes "["+ .@npc_name$ +"]";
mes "I can refine this to the safe limit or a desired number of times. It's your choice.";
next;
Add this snippet to new NPC file, make sure to load it
- Don't forget to define all items by Item ID
- Don't forget to define the rates
- Don't forget to define the cost
- Don't forget to define the material ID ^because I just put an example.
// Don't forget to load the script
- script InitCustomLevels -1,{
OnInit:
$WeaponL5_Zeny = 17600;
$WeaponL5_Material = 6224;
setarray $WeaponL5[0],1136;
$WeaponL6_Zeny = 31700;
$WeaponL6_Material = 6090;
setarray $WeaponL6[0],1138,1140;
setarray $ArmorL2[0],2339;
setarray $ArmorL3[0],0;
setarray $ArmorL4[0],0;
setarray $ArmorL5[0],0;
setarray $ArmorL6[0],0;
setarray $ShieldL2[0],2339;
setarray $ShieldL3[0],0;
setarray $ShieldL4[0],0;
setarray $ShieldL5[0],0;
setarray $ShieldL6[0],0;
// CONTINUE The list yourself...........
setarray $WeaponL5_Rates[0],100,100,100,100,95,90,85,80,75,70,65,60,55,50,45,40,35,30,25,20;
// CONTINUE The rate yourself...........
end;
}
// callfunc("F_isCustomLevels",.@itemid,.@typevar$,.@levelvar,.@zenyvar,.@materialvar);
// .@itemid Item ID need to check
// .@typevar$ this variable will be set to "Armor","Weapon","Shield"
// .@levelvar this variable will be set to custom equip level
// .@zenyvar this variable will be set to zeny requirement for refining. or you can use getd later: getd("$"+.@typevar$.+""+.@levelvar)
// .@materialvar this variable will be set to item id of material for refining. or you can use getd later: getd("$"+.@typevar$.+""+.@levelvar)
function script F_isCustomLevels {
.@itemid = getarg(0,0);
.@n = getargcount();
.@zenyvar = (.@n > 3);
.@materialvar = (.@n > 4);
.@type$ = "Weapon";
for (.@lv = 5; .@lv <= 6; .@lv++) {
.@str$ = "$"+.@type$+"L"+.@lv;
for (.@i = 0; .@i < getarraysize(getd(.@str$)); .@i++) {
if (getd(.@str$+"["+.@i+"]") == .@itemid) {
set getarg(1),.@type$;
set getarg(2),.@lv;
if (.@zenyvar) set getarg(3),getd(.@str$+"_Zeny");
if (.@materialvar) set getarg(4),getd(.@str$+"_Material");
return 1;
}
}
}
.@type$ = "Armor";
for (.@lv = 2; .@lv <= 6; .@lv++) {
.@str$ = "$"+.@type$+"L"+.@lv;
for (.@i = 0; .@i < getarraysize(getd(.@str$)); .@i++) {
if (getd(.@str$+"["+.@i+"]") == .@itemid) {
set getarg(1),.@type$;
set getarg(2),.@lv;
if (.@zenyvar) set getarg(3),getd(.@str$+"_Zeny");
if (.@materialvar) set getarg(4),getd(.@str$+"_Material");
return 1;
}
}
}
.@type$ = "Shield";
for (.@lv = 2; .@lv <= 6; .@lv++) {
.@str$ = "$"+.@type$+"L"+.@lv;
for (.@i = 0; .@i < getarraysize(getd(.@str$)); .@i++) {
if (getd(.@str$+"["+.@i+"]") == .@itemid) {
set getarg(1),.@type$;
set getarg(2),.@lv;
if (.@zenyvar) set getarg(3),getd(.@str$+"_Zeny");
if (.@materialvar) set getarg(4),getd(.@str$+"_Material");
return 1;
}
}
}
return 0;
}
PS: UNTESTED