Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== rAthena Script =======================================
- //= Disenchant NPC
- //===== By: ==================================================
- //= Sehrentos
- //===== Current Version: =====================================
- //= 1.0
- //===== Compatible With: =====================================
- //= rAthena Project
- //===== Description: =========================================
- //= NPC that can melt or disenchant your inventory equipment
- //= for refining materials.
- //= @disenchant - Disenchant equipment from inventory.
- //===== Additional Comments: =================================
- //= For Item Types see: IT_ in src/map/script_constants.hpp
- //= 1.0 Initial script.
- //============================================================
- function script disenchantmain {
- disable_items;
- .@total = 0;
- .@npcname$ = getarg(0);
- getinventorylist();
- mes "["+ .@npcname$ +"]";
- mes "Do you wish to disenchant ^FF0000ALL^000000 equipment in your inventory?";
- for(.@i=0; .@i<@inventorylist_count; .@i++) {
- .@item_id = @inventorylist_id[.@i];
- .@item_type = getiteminfo(.@item_id, 2);
- .@item_slot = getiteminfo(.@item_id, 10);
- setarray .@cards[0],@inventorylist_card1[.@i],@inventorylist_card2[.@i],@inventorylist_card3[.@i],@inventorylist_card4[.@i];
- // Check item is NOT(Pet, Forged, Created, Equiped) and type IS(Armor, Weapon) and does not have any cards equiped
- if (@inventorylist_card1[.@i] != CARD0_PET &&
- @inventorylist_card1[.@i] != CARD0_FORGE &&
- @inventorylist_card1[.@i] != CARD0_CREATE &&
- @inventorylist_equip[.@i] <= 0 &&
- getarraysize(.@cards) <= 0 &&
- (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON))
- {
- // 1 x +1 Knife[0/3] | 1 x Unidentified
- mes @inventorylist_amount[.@i] + " x" +
- (@inventorylist_refine[.@i] ? "+"+ @inventorylist_refine[.@i] : "") +
- (@inventorylist_identify[.@i] > 0 ? getitemname(.@item_id) + "["+ getarraysize(.@cards) +"/"+ .@item_slot +"]" : "Unidentified");
- .@total++;
- }
- }
- mes "Total ("+.@total+") item.";
- switch(select("Select Item:Disenchant All:Purify Rough Stones:Leave")) {
- case 1: goto L_Select; break;
- case 2: goto L_All; break;
- case 3: goto L_Purify; break;
- default: goto L_Leave; break;
- }
- close;
- L_Leave:
- clear;
- mes "["+ .@npcname$ +"]";
- mes "Good bye.";
- close;
- L_Select:
- clear;
- getinventorylist();
- copyarray .@inventorylist_id[0],@inventorylist_id[0],@inventorylist_count;
- mes "["+ .@npcname$ +"]";
- mes "Select single item that will be ^FF0000destroyed^000000 in process and you will receive one";
- mes "^3A4750Phracon, Emvertarcon, Rough Oridecon, Rough Elunium^000000";
- mes "depending on the item level.";
- // Create menu
- for(.@i=0; .@i<@inventorylist_count; .@i++) {
- .@item_id = @inventorylist_id[.@i];
- .@item_type = getiteminfo(.@item_id, 2);
- setarray .@cards[0],@inventorylist_card1[.@i],@inventorylist_card2[.@i],@inventorylist_card3[.@i],@inventorylist_card4[.@i];
- // Check item is NOT(Pet, Forged, Created, Equiped) and type IS(Armor, Weapon) and does not have any cards equiped
- if (@inventorylist_card1[.@i] != CARD0_PET &&
- @inventorylist_card1[.@i] != CARD0_FORGE &&
- @inventorylist_card1[.@i] != CARD0_CREATE &&
- @inventorylist_equip[.@i] <= 0 &&
- getarraysize(.@cards) <= 0 &&
- (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON))
- {
- .@str$ = (@inventorylist_refine[.@i] > 0 ? "+"+ @inventorylist_refine[.@i] : "") +
- (@inventorylist_identify[.@i] > 0 ? getitemname(.@item_id) + "["+ getarraysize(.@cards) +"/"+ getiteminfo(.@item_id, 10) +"]" : "Unidentified");
- // +1 Knife[0/3] | Unidentified
- setarray .@menu_name$[getarraysize(.@menu_name$)], .@str$;
- setarray .@menu_index[getarraysize(.@menu_name$)-1], .@i;
- }
- }
- // Check available items
- if (getarraysize(.@menu_name$) < 1) {
- clear;
- mes "["+ .@npcname$ +"]";
- mes "You have nothing,";
- mes "that I can disenchant.";
- close;
- }
- .@menu$ = implode(.@menu_name$, ":");
- .@select = select(.@menu$) - 1; // select start from index 1
- .@index = .@menu_index[.@select];
- getinventorylist(); //Refresh itemlist after select
- .@item_id = @inventorylist_id[.@index];
- .@item_amount = @inventorylist_amount[.@index];
- .@item_level = getiteminfo(.@item_id, 13);
- // Check if target item has changed
- if(.@inventorylist_id[.@index] != .@item_id || .@item_id <= 0) {
- clear;
- mes "["+ .@npcname$ +"]";
- mes "Something went wrong!";
- mes "Please try again.";
- close;
- }
- // Material for each Weapon/Armor level
- setarray .@material[0],
- 757, // 0)Rough Elunium
- 1010, // 1)Phracon
- 1011, // 2)Emvertarcon
- 756, // 3)Rough Oridecon
- 756, // 4)Rough Oridecon
- 984; // 5)Oridecon
- clear;
- delitem .@item_id, .@item_amount;
- getitem .@material[.@item_level], .@item_amount;
- mes "["+ .@npcname$ +"]";
- mes "Total ("+ .@item_amount +") item disenchanted.";
- close;
- L_All:
- clear;
- mes "["+ .@npcname$ +"]";
- mes "Are you sure?";
- mes "All items will be ^FF0000destroyed^000000 in process and you will receive one";
- mes "^3A4750Phracon, Emvertarcon, Rough Oridecon, Rough Elunium^000000";
- mes "depending on the item level.";
- if(select("Yes:No") != 1) {
- goto L_Leave;
- }
- .@total = 0;
- getinventorylist();
- // Material for each Weapon/Armor level
- setarray .@material[0],
- 757, // 0)Rough Elunium
- 1010, // 1)Phracon
- 1011, // 2)Emvertarcon
- 756, // 3)Rough Oridecon
- 756, // 4)Rough Oridecon
- 984; // 5)Oridecon
- clear;
- mes "["+ .@npcname$ +"]";
- for(.@i=0; .@i<@inventorylist_count; .@i++) {
- // Check item is NOT(Pet, Forged, Created, Equiped) and type IS(Armor, Weapon) and does not have any cards equiped
- .@item_id = @inventorylist_id[.@i];
- .@item_amount = @inventorylist_amount[.@i];
- .@item_type = getiteminfo(.@item_id, 2);
- .@item_level = getiteminfo(.@item_id, 13);
- setarray .@cards[0],@inventorylist_card1[.@i],@inventorylist_card2[.@i],@inventorylist_card3[.@i],@inventorylist_card4[.@i];
- if (@inventorylist_card1[.@i] != CARD0_PET &&
- @inventorylist_card1[.@i] != CARD0_FORGE &&
- @inventorylist_card1[.@i] != CARD0_CREATE &&
- @inventorylist_equip[.@i] <= 0 &&
- getarraysize(.@cards) <= 0 &&
- (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON))
- {
- delitem .@item_id, .@item_amount;
- getitem .@material[.@item_level], .@item_amount;
- .@total = .@total + .@item_amount;
- }
- }
- mes "Total ("+.@total+") item disenchanted.";
- close;
- L_Purify:
- clear;
- mes "["+ .@npcname$ +"]";
- mes "I can purify your";
- mes "^3A4750Rough Oridecon^000000 or";
- mes "^3A4750Rough Elunium^000000. I'll need";
- mes "5 Rough Stones to make";
- mes "1 pure one for you.";
- if(select("Purify All:Leave") != 1) {
- goto L_Leave;
- }
- clear;
- .@total = 0;
- mes "["+ .@npcname$ +"]";
- while(countitem(756) > 4) {
- delitem 756,5; // Oridecon_Stone
- getitem 984,1; // Oridecon
- .@total++;
- }
- while(countitem(757) > 4) {
- delitem 757,5; // Elunium_Stone
- getitem 985,1; // Elunium
- .@total++;
- }
- if(.@total > 0)
- mes "Total ("+.@total+") purified.";
- else
- mes "I need 5 ^3A4750Rough Oridecon^000000 or ^3A4750Rough Elunium^000000.";
- close;
- }
- // At Command
- // ===================================================
- - script #atcmd_disenchant -1,{
- OnInit:
- bindatcmd "disenchant", strnpcinfo(3)+"::OnAtCommand",0,10;
- end;
- OnAtCommand:
- showscript "Disenchant!!", getcharid(3), SELF;
- callfunc "disenchantmain","Disenchant";
- end;
- }
- // Disenchant NPC
- // ===================================================
- prontera,157,174,5 script Disenchant#prt1 828,{
- callfunc "disenchantmain","Disenchant";
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement