yuhsing

Untitled

Apr 12th, 2013
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.45 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= All-in-One NPC
  3. //===== By: ==================================================
  4. //= Euphy, modification by Shakto
  5. //===== Current Version: =====================================
  6. //= 1.6
  7. //===== Description: =========================================
  8. //= A compilation of commonly-used NPC scripts.
  9. //== Includes job changer, stylist, refiner, card remover,
  10. //== coin exchanger, rentals, resetter, platinum skills,
  11. //== sex changer, identifier, healer, buffer, and repairman.
  12. //============================================================
  13.  
  14. prt_in,86,57,6 script Refiner NPC 52,{
  15. function Equip_Menu; function Refine_Item;
  16.  
  17. set .@menu$,"";
  18. for (set .@i,0; .@i < getarraysize(.MainMenu$); set .@i,.@i+1) {
  19. if (.MenuOption & pow(2,.@i))
  20. set .@menu$, .@menu$+" ~ "+.MainMenu$[.@i];
  21. set .@menu$, .@menu$+":"; }
  22. switch(select(.@menu$)) {
  23. case 1:
  24. Equip_Menu(1);
  25. setarray .@Materials[0],985,1010,1011,984,984;
  26. setarray .@Safe[0],4,7,6,5,4;
  27. set .@WLv, getequipweaponlv(@i);
  28. set .@SafeCount, .@Safe[.@WLv]-getequiprefinerycnt(@i);
  29. message strcharinfo(0),"Item: +"+getequiprefinerycnt(@i)+" "+getequipname(@i);
  30. switch(select(" ~ Refine once (^0055FF"+getequippercentrefinery(@i)+"^000000% success): ~ Refine multiple times (up to "+(10-getequiprefinerycnt(@i))+"): ~ Refine to safe limit ("+((.@SafeCount>0)?.@SafeCount+" refines":"^777777disabled^000000")+"): ~ ^777777Cancel^000000")) {
  31. case 1: Refine_Item(1, .@Materials[.@WLv], .RP[.@WLv], .@Safe[.@WLv]); close;
  32. case 2:
  33. input .@Refines;
  34. if (.@Refines+getequiprefinerycnt(@i) > 10 || .@Refines < 1) message strcharinfo(0),"Invalid number ("+.@Refines+").";
  35. else Refine_Item(.@Refines, .@Materials[.@WLv], .RP[.@WLv], .@Safe[.@WLv]);
  36. close;
  37. case 3:
  38. if (.@SafeCount < 1) message strcharinfo(0),"The item has already reached the safe limit.";
  39. else Refine_Item(.@SafeCount, .@Materials[.@WLv], .RP[.@WLv], .@Safe[.@WLv]);
  40. close;
  41. case 4: close;
  42. }
  43. case 2:
  44. Equip_Menu(1);
  45. setarray .@Materials[0],7619,7620,7620,7620,7620;
  46. setarray .@Safe[0],4,7,6,5,4;
  47. set .@WLv, getequipweaponlv(@i);
  48. message strcharinfo(0),"Item: +"+getequiprefinerycnt(@i)+" "+getequipname(@i);
  49. if(select(" ~ Refine item (2 * ^0055FF"+getequippercentrefinery(@i)+"^000000% success): ~ ^777777Cancel^000000")==2) close;
  50. Refine_Item(1, .@Materials[.@WLv], .RP[.@WLv], .@Safe[.@WLv], 1);
  51. close;
  52. case 3:
  53. setarray .@position$[1], "Head","Body","Left hand","Right hand","Robe","Shoes","Accessory 1","Accessory 2","Head 2","Head 3";
  54. set .@menu$,"";
  55. for( set .@i,1; .@i <= 10; set .@i,.@i+1 )
  56. {
  57. if( getequipisequiped(.@i) )
  58. set .@menu$, .@menu$ + .@position$[.@i] + "-" + "[" + getequipname(.@i) + "]";
  59. set .@menu$, .@menu$ + ":";
  60. }
  61. set .@part,select(.@menu$);
  62. if( !getequipisequiped(.@part) )
  63. close;
  64. if( !getequipisenableref(.@part) )
  65. {
  66. message strcharinfo(0),"You can't refine this item at all";
  67. }
  68. if( !getequipisidentify(.@part) )
  69. {
  70. message strcharinfo(0),"This item has not been identified";
  71. close;
  72. }
  73. if( getequiprefinerycnt(.@part) >= 10 || getequiprefinerycnt(.@part) < 7 )
  74. {
  75. message strcharinfo(0),"This item cannot be refined because it's refine level is more than 10 or less than 7...";
  76. close;
  77. }
  78. switch( getequipweaponlv(.@part) )
  79. {
  80. case 1: callsub S_RefineValidate,1,6240,50,.@part; break;
  81. case 2: callsub S_RefineValidate,2,6240,200,.@part; break;
  82. case 3: callsub S_RefineValidate,3,6240,5000,.@part; break;
  83. case 4: callsub S_RefineValidate,4,6240,20000,.@part; break;
  84. default: callsub S_RefineValidate,0,6241,2000,.@part; break;
  85. }
  86. if( getequippercentrefinery(.@part) > rand(100) || getequippercentrefinery(.@part) > rand(100) )
  87. {
  88. SuccessRefItem .@part;
  89. message strcharinfo(0),"All done";
  90. close;
  91. }
  92. if( getequiprefinerycnt(.@part) > 7 )
  93. {
  94. downrefitem .@part;
  95. }
  96. message strcharinfo(0),"Your item "+getequipname(.@part)+" has not been refine";
  97. close;
  98. S_RefineValidate:
  99. if( select(" ~ Refine item (2*^0055FF"+getequippercentrefinery(getarg(3))+"^000000% success): ~ ^777777Cancel^000000") == 1 )
  100. {
  101. if( countitem(getarg(1)) > 0 && Zeny > getarg(2) )
  102. {
  103. delitem getarg(1), 1;
  104. set Zeny, Zeny - getarg(2);
  105. return;
  106. }
  107. message strcharinfo(0),"I'll need " + getarg(2) + " zeny and 1 " + getitemname(getarg(1)) + "...";
  108. close;
  109. }
  110. close;
  111. case 4:
  112. setarray .@position$[1],"Head","Body","Left hand","Right hand","Robe","Shoes","Accessory 1","Accessory 2","Head 2","Head 3";
  113. set .@menu$,"";
  114. for(set .@i,1; .@i<=10; set .@i,.@i+1) {
  115. if(getequipisequiped(.@i))
  116. set .@menu$, .@menu$ + .@position$[.@i] + "-" + "[" + getequipname(.@i) + "]";
  117. set .@menu$, .@menu$ + ":";
  118. }
  119. set .@part,select(.@menu$);
  120. if(!getequipisequiped(.@part)) {
  121. message strcharinfo(0),"You're not wearing anything that it can be refine";
  122. close;
  123. }
  124. if(!getequipisenableref(.@part)) {
  125. message strcharinfo(0),"This item can't be refine";
  126. close;
  127. }
  128. if(!getequipisidentify(.@part)) {
  129. message strcharinfo(0),"This item is not identified";
  130. close;
  131. }
  132. if(getequiprefinerycnt(.@part) < 10) {
  133. message strcharinfo(0),"Only item at least lv. 10 can be refine";
  134. close;
  135. }
  136. if(getequiprefinerycnt(.@part) >= 20) {
  137. message strcharinfo(0),"This item can't be refined anymore";
  138. close;
  139. }
  140. set .@refineitemid, getequipid(.@part); // save id of the item
  141. set .@refinerycnt, getequiprefinerycnt(.@part); //save refinery count
  142. if ((getequipweaponlv(.@part) >= 1) && (getequipweaponlv(.@part) <= 4)) {
  143. set .@material,6226;
  144. set .@price,100000;
  145. set .@safe,10;
  146. } else {
  147. set .@material,6225;
  148. set .@price,100000;
  149. set .@safe,10;
  150. }
  151. if(countitem(.@material) < 1 || Zeny < .@price) {
  152. message strcharinfo(0),"I'll need " + .@price + " zeny and 1 " + getitemname(.@material) + "...";
  153. close;
  154. }
  155. if( select(" ~ Refine item (^0055FF33^000000% success): ~ ^777777Cancel^000000") == 1 )
  156. {
  157. set Zeny,Zeny - .@price;
  158. delitem .@material,1;
  159. if(getequipisequiped(.@part) == 0) { // hacker has removed the item (not changed, why?)
  160. message strcharinfo(0),"You don't have item on you";
  161. close;
  162. }
  163. if(getequiprefinerycnt(.@part) != .@refinerycnt || getequipid(.@part) != .@refineitemid) { // hacker has changed the item
  164. message strcharinfo(0),"You switched the item...";
  165. close;
  166. }
  167. set .@rand,rand(1,3);
  168. if (.@rand == 1) {
  169. message strcharinfo(0),"All done";
  170. successrefitem .@part;
  171. close;
  172. }
  173. if (.@rand == 2 || .@rand == 3) {
  174. if(getequiprefinerycnt(.@part) > 10){
  175. downrefitem .@part;
  176. }
  177. message strcharinfo(0),"Your item "+getequipname(.@part)+" has not been refine";
  178. close;
  179. }
  180. }
  181. close;
  182.  
  183. function Equip_Menu {
  184. setarray .@pos$[1],"Upper Headgear","Armor","Left hand","Right hand","Garment","Footgear","Left Accessory","Right Accessory","Mid Headgear","Lower Headgear";
  185. set .@menu$,"";
  186. for (set .@i,1; .@i <= 10; set .@i,.@i+1) {
  187. if (getequipisequiped(.@i))
  188. set .@menu$, .@menu$+.@pos$[.@i]+" [^0055FF"+getequipname(.@i)+"^000000]";
  189. set .@menu$, .@menu$+":"; }
  190. set @i, select(.@menu$);
  191. if (!getequipisequiped(@i)) { message strcharinfo(0),"Nothing is equipped there!"; close; }
  192. if (getarg(0)) {
  193. if (!getequipisenableref(@i)) { message strcharinfo(0),getequipname(@i)+" cannot be refined."; close; }
  194. if (getequiprefinerycnt(@i) >= 10 ) { message strcharinfo(0),"+"+getequiprefinerycnt(@i)+" "+getequipname(@i)+" cannot be refined any further."; close; } }
  195. return; }
  196. function Refine_Item {
  197. message strcharinfo(0),"I'll need "+getarg(0)+"x "+getitemname(getarg(1))+" and "+getarg(0)*getarg(2)+" Zeny.";
  198. if (countitem(getarg(1)) < getarg(0) || Zeny < getarg(0)*getarg(2)) {
  199. sleep2 500; message strcharinfo(0),"Come back when you have the required materials."; close; }
  200. if (getequiprefinerycnt(@i)+getarg(0) > getarg(3)) {
  201. sleep2 500; message strcharinfo(0),"The item will be refined above the safe limit. It may break."; }
  202. sleep2 500;
  203. if(select(" ~ ^0055FFContinue^000000: ~ ^777777Cancel^000000")==2) close;
  204. set .@j, getarg(0);
  205. while(.@j) {
  206. delitem getarg(1), 1;
  207. set Zeny, Zeny-getarg(2);
  208. if (getarg(4,0)) {
  209. if (getequippercentrefinery(@i) <= rand(100) && getequippercentrefinery(@i) <= rand(100)) {
  210. message strcharinfo(0),getequipname(@i)+" broke while refining."; failedrefitem @i; close; } }
  211. else {
  212. if (getequippercentrefinery(@i) <= rand(100)) {
  213. message strcharinfo(0),getequipname(@i)+" broke while refining."; failedrefitem @i; close; } }
  214. successrefitem @i;
  215. set .@j, .@j-1; }
  216. message strcharinfo(0),"All done!";
  217. close; }
  218. }
  219. OnInit:
  220.  
  221. // --------------------- Config ---------------------
  222.  
  223. setarray .MainMenu$[0], // Set menu options!
  224. "Normal Refiner", // [1]
  225. "Enriched Refiner", // [2]
  226. "Purified Refiner", // [4]
  227. "Bradium / Carnium Refiner"; // [8]
  228.  
  229. set .MenuOption,1|2|4|8;
  230.  
  231. set .EnrichedRefine,1; // Allow enriched refiner option? (1: yes / 0: no)
  232. setarray .RP[0],2000,50,200,5000,20000; // Zeny for armor, lv1, lv2, lv3, lv4 refines
  233.  
  234. // --------------------------------------------------
  235. end;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment