Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== rAthena Script =======================================
- //= Refine
- //===== By: ==================================================
- //= Sehrentos
- //===== Current Version: =====================================
- //= 1.0
- //===== Compatible With: =====================================
- //= rAthena Project
- //===== Description: =========================================
- //= Refine NPC with account wide material storage.
- //===== Additional Comments: =================================
- //= 1.0 Initial script.
- //============================================================
- prontera,155,174,5 script Refine#prt1::zRef -1,{
- disable_items;
- mes "[" + strnpcinfo(1) + "]";
- mes "I am the Armsmith";
- mes "I can refine all kinds of weapons,";
- mes "armor and equipment, so let me";
- mes "know what you want to refine.";
- setarray .@indices[1], EQI_HEAD_TOP, EQI_HEAD_MID, EQI_HEAD_LOW, EQI_ARMOR, EQI_HAND_L, EQI_HAND_R, EQI_GARMENT, EQI_SHOES, EQI_ACC_L, EQI_ACC_R;
- setarray .@position$[1], "Top", "Mid", "Low", "Armor", "Hand L", "Hand R", "Garment", "Shoes", "Accessory L", "Accessory R";
- setarray .@option[1], 1, 1, 1, 1, 1, 1, 1, 1, 1, 1; // 1=allow, 0=deny
- for(.@i=1; .@i<getarraysize(.@indices); .@i++) {
- if(.@option[.@i] && getequipisequiped(.@indices[.@i])) {
- .@ref = getequiprefinerycnt(.@indices[.@i]);
- .@menu$ = .@menu$+"^3a4750"+.@position$[.@i]+"-[^000000"+(.@ref>0?"+"+.@ref+" ":"")+""+getequipname(.@indices[.@i])+"^3a4750]";
- }
- .@menu$ = .@menu$ + ":";
- }
- // Options menu
- .@menu$ = .@menu$ + "Store Materials";
- .@index = select(.@menu$);
- if(.@index >= getarraysize(.@indices)) goto L_MaterialStorage;
- // Continue refine
- .@part = .@indices[.@index];
- if(!getequipisequiped(.@part)) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "But, there is nothing equiped...";
- close;
- }
- if(!getequipisenableref(.@part)) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "I don't think I can refine this item at all.";
- close;
- }
- .@refineitemid = getequipid(.@part);
- .@refinerycnt = getequiprefinerycnt(.@part);
- setarray .@card[0], getequipcardid(.@part,0), getequipcardid(.@part,1), getequipcardid(.@part,2), getequipcardid(.@part,3);
- .@price = getequiprefinecost(.@part, REFINE_COST_NORMAL, REFINE_ZENY_COST);
- .@material = getequiprefinecost(.@part, REFINE_COST_NORMAL, REFINE_MATERIAL_ID);
- .@ms_material = getd("#MS_"+getitemname(.@material));
- .@level = getequipweaponlv(.@part);
- .@chance = getequippercentrefinery(.@part);
- // Over +10 cost
- if(.@refinerycnt >= 10) {
- .@price = getequiprefinecost(.@part, REFINE_COST_OVER10, REFINE_ZENY_COST);
- }
- // Max refine
- if(.@refinerycnt >= 20) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "This item cannot be refined because it has already reached its maximum level...";
- close;
- }
- clear;
- mes "[" + strnpcinfo(1) + "]";
- if(.@level > 0)
- mes "A level " + .@level + " weapon.";
- mes "To refine this, I need";
- mes ""+ callsub(S_ItemLink,.@material);
- mes .@price +" Zeny";
- if(getequippercentrefinery(.@part) < 100)
- mes .@chance +" % chance to success.";
- mes "Do you wish to continue?";
- if(select("Yes:No") != 1) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "There's no need to rush.";
- mes "Take your time.";
- close;
- }
- // Warn about change of failure
- if(getequippercentrefinery(.@part) < 100) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "This equipment may ^ff0000break^000000 if you refine it again.";
- mes "And if it breaks, ^ff0000Item will be lost!^000000";
- mes .@chance +" % chance to success.";
- mes "Are you sure you still want to continue?";
- if(select("Yes:No") != 1) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "I completely agree...";
- mes "I might be a great smith, but sometimes even I make mistakes.";
- close;
- }
- }
- // Count materials from inventory first, then in material storage
- if(countitem(.@material) < 1 && .@ms_material < 1) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "You don't seem to have enough";
- mes ""+ callsub(S_ItemLink,.@material) + "";
- close;
- }
- // Count currency
- if(Zeny < .@price) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "You don't seem to have enough";
- mes "Zeny";
- close;
- }
- // Remove materials from inventory if exist, else in material storage
- if(countitem(.@material) > 0)
- delitem .@material, 1;
- else
- setd "#MS_"+getitemname(.@material), .@ms_material-1;
- set Zeny, Zeny - .@price;
- // Anti-hack checks
- if(.@refineitemid != getequipid(.@part) || .@refinerycnt != getequiprefinerycnt(.@part) || (.@card[0] != getequipcardid(.@part,0) && .@card[1] != getequipcardid(.@part,1) && .@card[2] != getequipcardid(.@part,2) && .@card[3] != getequipcardid(.@part,3))) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "Oh, almost refined wrong equipment.";
- mes "Please select again.";
- close;
- }
- // Safe refine
- if(getequippercentrefinery(.@part) >= 100) {
- successrefitem .@part;
- clear;
- mes "[" + strnpcinfo(1) + "]";
- switch(rand(5)){
- case 1: mes "Here you are!"; break;
- case 2: mes "Here is your item!"; break;
- case 3: mes "A great work, don't you think!"; break;
- case 4: mes "Works every time!"; break;
- default: mes "What a great "+(isday()?"day":"night")+" to be a smith!"; break;
- }
- close;
- }
- // Chance of success
- if(getequippercentrefinery(.@part) >= rand(100)) {
- successrefitem .@part;
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "^009900Success^000000";
- mes "Here you are! It's done.";
- if(rand(100) <= 5) {
- mes "It's been a while since I've made such a fine refine!";
- emotion ET_BEST;
- }
- close;
- }
- // Failure
- failedrefitem .@part;
- emotion ET_SWEAT;
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "^ff0000Failed^000000";
- mes "What a shame...";
- mes "Your equipment ^ff0000broke^000000 during the refining process. I had told you earlier this might happen!";
- close;
- L_MaterialStorage:
- // All materials to store
- setarray .@materials[0],
- 984/*Oridecon*/,
- 985/*Elunium*/,
- 1010/*Phracon*/,
- 1011/*Emvertarcon*/,
- 6224/*Bradium*/,
- 6223/*Carnium*/;
- clear;
- emotion ET_QUESTION;
- mes "[" + strnpcinfo(1) + "]";
- mes "Do you want to store the materials in my storage?";
- mes "Your current balance is:";
- for(.@i=0; .@i<getarraysize(.@materials); .@i++) {
- .@name$ = getitemname(.@materials[.@i]);
- .@amount = getd("#MS_"+.@name$);//#MS_Oridecon, #MS_Elunium
- // inventory
- //mes ""+ .@name$ +" x "+ countitem(.@materials[.@i]);
- // variable
- mes ""+ .@name$ +" x "+ .@amount;
- }
- switch(select("Store All:Withdraw All:Leave")) {
- case 1:
- clear;
- .@total = 0;
- mes "[" + strnpcinfo(1) + "]";
- for(.@i=0; .@i<getarraysize(.@materials); .@i++) {
- .@name$ = getitemname(.@materials[.@i]);
- .@amount = countitem(.@materials[.@i]);
- .@stored = getd("#MS_"+.@name$);
- if(.@amount > 0) {
- .@total = .@total + .@amount;
- setd "#MS_"+.@name$, .@stored+.@amount;
- delitem .@materials[.@i], .@amount;
- mes .@name$ + " x "+ .@amount;
- }
- }
- mes "Store ("+ .@total +") item.";
- emotion ET_MONEY;
- break;
- case 2:
- clear;
- .@total = 0;
- mes "[" + strnpcinfo(1) + "]";
- for(.@i=0; .@i<getarraysize(.@materials); .@i++) {
- .@name$ = getitemname(.@materials[.@i]);
- .@amount = getd("#MS_"+.@name$);
- if(.@amount > 0) {
- .@total = .@total + .@amount;
- setd "#MS_"+.@name$, 0;
- getitem .@materials[.@i], .@amount;
- mes .@name$ + " x "+ .@amount;
- }
- }
- mes "Withdraw ("+ .@total +") item.";
- emotion ET_CRY;
- break;
- default:
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "Some other time.";
- break;
- }
- close;
- S_ItemLink:
- // ^nItemIDXXXX^ where XXXX=ID or
- // client 2015+ uses ITEM and older use ITEMLINK
- return "<ITEM>"+getitemname(getarg(0))+"<INFO>"+getarg(0)+"</INFO></ITEM>";
- S_RefineValidate:
- .@level = getarg(0);
- .@refineitemid = getarg(1);
- .@price = getarg(2);
- .@part = getarg(3);
- clear;
- mes "[" + strnpcinfo(1) + "]";
- if (.@level) mes "A level " + .@level + " weapon.";
- mes "To refine this, I need";
- mes ""+ callsub(S_ItemLink,.@refineitemid) + "";
- mes "and "+ .@price +" Zeny";
- mes "Do you wish to continue?";
- if(select("Yes:No") == 1) {
- if(getequippercentrefinery(.@part) < 100) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "This equipment looks like it's been refined many times... It may ^ff0000break^000000 if you refine it again.";
- mes "And if it breaks,";
- mes "^ff0000Item will be lost!^000000";
- mes "Are you sure you still want to continue?";
- if(select("Yes:No") != 1) {
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "I completely agree...";
- mes "I might be a great refiner, but sometimes even I make mistakes.";
- close;
- }
- }
- if(countitem(.@refineitemid) > 0 && Zeny > .@price) {
- delitem .@refineitemid, 1;
- set Zeny, Zeny - .@price;
- return;
- }
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "You don't seem to have enough";
- mes ""+ callsub(S_ItemLink,.@refineitemid) + "";
- mes "or Zeny.";
- close;
- }
- clear;
- mes "[" + strnpcinfo(1) + "]";
- mes "There's no need to rush.";
- mes "Take your time.";
- close;
- }
- // NPC Duplicates
- prontera,155,174,5 duplicate(zRef) Refiner#prt1 826
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement