Advertisement
Sehrentos

rAthena NPC script disenchant

Oct 10th, 2018
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.52 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Disenchant NPC
  3. //===== By: ==================================================
  4. //= Sehrentos
  5. //===== Current Version: =====================================
  6. //= 1.0
  7. //===== Compatible With: =====================================
  8. //= rAthena Project
  9. //===== Description: =========================================
  10. //= NPC that can melt or disenchant your inventory equipment
  11. //= for refining materials.
  12. //= @disenchant - Disenchant equipment from inventory.
  13. //===== Additional Comments: =================================
  14. //= For Item Types see: IT_ in src/map/script_constants.hpp
  15. //= 1.0 Initial script.
  16. //============================================================
  17. function script disenchantmain {
  18. disable_items;
  19. .@total = 0;
  20. .@npcname$ = getarg(0);
  21. getinventorylist();
  22. mes "["+ .@npcname$ +"]";
  23. mes "Do you wish to disenchant ^FF0000ALL^000000 equipment in your inventory?";
  24. for(.@i=0; .@i<@inventorylist_count; .@i++) {
  25. .@item_id = @inventorylist_id[.@i];
  26. .@item_type = getiteminfo(.@item_id, 2);
  27. .@item_slot = getiteminfo(.@item_id, 10);
  28. setarray .@cards[0],@inventorylist_card1[.@i],@inventorylist_card2[.@i],@inventorylist_card3[.@i],@inventorylist_card4[.@i];
  29. // Check item is NOT(Pet, Forged, Created, Equiped) and type IS(Armor, Weapon) and does not have any cards equiped
  30. if (@inventorylist_card1[.@i] != CARD0_PET &&
  31. @inventorylist_card1[.@i] != CARD0_FORGE &&
  32. @inventorylist_card1[.@i] != CARD0_CREATE &&
  33. @inventorylist_equip[.@i] <= 0 &&
  34. getarraysize(.@cards) <= 0 &&
  35. (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON))
  36. {
  37. // 1 x +1 Knife[0/3] | 1 x Unidentified
  38. mes @inventorylist_amount[.@i] + " x" +
  39. (@inventorylist_refine[.@i] ? "+"+ @inventorylist_refine[.@i] : "") +
  40. (@inventorylist_identify[.@i] > 0 ? getitemname(.@item_id) + "["+ getarraysize(.@cards) +"/"+ .@item_slot +"]" : "Unidentified");
  41. .@total++;
  42. }
  43. }
  44. mes "Total ("+.@total+") item.";
  45. switch(select("Select Item:Disenchant All:Purify Rough Stones:Leave")) {
  46. case 1: goto L_Select; break;
  47. case 2: goto L_All; break;
  48. case 3: goto L_Purify; break;
  49. default: goto L_Leave; break;
  50. }
  51. close;
  52.  
  53. L_Leave:
  54. clear;
  55. mes "["+ .@npcname$ +"]";
  56. mes "Good bye.";
  57. close;
  58.  
  59. L_Select:
  60. clear;
  61. getinventorylist();
  62. copyarray .@inventorylist_id[0],@inventorylist_id[0],@inventorylist_count;
  63. mes "["+ .@npcname$ +"]";
  64. mes "Select single item that will be ^FF0000destroyed^000000 in process and you will receive one";
  65. mes "^3A4750Phracon, Emvertarcon, Rough Oridecon, Rough Elunium^000000";
  66. mes "depending on the item level.";
  67. // Create menu
  68. for(.@i=0; .@i<@inventorylist_count; .@i++) {
  69. .@item_id = @inventorylist_id[.@i];
  70. .@item_type = getiteminfo(.@item_id, 2);
  71. setarray .@cards[0],@inventorylist_card1[.@i],@inventorylist_card2[.@i],@inventorylist_card3[.@i],@inventorylist_card4[.@i];
  72. // Check item is NOT(Pet, Forged, Created, Equiped) and type IS(Armor, Weapon) and does not have any cards equiped
  73. if (@inventorylist_card1[.@i] != CARD0_PET &&
  74. @inventorylist_card1[.@i] != CARD0_FORGE &&
  75. @inventorylist_card1[.@i] != CARD0_CREATE &&
  76. @inventorylist_equip[.@i] <= 0 &&
  77. getarraysize(.@cards) <= 0 &&
  78. (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON))
  79. {
  80. .@str$ = (@inventorylist_refine[.@i] > 0 ? "+"+ @inventorylist_refine[.@i] : "") +
  81. (@inventorylist_identify[.@i] > 0 ? getitemname(.@item_id) + "["+ getarraysize(.@cards) +"/"+ getiteminfo(.@item_id, 10) +"]" : "Unidentified");
  82. // +1 Knife[0/3] | Unidentified
  83. setarray .@menu_name$[getarraysize(.@menu_name$)], .@str$;
  84. setarray .@menu_index[getarraysize(.@menu_name$)-1], .@i;
  85. }
  86. }
  87.  
  88. // Check available items
  89. if (getarraysize(.@menu_name$) < 1) {
  90. clear;
  91. mes "["+ .@npcname$ +"]";
  92. mes "You have nothing,";
  93. mes "that I can disenchant.";
  94. close;
  95. }
  96.  
  97. .@menu$ = implode(.@menu_name$, ":");
  98. .@select = select(.@menu$) - 1; // select start from index 1
  99. .@index = .@menu_index[.@select];
  100. getinventorylist(); //Refresh itemlist after select
  101. .@item_id = @inventorylist_id[.@index];
  102. .@item_amount = @inventorylist_amount[.@index];
  103. .@item_level = getiteminfo(.@item_id, 13);
  104.  
  105. // Check if target item has changed
  106. if(.@inventorylist_id[.@index] != .@item_id || .@item_id <= 0) {
  107. clear;
  108. mes "["+ .@npcname$ +"]";
  109. mes "Something went wrong!";
  110. mes "Please try again.";
  111. close;
  112. }
  113.  
  114. // Material for each Weapon/Armor level
  115. setarray .@material[0],
  116. 757, // 0)Rough Elunium
  117. 1010, // 1)Phracon
  118. 1011, // 2)Emvertarcon
  119. 756, // 3)Rough Oridecon
  120. 756, // 4)Rough Oridecon
  121. 984; // 5)Oridecon
  122.  
  123. clear;
  124. delitem .@item_id, .@item_amount;
  125. getitem .@material[.@item_level], .@item_amount;
  126. mes "["+ .@npcname$ +"]";
  127. mes "Total ("+ .@item_amount +") item disenchanted.";
  128. close;
  129.  
  130. L_All:
  131. clear;
  132. mes "["+ .@npcname$ +"]";
  133. mes "Are you sure?";
  134. mes "All items will be ^FF0000destroyed^000000 in process and you will receive one";
  135. mes "^3A4750Phracon, Emvertarcon, Rough Oridecon, Rough Elunium^000000";
  136. mes "depending on the item level.";
  137. if(select("Yes:No") != 1) {
  138. goto L_Leave;
  139. }
  140.  
  141. .@total = 0;
  142. getinventorylist();
  143.  
  144. // Material for each Weapon/Armor level
  145. setarray .@material[0],
  146. 757, // 0)Rough Elunium
  147. 1010, // 1)Phracon
  148. 1011, // 2)Emvertarcon
  149. 756, // 3)Rough Oridecon
  150. 756, // 4)Rough Oridecon
  151. 984; // 5)Oridecon
  152.  
  153. clear;
  154. mes "["+ .@npcname$ +"]";
  155. for(.@i=0; .@i<@inventorylist_count; .@i++) {
  156. // Check item is NOT(Pet, Forged, Created, Equiped) and type IS(Armor, Weapon) and does not have any cards equiped
  157. .@item_id = @inventorylist_id[.@i];
  158. .@item_amount = @inventorylist_amount[.@i];
  159. .@item_type = getiteminfo(.@item_id, 2);
  160. .@item_level = getiteminfo(.@item_id, 13);
  161. setarray .@cards[0],@inventorylist_card1[.@i],@inventorylist_card2[.@i],@inventorylist_card3[.@i],@inventorylist_card4[.@i];
  162. if (@inventorylist_card1[.@i] != CARD0_PET &&
  163. @inventorylist_card1[.@i] != CARD0_FORGE &&
  164. @inventorylist_card1[.@i] != CARD0_CREATE &&
  165. @inventorylist_equip[.@i] <= 0 &&
  166. getarraysize(.@cards) <= 0 &&
  167. (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON))
  168. {
  169. delitem .@item_id, .@item_amount;
  170. getitem .@material[.@item_level], .@item_amount;
  171. .@total = .@total + .@item_amount;
  172. }
  173. }
  174. mes "Total ("+.@total+") item disenchanted.";
  175. close;
  176.  
  177. L_Purify:
  178. clear;
  179. mes "["+ .@npcname$ +"]";
  180. mes "I can purify your";
  181. mes "^3A4750Rough Oridecon^000000 or";
  182. mes "^3A4750Rough Elunium^000000. I'll need";
  183. mes "5 Rough Stones to make";
  184. mes "1 pure one for you.";
  185. if(select("Purify All:Leave") != 1) {
  186. goto L_Leave;
  187. }
  188. clear;
  189. .@total = 0;
  190. mes "["+ .@npcname$ +"]";
  191. while(countitem(756) > 4) {
  192. delitem 756,5; // Oridecon_Stone
  193. getitem 984,1; // Oridecon
  194. .@total++;
  195. }
  196. while(countitem(757) > 4) {
  197. delitem 757,5; // Elunium_Stone
  198. getitem 985,1; // Elunium
  199. .@total++;
  200. }
  201. if(.@total > 0)
  202. mes "Total ("+.@total+") purified.";
  203. else
  204. mes "I need 5 ^3A4750Rough Oridecon^000000 or ^3A4750Rough Elunium^000000.";
  205. close;
  206. }
  207.  
  208. // At Command
  209. // ===================================================
  210. - script #atcmd_disenchant -1,{
  211. OnInit:
  212. bindatcmd "disenchant", strnpcinfo(3)+"::OnAtCommand",0,10;
  213. end;
  214.  
  215. OnAtCommand:
  216. showscript "Disenchant!!", getcharid(3), SELF;
  217. callfunc "disenchantmain","Disenchant";
  218. end;
  219. }
  220.  
  221. // Disenchant NPC
  222. // ===================================================
  223. prontera,157,174,5 script Disenchant#prt1 828,{
  224. callfunc "disenchantmain","Disenchant";
  225. end;
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement