Advertisement
Guest User

Quest Shop

a guest
Jul 3rd, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.45 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Euphy's Quest Shop
  3. //===== By: ==================================================
  4. //= Euphy
  5. //===== Current Version: =====================================
  6. //= 1.4a
  7. //===== Compatible With: =====================================
  8. //= rAthena SVN r15340+
  9. //===== Description: =========================================
  10. //= A dynamic quest shop based on Lunar's, with easier config.
  11. //= Includes support for multiple shops & cashpoints.
  12. //= Item Preview script by ToastOfDoom.
  13. //============================================================
  14.  
  15. ayothaya,177,152,3 script Quest Shop_v2 998,{
  16. function Add; function Chk; function Slot; function A_An;
  17.  
  18. if(.Shops$ != "") set .@i,1;
  19. else {
  20. set .@menu$,"";
  21. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1)
  22. set .@menu$, .@menu$+.Shops$[.@i]+":";
  23. set .@i, select(.@menu$); }
  24. dispbottom "Select one item at a time.";
  25. callshop "qshop"+.@i,1;
  26. npcshopattach "qshop"+.@i;
  27. end;
  28.  
  29. function Add {
  30. if (getitemname(getarg(1))=="null") {
  31. debugmes "Quest reward #"+getarg(1)+" invalid (skipped)."; return; }
  32. for(set .@n,5; .@n<127; set .@n,.@n+2) {
  33. if (!getarg(.@n,0)) break;
  34. if (getitemname(getarg(.@n))=="null") {
  35. debugmes "Quest requirement #"+getarg(.@n)+" invalid (skipped)."; return; } }
  36. for(set .@i,2; .@i<.@n; set .@i,.@i+1)
  37. set getd(".q_"+getarg(1)+"["+(.@i-2)+"]"), getarg(.@i);
  38. npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
  39. return; }
  40. function Chk {
  41. if (getarg(0)<getarg(1)) { set @qe0,1; return "^FF0000"; }
  42. else return "^00FF00"; }
  43. function Slot {
  44. set .@s$,getitemname(getarg(0));
  45. switch(.ShowSlot){
  46. case 1: if (!getitemslots(getarg(0))) return .@s$;
  47. case 2: if (getiteminfo(getarg(0),11)>0) return .@s$+" ["+getitemslots(getarg(0))+"]";
  48. default: return .@s$; } }
  49. function A_An {
  50. setarray .@A$[0],"a","e","i","o","u";
  51. set .@B$, "_"+getarg(0);
  52. for(set .@i,0; .@i<5; set .@i,.@i+1)
  53. if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
  54. return "a "+getarg(0); }
  55.  
  56. OnBuyItem:
  57. set .@q[0],@bought_nameid;
  58. copyarray .@q[1],getd(".q_"+@bought_nameid+"[0]"),getarraysize(getd(".q_"+@bought_nameid+"[0]"));
  59. if (!.@q[1]) { message strcharinfo(0),"An error has occurred."; end; }
  60. mes "[Quest Shop]";
  61. mes "Reward: ^0055FF"+((.@q[1]>1)?.@q[1]+"x ":"")+Slot(.@q[0])+"^000000";
  62. mes "Requirements:";
  63. if (.@q[2]) mes " > "+Chk(Zeny,.@q[2])+.@q[2]+" Zeny^000000";
  64. if (.@q[3]) mes " > "+Chk(getd(.Points$[0]),.@q[3])+.@q[3]+" "+.Points$[1]+" ("+getd(.Points$[0])+"/"+.@q[3]+")^000000";
  65. if (.@q[4]) for(set .@i,4; .@i<getarraysize(.@q); set .@i,.@i+2)
  66. mes " > "+Chk(countitem(.@q[.@i]),.@q[.@i+1])+((.DisplayID)?"{"+.@q[.@i]+"} ":"")+Slot(.@q[.@i])+" ("+countitem(.@q[.@i])+"/"+.@q[.@i+1]+")^000000";
  67. next;
  68. set @qe1, getiteminfo(.@q[0],5); set @qe2, getiteminfo(.@q[0],11);
  69. addtimer 1000, strnpcinfo(1)+"::OnEnd";
  70. while(1){
  71. switch(select(" ~ Purchase ^0055FF"+getitemname(.@q[0])+"^000000:"+((((@qe1&1) || (@qe1&256) || (@qe1&512)) && @qe2>0 && !@qe6)?" ~ Preview...":"")+": ~ ^777777Cancel^000000")) {
  72. case 1:
  73. if (@qe0) {
  74. mes "[Quest Shop]";
  75. mes "You're missing one or more quest requirements.";
  76. close; }
  77. if (!checkweight(.@q[0],.@q[1])) {
  78. mes "[Quest Shop]";
  79. mes "^FF0000You need "+(((.@q[1]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" additional weight capacity to complete this trade.^000000";
  80. close; }
  81. if (.@q[2]) set Zeny, Zeny-.@q[2];
  82. if (.@q[3]) setd .Points$[0], getd(.Points$[0])-.@q[3];
  83. if (.@q[4]) for(set .@i,4; .@i<getarraysize(.@q); set .@i,.@i+2)
  84. delitem .@q[.@i],.@q[.@i+1];
  85. getitem .@q[0],.@q[1];
  86. if (.Announce) announce strcharinfo(0)+" has created "+A_An(getitemname(.@q[0]))+"!",0;
  87. specialeffect2 699;
  88. close;
  89. case 2:
  90. set @qe3, getlook(3); set @qe4, getlook(4); set @qe5, getlook(5);
  91. if (@qe1&1) atcommand "@changelook 3 "+@qe2;
  92. if (@qe1&256) atcommand "@changelook 1 "+@qe2;
  93. if (@qe1&512) atcommand "@changelook 2 "+@qe2;
  94. set @qe6,1;
  95. break;
  96. case 3:
  97. close; } }
  98. OnEnd:
  99. if (@qe6) { atcommand "@changelook 3 "+@qe3; atcommand "@changelook 1 "+@qe4; atcommand "@changelook 2 "+@qe5; }
  100. for(set .@i,0; .@i<7; set .@i,.@i+1) setd "@qe"+.@i,0;
  101. end;
  102. OnInit:
  103. freeloop(1);
  104. // --------------------- Config ---------------------
  105. // Custom points, if needed: "<variable>","<name to display>"
  106. setarray .Points$[0],"#CASHPOINTS","Cash Points";
  107.  
  108. set .Announce,1; // Announce quest completion? (1: yes / 0: no)
  109. set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
  110. set .DisplayID,0; // Show item IDs? (1: yes / 0: no)
  111. set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
  112.  
  113. // Shop categories, if needed: "<Shop 1>","<Shop 2>"{,...};
  114. // Duplicate dummy data for any additional shops (bottom of script).
  115. // If no categories, use the second line instead (remove //).
  116.  
  117. setarray .Shops$[1],"Headgears","Weapons","Other";
  118. // set .Shops$,"n/a";
  119.  
  120. // Add(<shop number>,<reward ID>,<reward amount>,<Zeny cost>,<point cost>,
  121. // <required item ID>,<required item amount>{,...});
  122. // Shop number corresponds with order above (default is 1).
  123. // Note: Do NOT use a reward item more than once!
  124.  
  125. Add(1,30080,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  126. Add(1,30082,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  127. Add(1,30089,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  128. Add(1,30122,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  129. Add(1,30143,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  130. Add(1,30144,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  131. Add(1,30160,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  132. Add(1,30161,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  133. Add(1,30162,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  134. Add(1,30163,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  135. Add(1,30164,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  136. Add(1,30165,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  137. Add(1,30166,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  138. Add(1,30005,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  139. Add(1,30021,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  140. Add(1,30023,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  141. Add(1,30024,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  142. Add(1,30025,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  143. Add(1,30026,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  144.  
  145. Add(2,30006,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  146. Add(2,30018,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  147. Add(2,30094,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  148. Add(2,30115,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  149. Add(2,30123,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  150. Add(2,30155,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  151. Add(2,30020,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  152. Add(2,30022,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  153. Add(2,30027,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  154. Add(2,30028,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  155. Add(2,30029,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  156.  
  157. Add(3,30004,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  158. Add(3,30013,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  159. Add(3,30014,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  160. Add(3,30015,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  161. Add(3,30067,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  162. Add(3,30070,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  163. Add(3,30077,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  164. Add(3,30081,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  165. Add(3,30086,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  166. Add(3,30119,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  167. Add(3,30141,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  168. Add(3,30016,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  169. Add(3,30017,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  170. Add(3,30019,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  171. Add(3,30038,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  172. Add(3,30039,1,0,0,7511,300,7799,300,7798,300,0,0,0,0,0,0,0,0);
  173.  
  174. // --------------------------------------------------
  175. freeloop(0);
  176. for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1)
  177. npcshopdelitem "qshop"+.@i,909;
  178. end;
  179. }
  180.  
  181. // -------- Dummy data (duplicate as needed) --------
  182. - shop qshop1 -1,909:-1
  183. - shop qshop2 -1,909:-1
  184. - shop qshop3 -1,909:-1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement